/* layout.css — App Shell: Sidebar + Main */
html, body { height: 100%; }
body {
  font-family: var(--font-family);
  background: var(--bg-secondary);
  color: var(--text-primary);
  display: flex;
}

/* Sidebar */
.sidebar {
  width: var(--sidebar-width);
  min-height: 100vh;
  background: var(--bg-sidebar);
  display: flex;
  flex-direction: column;
  position: fixed;
  left: 0; top: 0; bottom: 0;
  z-index: 100;
  overflow-y: auto;
}

.sidebar-brand {
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}

.sidebar-brand h1 {
  font-size: 1.125rem;
  color: #38bdf8;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.sidebar-brand small {
  display: block;
  color: var(--slate-500);
  font-size: 0.75rem;
  margin-top: 0.125rem;
}

.sidebar-nav {
  flex: 1;
  padding: 0.75rem 0.75rem;
}

.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.625rem 0.875rem;
  border-radius: 8px;
  color: var(--text-sidebar);
  font-size: 0.875rem;
  font-weight: 500;
  transition: all 0.15s;
  margin-bottom: 2px;
}

.sidebar-nav a:hover {
  background: rgba(255,255,255,0.08);
  color: #fff;
}

.sidebar-nav a.active {
  background: rgba(56, 189, 248, 0.15);
  color: #38bdf8;
}

.sidebar-nav .nav-icon {
  font-size: 1.125rem;
  width: 1.5rem;
  text-align: center;
}

.sidebar-nav .nav-badge {
  margin-left: auto;
  background: var(--blue-600);
  color: #fff;
  font-size: 0.7rem;
  padding: 0.125rem 0.5rem;
  border-radius: 999px;
  font-weight: 600;
}

.sidebar-footer {
  padding: 1rem 1.25rem;
  border-top: 1px solid rgba(255,255,255,0.08);
  font-size: 0.8rem;
  color: var(--slate-600);
}

.sidebar-footer .user-info {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  margin-bottom: 0.5rem;
}

.sidebar-footer .user-avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: var(--slate-700);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.875rem;
  color: var(--slate-300);
  font-weight: 600;
}

.sidebar-footer .user-name {
  color: var(--slate-300);
  font-size: 0.8125rem;
  font-weight: 500;
}

.sidebar-footer .user-email {
  color: var(--slate-500);
  font-size: 0.75rem;
}

/* Main area */
.main {
  margin-left: var(--sidebar-width);
  flex: 1;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.main-header {
  height: var(--header-height);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.5rem;
  background: var(--bg-primary);
  border-bottom: 1px solid var(--border-color);
  position: sticky;
  top: 0;
  z-index: 50;
}

.main-header h2 {
  font-size: 1.125rem;
  font-weight: 600;
}

.main-header-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.main-content {
  flex: 1;
  padding: 1.5rem;
  max-width: 1200px;
  width: 100%;
  margin: 0 auto;
}

/* Login page (full screen, no sidebar) */
.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: var(--bg-secondary);
  padding: 1rem;
}

.login-card {
  width: 100%;
  max-width: 400px;
  background: var(--bg-card);
  border-radius: var(--border-radius-lg);
  padding: 2.5rem;
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--border-color);
}

.login-card h1 {
  font-size: 1.5rem;
  margin-bottom: 0.25rem;
  color: #38bdf8;
}

.login-card .subtitle {
  color: var(--text-secondary);
  font-size: 0.875rem;
  margin-bottom: 1.5rem;
}

.login-card .login-error {
  color: var(--red-500);
  font-size: 0.8125rem;
  margin-bottom: 1rem;
  padding: 0.5rem 0.75rem;
  background: var(--red-50);
  border-radius: var(--border-radius-sm);
  display: none;
}

@media (prefers-color-scheme: dark) {
  .login-card .login-error {
    background: rgba(239,68,68,0.1);
  }
}

/* Page sections */
.page-section {
  background: var(--bg-card);
  border-radius: var(--border-radius-lg);
  border: 1px solid var(--border-color);
  padding: 1.5rem;
  margin-bottom: 1.5rem;
}

.page-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
}

.page-section-header h3 {
  font-size: 1rem;
  font-weight: 600;
}

/* Stats grid */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius-lg);
  padding: 1.25rem;
}

.stat-card .stat-value {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--text-primary);
}

.stat-card .stat-label {
  font-size: 0.8125rem;
  color: var(--text-secondary);
  margin-top: 0.25rem;
}

.stat-card .stat-icon {
  font-size: 1.5rem;
  margin-bottom: 0.5rem;
}

/* Empty state */
.empty-state {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--text-secondary);
}

.empty-state .empty-icon {
  font-size: 2.5rem;
  margin-bottom: 0.75rem;
}

.empty-state .empty-text {
  font-size: 0.9375rem;
}

/* Loading */
.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 3rem;
  color: var(--text-tertiary);
}

.spinner {
  width: 20px; height: 20px;
  border: 2px solid var(--border-color);
  border-top-color: var(--blue-500);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  margin-right: 0.5rem;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* Responsive */
@media (max-width: 768px) {
  .sidebar {
    width: 100%;
    min-height: auto;
    position: relative;
    height: auto;
  }
  .main {
    margin-left: 0;
  }
  .sidebar-nav {
    display: flex;
    overflow-x: auto;
    padding: 0.5rem;
  }
  .sidebar-nav a {
    white-space: nowrap;
    margin-bottom: 0;
  }
  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}
