/* Modern Design System */
* { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  /* Colors */
  --primary: #6366f1;
  --primary-dark: #4f46e5;
  --primary-light: #a5b4fc;
  --success: #10b981;
  --success-light: #6ee7b7;
  --danger: #ef4444;
  --danger-light: #fca5a5;
  --warning: #f59e0b;
  --warning-light: #fcd34d;
  
  /* Neutrals */
  --gray-50: #f9fafb;
  --gray-100: #f3f4f6;
  --gray-200: #e5e7eb;
  --gray-300: #d1d5db;
  --gray-400: #9ca3af;
  --gray-500: #6b7280;
  --gray-600: #4b5563;
  --gray-700: #374151;
  --gray-800: #1f2937;
  --gray-900: #111827;
  
  /* Backgrounds */
  --bg-primary: #ffffff;
  --bg-secondary: #f8fafc;
  --bg-tertiary: #f1f5f9;
  
  /* Text */
  --text-primary: var(--gray-900);
  --text-secondary: var(--gray-600);
  --text-muted: var(--gray-500);
  
  /* Shadows */
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
  
  /* Border radius */
  --radius-sm: 0.375rem;
  --radius: 0.5rem;
  --radius-md: 0.75rem;
  --radius-lg: 1rem;
  --radius-xl: 1.5rem;
  
  /* Transitions */
  --transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-fast: all 0.15s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Base styles */
html { font-size: 16px; }
body { 
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: linear-gradient(135deg, var(--bg-secondary) 0%, var(--bg-tertiary) 100%);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
}

/* Layout */
.container { 
  max-width: 1200px; 
  margin: 0 auto; 
  padding: 0 1.5rem; 
}

/* Header */
.header { 
  background: var(--bg-primary);
  border-bottom: 1px solid var(--gray-200);
  backdrop-filter: blur(10px);
  position: sticky;
  top: 0;
  z-index: 50;
}

.header .inner { 
  max-width: 1200px; 
  margin: 0 auto; 
  padding: 1rem 1.5rem; 
  display: flex; 
  align-items: center; 
  justify-content: space-between; 
}

.brand { 
  font-weight: 800; 
  font-size: 1.5rem;
  letter-spacing: -0.025em; 
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* Typography */
h1, h2, h3, h4, h5, h6 { 
  font-weight: 700; 
  line-height: 1.25; 
  color: var(--text-primary);
  margin-bottom: 0.5rem;
}

h1 { font-size: 2.25rem; }
h2 { font-size: 1.875rem; }
h3 { font-size: 1.5rem; }
h4 { font-size: 1.25rem; }

p { 
  margin-bottom: 1rem; 
  color: var(--text-secondary); 
}

/* Cards */
.card { 
  background: var(--bg-primary);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-lg);
  padding: 2rem;
  box-shadow: var(--shadow);
  transition: var(--transition);
  position: relative;
  overflow: hidden;
}

.card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: linear-gradient(90deg, var(--primary) 0%, var(--primary-light) 100%);
  opacity: 0;
  transition: var(--transition);
}

.card:hover {
  box-shadow: var(--shadow-lg);
  transform: translateY(-2px);
}

.card:hover::before {
  opacity: 1;
}

.card + .card { margin-top: 2rem; }

/* Forms */
.form-group { margin-bottom: 1.5rem; }

label { 
  display: block; 
  font-weight: 600; 
  font-size: 0.875rem;
  color: var(--text-primary);
  margin-bottom: 0.5rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

input[type="text"], 
input[type="date"], 
input[type="number"], 
input[type="password"], 
input[type="email"],
select { 
  display: block; 
  width: 100%; 
  padding: 0.875rem 1rem; 
  border: 2px solid var(--gray-200);
  border-radius: var(--radius-md);
  background: var(--bg-primary);
  font-size: 1rem;
  transition: var(--transition);
  outline: none;
}

input:focus, 
select:focus { 
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
  transform: translateY(-1px);
}

input::placeholder {
  color: var(--text-muted);
}

/* Buttons */
.button { 
  display: inline-flex; 
  align-items: center; 
  justify-content: center;
  gap: 0.5rem;
  padding: 0.875rem 1.5rem;
  border: none;
  border-radius: var(--radius-md);
  font-weight: 600;
  font-size: 0.875rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  cursor: pointer;
  transition: var(--transition);
  position: relative;
  overflow: hidden;
}

.button::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.2), transparent);
  transition: left 0.5s;
}

.button:hover::before {
  left: 100%;
}

.button-primary {
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
  color: white;
  box-shadow: var(--shadow);
}

.button-primary:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}

.button-secondary {
  background: linear-gradient(135deg, var(--success) 0%, #059669 100%);
  color: white;
  box-shadow: var(--shadow);
}

.button-secondary:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}

