/* ============================================================
   CSS Custom Properties
   ============================================================ */
:root {
  --primary:        #2563eb;
  --primary-dark:   #1d4ed8;
  --primary-light:  #eff6ff;
  --secondary:      #64748b;
  --accent:         #10b981;
  --accent-dark:    #059669;
  --danger:         #ef4444;
  --danger-dark:    #dc2626;
  --warning:        #f59e0b;
  --info:           #3b82f6;
  --success:        #10b981;

  --text-primary:   #1e293b;
  --text-secondary: #475569;
  --text-muted:     #94a3b8;

  --bg-light:       #f1f5f9;
  --bg-white:       #ffffff;
  --border:         #e2e8f0;
  --border-dark:    #cbd5e1;

  --sidebar-width:  260px;
  --topnav-height:  60px;

  --radius-sm:  4px;
  --radius-md:  8px;
  --radius-lg:  12px;
  --radius-xl:  16px;

  --shadow-sm:  0 1px 3px rgba(0,0,0,.06), 0 1px 2px rgba(0,0,0,.04);
  --shadow-md:  0 4px 6px -1px rgba(0,0,0,.07), 0 2px 4px -1px rgba(0,0,0,.04);
  --shadow-lg:  0 10px 15px -3px rgba(0,0,0,.08), 0 4px 6px -2px rgba(0,0,0,.05);

  --font-sans:  'Segoe UI', system-ui, -apple-system, sans-serif;
  --font-mono:  'Courier New', monospace;
  --transition: 200ms ease;
}

/* ============================================================
   Reset & Base
   ============================================================ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--font-sans);
  color: var(--text-primary);
  background: var(--bg-light);
  line-height: 1.6;
  min-height: 100vh;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; height: auto; }
ul, ol { list-style: none; }
button { cursor: pointer; font-family: inherit; }
input, select, textarea { font-family: inherit; }

/* ============================================================
   Layout
   ============================================================ */
.layout {
  display: flex;
  margin-top: var(--topnav-height);
  min-height: calc(100vh - var(--topnav-height));
}

.main-content {
  flex: 1;
  margin-left: var(--sidebar-width);
  padding: 2rem;
  min-width: 0;
  transition: margin-left var(--transition);
}

/* ============================================================
   Top Navigation
   ============================================================ */
.topnav {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--topnav-height);
  background: #f9f9f9;
  color: #1e3a5f;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.25rem;
  z-index: 1000;
  box-shadow: 0 1px 3px rgba(0,0,0,.1);
  border-bottom: 1px solid #e5e7eb;
}

.topnav-left { display: flex; align-items: center; gap: 0.75rem; }
.topnav-right { display: flex; align-items: center; gap: 1rem; }

.sidebar-toggle {
  background: none;
  border: none;
  color: #1e3a5f;
  font-size: 1.25rem;
  padding: 0.25rem 0.5rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background var(--transition);
  display: inline-flex;
  align-items: center;
}
.sidebar-toggle:hover { background: rgba(30,58,95,.08); }

