/* ===== RESET & BASE ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; }
body { font-family: 'Segoe UI', Roboto, Arial, sans-serif; background: #f5f5f5; color: #212121; line-height: 1.5; }
a { color: #1976d2; text-decoration: none; }
a:hover { text-decoration: underline; }
button { cursor: pointer; font-family: inherit; font-size: 0.875rem; border: none; border-radius: 4px; }
input, select, textarea { font-family: inherit; font-size: 0.875rem; }
h1 { font-size: 2rem; font-weight: 400; margin-bottom: 0.5rem; }
h2 { font-size: 1.5rem; font-weight: 400; margin-bottom: 0.25rem; }
.subtitle { color: #757575; font-size: 0.875rem; margin-bottom: 0.5rem; }
.subtitle.small { font-size: 0.8rem; }
.text-muted { color: #9e9e9e; }
.mb-2 { margin-bottom: 0.5rem; }
.mb-3 { margin-bottom: 1rem; }
.mb-4 { margin-bottom: 1.5rem; }
.mt-1 { margin-top: 0.25rem; }
.mt-2 { margin-top: 0.5rem; }
.mt-3 { margin-top: 1rem; }
.w100 { width: 100%; }

/* ===== HEADER ===== */
#app-header { background: #1976d2; color: #fff; box-shadow: 0 2px 4px rgba(0,0,0,.2); position: sticky; top: 0; z-index: 100; }
.header-inner { display: flex; align-items: center; justify-content: space-between; padding: 0 24px; height: 56px; max-width: 1200px; margin: 0 auto; }
.header-title { font-size: 1.25rem; font-weight: 500; cursor: pointer; }
.header-title:hover { opacity: .85; }

