/* ── Reset ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; -webkit-font-smoothing: antialiased; }
body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; }

/* ── Theme Variables ── */
:root {
  --sidebar-w: 240px;
  --radius: 10px;
  --radius-sm: 6px;
  --transition: 0.2s ease;
}

[data-theme="dark"] {
  --bg: #0f0f0f;
  --bg-surface: #1a1a1a;
  --bg-elevated: #242424;
  --bg-hover: #2a2a2a;
  --border: #2e2e2e;
  --text: #e8e8e8;
  --text-secondary: #8e8e93;
  --text-tertiary: #636366;
  --accent: #ff9f0a;
  --accent-hover: #f0a024;
  --green: #30d158;
  --red: #ff453a;
  --sidebar-bg: #121212;
  --sidebar-border: #1e1e1e;
  --shadow: 0 1px 3px rgba(0,0,0,0.4);
}

[data-theme="light"] {
  --bg: #f5f5f7;
  --bg-surface: #ffffff;
  --bg-elevated: #ffffff;
  --bg-hover: #e8e8ed;
  --border: #d2d2d7;
  --text: #1d1d1f;
  --text-secondary: #6e6e73;
  --text-tertiary: #aeaeb2;
  --accent: #ff9f0a;
  --accent-hover: #e89400;
  --green: #30d158;
  --red: #ff453a;
  --sidebar-bg: #ffffff;
  --sidebar-border: #d2d2d7;
  --shadow: 0 1px 3px rgba(0,0,0,0.08);
}

/* ── Layout ── */
#app {
  display: flex;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
}

/* ── Sidebar ── */
#sidebar {
  width: var(--sidebar-w);
  display: flex;
  flex-direction: column;
  background: var(--sidebar-bg);
  border-right: 1px solid var(--sidebar-border);
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 100;
}

.sidebar-header {
  padding: 20px 20px 16px;
  border-bottom: 1px solid var(--sidebar-border);
}

.logo {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--accent);
  text-decoration: none;
  letter-spacing: -0.02em;
}

.sidebar-nav {
  flex: 1;
  padding: 12px 10px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 500;
  transition: all var(--transition);
}

.nav-item:hover {
  background: var(--bg-hover);
  color: var(--text);
}

.nav-item.active {
  background: var(--accent);
  color: #fff;
}

.nav-item svg {
  flex-shrink: 0;
}

/* ── Sidebar Footer ── */
.sidebar-footer {
  padding: 12px 10px;
  border-top: 1px solid var(--sidebar-border);
  display: flex;
  align-items: center;
  gap: 8px;
}

.theme-toggle {
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px;
  cursor: pointer;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition);
  flex-shrink: 0;
}

.theme-toggle:hover {
  background: var(--bg-hover);
  color: var(--text);
}

[data-theme="dark"] .theme-toggle .sun { display: block; }
[data-theme="dark"] .theme-toggle .moon { display: none; }
[data-theme="light"] .theme-toggle .sun { display: none; }
[data-theme="light"] .theme-toggle .moon { display: block; }

.user-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  min-width: 0;
}

.avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 600;
  flex-shrink: 0;
}

.user-name {
  font-size: 0.8rem;
  color: var(--text-secondary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ── Main Content ── */
#content {
  flex: 1;
  margin-left: var(--sidebar-w);
  padding: 32px 40px;
  max-width: 1100px;
}

#page-root {
  animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── Page Header ── */
.page-header {
  margin-bottom: 28px;
}

.page-header h1 {
  font-size: 1.75rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-bottom: 4px;
}

.page-header p {
  color: var(--text-secondary);
  font-size: 0.9rem;
}

/* ── Stat Cards ── */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 28px;
}

.stat-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
}

.stat-card .label {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-tertiary);
  margin-bottom: 6px;
}

.stat-card .value {
  font-size: 1.75rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.stat-card .change {
  font-size: 0.8rem;
  margin-top: 4px;
}

.stat-card .change.positive { color: var(--green); }
.stat-card .change.negative { color: var(--red); }

/* ── List / Cards ── */
.card-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 20px;
  box-shadow: var(--shadow);
  cursor: pointer;
  transition: all var(--transition);
}

.card:hover {
  border-color: var(--accent);
}

.card-title {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 4px;
}

.card-subtitle {
  font-size: 0.85rem;
  color: var(--text-secondary);
}

/* ── Placeholder ── */
.placeholder-page {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 60vh;
  color: var(--text-tertiary);
  text-align: center;
  gap: 12px;
}

.placeholder-page svg {
  opacity: 0.3;
  margin-bottom: 8px;
}

.placeholder-page h2 {
  font-size: 1.2rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.placeholder-page p {
  font-size: 0.9rem;
  max-width: 300px;
}

/* ── Utilities ── */
.section-title {
  font-size: 1.1rem;
  font-weight: 600;
  margin-bottom: 14px;
  letter-spacing: -0.01em;
}

/* ── Responsive ── */
/* ── No Sidebar (Home / Login / Signup) ── */
#app.no-sidebar #sidebar { display: none; }
#app.no-sidebar #content {
  margin-left: 0;
  padding: 0;
  max-width: 100%;
}

