/* =============================================
   LAYOUT - Sidebar, Header, Main Content
   ============================================= */

/* --- App Container --- */
.app { display: flex; min-height: 100vh; position: relative; z-index: 1; }

/* --- LOGIN PAGE --- */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-6);
  position: relative;
  z-index: 1;
}
.login-card {
  width: 100%;
  max-width: 420px;
  background: var(--glass-bg);
  backdrop-filter: var(--glass-blur);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-xl);
  padding: var(--space-10);
  animation: scaleIn 0.4s ease-out;
}
.login-logo {
  text-align: center;
  margin-bottom: var(--space-8);
}
.login-logo .logo-icon {
  width: 64px; height: 64px;
  margin: 0 auto var(--space-4);
  background: linear-gradient(135deg, var(--primary-500), var(--accent-500));
  border-radius: var(--radius-lg);
  display: flex; align-items: center; justify-content: center;
  font-size: 28px;
  box-shadow: 0 8px 24px rgba(6,182,212,0.3);
}
.login-logo h1 {
  font-size: var(--text-2xl);
  font-weight: 700;
  background: linear-gradient(135deg, var(--primary-300), var(--accent-400));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.login-logo p { color: var(--text-secondary); font-size: var(--text-sm); margin-top: var(--space-1); }
.login-card .form-input { background: var(--bg-input); border: 1px solid var(--border-input); }
[data-theme="dark"] .login-card .form-input { background: rgba(15, 23, 42, 0.8); }
.login-btn {
  width: 100%;
  padding: 12px;
  font-size: var(--text-lg);
  margin-top: var(--space-4);
}

/* --- SIDEBAR --- */
.sidebar {
  width: var(--sidebar-width);
  height: 100vh;
  position: fixed;
  top: 0; left: 0;
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border-primary);
  z-index: var(--z-sidebar);
  display: flex;
  flex-direction: column;
  transition: width var(--transition-base), transform var(--transition-base);
  overflow: hidden;
}
.sidebar.collapsed { width: var(--sidebar-collapsed); }

.sidebar-header {
  padding: var(--space-5) var(--space-5);
  border-bottom: 1px solid var(--border-primary);
  display: flex;
  align-items: center;
  gap: var(--space-3);
  flex-shrink: 0;
  min-height: var(--header-height);
}
.sidebar-header .logo {
  width: 36px; height: 36px;
  background: linear-gradient(135deg, var(--primary-500), var(--accent-500));
  border-radius: var(--radius-md);
  display: flex; align-items: center; justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
}
.sidebar-header .logo-text {
  font-weight: 700;
  font-size: var(--text-lg);
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
}
.sidebar.collapsed .logo-text { display: none; }

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-3);
}

.nav-group {
  margin-bottom: var(--space-4);
}
.nav-group-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-tertiary);
  padding: var(--space-2) var(--space-3);
  margin-bottom: var(--space-1);
}
.sidebar.collapsed .nav-group-label { display: none; }

.nav-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: 9px var(--space-3);
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--text-secondary);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--transition-fast);
  white-space: nowrap;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
  font-family: var(--font-family);
  position: relative;
}
.nav-item:hover { background: rgba(6, 182, 212, 0.08); color: var(--text-primary); }
.nav-item.active {
  background: rgba(6, 182, 212, 0.12);
  color: var(--primary-400);
}
.nav-item.active::before {
  content: '';
  position: absolute;
  left: 0; top: 6px; bottom: 6px;
  width: 3px;
  background: var(--primary-500);
  border-radius: 0 3px 3px 0;
}
.nav-item svg, .nav-item .nav-icon {
  width: 18px; height: 18px;
  flex-shrink: 0;
  opacity: 0.7;
}
.nav-item.active svg, .nav-item.active .nav-icon { opacity: 1; }
.nav-item .nav-text { overflow: hidden; }
.sidebar.collapsed .nav-text { display: none; }
.sidebar.collapsed .nav-item { justify-content: center; padding: 10px; }
.nav-item .nav-badge {
  margin-left: auto;
  background: var(--danger-600);
  color: white;
  font-size: 10px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: var(--radius-full);
  min-width: 18px;
  text-align: center;
}
.sidebar.collapsed .nav-badge { display: none; }

/* Sidebar toggle button */
.sidebar-toggle {
  position: absolute;
  top: 50%;
  right: -14px;
  width: 28px; height: 28px;
  background: var(--bg-sidebar);
  border: 1px solid var(--border-primary);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  color: var(--text-secondary);
  font-size: 14px;
  transition: all var(--transition-fast);
  z-index: 10;
}
.sidebar-toggle:hover { background: var(--bg-card-hover); color: var(--text-primary); }

