/* Shared nav shell styling — included on every authenticated page via _nav.html.
   Bumping the ?v= query in _nav.html invalidates the browser cache. */

/* ── Nav Tokens (augments page tokens) ── */
:root {
  --sidebar-w: 230px;
  --bottom-nav-h: 60px;
  --amber-dim: rgba(255,179,64,0.12);
}

/* ── APP SHELL ── */
.app-shell { display: flex; min-height: 100vh; flex-direction: column; }

/* ── SIDEBAR ── */
.sidebar {
  display: none;
  width: var(--sidebar-w); flex-shrink: 0;
  position: fixed; top: 0; left: 0; height: 100vh;
  background: var(--surface);
  border-right: 1px solid var(--border);
  flex-direction: column;
  z-index: 100;
  overflow: hidden;
}
.sidebar-brand {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}
.brand-title {
  font-family: "DM Sans", "Noto Sans SC", -apple-system, sans-serif;
  font-style: normal;
  letter-spacing: -0.02em;
  display: flex; align-items: center; gap: 12px;
  color: var(--text);
}
.brand-title .brand-icon {
  flex-shrink: 0;
  display: inline-flex; align-items: center; justify-content: center;
}
.brand-title .brand-text {
  display: flex; flex-direction: column;
  line-height: 1.05;
  font-weight: 700;
}
.brand-title .brand-row-1 { font-size: 18px; color: var(--text); }
.brand-title .brand-row-2 { font-size: 18px; color: var(--amber); margin-top: 1px; }

.sidebar-nav { flex: 1; padding: 12px 0; overflow-y: auto; }
.nav-group-label {
  font-size: 10px; font-weight: 700; letter-spacing: 0.10em; text-transform: uppercase;
  color: var(--text-3); padding: 12px 20px 6px;
}
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 20px;
  color: var(--text-2);
  text-decoration: none;
  font-size: 13.5px; font-family: "DM Sans", sans-serif;
  transition: background 0.15s, color 0.15s;
  position: relative;
}
.nav-item:hover { background: var(--surface-2); color: var(--text); }
.nav-item.active { background: var(--amber-dim); color: var(--text); }
.nav-item.active::before {
  content: ''; position: absolute;
  left: 0; top: 18%; bottom: 18%;
  width: 3px; border-radius: 0 2px 2px 0;
  background: var(--amber);
}
.nav-icon { width: 18px; height: 18px; flex-shrink: 0; opacity: 0.7; transition: opacity 0.15s; }
.nav-item.active .nav-icon, .nav-item:hover .nav-icon { opacity: 1; }
.nav-item-text { flex: 1; }
.nav-badge {
  font-family: "DM Mono", monospace; font-size: 10px; font-weight: 600;
  background: rgba(255,179,64,0.12); color: var(--amber);
  border: 1px solid rgba(255,179,64,0.25);
  border-radius: 6px; padding: 1px 6px; min-width: 20px; text-align: center;
  letter-spacing: 0.2px;
}
.nav-badge.amber {
  background: rgba(255,179,64,0.12); color: var(--amber);
  border: 1px solid rgba(255,179,64,0.25);
}

.sidebar-footer {
  padding: 20px 20px; border-top: 1px solid var(--border);
}
.footer-status { display: flex; align-items: center; gap: 7px; margin-bottom: 6px; }
.status-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--green); flex-shrink: 0; }
.footer-label { font-family: "DM Mono", monospace; font-size: 11px; color: var(--text-3); }
.footer-time { font-family: "DM Mono", monospace; font-size: 18px; font-weight: 500; color: var(--text-2); line-height: 1; margin-top: 4px; }
.footer-date { font-family: "DM Mono", monospace; font-size: 10px; color: var(--text-3); margin-top: 2px; }

/* ── MAIN CONTENT ── */
.main-content {
  flex: 1; min-width: 0;
  padding-bottom: calc(var(--bottom-nav-h) + env(safe-area-inset-bottom, 0px) + 16px);
}

/* ── MOBILE TOP BAR ── */
.mobile-topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 16px 8px;
  padding-top: max(16px, env(safe-area-inset-top, 16px));
  position: sticky; top: 0;
  background: var(--bg); z-index: 10;
  border-bottom: 1px solid var(--border-2);
}
.topbar-brand {
  font-family: "DM Sans", "Noto Sans SC", -apple-system, sans-serif;
  font-style: normal; font-size: 17px; font-weight: 500;
  letter-spacing: -0.02em; color: var(--text);
}

/* ── BOTTOM TAB BAR ── */
.bottom-nav {
  position: fixed; bottom: 0; left: 0; right: 0;
  height: calc(var(--bottom-nav-h) + env(safe-area-inset-bottom, 0px));
  padding-bottom: env(safe-area-inset-bottom, 0px);
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-top: 1px solid var(--border);
  display: flex; align-items: stretch;
  z-index: 200;
}
.tab-item {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 3px; cursor: pointer; text-decoration: none;
  color: var(--text-3); font-family: "DM Sans", sans-serif;
  font-size: 10px; font-weight: 500;
  position: relative;
  transition: color 0.15s;
  -webkit-tap-highlight-color: transparent;
}
.tab-item:hover { color: var(--text-2); }
.tab-item.active { color: var(--amber); }
.tab-item.active::before {
  content: ''; position: absolute;
  top: 0; left: 20%; right: 20%;
  height: 2px; border-radius: 0 0 2px 2px;
  background: var(--amber);
}
.tab-icon-wrap { position: relative; width: 24px; height: 24px; display: flex; align-items: center; justify-content: center; }
.tab-icon { width: 22px; height: 22px; transition: transform 0.15s; }
.tab-item.active .tab-icon { transform: translateY(-1px); }
.tab-badge {
  position: absolute; top: -3px; right: -6px;
  min-width: 15px; height: 15px;
  background: rgba(255,179,64,0.18); color: var(--amber);
  border: 1.5px solid var(--bg);
  border-radius: 5px; font-family: "DM Mono", monospace;
  font-size: 9px; font-weight: 600;
  display: flex; align-items: center; justify-content: center;
  padding: 0 3px;
}
.tab-label { line-height: 1; }