.button-danger {
  background: linear-gradient(135deg, var(--danger) 0%, #dc2626 100%);
  color: white;
  box-shadow: var(--shadow);
}

.button-danger:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}

.button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none !important;
}

/* Tables */
.table { 
  width: 100%; 
  border-collapse: collapse; 
  background: var(--bg-primary);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow);
}

.table th, 
.table td { 
  padding: 1rem 1.5rem; 
  text-align: left;
  border-bottom: 1px solid var(--gray-100);
}

.table th { 
  background: var(--bg-secondary);
  font-weight: 700;
  font-size: 0.875rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-primary);
}

.table tbody tr {
  transition: var(--transition);
}

.table tbody tr:hover {
  background: var(--bg-secondary);
  transform: scale(1.01);
}

.table tbody tr:last-child td {
  border-bottom: none;
}

/* Grid */
.grid { 
  display: grid; 
  gap: 2rem; 
}

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

@media (min-width: 768px) { 
  .grid-2 { 
    grid-template-columns: 1fr 1fr; 
  } 
}

/* Badges */
.badge { 
  display: inline-flex;
  align-items: center;
  padding: 0.25rem 0.75rem;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.badge-primary {
  background: rgba(99, 102, 241, 0.1);
  color: var(--primary-dark);
}

.badge-success {
  background: rgba(16, 185, 129, 0.1);
  color: #059669;
}

.badge-warning {
  background: rgba(245, 158, 11, 0.1);
  color: #d97706;
}

.badge-danger {
  background: rgba(239, 68, 68, 0.1);
  color: #dc2626;
}

/* Hide dashboard until session check completes (avoids unified-login flash) */
body.dashboard-auth-pending {
  visibility: hidden;
}

/* Loading states */
.loading {
  position: relative;
  pointer-events: none;
}

.loading::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 1rem;
  height: 1rem;
  margin: -0.5rem 0 0 -0.5rem;
  border: 2px solid var(--gray-200);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

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

/* Animations */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes slideIn {
  from { opacity: 0; transform: translateX(-20px); }
  to { opacity: 1; transform: translateX(0); }
}

.animate-fade-in {
  animation: fadeIn 0.5s ease-out;
}

.animate-slide-in {
  animation: slideIn 0.3s ease-out;
}

/* Utilities */
.mt-2 { margin-top: 0.5rem; }
.mt-3 { margin-top: 0.75rem; }
.mt-4 { margin-top: 1rem; }
.mt-6 { margin-top: 1.5rem; }
.mt-8 { margin-top: 2rem; }

.mb-2 { margin-bottom: 0.5rem; }
.mb-3 { margin-bottom: 0.75rem; }
.mb-4 { margin-bottom: 1rem; }
.mb-6 { margin-bottom: 1.5rem; }
.mb-8 { margin-bottom: 2rem; }

.flex { display: flex; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.justify-center { justify-content: center; }
.gap-2 { gap: 0.5rem; }
.gap-4 { gap: 1rem; }

.hidden { display: none; }
.text-center { text-align: center; }
.text-muted { color: var(--text-muted); }

/* Admin tabbed layout */
.admin-panel-layout {
  max-width: 1200px;
  margin: 0 auto;
}

.admin-topbar {
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--gray-200);
}

.admin-main-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  margin: 1.25rem 0 0;
  padding: 0;
  border-bottom: 2px solid var(--gray-200);
}

.admin-main-tab {
  appearance: none;
  border: none;
  background: transparent;
  padding: 0.85rem 1.15rem;
  margin: 0 0 -2px;
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
  border-bottom: 3px solid transparent;
  border-radius: var(--radius) var(--radius) 0 0;
  transition: color 0.15s ease, border-color 0.15s ease, background 0.15s ease;
}

.admin-main-tab:hover {
  color: var(--primary);
  background: rgba(99, 102, 241, 0.06);
}

.admin-main-tab.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
  background: rgba(99, 102, 241, 0.08);
}

.admin-sub-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin: 1rem 0 1.25rem;
  min-height: 2.25rem;
}

.admin-sub-tabs:empty {
  display: none;
  margin: 0;
  min-height: 0;
}

.admin-sub-tab {
  appearance: none;
  border: 1px solid var(--gray-200);
  background: var(--bg-secondary);
  color: var(--text-secondary);
  padding: 0.4rem 0.9rem;
  border-radius: 999px;
  font-size: 0.8125rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease;
}

.admin-sub-tab:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.admin-sub-tab.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

.admin-content {
  width: 100%;
}

.content-sections .admin-section-card {
  display: none;
  margin-bottom: 0;
}

.content-sections .admin-section-card.is-active-section {
  display: block;
  animation: fadeIn 0.35s ease-out;
}

/* Legacy sidebar (removed from layout) */
.admin-navigation {
  display: none !important;
}

