/* ═══════════════════════════════════════════
   ADI GURU — Shared Design System
   Theme: Paper & Sage
═══════════════════════════════════════════ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:           #fafaf7;
  --surface:      #f4f3ee;
  --surface2:     #eceae3;
  --surface3:     #e4e1d8;
  --border:       #ddd8cc;
  --border2:      #cec8b8;
  --accent:       #3d7a52;
  --accent2:      #2a5c3f;
  --accent-glow:  rgba(61,122,82,.12);
  --accent-dim:   #e4f0e8;
  --text:         #1c1c14;
  --text-dim:     #5a5a4a;
  --muted:        #8a8878;
  --error:        #dc2626;
  --warn:         #d97706;
  --header-h:     72px;
  --footer-h:     44px;
  --sidebar-w:    210px;
  --radius:       10px;
}

html, body { height: 100%; overflow: hidden; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  font-size: 14px;
}

/* ── SCROLLBAR ── */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 4px; }

/* ══════════════════════════════════════════
   HEADER
══════════════════════════════════════════ */
.ag-header {
  height: var(--header-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 20px;
  gap: 0;
  flex-shrink: 0;
  z-index: 100;
  position: relative;
}
.ag-header::after {
  content: '';
  position: absolute;
  bottom: 0; left: 0; right: 0;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--accent), transparent);
  opacity: .4;
}

.ag-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  flex-shrink: 0;
}
.ag-logo-icon {
  width: 54px; height: 54px;
  background: linear-gradient(135deg, var(--accent-dim), var(--accent));
  border-radius: 15px;
  display: flex; align-items: center; justify-content: center;
  font-size: 27px;
  overflow: hidden;
}
.ag-logo-icon img {
  width: 100%; height: 100%;
  object-fit: contain;
  padding: 4px;
  box-sizing: border-box;
}
.ag-logo-text {
  font-size: 1.8rem;
  font-weight: 800;
  letter-spacing: -0.4px;
  color: var(--text);
}
.ag-logo-text span { color: var(--accent); }

.ag-header-sep {
  width: 1px; height: 39px;
  background: var(--border2);
  margin: 0 18px;
}
.ag-tagline {
  font-size: 1.14rem;
  color: var(--muted);
  white-space: nowrap;
}


/* ══════════════════════════════════════════
   APP BODY
══════════════════════════════════════════ */
.ag-body {
  flex: 1;
  display: flex;
  overflow: hidden;
  height: calc(100vh - var(--header-h) - var(--footer-h));
}

/* ══════════════════════════════════════════
   LEFT SIDEBAR
══════════════════════════════════════════ */
.ag-sidebar {
  width: var(--sidebar-w);
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  overflow-y: auto;
}

.ag-nav-section {
  padding: 16px 12px 6px;
  font-size: .65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1.1px;
  color: var(--muted);
}

.ag-nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  margin: 1px 8px;
  border-radius: var(--radius);
  cursor: pointer;
  text-decoration: none;
  color: var(--text-dim);
  transition: background .18s, color .18s;
  position: relative;
}
.ag-nav-item:hover { background: var(--surface2); color: var(--text); }
.ag-nav-item:hover .ag-nav-icon { border-color: var(--border2); }
.ag-nav-item.active {
  background: var(--accent-glow);
  color: var(--accent);
  border: 1px solid rgba(61,122,82,.25);
}
.ag-nav-item.active .ag-nav-text span { color: var(--accent2); }
.ag-nav-item.active .ag-nav-icon {
  background: var(--accent-dim);
  border-color: rgba(61,122,82,.35);
  filter: none;
}
.ag-nav-item.disabled { opacity: .35; cursor: not-allowed; pointer-events: none; }

.ag-nav-icon {
  width: 30px; height: 30px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-size: 14px; flex-shrink: 0;
  transition: background .18s, border-color .18s;
}
.ag-nav-text { flex: 1; }
.ag-nav-text span { display: block; font-size: .84rem; font-weight: 600; }
.ag-nav-text small { font-size: .7rem; color: var(--muted); }
.ag-nav-badge {
  font-size: .6rem;
  font-weight: 700;
  background: var(--surface3);
  border: 1px solid var(--border2);
  border-radius: 4px;
  padding: 2px 6px;
  color: var(--muted);
  letter-spacing: .3px;
}

/* Sub-items */
.ag-nav-sub { margin-left: 14px; border-left: 2px solid var(--border); padding-left: 4px; }
.ag-nav-sub .ag-nav-item { padding: 6px 10px; border-radius: 7px; }
.ag-nav-sub .ag-nav-icon { width: 24px; height: 24px; font-size: 11px; background: var(--surface3); border-color: var(--border); }
.ag-nav-sub .ag-nav-item.active .ag-nav-icon { background: var(--accent-dim); }
.ag-nav-sub .ag-nav-text span { font-size: .8rem; }

