/* ============================================================
   Design tokens
   ============================================================ */
:root {
  --sidebar-width: 240px;
  --topbar-height: 52px;
  --radius-card: 12px;
  --radius-input: 8px;
  --radius-btn: 8px;
  --shadow-card: 0 1px 3px rgba(0,0,0,.06), 0 1px 2px rgba(0,0,0,.04);
  --color-primary: #4f46e5;
  --color-primary-hover: #4338ca;
  --color-sidebar-bg: #18181b;
  --color-sidebar-text: #a1a1aa;
  --color-sidebar-text-active: #ffffff;
  --color-sidebar-hover: rgba(255,255,255,.06);
  --color-sidebar-active: rgba(255,255,255,.10);
  --color-body: #f4f4f5;
  --color-surface: #ffffff;
  --color-border: #e4e4e7;
  --color-text: #18181b;
  --color-text-muted: #71717a;
}

/* ============================================================
   Reset / Base
   ============================================================ */
*, *::before, *::after { box-sizing: border-box; }

/* ============================================================
   App shell
   ============================================================ */
.app-layout {
  display: flex;
  min-height: 100vh;
  background: var(--color-body);
}

/* ============================================================
   Sidebar — permanent on desktop, slide-in on mobile
   ============================================================ */
.app-sidebar {
  width: var(--sidebar-width);
  background: var(--color-sidebar-bg);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  overflow-y: auto;
  /* Desktop: always visible */
  position: sticky;
  top: 0;
  height: 100vh;
  z-index: 30;
}

/* Mobile: hidden off-screen to the left */
@media (max-width: 1023px) {
  .app-sidebar {
    position: fixed;
    left: 0;
    top: 0;
    height: 100vh;
    transform: translateX(calc(-1 * var(--sidebar-width)));
    transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 50;
    box-shadow: none;
  }
  .app-sidebar.sidebar-open {
    transform: translateX(0);
    box-shadow: 8px 0 32px rgba(0,0,0,.35);
  }
}

.sidebar-header {
  padding: 1.25rem 1rem 0.75rem;
  border-bottom: 1px solid rgba(255,255,255,.06);
}

.sidebar-logo {
  font-size: 1rem;
  font-weight: 700;
  color: #fff;
  text-decoration: none;
  letter-spacing: -0.02em;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.sidebar-nav {
  flex: 1;
  padding: 0.75rem 0.625rem;
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  padding: 0.5rem 0.75rem;
  border-radius: 8px;
  color: var(--color-sidebar-text);
  font-size: 0.875rem;
  font-weight: 500;
  text-decoration: none;
  transition: background 0.12s, color 0.12s;
}
.nav-item:hover { background: var(--color-sidebar-hover); color: #fff; }
.nav-item.active { background: var(--color-sidebar-active); color: var(--color-sidebar-text-active); }
.nav-item-icon { width: 1rem; text-align: center; font-size: 0.875rem; flex-shrink: 0; }

.sidebar-footer {
  padding: 0.75rem 1rem;
  border-top: 1px solid rgba(255,255,255,.06);
}

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

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

.sidebar-user-name {
  font-size: 0.8125rem;
  font-weight: 500;
  color: #d4d4d8;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-signout-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  padding: 0.4375rem 0.75rem;
  background: transparent;
  border: 1px solid rgba(255,255,255,.12);
  border-radius: 7px;
  color: #a1a1aa;
  font-size: 0.8125rem;
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.12s, color 0.12s;
}
.sidebar-signout-btn:hover { background: rgba(255,255,255,.06); color: #e4e4e7; }

/* ============================================================
   Mobile topbar (hidden on desktop)
   ============================================================ */
.mobile-topbar {
  display: none;
  position: sticky;
  top: 0;
  z-index: 40;
  height: var(--topbar-height);
  background: var(--color-sidebar-bg);
  padding: 0 1rem;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid rgba(255,255,255,.06);
}

@media (max-width: 1023px) {
  .mobile-topbar { display: flex; }
}

.mobile-topbar-logo {
  font-size: 1rem;
  font-weight: 700;
  color: #fff;
  text-decoration: none;
}

.topbar-hamburger {
  background: none;
  border: none;
  color: #a1a1aa;
  cursor: pointer;
  padding: 0.4375rem;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 40px;
  min-height: 40px;
}
.topbar-hamburger:hover { color: #fff; background: rgba(255,255,255,.08); }
.topbar-hamburger svg { display: block; }

/* ============================================================
   Sidebar overlay (mobile only)
   ============================================================ */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.5);
  z-index: 45;
  cursor: pointer;
}
.sidebar-overlay.active { display: block; }

/* ============================================================
   Main content area
   ============================================================ */
.main-content {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

@media (max-width: 1023px) {
  .main-content { padding-top: 0; }
}

/* ============================================================
   Cards
   ============================================================ */
.card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-card);
  overflow: hidden;
}

.card-header {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.card-body {
  padding: 1.25rem;
}

/* ============================================================
   Buttons
   ============================================================ */
.btn-primary {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  background: var(--color-primary);
  color: #fff;
  font-size: 0.875rem;
  font-weight: 600;
  padding: 0.5rem 0.875rem;
  border-radius: var(--radius-btn);
  border: none;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.12s, box-shadow 0.12s;
  box-shadow: 0 1px 2px rgba(79,70,229,.2);
  line-height: 1.25;
}
.btn-primary:hover { background: var(--color-primary-hover); }
.btn-primary:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
}

.btn-secondary {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  background: var(--color-surface);
  color: #3f3f46;
  font-size: 0.875rem;
  font-weight: 500;
  padding: 0.5rem 0.875rem;
  border-radius: var(--radius-btn);
  border: 1px solid var(--color-border);
  cursor: pointer;
  text-decoration: none;
  transition: background 0.12s;
  line-height: 1.25;
}
.btn-secondary:hover { background: #f4f4f5; }
.btn-secondary:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
}

.btn-danger {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  background: #fee2e2;
  color: #dc2626;
  font-size: 0.875rem;
  font-weight: 600;
  padding: 0.5rem 0.875rem;
  border-radius: var(--radius-btn);
  border: 1px solid #fecaca;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.12s;
  line-height: 1.25;
}
.btn-danger:hover { background: #fecaca; }

/* ============================================================
   Form elements
   ============================================================ */
.form-label {
  display: block;
  font-size: 0.875rem;
  font-weight: 500;
  color: #3f3f46;
  margin-bottom: 0.375rem;
}

.form-input {
  display: block;
  width: 100%;
  padding: 0.5rem 0.75rem;
  font-size: 0.875rem;
  line-height: 1.5;
  color: var(--color-text);
  background: var(--color-surface);
  border: 1px solid #d4d4d8;
  border-radius: var(--radius-input);
  transition: border-color 0.12s, box-shadow 0.12s;
}
.form-input:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(79,70,229,.12);
}
.form-input::placeholder { color: #a1a1aa; }

/* ============================================================
   Flash messages
   ============================================================ */
.flash-notice {
  padding: 0.625rem 1.25rem;
  background: #f0fdf4;
  border-bottom: 1px solid #bbf7d0;
  color: #166534;
  font-size: 0.875rem;
}

.flash-alert {
  padding: 0.625rem 1.25rem;
  background: #fef2f2;
  border-bottom: 1px solid #fecaca;
  color: #991b1b;
  font-size: 0.875rem;
}

/* ============================================================
   Section divider + headings (used inside pages)
   ============================================================ */
.section-title {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--color-text-muted);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  margin-bottom: 0.5rem;
}
