/* ============================================================
   Dental Call Analyzer — Dark Glassmorphism Dense Bento
   Based on 001-dense-bento reference + real API integration
   ============================================================ */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:            #0f1a12;
  --glass:         rgba(255, 255, 255, 0.06);
  --glass-sm:      rgba(255, 255, 255, 0.04);
  --glass-border:  rgba(255, 255, 255, 0.08);
  --glass-border-sm: rgba(255, 255, 255, 0.06);
  --green:         #609966;
  --green-light:   #86C38E;
  --green-dim:     #4a6a4e;
  --red:           #ff6b6b;
  --orange:        #ffb300;
  --text:          #e8f5e9;
  --text-dim:      #b0c8b3;
  --text-muted:    #6a8a6e;
  --text-dark:     #4a6a4e;
  --font:          'Outfit', sans-serif;
  --radius:        24px;
  --radius-sm:     16px;
  --radius-xs:     12px;
  --transition:    0.2s ease;
}

html { font-size: 16px; -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; }

body {
  font-family: var(--font);
  color: #1a1a1a;
  background: var(--bg);
  min-height: 100vh;
  min-height: -webkit-fill-available;
  line-height: 1.5;
}

#root { min-height: 100vh; min-height: -webkit-fill-available; }

/* ── Glass ── */
.glass {
  background: var(--glass);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius);
}
.glass-sm {
  background: var(--glass-sm);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--glass-border-sm);
  border-radius: var(--radius-sm);
}

/* ── Layout: sidebar + main ── */
.layout { display: flex; min-height: 100vh; min-height: -webkit-fill-available; }
.sidebar {
  position: fixed; top: 0; left: 0; bottom: 0;
  width: 260px; padding: 24px 16px;
  display: flex; flex-direction: column;
  border-right: 1px solid var(--glass-border-sm);
  background: rgba(0,0,0,0.2);
  flex-shrink: 0;
  overflow-y: auto;
  z-index: 100;
}
.main { flex: 1; padding: 24px; overflow-y: auto; -webkit-overflow-scrolling: touch; margin-left: 260px; }

/* ── Sidebar ── */
.logo { display: flex; align-items: center; gap: 10px; padding: 0 12px; margin-bottom: 32px; }
.logo-icon {
  width: 36px; height: 36px; border-radius: 12px;
  background: linear-gradient(135deg, var(--green), var(--green-light));
  display: flex; align-items: center; justify-content: center;
  color: white; font-size: 18px;
}
.logo-text { font-weight: 700; font-size: 16px; color: var(--text); }
.logo-text span { font-weight: 300; color: var(--green-light); }

.nav-section { font-size: 11px; text-transform: uppercase; letter-spacing: 1px; color: var(--text-dark); padding: 0 12px; margin-bottom: 8px; margin-top: 20px; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; border-radius: var(--radius-xs);
  font-size: 14px; color: #8aaa8e; cursor: pointer;
  transition: all var(--transition); border: none; background: none; width: 100%;
  font-family: var(--font); text-align: left;
}
.nav-item:hover { background: rgba(96,153,102,0.1); color: #c8e6c9; }
.nav-item.active { background: rgba(96,153,102,0.15); color: var(--text); font-weight: 500; }
.nav-item .material-icons-round { font-size: 20px; }
.nav-badge {
  margin-left: auto; padding: 2px 8px; border-radius: 50px;
  font-size: 11px; font-weight: 600;
  background: rgba(220,53,69,0.2); color: var(--red);
}
.sidebar-bottom { margin-top: auto; padding-top: 20px; border-top: 1px solid var(--glass-border-sm); }
.sidebar-user { display: flex; align-items: center; gap: 10px; padding: 10px 12px; }
.sidebar-avatar {
  width: 32px; height: 32px; border-radius: 10px;
  background: linear-gradient(135deg, var(--green), var(--green-light));
  display: flex; align-items: center; justify-content: center;
  color: white; font-size: 14px; font-weight: 600;
}
.sidebar-user-info { flex: 1; }
.sidebar-user-name { font-size: 13px; font-weight: 500; color: var(--text); }
.sidebar-user-role { font-size: 11px; color: var(--text-muted); }

/* ── Topbar ── */
.topbar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; flex-wrap: wrap; gap: 10px; }
.topbar-title { font-size: 22px; font-weight: 700; color: var(--text); }
.topbar-actions { display: flex; gap: 10px; align-items: center; }