/* ── Home Page ── */
.home-page {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
}

.home-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px 40px;
  max-width: 1200px;
  margin: 0 auto;
  width: 100%;
}

.hero {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 60px 40px;
  text-align: center;
}

.hero-content {
  max-width: 680px;
}

.hero-icon {
  color: var(--accent);
  margin-bottom: 24px;
}

.hero-title {
  font-size: 3rem;
  font-weight: 800;
  line-height: 1.1;
  letter-spacing: -0.03em;
  margin-bottom: 16px;
}

.hero-subtitle {
  font-size: 1.15rem;
  color: var(--text-secondary);
  line-height: 1.6;
  margin-bottom: 36px;
}

.hero-cta {
  display: flex;
  gap: 12px;
  justify-content: center;
  flex-wrap: wrap;
}

.btn-lg {
  padding: 14px 28px;
  font-size: 1rem;
  border-radius: 8px;
}

.features {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 20px;
  padding: 40px;
  max-width: 1100px;
  margin: 0 auto 60px;
  width: 100%;
}

.feature-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px 24px;
  text-align: center;
  transition: border-color var(--transition);
}

.feature-card:hover {
  border-color: var(--accent);
}

.feature-card svg {
  color: var(--accent);
  margin-bottom: 16px;
}

.feature-card h3 {
  font-size: 1.05rem;
  font-weight: 600;
  margin-bottom: 8px;
}

.feature-card p {
  font-size: 0.85rem;
  color: var(--text-secondary);
  line-height: 1.6;
}

.home-footer {
  text-align: center;
  padding: 24px;
  color: var(--text-tertiary);
  font-size: 0.8rem;
  border-top: 1px solid var(--border);
}

@media (max-width: 768px) {
  #sidebar {
    width: 60px;
  }

  .sidebar-header .logo,
  .nav-item span,
  .user-badge .user-name {
    display: none;
  }

  .sidebar-header {
    padding: 16px 12px;
    text-align: center;
  }

  .nav-item {
    justify-content: center;
    padding: 10px;
  }

  .sidebar-footer {
    flex-direction: column;
    padding: 8px;
  }

  #content {
    margin-left: 60px;
    padding: 20px 16px;
  }

  .stat-grid {
    grid-template-columns: 1fr 1fr;
  }

  .hero-title { font-size: 2rem; }
  .hero { padding: 40px 20px; }
  .features { padding: 20px; grid-template-columns: 1fr; }
  .home-header { padding: 16px 20px; }
  .feature-card { padding: 20px 16px; }
}

/* ── Form Elements ── */
.form-group {
  margin-bottom: 16px;
}

.form-group label {
  display: block;
  font-size: 0.85rem;
  font-weight: 500;
  margin-bottom: 6px;
  color: var(--text-secondary);
}

.form-group input,
.form-group select {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-surface);
  color: var(--text);
  font-size: 0.95rem;
  transition: border-color var(--transition);
}

.form-group input:focus,
.form-group select:focus {
  outline: none;
  border-color: var(--accent);
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
  text-decoration: none;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
}

.btn-primary:hover {
  background: var(--accent-hover);
}

.btn-secondary {
  background: var(--bg-elevated);
  color: var(--text);
  border: 1px solid var(--border);
}

.btn-secondary:hover {
  background: var(--bg-hover);
}

.btn-danger {
  background: var(--red);
  color: #fff;
}

/* ── Auth Pages (Login / Signup) ── */
.auth-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  margin-left: 0;
}

.auth-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 40px 36px;
  width: 100%;
  max-width: 380px;
  box-shadow: 0 4px 24px rgba(0,0,0,0.15);
}

.auth-card-header {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  margin-bottom: 6px;
}

.auth-icon {
  color: var(--accent);
}

.auth-logo {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: -0.02em;
}

.auth-subtitle {
  text-align: center;
  font-size: 1.15rem;
  font-weight: 600;
  margin: 20px 0 4px;
}

.auth-desc {
  text-align: center;
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-bottom: 24px;
}

.auth-btn {
  width: 100%;
  justify-content: center;
  padding: 12px 20px;
}

.auth-footer {
  text-align: center;
  margin-top: 20px;
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.auth-footer a {
  color: var(--accent);
  text-decoration: none;
  font-weight: 500;
}

.auth-footer a:hover {
  text-decoration: underline;
}

/* Spinner animation for signup loading state */
@keyframes spin {
  from { transform: rotate(0deg); }
  to   { transform: rotate(360deg); }
}

/* ── Modal Overlay ── */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 16px;
}

.modal {
  background: var(--card-bg, #1c1c1e);
  border: 1px solid var(--border, #38383a);
  border-radius: 12px;
  padding: 24px;
  width: 100%;
  max-width: 480px;
  max-height: 90vh;
  overflow-y: auto;
}
