﻿/* === reset === */
/* ════════ CSS Reset ════════ */
/* ── Reset ── */
*,
*::before,
*::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.5;
}

button {
  cursor: pointer;
  font-family: inherit;
  border: none;
}

input,
select {
  font-family: inherit;
}

svg {
  display: block;
}

/* === globals === */
/* ════════ Global Utilities ════════ */
/* ── Misc ── */
.hidden {
  display: none !important;
}

.highlight {
  color: var(--primary);
  font-weight: 700;
}

/* Overlay học từ mới — phủ toàn màn hình, z-index cao hơn sidebar */
.learn-overlay {
  position: fixed;
  inset: 0;
  z-index: 300;
  background: var(--bg);
  overflow-y: auto;
  padding-bottom: calc(40px + env(safe-area-inset-bottom, 0px));
}

/* === layout === */
/* ════════ App Layout (shell, navbar, sidebar, main, tab-panel, page-header) ════════ */

/* ── App shell ── */
.app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}

/* App body: sidebar + main (below navbar) */
.app-body {
  display: flex;
  flex: 1;
  overflow: hidden;
  min-height: 0;
}

/* ══════════════════════════════════════════ NAVBAR ══ */
.navbar {
  height: var(--nav-h);
  background: var(--card);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: var(--space-4);
  padding: 0 var(--space-6);
  position: sticky;
  top: 0;
  z-index: 200;
  box-shadow: var(--shadow-sm);
  flex-shrink: 0;
}

/* ── Brand ── */
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  flex: 1;
  min-width: 0;
}

.brand-icon { font-size: 1.5rem; }

.brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.2;
}

.brand-name {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--primary);
  letter-spacing: -0.3px;
}

.brand-tagline {
  font-size: var(--text-xs);
  color: var(--text-muted);
  font-weight: var(--font-weight-medium);
}

/* ── Search bar (desktop only) ── */
.nav-search {
  flex: 0 1 440px;
  position: relative;
  display: flex;
  align-items: center;
}

.nav-search-icon {
  position: absolute;
  left: 12px;
  width: 16px;
  height: 16px;
  color: var(--text-muted);
  pointer-events: none;
}

.nav-search-input {
  width: 100%;
  padding: 9px 90px 9px 38px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-pill);
  background: var(--bg);
  color: var(--text);
  font-size: var(--text-sm);
  transition: var(--transition);
  outline: none;
}

.nav-search-input:focus {
  border-color: var(--primary);
  background: var(--card);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 12%, transparent);
}

.nav-search-input::placeholder { color: var(--text-light); }

.nav-search-kbd {
  position: absolute;
  right: 12px;
  font-size: 0.65rem;
  color: var(--text-muted);
  background: var(--border-light);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 2px 6px;
  white-space: nowrap;
  pointer-events: none;
}

/* ── Right actions ── */
.nav-end {
  flex: 1;
  display: flex;
  align-items: center;
  gap: var(--space-2);
  justify-content: flex-end;
}