/* ── DESKTOP OVERRIDES ── */
@media (min-width: 1024px) {
  .app-shell { flex-direction: row; }
  .sidebar { display: flex; }
  .main-content {
    margin-left: var(--sidebar-w);
    padding-bottom: 48px;
  }
  .mobile-topbar { display: none; }
  .bottom-nav { display: none; }

  /* ── Drill-down two-panel structure ── */
  .sidebar-root,
  .sidebar-sub {
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    display: flex; flex-direction: column;
    transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    overflow-y: auto; scrollbar-width: none;
  }
  .sidebar-root::-webkit-scrollbar,
  .sidebar-sub::-webkit-scrollbar { display: none; }
  .sidebar-root { transform: translateX(0); }
  .sidebar-root.hidden { transform: translateX(-100%); }
  .sidebar-sub { transform: translateX(100%); }
  .sidebar-sub.visible { transform: translateX(0); }

  /* Sub panel header */
  .sidebar-sub-header {
    display: flex; align-items: center; gap: 8px;
    padding: 14px 16px 12px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
  }
  .sidebar-back {
    display: flex; align-items: center; gap: 4px;
    padding: 4px 8px 4px 4px;
    border: none; background: transparent;
    color: var(--text-3); cursor: pointer;
    font-size: 12px; font-family: "DM Sans", sans-serif;
    border-radius: 6px;
    transition: color 0.15s, background 0.15s;
  }
  .sidebar-back:hover { color: var(--text); background: var(--surface-2); }
  .sidebar-back svg { flex-shrink: 0; }
  .sidebar-sub-title {
    font-size: 14px; font-weight: 600; color: var(--text);
    font-family: "DM Sans", sans-serif;
  }
  .sidebar-sub-content {
    flex: 1; overflow-y: auto; padding: 12px 0;
    scrollbar-width: none;
  }
  .sidebar-sub-content::-webkit-scrollbar { display: none; }
  .sidebar-divider { height: 1px; background: var(--border-2); margin: 8px 0; }

  /* Filter buttons */
  .sidebar-group { margin-bottom: 4px; }
  .sidebar-group-label {
    font-size: 10px; font-weight: 700; letter-spacing: 0.1em;
    text-transform: uppercase; color: var(--text-3);
    padding: 10px 20px 4px;
  }
  .sidebar-filter-btn {
    display: flex; align-items: center; gap: 8px;
    width: 100%; padding: 8px 20px;
    border: none; background: transparent;
    color: var(--text-2); font-size: 13px;
    font-family: "DM Sans", sans-serif;
    cursor: pointer; text-align: left;
    transition: background 0.15s, color 0.15s;
    position: relative;
  }
  .sidebar-filter-btn:hover { background: var(--surface-2); color: var(--text); }
  .sidebar-filter-btn.active { color: var(--text); background: var(--surface-2); }
  .sidebar-filter-btn.active::before {
    content: '';
    position: absolute; left: 0; top: 20%; bottom: 20%;
    width: 3px; border-radius: 2px; background: var(--amber);
  }
  .sidebar-filter-count {
    margin-left: auto;
    font-family: "DM Mono", monospace; font-size: 11px; color: var(--text-3);
  }
  .sidebar-time { padding-bottom: 8px; }
  .sidebar-time-btn {
    display: block; width: 100%; padding: 8px 20px;
    border: none; background: transparent;
    color: var(--text-3); font-size: 13px;
    font-family: "DM Sans", sans-serif;
    cursor: pointer; text-align: left;
    transition: background 0.15s, color 0.15s;
  }
  .sidebar-time-btn:hover { background: var(--surface-2); color: var(--text-2); }
  .sidebar-time-btn.active { color: var(--text); background: var(--surface-2); }
}

/* ── MOBILE TOPBAR LANGUAGE SWITCHER ── */
.topbar-lang {
  position: relative;
}
.topbar-lang-btn {
  display: flex; align-items: center; gap: 5px;
  min-height: 44px; padding: 8px 12px;
  background: transparent; border: none;
  color: var(--text-2); cursor: pointer;
  font-family: "DM Sans", sans-serif; font-size: 12px; font-weight: 500;
  border-radius: 8px;
  -webkit-tap-highlight-color: transparent;
  transition: background 0.15s, color 0.15s;
}
.topbar-lang-btn:hover,
.topbar-lang-btn:focus-visible { background: var(--surface-2); color: var(--text); outline: none; }
.topbar-lang-dropdown {
  position: absolute; top: 100%; right: 0;
  margin-top: 4px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 8px; box-shadow: 0 4px 16px rgba(0,0,0,0.3);
  min-width: 120px; padding: 4px 0;
  z-index: 20;
  opacity: 0; visibility: hidden;
  transition: opacity 0.15s, visibility 0.15s;
}
.topbar-lang-dropdown.visible { opacity: 1; visibility: visible; }
.topbar-lang-item {
  display: block; padding: 8px 14px;
  font-size: 13px; color: var(--text-3); text-decoration: none;
  font-family: "DM Sans", sans-serif;
}
.topbar-lang-item.active { color: var(--amber); font-weight: 600; }
.topbar-lang-item:hover { background: var(--surface-2); color: var(--text); }