.ag-nav-divider { border: none; border-top: 1px solid var(--border); margin: 8px 12px; }

.ag-sidebar-footer {
  margin-top: auto;
  padding: 12px 14px;
  border-top: 1px solid var(--border);
}
.ag-sidebar-footer p { font-size: .7rem; color: var(--muted); line-height: 1.6; }

/* ══════════════════════════════════════════
   MAIN CONTENT
══════════════════════════════════════════ */
.ag-main {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  background: var(--bg);
}

/* ══════════════════════════════════════════
   FOOTER
══════════════════════════════════════════ */
.ag-footer {
  height: var(--footer-h);
  background: var(--surface);
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 22px;
  flex-shrink: 0;
  z-index: 100;
}
.ag-footer-left {
  display: flex; align-items: center; gap: 12px;
  font-size: .72rem; color: var(--muted);
}
.ag-status-dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 6px var(--accent);
  flex-shrink: 0;
}
.ag-footer-right { font-size: .72rem; color: var(--muted); }
.ag-footer-right a { color: var(--muted); text-decoration: none; transition: color .15s; }
.ag-footer-right a:hover { color: var(--accent2); }
.ag-footer-sep { color: var(--border2); }

/* ══════════════════════════════════════════
   SHARED COMPONENTS
══════════════════════════════════════════ */
.btn {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 9px 18px; border-radius: var(--radius);
  font-size: .88rem; font-weight: 600;
  cursor: pointer; border: none;
  transition: opacity .18s, transform .13s;
  text-decoration: none; white-space: nowrap;
}
.btn:active { transform: scale(.97); }
.btn:hover  { opacity: .85; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-outline { background: transparent; border: 1.5px solid var(--border2); color: var(--text); }
.btn-outline:hover { border-color: var(--accent); color: var(--accent); }
.btn-ghost   { background: var(--surface2); color: var(--text); }
.btn-ghost:hover { background: var(--surface3); }
.btn-sm { padding: 6px 14px; font-size: .82rem; }

/* ══════════════════════════════════════════
   AUTH HEADER COMPONENTS
══════════════════════════════════════════ */

/* Sign In button shown when logged out */
.auth-login-btn {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 7px 16px;
  border-radius: 20px;
  background: var(--accent-dim);
  border: 1px solid var(--accent);
  color: var(--accent2);
  font-size: .82rem; font-weight: 600;
  text-decoration: none;
  transition: background .18s, color .18s, box-shadow .18s;
  white-space: nowrap;
}
.auth-login-btn:hover {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 0 10px var(--accent-glow);
  text-decoration: none;
}

.auth-user-btn {
  display: flex; align-items: center; gap: 8px;
  padding: 5px 10px 5px 5px;
  border-radius: 22px;
  cursor: pointer;
  border: 1px solid var(--border2);
  background: var(--surface2);
  transition: border-color .18s, background .18s;
  user-select: none;
}
.auth-user-btn:hover { border-color: var(--accent); background: var(--surface3); }

.auth-avatar {
  width: 28px; height: 28px; border-radius: 50%;
  background: linear-gradient(135deg, var(--accent-dim), var(--accent));
  display: flex; align-items: center; justify-content: center;
  font-size: .72rem; font-weight: 800; color: #fff;
  flex-shrink: 0;
}
.auth-name { font-size: .82rem; font-weight: 600; color: var(--text); }

/* Dropdown */
.auth-user-btn { position: relative; }
#auth-area {
  position: relative;
  display: flex;
  align-items: center;
  flex-shrink: 0;
  min-width: max-content;
  margin-left: auto;
}

.auth-dropdown {
  display: none;
  position: absolute;
  right: 0; top: calc(100% + 8px);
  width: 220px;
  background: var(--surface2);
  border: 1px solid var(--border2);
  border-radius: 12px;
  box-shadow: 0 8px 32px rgba(0,0,0,.15);
  z-index: 200;
  overflow: hidden;
}
.auth-dropdown.open { display: block; }

.auth-dd-info { padding: 14px 14px 10px; }
.auth-dd-name { font-size: .88rem; font-weight: 700; }
.auth-dd-email { font-size: .74rem; color: var(--muted); margin-top: 2px; }

.auth-dd-sep { border: none; border-top: 1px solid var(--border); margin: 0; }

.auth-dd-item {
  display: block; padding: 10px 14px;
  font-size: .84rem; color: var(--text-dim);
  text-decoration: none; cursor: pointer;
  transition: background .15s, color .15s;
}
.auth-dd-item:hover { background: var(--surface3); color: var(--text); }
.auth-dd-danger:hover { color: var(--error) !important; background: rgba(248,113,113,.08) !important; }