/* ── Buttons ── */
.btn-glass {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 10px 18px; border-radius: var(--radius-xs);
  background: rgba(96,153,102,0.15); border: 1px solid rgba(96,153,102,0.2);
  color: var(--green-light); font-size: 14px; font-weight: 500;
  cursor: pointer; transition: all var(--transition);
  font-family: var(--font); white-space: nowrap;
  -webkit-tap-highlight-color: transparent;
}
.btn-glass:hover { background: rgba(96,153,102,0.25); }
.btn-glass .material-icons-round { font-size: 18px; }
.btn-primary {
  background: linear-gradient(135deg, var(--green), var(--green-light));
  color: var(--bg); border: none; font-weight: 600;
}
.btn-primary:hover { filter: brightness(1.1); }
.btn-sm {
  padding: 5px 12px; border-radius: 8px;
  font-size: 12px; font-weight: 500;
  border: 1px solid rgba(96,153,102,0.2); background: transparent;
  color: var(--green-light); cursor: pointer; transition: all var(--transition);
  font-family: var(--font); display: inline-flex; align-items: center; gap: 4px;
  -webkit-tap-highlight-color: transparent;
}
.btn-sm:hover { background: rgba(96,153,102,0.15); }
.btn-sm:disabled { opacity: 0.3; cursor: default; }

/* ── Upload Zone ── */
.upload-zone {
  padding: 32px 24px; text-align: center;
  border: 2px dashed rgba(134,195,142,0.2);
  border-radius: var(--radius);
  background: var(--glass-sm);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  cursor: pointer; transition: all var(--transition);
  margin-bottom: 20px;
  -webkit-tap-highlight-color: transparent;
}
.upload-zone:hover,
.upload-zone--active {
  border-color: var(--green);
  background: rgba(96,153,102,0.08);
  box-shadow: 0 0 40px rgba(96,153,102,0.1);
}
.upload-zone__icon { font-size: 40px; color: var(--green-dim); margin-bottom: 8px; }
.upload-zone__text { color: var(--text-muted); font-size: 14px; }
.upload-zone__hint { color: var(--text-dark); font-size: 12px; margin-top: 4px; }

/* ── Stats Row ── */
.stats-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px; margin-bottom: 20px;
}
.stat-card { padding: 16px 18px; display: flex; flex-direction: column; gap: 2px; }
.stat-label { font-size: 12px; color: var(--text-muted); }
.stat-value { font-size: 28px; font-weight: 700; color: var(--text); line-height: 1.1; }
.stat-sub { font-size: 12px; color: var(--green); }

/* ── Table (Journal — full width) ── */
.journal-card { padding: 20px; margin-bottom: 20px; overflow-x: auto; -webkit-overflow-scrolling: touch; }
.section-title {
  font-size: 15px; font-weight: 600; color: #c8e6c9; margin-bottom: 14px;
  display: flex; align-items: center; gap: 8px;
}
.section-title .material-icons-round { font-size: 18px; color: var(--green); }