/* Sidebar footer */
.sidebar-footer {
  padding: var(--space-4);
  border-top: 1px solid var(--border-primary);
  flex-shrink: 0;
}
.sidebar-user {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: background var(--transition-fast);
}
.sidebar-user:hover { background: var(--bg-card-hover); }
.sidebar-user-info { overflow: hidden; }
.sidebar-user-name { font-size: var(--text-sm); font-weight: 600; color: var(--text-primary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-user-role { font-size: var(--text-xs); color: var(--text-tertiary); white-space: nowrap; }
.sidebar.collapsed .sidebar-user-info { display: none; }

/* --- HEADER --- */
.header {
  height: var(--header-height);
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-primary);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--space-6);
  position: sticky;
  top: 0;
  z-index: var(--z-header);
}
[data-theme="dark"] .header { background: rgba(10, 14, 26, 0.8); }
.header-left {
  display: flex;
  align-items: center;
  gap: var(--space-4);
}
.header-title {
  font-size: var(--text-xl);
  font-weight: 600;
  color: var(--text-primary);
}
.header-breadcrumb {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-sm);
  color: var(--text-tertiary);
}
.header-breadcrumb span { color: var(--text-secondary); }

.header-right {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.mobile-menu-btn {
  display: none;
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 24px;
  cursor: pointer;
  padding: var(--space-2);
}

/* --- MAIN CONTENT --- */
.main {
  flex: 1;
  margin-left: var(--sidebar-width);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  transition: margin-left var(--transition-base);
}
.sidebar.collapsed ~ .main { margin-left: var(--sidebar-collapsed); }

.page-content {
  flex: 1;
  padding: var(--space-6);
  max-width: var(--content-max-width);
  width: 100%;
  margin: 0 auto;
}

/* Page header with actions */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  margin-bottom: var(--space-6);
  flex-wrap: wrap;
}
.page-header h1 {
  font-size: var(--text-2xl);
  font-weight: 700;
}
.page-actions {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  flex-wrap: wrap;
}

/* Filter bar */
.filter-bar {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin-bottom: var(--space-5);
  flex-wrap: wrap;
}
.filter-bar .form-input,
.filter-bar .form-select {
  width: auto;
  min-width: 140px;
}

/* --- STAT GRID --- */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: var(--space-5);
  margin-bottom: var(--space-6);
}

/* --- CALENDAR OVERRIDES (FullCalendar) --- */
.fc {
  --fc-border-color: var(--border-primary);
  --fc-button-bg-color: var(--bg-card-solid);
  --fc-button-border-color: var(--border-primary);
  --fc-button-hover-bg-color: var(--bg-card-hover);
  --fc-button-hover-border-color: var(--border-hover);
  --fc-button-active-bg-color: var(--primary-700);
  --fc-button-active-border-color: var(--primary-600);
  --fc-button-text-color: var(--text-primary);
  --fc-page-bg-color: transparent;
  --fc-neutral-bg-color: var(--bg-card);
  --fc-today-bg-color: rgba(6, 182, 212, 0.06);
  --fc-event-bg-color: var(--primary-600);
  --fc-event-border-color: transparent;
  --fc-event-text-color: white;
  --fc-list-event-hover-bg-color: var(--bg-table-hover);
  --fc-now-indicator-color: var(--danger-500);
  font-family: var(--font-family);
  font-size: var(--text-sm);
}
.fc .fc-toolbar-title { font-size: var(--text-xl) !important; font-weight: 600; }
.fc .fc-button { font-size: var(--text-sm) !important; padding: 6px 14px !important; border-radius: var(--radius-md) !important; font-weight: 500 !important; font-family: var(--font-family) !important; }
.fc .fc-col-header-cell { padding: 8px 0 !important; }
.fc .fc-col-header-cell-cushion { color: var(--text-secondary) !important; font-weight: 600 !important; text-transform: uppercase !important; font-size: var(--text-xs) !important; }
.fc .fc-daygrid-day-number { color: var(--text-secondary) !important; padding: 6px 8px !important; }
.fc .fc-event { border-radius: var(--radius-sm) !important; padding: 2px 6px !important; font-size: var(--text-xs) !important; cursor: pointer !important; }
.fc .fc-event:hover { filter: brightness(1.15); }
.fc .fc-timegrid-slot { height: 40px !important; }
.fc .fc-timegrid-slot-label-cushion { color: var(--text-tertiary) !important; font-size: var(--text-xs) !important; }
.fc .fc-scrollgrid { border-radius: var(--radius-lg) !important; overflow: hidden !important; }
.fc .fc-scrollgrid td, .fc .fc-scrollgrid th { border-color: var(--border-primary) !important; }
.fc .fc-day-today .fc-daygrid-day-number { color: var(--primary-400) !important; font-weight: 700 !important; }

/* Calendar event custom styles */
.fc-event-main { display: flex; flex-direction: column; gap: 1px; }
.fc-event-time { font-weight: 600; }

/* Doctor resource headers */
.fc .fc-resource-header { background: rgba(15,23,42,0.6) !important; }