.streak-badge {
  display: flex;
  align-items: center;
  gap: 5px;
  background: linear-gradient(135deg, #FEF3C7, #FDE68A);
  border: 1px solid #F59E0B;
  color: #92400E;
  padding: 5px 12px;
  border-radius: var(--radius-pill);
  font-size: var(--text-xs);
  font-weight: var(--font-weight-bold);
  white-space: nowrap;
}

.streak-label { font-weight: var(--font-weight-medium); }

.nav-bell {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: none;
  background: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  transition: var(--transition);
  flex-shrink: 0;
}

.nav-bell:hover { background: var(--border-light); color: var(--text); }

.nav-user {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  cursor: pointer;
  padding: 4px var(--space-2);
  border-radius: var(--radius);
  transition: var(--transition);
  flex-shrink: 0;
}

.nav-user:hover { background: var(--border-light); }

.nav-user-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  color: #fff;
  font-weight: var(--font-weight-bold);
  font-size: var(--text-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.nav-user-info {
  display: flex;
  flex-direction: column;
  line-height: 1.2;
}

.nav-user-name {
  font-size: var(--text-sm);
  font-weight: var(--font-weight-semibold);
  color: var(--text);
  white-space: nowrap;
}

.nav-user-level {
  font-size: var(--text-xs);
  color: var(--text-muted);
}

/* ── Theme toggle ── */
.theme-toggle {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--border-light);
  border: 1px solid var(--border);
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: var(--transition);
}

.theme-toggle svg {
  width: 18px;
  height: 18px;
  pointer-events: none;
}

.theme-toggle:hover {
  background: var(--primary-light);
  color: var(--primary);
  border-color: var(--primary);
}

/* ── Nav tabs (mobile bottom nav only — hidden on desktop) ── */
.nav-tabs {
  display: none; /* shown on mobile via responsive.css */
  gap: 2px;
  flex: 1;
  overflow-x: auto;
  scrollbar-width: none;
}

.nav-tabs::-webkit-scrollbar { display: none; }

.nav-tab {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 0.875rem;
  font-weight: 500;
  white-space: nowrap;
  transition: background 0.15s, color 0.15s;
}

.nav-tab svg { width: 16px; height: 16px; flex-shrink: 0; }
.nav-tab:hover { background: var(--primary-light); color: var(--primary); }
.nav-tab.active { background: var(--primary); color: #fff; }

/* ══════════════════════════════════════════ SIDEBAR ══ */
.sidebar {
  width: 220px;
  flex-shrink: 0;
  background: var(--card);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: var(--space-4) var(--space-3) var(--space-4);
  overflow-y: auto;
  scrollbar-width: none;
  height: 100%;
}

.sidebar::-webkit-scrollbar { display: none; }

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.sidebar-upgrade {
  margin-top: var(--space-4);
}

.sidebar-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: 10px var(--space-3);
  border-radius: var(--radius);
  border: none;
  background: none;
  cursor: pointer;
  width: 100%;
  text-align: left;
  font-size: var(--text-sm);
  font-weight: var(--font-weight-medium);
  color: var(--text-muted);
  transition: var(--transition);
}

.sidebar-item:hover {
  background: var(--border-light);
  color: var(--text);
}

.sidebar-item.active {
  background: var(--primary-light);
  color: var(--primary);
  font-weight: var(--font-weight-semibold);
}

.sidebar-upgrade {
  background: linear-gradient(135deg, #4F46E5, #7C3AED);
  border-radius: var(--radius-lg);
  padding: var(--space-4);
  text-align: center;
  color: #fff;
  margin-top: var(--space-4);
  flex-shrink: 0;
}

.sidebar-upgrade-icon { font-size: 1.5rem; margin-bottom: var(--space-1); }

.sidebar-upgrade-title {
  font-weight: var(--font-weight-bold);
  font-size: var(--text-sm);
  margin-bottom: var(--space-1);
}

.sidebar-upgrade-desc {
  font-size: var(--text-xs);
  opacity: 0.85;
  margin-bottom: var(--space-3);
  line-height: 1.4;
}

.sidebar-upgrade-list {
  list-style: none;
  margin: 0 0 var(--space-3) 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.sidebar-upgrade-list li {
  font-size: var(--text-xs);
  opacity: 0.88;
}

.sidebar-upgrade-btn {
  width: 100%;
  padding: 8px;
  border-radius: var(--radius-pill);
  border: none;
  background: rgba(255,255,255,0.95);
  color: var(--primary);
  font-weight: var(--font-weight-bold);
  font-size: var(--text-xs);
  cursor: pointer;
  transition: var(--transition);
}

.sidebar-upgrade-btn:hover { background: #fff; }

.sidebar-rocket {
  text-align: center;
  font-size: 3rem;
  padding: var(--space-3) 0 var(--space-2);
  filter: drop-shadow(0 4px 8px rgba(99,102,241,0.3));
  animation: rocketFloat 4s ease-in-out infinite;
}

@keyframes rocketFloat {
  0%, 100% { transform: translateY(0) rotate(-15deg); }
  50%       { transform: translateY(-8px) rotate(-15deg); }
}

/* ══════════════════════════════════════════ MAIN ══ */
.main {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-7) clamp(20px, 3vw, 48px) var(--space-8);
  min-width: 0;
}

/* ── Tab panels ── */
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ── Page header ── */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-6);
}

.page-title {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.5px;
}

.page-subtitle {
  font-size: 0.925rem;
  color: var(--text-muted);
  margin-top: 2px;
}