table { width: 100%; border-collapse: collapse; }
th {
  text-align: left; font-size: 11px; font-weight: 500; color: var(--text-dark);
  text-transform: uppercase; letter-spacing: 0.5px; padding: 8px 12px;
  border-bottom: 1px solid var(--glass-border-sm); white-space: nowrap;
}
td {
  padding: 12px; font-size: 13px;
  border-bottom: 1px solid rgba(255,255,255,0.03);
  color: var(--text-dim); white-space: nowrap;
}
tr:hover td { background: rgba(96,153,102,0.05); }
td strong { color: #e0efe2; font-weight: 500; }

/* Status badges */
.status { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; }
.status-dot { width: 7px; height: 7px; border-radius: 50%; display: inline-block; }
.status-done .status-dot { background: var(--green); }
.status-processing .status-dot { background: var(--orange); animation: pulse 1.5s infinite; }
.status-queued .status-dot { background: #555; }
.status-failed .status-dot { background: var(--red); }
@keyframes pulse { 0%,100% { opacity:1; } 50% { opacity:0.3; } }

/* Score badges */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 10px; border-radius: 50px;
  font-size: 11px; font-weight: 600;
}
.badge-dot { width: 5px; height: 5px; border-radius: 50%; display: inline-block; }
.badge-ok   { background: rgba(96,153,102,0.15); color: var(--green-light); }
.badge-ok .badge-dot { background: var(--green); }
.badge-warn { background: rgba(255,179,0,0.15); color: var(--orange); }
.badge-warn .badge-dot { background: var(--orange); }
.badge-bad  { background: rgba(220,53,69,0.15); color: var(--red); }
.badge-bad .badge-dot { background: #dc3545; }

/* ── Notifications (bottom, full width) ── */
.notif-card { padding: 0; overflow: hidden; }
.notif-title { padding: 20px 20px 0; }
.alert-item { padding: 14px 20px; border-bottom: 1px solid rgba(255,255,255,0.04); }
.alert-item:last-child { border-bottom: none; }
.alert-head { display: flex; justify-content: space-between; margin-bottom: 4px; }
.alert-title { font-size: 13px; font-weight: 600; }
.alert-time { font-size: 11px; color: var(--text-dark); }
.alert-text { font-size: 12px; color: var(--text-muted); line-height: 1.4; }

/* ── Login ── */
.login-wrapper {
  display: flex; align-items: center; justify-content: center;
  min-height: 100vh; min-height: -webkit-fill-available;
  padding: 20px;
}
.login-card { width: 100%; max-width: 400px; padding: 40px 28px; text-align: center; }
.login-card h1 {
  font-size: 24px; font-weight: 700;
  background: linear-gradient(135deg, var(--green-light), var(--green));
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  background-clip: text; margin-bottom: 8px;
}
.login-card p { color: var(--text-muted); font-size: 13px; margin-bottom: 28px; }
.login-card form { display: flex; flex-direction: column; gap: 14px; }

.input-field {
  width: 100%; padding: 12px 16px;
  border: 1px solid var(--glass-border-sm); border-radius: var(--radius-xs);
  background: rgba(15,26,18,0.6); color: var(--text);
  font-family: var(--font); font-size: 14px; outline: none;
  transition: border-color var(--transition);
  -webkit-appearance: none;
}
.input-field:focus { border-color: var(--green); }
.input-field::placeholder { color: var(--text-dark); }
.input-wrap { position: relative; }
.input-wrap .input-field { padding-right: 44px; }
.pw-toggle {
  position: absolute; right: 8px; top: 50%; transform: translateY(-50%);
  background: none; border: none; color: var(--text-muted);
  cursor: pointer; padding: 6px; font-size: 0; line-height: 1;
  -webkit-tap-highlight-color: transparent;
}
.pw-toggle .material-icons-round { font-size: 20px; }

.login-error {
  padding: 10px 14px; border-radius: var(--radius-xs);
  background: rgba(220,53,69,0.12); border: 1px solid rgba(220,53,69,0.25);
  color: var(--red); font-size: 13px;
}

/* ── Modal ── */
.modal-overlay {
  position: fixed; inset: 0; z-index: 500;
  display: flex; align-items: center; justify-content: center;
  background: rgba(0,0,0,0.6); backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  padding: 20px;
}
.modal-card { width: 100%; max-width: 420px; padding: 28px; }
.modal-card h2 { font-size: 18px; font-weight: 600; color: var(--text); margin-bottom: 20px; }
.modal-card form { display: flex; flex-direction: column; gap: 14px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; }
.btn-text {
  padding: 10px 18px; border: none; border-radius: var(--radius-xs);
  background: none; color: var(--text-muted); font-family: var(--font);
  font-size: 14px; cursor: pointer;
}
.btn-text:hover { color: var(--text); }
.btn-submit {
  padding: 10px 22px; border: none; border-radius: var(--radius-xs);
  background: linear-gradient(135deg, var(--green), var(--green-light));
  color: var(--bg); font-family: var(--font); font-size: 14px; font-weight: 600;
  cursor: pointer;
}
.btn-submit:hover { filter: brightness(1.1); }

/* ── Toast ── */
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  padding: 12px 24px; border-radius: var(--radius-xs);
  font-size: 13px; z-index: 600; animation: toastIn 0.3s ease;
  font-family: var(--font); max-width: 90vw; text-align: center;
}
.toast-success { background: rgba(96,153,102,0.9); color: #fff; }
.toast-error   { background: rgba(220,53,69,0.9);  color: #fff; }
.toast-warning { background: rgba(255,179,0,0.9);  color: var(--bg); }
@keyframes toastIn {
  from { opacity: 0; transform: translateX(-50%) translateY(12px); }
  to   { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* ── Settings ── */
.settings-card { padding: 24px; }
.settings-card h2 { font-size: 18px; font-weight: 600; color: var(--text); margin-bottom: 6px; }
.settings-card .desc { color: var(--text-muted); font-size: 13px; margin-bottom: 20px; }
.norm-row { display: flex; gap: 12px; margin-bottom: 20px; align-items: center; flex-wrap: wrap; }
.norm-row .input-field { flex: 1; min-width: 140px; }
.norm-table td { white-space: normal; }
.norm-wrong { color: var(--red); font-family: 'JetBrains Mono', 'Fira Code', monospace; }
.norm-correct { color: var(--green-light); font-family: 'JetBrains Mono', 'Fira Code', monospace; font-weight: 600; }
.norm-empty { text-align: center; padding: 24px; color: var(--text-dark); }

/* ── Spinner ── */
.spinner {
  display: inline-block; border: 3px solid var(--glass-border);
  border-top-color: var(--green); border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Scrollbar ── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--green-dim); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--green); }

/* ═══════════════════════════════════════════════
   RESPONSIVE — iPhone / Android
   ═══════════════════════════════════════════════ */
@media (max-width: 768px) {
  .sidebar { display: none !important; }
  .layout { flex-direction: column; }
  .main { padding: 16px; margin-left: 0 !important; }
  .stats-row { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .topbar { margin-bottom: 16px; }
  .topbar-title { font-size: 18px; }
  .upload-zone { padding: 24px 16px; }
  .stat-value { font-size: 22px; }
  .btn-glass { padding: 8px 14px; font-size: 13px; }
  .btn-glass .material-icons-round { font-size: 16px; }
  /* Mobile bottom nav */
  .mobile-nav {
    display: flex !important;
    position: fixed; bottom: 0; left: 0; right: 0;
    background: rgba(15,26,18,0.95);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-top: 1px solid var(--glass-border-sm);
    padding: 8px 0; padding-bottom: max(8px, env(safe-area-inset-bottom));
    z-index: 400;
  }
  .mobile-nav-item {
    flex: 1; display: flex; flex-direction: column; align-items: center;
    gap: 2px; padding: 6px 0; border: none; background: none;
    color: var(--text-muted); font-size: 10px; font-family: var(--font);
    cursor: pointer; -webkit-tap-highlight-color: transparent;
  }
  .mobile-nav-item.active { color: var(--green-light); }
  .mobile-nav-item .material-icons-round { font-size: 22px; }
  /* Push content above bottom nav */
  .main { padding-bottom: 80px; }
  /* Journal card less padding */
  .journal-card { padding: 12px; }
  th, td { padding: 10px 8px; font-size: 12px; }
  /* Notifications stacked */
  .notif-card { border-radius: var(--radius-sm); }
}

@media (min-width: 769px) {
  .mobile-nav { display: none !important; }
}