/* ══════════════════════════════════════════
   LOGIN PAGE
══════════════════════════════════════════ */
.login-page {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 32px 20px;
  background: var(--bg);
  overflow-y: auto;
}
.login-card {
  width: 100%;
  max-width: 420px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 36px 32px;
  display: flex;
  flex-direction: column;
  gap: 22px;
}
.login-logo {
  display: flex; flex-direction: column;
  align-items: center; gap: 10px; text-align: center;
}
.login-logo-icon {
  width: 52px; height: 52px;
  background: linear-gradient(135deg, var(--accent-dim), var(--accent));
  border-radius: 14px;
  display: flex; align-items: center; justify-content: center;
  font-size: 24px;
  overflow: hidden;
}
.login-logo-icon img {
  width: 100%; height: 100%;
  object-fit: contain;
  padding: 4px;
  box-sizing: border-box;
}
.login-logo h1 { font-size: 1.4rem; font-weight: 800; }
.login-logo h1 span { color: var(--accent); }
.login-logo p { font-size: .82rem; color: var(--muted); }

/* Tab switcher */
.auth-tabs {
  display: flex;
  background: var(--surface2);
  border-radius: 10px;
  padding: 4px;
  gap: 2px;
}
.auth-tab {
  flex: 1; text-align: center;
  padding: 8px 0;
  border-radius: 8px;
  font-size: .86rem; font-weight: 600;
  cursor: pointer;
  color: var(--muted);
  transition: background .18s, color .18s;
}
.auth-tab.active { background: var(--surface); color: var(--text); box-shadow: 0 1px 4px rgba(0,0,0,.3); }

/* Form fields */
.auth-form { display: flex; flex-direction: column; gap: 14px; }
.auth-field { display: flex; flex-direction: column; gap: 5px; }
.auth-field label { font-size: .8rem; font-weight: 600; color: var(--text-dim); }
.auth-field input {
  background: var(--surface2);
  border: 1px solid var(--border2);
  border-radius: 9px;
  padding: 11px 14px;
  color: var(--text);
  font-size: .9rem;
  transition: border-color .18s;
  outline: none;
}
.auth-field input:focus { border-color: var(--accent); }
.auth-field input::placeholder { color: var(--muted); }

.auth-submit {
  width: 100%;
  padding: 12px;
  border-radius: 10px;
  border: none;
  background: var(--accent);
  color: #fff;
  font-size: .95rem;
  font-weight: 700;
  cursor: pointer;
  transition: opacity .18s;
  margin-top: 4px;
}
.auth-submit:hover { opacity: .88; }
.auth-submit:disabled { opacity: .5; cursor: not-allowed; }

.auth-divider {
  display: flex; align-items: center; gap: 12px;
  font-size: .78rem; color: var(--muted);
}
.auth-divider::before, .auth-divider::after {
  content: ''; flex: 1; border-top: 1px solid var(--border);
}

.auth-google {
  width: 100%; padding: 11px;
  border-radius: 10px;
  border: 1.5px solid var(--border2);
  background: transparent; color: var(--text);
  font-size: .9rem; font-weight: 600;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center; gap: 10px;
  transition: border-color .18s, background .18s;
}
.auth-google:hover { border-color: var(--accent); background: var(--surface2); }

.auth-msg {
  font-size: .82rem;
  text-align: center;
  padding: 10px;
  border-radius: 8px;
  display: none;
}
.auth-msg.success { background: var(--accent-glow); color: var(--accent2); border: 1px solid rgba(61,122,82,.25); display: block; }
.auth-msg.error   { background: rgba(248,113,113,.1); color: var(--error); border: 1px solid rgba(248,113,113,.25); display: block; }

.auth-footer-link {
  text-align: center;
  font-size: .8rem;
  color: var(--muted);
}
.auth-footer-link a { color: var(--accent2); text-decoration: none; }
.auth-footer-link a:hover { text-decoration: underline; }

/* ══════════════════════════════════════════
   DASHBOARD
══════════════════════════════════════════ */
.dash-body { flex: 1; overflow-y: auto; padding: 28px 32px; display: flex; flex-direction: column; gap: 28px; }

.dash-welcome {
  display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap;
}
.dash-welcome h2 { font-size: 1.4rem; font-weight: 800; }
.dash-welcome h2 span { color: var(--accent); }
.dash-welcome p { font-size: .86rem; color: var(--muted); margin-top: 4px; }

/* Stats row */
.dash-stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 14px; }
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 16px;
  display: flex; flex-direction: column; gap: 6px;
}
.stat-card .stat-icon { font-size: 1.4rem; }
.stat-card .stat-val  { font-size: 1.8rem; font-weight: 800; color: var(--accent2); }
.stat-card .stat-lbl  { font-size: .76rem; color: var(--muted); }