.nav-sidebar {
  display: none !important;
}

.nav-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.5rem;
  padding-bottom: 1rem;
  border-bottom: 2px solid var(--gray-100);
}

.nav-header h3 {
  color: var(--text-primary);
  font-size: 1.25rem;
  font-weight: 600;
  margin: 0;
}


.nav-search {
  margin-bottom: 1.5rem;
}

.nav-search input {
  width: 100%;
  padding: 0.75rem 1rem;
  border: 2px solid var(--gray-200);
  border-radius: var(--radius);
  font-size: 0.875rem;
  transition: all 0.2s ease;
  background: var(--bg-secondary);
}

.nav-search input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
  background: var(--bg-primary);
}

.nav-menu {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.nav-section {
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--gray-200);
  background: var(--bg-secondary);
}

.nav-section-header {
  display: flex;
  align-items: center;
  padding: 1rem;
  cursor: pointer;
  transition: all 0.2s ease;
  background: var(--bg-primary);
  border-bottom: 1px solid var(--gray-200);
}

.nav-section-header:hover {
  background: var(--primary);
  color: white;
  transform: translateX(2px);
}

.nav-section-header.active {
  background: var(--primary);
  color: white;
}

.nav-section-header .nav-icon {
  font-size: 1.125rem;
  margin-right: 0.75rem;
  width: 20px;
  text-align: center;
}

.nav-section-header .nav-text {
  flex: 1;
  font-weight: 600;
  font-size: 0.875rem;
}

.nav-section-header .nav-arrow {
  font-size: 0.75rem;
  transition: transform 0.2s ease;
}

.nav-section-header.active .nav-arrow {
  transform: rotate(180deg);
}

.nav-items {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.3s ease;
  background: var(--bg-secondary);
}

.nav-items.expanded {
  max-height: 500px;
}

.nav-item {
  display: block;
  padding: 0.75rem 1rem 0.75rem 3rem;
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 0.875rem;
  transition: all 0.2s ease;
  border-bottom: 1px solid var(--gray-100);
}

.nav-item:last-child {
  border-bottom: none;
}

.nav-item:hover {
  background: var(--primary-light);
  color: var(--primary-dark);
  transform: translateX(4px);
  font-weight: 500;
}

.nav-item.active {
  background: var(--primary);
  color: white;
  font-weight: 600;
}

.admin-content {
  flex: 1;
  min-width: 0;
}

.content-sections {
  display: flex;
  flex-direction: column;
  gap: 2rem;
}

.content-sections .card {
  margin-bottom: 0;
}

/* Smooth scrolling for navigation */
html {
  scroll-behavior: smooth;
}

/* Navigation animations */
@keyframes slideInLeft {
  from {
    opacity: 0;
    transform: translateX(-20px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

.nav-sidebar {
  animation: slideInLeft 0.5s ease;
}

/* Leave type window toggle (admin) */
.leave-window-toggle {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.toggle-switch {
  position: relative;
  display: inline-block;
  width: 2.75rem;
  height: 1.5rem;
  flex-shrink: 0;
}

.toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-slider {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background-color: var(--gray-300);
  border-radius: 1.5rem;
  transition: background-color 0.2s ease;
}

.toggle-slider::before {
  position: absolute;
  content: '';
  height: 1.125rem;
  width: 1.125rem;
  left: 0.1875rem;
  bottom: 0.1875rem;
  background-color: white;
  border-radius: 50%;
  transition: transform 0.2s ease;
  box-shadow: var(--shadow-sm);
}

.toggle-switch input:checked + .toggle-slider {
  background-color: var(--success);
}

.toggle-switch input:checked + .toggle-slider::before {
  transform: translateX(1.25rem);
}

.toggle-switch input:disabled + .toggle-slider {
  opacity: 0.65;
  cursor: not-allowed;
}

.toggle-switch--loading .toggle-slider {
  cursor: wait;
}

.toggle-state-label {
  font-size: 0.8125rem;
  font-weight: 600;
  min-width: 3.25rem;
}

.toggle-state-label.is-open {
  color: var(--success);
}

.toggle-state-label.is-closed {
  color: var(--danger);
}

/* Responsive admin tabs */
@media (max-width: 768px) {
  .container { padding: 0 1rem; }
  .header .inner { padding: 1rem; }
  .card { padding: 1.5rem; }
  .table th, .table td { padding: 0.75rem 1rem; }

  .admin-topbar {
    flex-direction: column;
    align-items: flex-start !important;
    gap: 0.75rem;
  }

  .admin-main-tab {
    padding: 0.65rem 0.75rem;
    font-size: 0.8125rem;
  }

  .admin-sub-tab {
    font-size: 0.75rem;
    padding: 0.35rem 0.65rem;
  }
}