/* ===== LAYOUT ===== */
#app-main { max-width: 1200px; margin: 0 auto; padding: 24px 16px 48px; }
.loading { padding: 2rem; text-align: center; color: #757575; }

/* ===== CARD ===== */
.card { background: #fff; border-radius: 4px; box-shadow: 0 1px 3px rgba(0,0,0,.12), 0 1px 2px rgba(0,0,0,.08); overflow: hidden; }
.card-header { padding: 16px 24px 8px; border-bottom: 1px solid #f0f0f0; }
.card-header h2, .card-header strong { font-size: 1.25rem; font-weight: 500; }
.card-body { padding: 16px 24px; }
.card-body.p-0 { padding: 0; }

/* ===== BUTTONS ===== */
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 8px 16px; border-radius: 4px; font-size: 0.875rem; font-weight: 500; transition: all .15s; white-space: nowrap; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: #1976d2; color: #fff; }
.btn-primary:hover:not(:disabled) { background: #1565c0; }
.btn-outline { background: transparent; color: #1976d2; border: 1px solid #1976d2; }
.btn-outline:hover:not(:disabled) { background: #e3f2fd; }
.btn-success { background: #4caf50; color: #fff; }
.btn-danger { background: #f44336; color: #fff; font-size: 0.8rem; padding: 4px 10px; }
.btn-danger:hover:not(:disabled) { background: #d32f2f; }
.btn-warning { background: #ff9800; color: #fff; }
.btn-warning:hover:not(:disabled) { background: #f57c00; }
.btn-sm { padding: 4px 10px; font-size: 0.8rem; }
.btn-lg { padding: 12px 24px; font-size: 1rem; }
.btn-text { background: none; color: #1976d2; padding: 4px 8px; }
.btn-text:hover { text-decoration: underline; }
.icon-btn { background: transparent; color: #fff; border: none; padding: 6px; border-radius: 50%; font-size: 1.2rem; line-height: 1; display: inline-flex; align-items: center; justify-content: center; width: 36px; height: 36px; }
.icon-btn:hover { background: rgba(255,255,255,.15); }
.icon-btn.dark { color: #555; }
.icon-btn.dark:hover { background: rgba(0,0,0,.08); }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; }

/* ===== FORMS ===== */
.form-group { display: flex; flex-direction: column; gap: 4px; }
.form-group label { font-size: 0.8rem; font-weight: 500; color: #555; }
.form-control { width: 100%; padding: 10px 12px; border: 1px solid #ccc; border-radius: 4px; font-size: 0.875rem; transition: border-color .15s; background: #fff; }
.form-control:focus { outline: none; border-color: #1976d2; box-shadow: 0 0 0 2px rgba(25,118,210,.15); }
.form-control:disabled, .form-control[readonly] { background: #f9f9f9; color: #555; }
.form-control.processing { color: #ff9800; font-style: italic; }
.form-control.failed { color: #f44336; font-style: italic; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 600px) { .form-grid { grid-template-columns: 1fr; } }
.form-actions { display: flex; justify-content: flex-end; gap: 12px; margin-top: 24px; flex-wrap: wrap; }
.age-row { display: flex; gap: 8px; }
.age-row > div { flex: 1; }
.help-text { font-size: 0.75rem; color: #757575; }
.checkbox-label { display: flex; align-items: center; gap: 8px; cursor: pointer; font-size: 0.875rem; }
.switch-label { display: flex; align-items: center; gap: 8px; font-size: 0.875rem; color: #fff; cursor: pointer; }
.switch-label input { cursor: pointer; }

/* ===== ALERTS ===== */
.alert { padding: 12px 16px; border-radius: 4px; margin-bottom: 12px; font-size: 0.875rem; }
.alert-error { background: #ffebee; color: #c62828; border-left: 4px solid #f44336; }
.alert-info { background: #e3f2fd; color: #1565c0; border-left: 4px solid #1976d2; }
.alert-warning { background: #fff3e0; color: #e65100; border-left: 4px solid #ff9800; }
.success-msg { background: #e8f5e9; color: #2e7d32; border-radius: 4px; padding: 8px 12px; text-align: center; font-size: 0.875rem; }

/* ===== CHIP ===== */
.chip { display: inline-block; padding: 2px 10px; border-radius: 16px; font-size: 0.75rem; font-weight: 500; }
.chip-primary { border: 1px solid #1976d2; color: #1976d2; background: transparent; }

/* ===== TABLE ===== */
.table-responsive { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 0.875rem; }
.table th { padding: 12px 16px; text-align: left; font-weight: 600; background: #fafafa; border-bottom: 2px solid #e0e0e0; white-space: nowrap; }
.table td { padding: 12px 16px; border-bottom: 1px solid #f0f0f0; }
.table-row { cursor: pointer; transition: background .1s; }
.table-row:hover { background: #f5f5f5; }
.date-cell { font-size: 0.8rem; color: #757575; white-space: nowrap; }
.empty-msg { padding: 32px 24px; text-align: center; color: #9e9e9e; }

/* ===== FILTER ROW ===== */
.filter-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 600px) { .filter-row { grid-template-columns: 1fr; } }
.filter-info { display: flex; align-items: center; gap: 8px; margin-top: 8px; font-size: 0.875rem; color: #757575; }

/* ===== PAGE HEADER ===== */
.page-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 24px; flex-wrap: wrap; gap: 12px; }
.page-header h1 { margin-bottom: 0; }
.header-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

/* ===== EXAM HEADER & SESSION STATUS ===== */
.exam-header-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 8px; }
.exam-session-status { display: flex; align-items: center; gap: 8px; }
.session-pill { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 999px; font-size: 0.8rem; font-weight: 500; }
.session-pill-active { background: #e8f5e9; color: #2e7d32; border: 1px solid #a5d6a7; box-shadow: 0 0 5px rgba(76,175,80,0.3); }
.session-pill-inactive { background: #ffebee; color: #c62828; border: 1px solid #ef9a9a; }
.session-pill-syncing { background: #fff3e0; color: #e65100; border: 1px solid #ffb74d; animation: pulse-yellow 1.5s infinite; }
@keyframes pulse-yellow { 0% { opacity: 1; } 50% { opacity: 0.6; } 100% { opacity: 1; } }

/* ===== BREADCRUMB ===== */
.breadcrumb { font-size: 0.875rem; color: #757575; margin-bottom: 12px; }
.breadcrumb a { color: #1976d2; }

/* ===== TEMPERATURE GRID ===== */
.temp-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
@media (max-width: 900px) { .temp-grid { grid-template-columns: 1fr 1fr; } }
@media (max-width: 600px) { .temp-grid { grid-template-columns: 1fr; } }
.temp-box .form-group { margin-bottom: 12px; }

/* ===== NOTES TOGGLE ===== */
.notes-section { border-top: 1px solid #f0f0f0; padding-top: 12px; }
.notes-toggle { display: flex; align-items: center; gap: 6px; cursor: pointer; font-size: 0.8rem; color: #555; user-select: none; }
.notes-toggle:hover { color: #1976d2; }
.toggle-icon { font-size: 1rem; font-weight: 700; line-height: 1; width: 16px; }
.notes-area { resize: vertical; min-height: 72px; }

/* ===== RECORDING GRID ===== */
.recording-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }
@media (max-width: 1000px) { .recording-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 500px) { .recording-grid { grid-template-columns: 1fr; } }
.rec-box { overflow: visible; }
.rec-header { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px; background: #fafafa; border-bottom: 1px solid #f0f0f0; }
.rec-body { padding: 12px 16px; display: flex; flex-direction: column; gap: 8px; }
.status-badge { display: inline-block; padding: 2px 10px; border-radius: 12px; font-size: 0.75rem; font-weight: 600; color: #fff; }
.play-btn { background: transparent; color: #1976d2; border: 1px solid #1976d2; }
.play-btn:hover:not(:disabled) { background: #e3f2fd; }
.pdf-btn { background: transparent; color: #7b1fa2; border: 1px solid #7b1fa2; font-size: 0.78rem; }
.pdf-btn:hover:not(:disabled) { background: #f3e5f5; }

/* PDF generating progress bar (indeterminate) */
.pdf-generating-wrap { width: 100%; margin-top: 4px; margin-bottom: 2px; }
.pdf-generating-label { font-size: 0.78rem; color: #7b1fa2; margin-bottom: 8px; display: flex; align-items: center; gap: 6px; font-weight: 500; }
.pdf-generating-track { height: 10px; background: #e8e0ec; border: 1px solid #cec4d4; border-radius: 5px; overflow: hidden; display: block; }
.pdf-generating-bar { display: block; height: 100%; min-height: 10px; width: 45%; min-width: 80px; border-radius: 5px; background: #7b1fa2; background: linear-gradient(90deg, rgba(123,31,162,.3), #7b1fa2, #9c27b0, rgba(123,31,162,.3)); animation: pdf-gen-shimmer 1.5s ease-in-out infinite; }
@keyframes pdf-gen-shimmer { 0% { transform: translateX(-150%); } 100% { transform: translateX(350%); } }

/* ===== WAVEFORM ===== */
.waveform { width: 100%; height: 60px; border: 1px solid #e0e0e0; border-radius: 4px; background: #fff; display: block; }

/* ===== UNKNOWN RECORDINGS ===== */
.unknown-grid { display: flex; gap: 16px; flex-wrap: wrap; }
.unknown-card { min-width: 280px; border: 2px solid #ff9800; background: #fff8f0; }

/* ===== EXAM ACTIONS ===== */
.exam-actions { display: flex; justify-content: flex-end; gap: 12px; margin-top: 24px; margin-bottom: 32px; flex-wrap: wrap; }
@media (max-width: 500px) { .exam-actions { flex-direction: column; } .exam-actions .btn { width: 100%; justify-content: center; } }

/* ===== DIVIDER ===== */
hr { border: none; border-top: 1px solid #e0e0e0; margin: 24px 0; }

/* ===== LOGIN ===== */
.login-screen { min-height: 60vh; display: flex; align-items: center; justify-content: center; padding: 24px; }
.login-card { max-width: 360px; width: 100%; }
.login-card h1 { text-align: center; margin-bottom: 0.25rem; }
.login-card .subtitle { text-align: center; margin-bottom: 24px; }
.login-card .btn-block { width: 100%; justify-content: center; margin-top: 8px; }
.device-badge { font-size: 0.8rem; color: #555; background: #eee; padding: 4px 10px; border-radius: 4px; margin-right: 8px; }

/* ===== SPEED TEST ===== */
.speedtest-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}
.speedtest-metric {
  background: #f7f9fc;
  border: 1px solid #e3eaf3;
  border-radius: 6px;
  padding: 12px 10px;
  text-align: center;
}
.speedtest-label { font-size: 0.75rem; color: #757575; margin-bottom: 4px; text-transform: uppercase; letter-spacing: .02em; }
.speedtest-value { font-size: 1.25rem; font-weight: 600; color: #1565c0; }
.speedtest-compact {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 14px;
  align-items: center;
  background: #f7f9fc;
  border: 1px solid #e3eaf3;
  border-radius: 6px;
  padding: 8px 12px;
  margin-bottom: 12px;
  font-size: 0.85rem;
  color: #555;
}
.speedtest-compact-label {
  font-weight: 600;
  color: #1565c0;
  margin-right: 4px;
}
.speedtest-compact strong { color: #212121; font-weight: 600; }
@media (max-width: 500px) {
  .speedtest-grid { grid-template-columns: 1fr; }
  .speedtest-value { font-size: 1.1rem; }
}

/* ===== PET MEDIA & ATTACHMENTS (CASE SHEET, ECHO, IMAGES, VIDEOS) ===== */
.media-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
}
.media-btn-group {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}
.btn-media {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  font-weight: 500;
  font-size: 0.875rem;
  border-radius: 4px;
  border: none;
  transition: background-color 0.15s ease;
  color: #fff;
}
.btn-media:hover {
  opacity: 0.9;
}
.btn-media-case {
  background: #0288d1;
}
.btn-media-case:hover {
  background: #0277bd;
}
.btn-media-echo {
  background: #6a1b9a;
}
.btn-media-echo:hover {
  background: #4a148c;
}
.btn-media-image {
  background: #00796b;
}
.btn-media-image:hover {
  background: #004d40;
}
.btn-media-video {
  background: #ef6c00;
}
.btn-media-video:hover {
  background: #e65100;
}

/* Tabs */
.media-tabs {
  display: flex;
  gap: 8px;
  border-bottom: 2px solid #e0e0e0;
  margin-bottom: 16px;
  overflow-x: auto;
  padding-bottom: 2px;
}
.media-tab {
  background: none;
  border: none;
  padding: 8px 16px;
  font-size: 0.9rem;
  font-weight: 500;
  color: #666;
  border-bottom: 3px solid transparent;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.2s ease;
}
.media-tab:hover {
  color: #1976d2;
}
.media-tab.active {
  color: #1976d2;
  border-bottom-color: #1976d2;
  font-weight: 600;
}

/* Media Gallery Grid */
.media-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}
.media-card-item {
  background: #ffffff;
  border: 1px solid #e0e0e0;
  border-radius: 8px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: all 0.2s ease;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}
.media-card-item:hover {
  box-shadow: 0 4px 10px rgba(0,0,0,0.12);
  border-color: #bbb;
}
.media-thumb-container {
  height: 160px;
  background: #212121;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
  cursor: pointer;
}
.media-thumb-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.2s ease;
}
.media-thumb-img:hover {
  transform: scale(1.03);
}
.media-thumb-doc {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  color: #fff;
  font-size: 0.9rem;
  background: linear-gradient(135deg, #37474f, #263238);
  width: 100%;
  height: 100%;
  justify-content: center;
}
.media-thumb-video {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  color: #fff;
  width: 100%;
  height: 100%;
  justify-content: center;
  background: linear-gradient(135deg, #1a237e, #0d47a1);
}
.media-category-badge {
  position: absolute;
  top: 8px;
  left: 8px;
  padding: 3px 8px;
  border-radius: 12px;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  color: #fff;
  letter-spacing: 0.03em;
  box-shadow: 0 1px 3px rgba(0,0,0,0.3);
}
.badge-case_sheet { background: #0288d1; }
.badge-echo { background: #8e24aa; }
.badge-image { background: #00897b; }
.badge-video { background: #fb8c00; }

.media-details {
  padding: 12px;
  display: flex;
  flex-direction: column;
  flex: 1;
}
.media-title {
  font-weight: 600;
  font-size: 0.95rem;
  margin-bottom: 4px;
  color: #212121;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.media-meta {
  font-size: 0.78rem;
  color: #757575;
  margin-bottom: 6px;
}
.media-notes {
  font-size: 0.82rem;
  color: #555;
  background: #f8f9fa;
  padding: 6px 8px;
  border-radius: 4px;
  margin-bottom: 10px;
  border-left: 3px solid #1976d2;
}
.media-card-actions {
  display: flex;
  gap: 8px;
  margin-top: auto;
  padding-top: 8px;
  border-top: 1px solid #f0f0f0;
}

/* Upload Modal */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 16px;
}
.modal-box {
  background: #fff;
  border-radius: 8px;
  width: 100%;
  max-width: 540px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 8px 24px rgba(0,0,0,0.25);
  display: flex;
  flex-direction: column;
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid #eee;
}
.modal-title {
  font-size: 1.15rem;
  font-weight: 600;
  margin: 0;
}
.modal-body {
  padding: 20px;
}
.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 14px 20px;
  border-top: 1px solid #eee;
  background: #fafafa;
}

/* Drag & Drop File Zone */
.dropzone {
  border: 2px dashed #b0bec5;
  border-radius: 8px;
  padding: 28px 16px;
  text-align: center;
  cursor: pointer;
  background: #f8fafc;
  transition: all 0.2s ease;
  margin-bottom: 16px;
}
.dropzone:hover, .dropzone.dragover {
  border-color: #1976d2;
  background: #e3f2fd;
}
.dropzone-icon {
  font-size: 2.5rem;
  color: #78909c;
  margin-bottom: 8px;
}
.file-selected-box {
  background: #e8f5e9;
  border: 1px solid #a5d6a7;
  border-radius: 6px;
  padding: 10px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  font-size: 0.88rem;
}

/* Progress bar for 5GB uploads */
.progress-container {
  margin: 16px 0;
}
.progress-bar-outer {
  background: #e0e0e0;
  border-radius: 8px;
  height: 16px;
  overflow: hidden;
  box-shadow: inset 0 1px 2px rgba(0,0,0,0.1);
}
.progress-bar-inner {
  height: 100%;
  background: linear-gradient(90deg, #1976d2, #42a5f5);
  width: 0%;
  transition: width 0.15s ease;
}
.progress-label {
  display: flex;
  justify-content: space-between;
  font-size: 0.8rem;
  color: #666;
  margin-top: 6px;
  font-weight: 500;
}

/* Viewer Modal (Video / PDF / Image) */
.viewer-modal-box {
  background: #111;
  color: #fff;
  border-radius: 8px;
  width: 100%;
  max-width: 900px;
  max-height: 92vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.viewer-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 18px;
  background: #1f1f1f;
  border-bottom: 1px solid #333;
}
.viewer-content {
  display: flex;
  align-items: center;
  justify-content: center;
  background: #000;
  min-height: 380px;
  max-height: 75vh;
}
.viewer-content video {
  max-width: 100%;
  max-height: 75vh;
}
.viewer-content img {
  max-width: 100%;
  max-height: 75vh;
  object-fit: contain;
}
.viewer-content iframe {
  width: 100%;
  height: 75vh;
  border: none;
}