/* Section */
.dash-section { display: flex; flex-direction: column; gap: 12px; }
.dash-section-hdr {
  display: flex; align-items: center; justify-content: space-between;
  font-size: .72rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: 1px; color: var(--muted);
  padding-bottom: 8px; border-bottom: 1px solid var(--border);
}
.dash-section-hdr a { font-size: .76rem; text-transform: none; letter-spacing: 0; color: var(--accent2); text-decoration: none; font-weight: 600; }
.dash-section-hdr a:hover { text-decoration: underline; }

/* Data cards */
.dash-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; }
.dash-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  display: flex; flex-direction: column; gap: 8px;
  position: relative;
}
.dash-card h4 { font-size: .88rem; font-weight: 700; }
.dash-card .dc-meta { font-size: .74rem; color: var(--muted); }
.dash-card .dc-actions { display: flex; gap: 6px; margin-top: 4px; }
.dc-btn {
  font-size: .74rem; padding: 4px 10px;
  border-radius: 6px; cursor: pointer; border: none;
  font-weight: 600; transition: opacity .15s;
}
.dc-btn:hover { opacity: .8; }
.dc-btn-primary { background: var(--accent-dim); color: var(--accent2); }
.dc-btn-danger  { background: rgba(248,113,113,.12); color: var(--error); }

.empty-state {
  padding: 28px;
  text-align: center;
  background: var(--surface);
  border: 1px dashed var(--border2);
  border-radius: var(--radius);
  color: var(--muted);
  font-size: .86rem;
}
.empty-state .es-icon { font-size: 2rem; margin-bottom: 8px; }

/* Profile section */
.profile-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  display: flex; gap: 20px; align-items: flex-start;
  flex-wrap: wrap;
}
.profile-avatar-big {
  width: 64px; height: 64px; border-radius: 50%;
  background: linear-gradient(135deg, var(--accent-dim), var(--accent));
  display: flex; align-items: center; justify-content: center;
  font-size: 1.4rem; font-weight: 800; color: #fff;
  flex-shrink: 0;
}
.profile-form { flex: 1; display: flex; flex-direction: column; gap: 12px; min-width: 220px; }
.profile-form input {
  background: var(--surface2); border: 1px solid var(--border2);
  border-radius: 8px; padding: 9px 12px; color: var(--text);
  font-size: .86rem; outline: none;
}
.profile-form input:focus { border-color: var(--accent); }
.profile-form label { font-size: .76rem; color: var(--muted); margin-bottom: 2px; display: block; }

.tag-soon {
  display: inline-block;
  font-size: .6rem; font-weight: 700;
  background: var(--surface3); border: 1px solid var(--border2);
  border-radius: 4px; padding: 2px 6px;
  color: var(--muted); letter-spacing: .4px;
}

/* ══════════════════════════════════════════
   MOBILE RESPONSIVENESS
══════════════════════════════════════════ */
.ag-mobile-toggle {
  display: none;
  align-items: center; justify-content: center;
  width: 38px; height: 38px;
  border-radius: 9px;
  border: 1px solid var(--border2);
  background: var(--surface2);
  color: var(--text);
  font-size: 18px;
  cursor: pointer;
  flex-shrink: 0;
  margin-right: 12px;
}
.ag-mobile-toggle:hover { background: var(--surface3); }

.ag-nav-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.45);
  z-index: 199;
}
.ag-nav-backdrop.open { display: block; }

@supports (height: 100dvh) {
  html, body { height: 100dvh; }
}

@media (max-width: 860px) {
  .ag-mobile-toggle { display: flex; }

  .ag-body {
    height: calc(100vh - var(--header-h) - var(--footer-h));
  }
  @supports (height: 100dvh) {
    .ag-body { height: calc(100dvh - var(--header-h) - var(--footer-h)); }
  }

  .ag-sidebar {
    position: fixed;
    top: var(--header-h);
    left: 0;
    bottom: var(--footer-h);
    width: min(var(--sidebar-w), 78vw);
    transform: translateX(-100%);
    transition: transform .25s ease;
    z-index: 200;
    box-shadow: 4px 0 18px rgba(0,0,0,.2);
  }
  .ag-sidebar.open { transform: translateX(0); }

  .ag-header { padding: 0 14px; }
  .ag-header-sep { margin: 0 12px; }
  .ag-tagline { display: none; }
  .ag-logo-text { font-size: 1.4rem; }
  .ag-logo-icon { width: 42px; height: 42px; font-size: 20px; }
}

@media (max-width: 460px) {
  .ag-header-sep { display: none; }
}