.brand {
  font-size: 1.125rem;
  font-weight: 700;
  color: #1e3a5f;
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.brand:hover { text-decoration: none; color: #1e3a5f; }
.brand-icon { font-size: 1.25rem; }

.user-greeting { font-size: 0.875rem; color: #555; }

.btn-logout {
  background: transparent;
  color: #1e3a5f;
  border: 1px solid #cbd5e1;
  border-radius: var(--radius-md);
  padding: 0.35rem 0.9rem;
  font-size: 0.875rem;
  transition: background var(--transition);
  text-decoration: none;
}
.btn-logout:hover { background: #e9ecef; text-decoration: none; color: #1e3a5f; }

/* ============================================================
   Sidebar
   ============================================================ */
.sidebar {
  position: fixed;
  top: var(--topnav-height);
  left: 0;
  width: var(--sidebar-width);
  height: calc(100vh - var(--topnav-height));
  background: #fff;
  border-right: 1px solid var(--border);
  overflow-y: auto;
  z-index: 900;
  transition: transform var(--transition);
}

.sidebar-nav { padding: 1rem 0; }

.nav-section-label {
  padding: 0.75rem 1.25rem 0.25rem;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--text-muted);
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.6rem 1.25rem;
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 0.9rem;
  border-left: 3px solid transparent;
  transition: all var(--transition);
}
.nav-item:hover { background: var(--bg-light); color: var(--primary); text-decoration: none; }
.nav-item.active {
  background: var(--primary-light);
  color: var(--primary);
  border-left-color: var(--primary);
  font-weight: 600;
}
.nav-icon { font-size: 1rem; width: 1.25rem; text-align: center; flex-shrink: 0; }

/* ============================================================
   Buttons
   ============================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.5rem 1.1rem;
  font-size: 0.9rem;
  font-weight: 500;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  cursor: pointer;
  transition: all var(--transition);
  text-decoration: none;
  line-height: 1.4;
  white-space: nowrap;
}
.btn:hover { text-decoration: none; }
.btn-primary { background: var(--primary); color: #fff; border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); color: #fff; }
.btn-secondary { background: #fff; color: var(--secondary); border-color: var(--border-dark); }
.btn-secondary:hover { background: var(--bg-light); }
.btn-success { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn-success:hover { background: var(--accent-dark); border-color: var(--accent-dark); color: #fff; }
.btn-danger { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn-danger:hover { background: var(--danger-dark); border-color: var(--danger-dark); color: #fff; }
.btn-warning { background: var(--warning); color: #fff; border-color: var(--warning); }
.btn-sm { padding: 0.3rem 0.7rem; font-size: 0.8rem; }
.btn-block { width: 100%; justify-content: center; }

/* ============================================================
   Cards
   ============================================================ */
.card {
  background: #fff;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
  overflow: hidden;
}
.card-header {
  padding: 1.1rem 1.5rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.75rem;
}
.card-header h2, .card-header h3 {
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0;
}
.card-body { padding: 1.5rem; }

/* ============================================================
   Page Header
   ============================================================ */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem;
  margin-bottom: 1.75rem;
}
.page-header h1 { font-size: 1.5rem; font-weight: 700; color: var(--text-primary); }
.page-header p { color: var(--text-muted); font-size: 0.9rem; margin-top: 0.25rem; }

/* ============================================================
   Flash messages
   ============================================================ */
.flash {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.875rem 1.1rem;
  border-radius: var(--radius-md);
  margin-bottom: 1.25rem;
  font-size: 0.9rem;
  font-weight: 500;
  border: 1px solid transparent;
}
.flash-success { background: #ecfdf5; color: #065f46; border-color: #a7f3d0; }
.flash-error   { background: #fef2f2; color: #991b1b; border-color: #fecaca; }
.flash-warning { background: #fffbeb; color: #92400e; border-color: #fde68a; }
.flash-info    { background: #eff6ff; color: #1e40af; border-color: #bfdbfe; }
.flash-close { background: none; border: none; font-size: 1.2rem; cursor: pointer; color: inherit; opacity: .6; padding: 0; line-height: 1; margin-left: auto; }
.flash-close:hover { opacity: 1; }

/* ============================================================
   Badges
   ============================================================ */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.2rem 0.6rem;
  border-radius: 99px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .05em;
}
.badge-primary   { background: var(--primary-light); color: var(--primary); }
.badge-success   { background: #ecfdf5; color: #065f46; }
.badge-warning   { background: #fffbeb; color: #92400e; }
.badge-danger    { background: #fef2f2; color: #991b1b; }
.badge-secondary { background: #f1f5f9; color: var(--secondary); }
.badge-info      { background: #eff6ff; color: #1e40af; }

/* ============================================================
   Utilities
   ============================================================ */
.text-center { text-align: center; }
.text-right  { text-align: right; }
.text-muted  { color: var(--text-muted); }
.text-sm     { font-size: 0.875rem; }
.text-xs     { font-size: 0.75rem; }
.fw-bold     { font-weight: 700; }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }
.d-flex { display: flex; }
.align-center { align-items: center; }
.gap-1 { gap: 0.5rem; }
.gap-2 { gap: 1rem; }
.justify-between { justify-content: space-between; }
.flex-wrap { flex-wrap: wrap; }

/* ============================================================
   Site Footer
   ============================================================ */
.site-footer {
  margin-left: var(--sidebar-width);
  padding: 1rem 2rem;
  border-top: 1px solid var(--border);
  font-size: 0.8rem;
  color: var(--text-muted);
  text-align: center;
  transition: margin-left var(--transition);
}

/* ============================================================
   Responsive
   ============================================================ */
@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .main-content { margin-left: 0; padding: 1.25rem 1rem; }
  .site-footer { margin-left: 0; }
  .user-greeting { display: none; }
}
