/* ============================================================
   MODERN ATTENDANCE SYSTEM THEME
   A complete modern redesign - sidebar layout, clean typography,
   card-based content areas, smooth transitions.
   ============================================================ */

/* ── Custom Properties ──────────────────────────────────────── */
:root {
  --sidebar-width: 250px;
  --sidebar-collapsed-width: 70px;
  --topbar-height: 60px;

  /* Brand palette */
  --primary:          #00897b !important;   /* Teal */
  --primary-dark:     #00695c !important;
  --primary-light:    #e0f2f1 !important;   /* Very light teal background tint */
  --accent:           #d4580f !important;   /* Dark orange */

  /* Map attendance/list.php teal variable names → our teal values */
  --primary-color:    #00897b !important;
  --primary-gradient: linear-gradient(135deg, #00897b 0%, #00695c 100%) !important;
  --primary-light:    #e0f2f1 !important;
  --success:       #10b981;
  --warning:       #f59e0b;
  --danger:        #ef4444;
  --info:          #3b82f6;

  /* Sidebar */
  --sidebar-bg:    #003d38;
  --sidebar-hover: rgba(255,255,255,0.08);
  --sidebar-active:#00897b;
  --sidebar-text:  rgba(255,255,255,0.80);
  --sidebar-muted: rgba(255,255,255,0.45);

  /* Main area */
  --body-bg:       #f1f5f9;
  --card-bg:       #ffffff;
  --border-color:  #e2e8f0;
  --text-primary:  #0f172a;
  --text-secondary:#64748b;
  --text-muted:    #94a3b8;

  /* Shadows */
  --shadow-sm: 0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.05);
  --shadow:    0 4px 6px -1px rgba(0,0,0,.08), 0 2px 4px -1px rgba(0,0,0,.05);
  --shadow-md: 0 10px 15px -3px rgba(0,0,0,.08), 0 4px 6px -2px rgba(0,0,0,.04);
  --shadow-lg: 0 20px 25px -5px rgba(0,0,0,.10), 0 10px 10px -5px rgba(0,0,0,.04);

  /* Typography */
  --font-sans: 'Inter', 'Poppins-Regular', system-ui, -apple-system, sans-serif;
  --radius-sm: 6px;
  --radius:    10px;
  --radius-lg: 16px;
  --transition: 0.2s ease;
}

/* ── Google Font import ─────────────────────────────────────── */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

/* ── Reset / Base ───────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  font-family: var(--font-sans);
  background: var(--body-bg);
  color: var(--text-primary);
  margin: 0;
  padding: 0;
  min-height: 100vh;
  font-size: 14px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

/* ── Layout Wrapper ─────────────────────────────────────────── */
.app-wrapper {
  display: flex;
  min-height: 100vh;
}

/* ── Sidebar ────────────────────────────────────────────────── */
.app-sidebar {
  width: var(--sidebar-width);
  background: var(--sidebar-bg);
  min-height: 100vh;
  position: fixed;
  top: 0; left: 0;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  transition: width var(--transition);
  overflow: hidden;
  box-shadow: 4px 0 20px rgba(0,0,0,0.15);
}

/* Brand / Logo */
/* Sidebar brand as collapse toggle button */
button.sidebar-brand {
  background: none;
  border: none;
  width: 100%;
  text-align: left;
  cursor: pointer;
  transition: background var(--transition);
}
button.sidebar-brand:hover {
  background: rgba(255,255,255,0.07);
}

/* Global sidebar collapse ─ works on every page */
.app-wrapper.sidebar-collapsed .app-sidebar {
  transform: translateX(-100%);
}
.app-wrapper.sidebar-collapsed .app-main {
  margin-left: 0;
  transition: margin-left var(--transition);
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 20px 20px 16px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  text-decoration: none !important;
  flex-shrink: 0;
}

.sidebar-brand-icon {
  width: 38px; height: 38px;
  background: linear-gradient(135deg, #00897b, var(--accent));
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  font-size: 18px;
  color: #fff;
  box-shadow: 0 4px 12px rgba(0,137,123,0.45);
}

.sidebar-brand-text {
  display: flex; flex-direction: column;
}

.sidebar-brand-title {
  font-size: 15px;
  font-weight: 700;
  color: #fff;
  line-height: 1.2;
  letter-spacing: -0.2px;
  white-space: nowrap;
}

.sidebar-brand-subtitle {
  font-size: 10px;
  color: var(--sidebar-muted);
  text-transform: uppercase;
  letter-spacing: 0.8px;
  white-space: nowrap;
}

/* User info */
.sidebar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 20px;
  border-bottom: 1px solid rgba(255,255,255,0.06);
}

.sidebar-user-avatar {
  width: 34px; height: 34px;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px;
  font-weight: 600;
  color: #fff;
  flex-shrink: 0;
}

.sidebar-user-info { overflow: hidden; }

.sidebar-user-name {
  font-size: 13px;
  font-weight: 600;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-user-role {
  font-size: 11px;
  color: var(--sidebar-muted);
}

/* Nav */
.sidebar-nav {
  flex: 1;
  padding: 12px 0;
  overflow-y: auto;
  overflow-x: hidden;
}

.sidebar-nav::-webkit-scrollbar { width: 4px; }
.sidebar-nav::-webkit-scrollbar-track { background: transparent; }
.sidebar-nav::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.15); border-radius: 4px; }

.sidebar-section-label {
  font-size: 10px;
  font-weight: 600;
  color: var(--sidebar-muted);
  text-transform: uppercase;
  letter-spacing: 1px;
  padding: 16px 20px 6px;
}

.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 20px;
  color: var(--sidebar-text);
  text-decoration: none !important;
  border-radius: 0;
  transition: all var(--transition);
  font-size: 13.5px;
  font-weight: 400;
  position: relative;
  white-space: nowrap;
}

.sidebar-nav a:hover {
  background: var(--sidebar-hover);
  color: #fff;
  padding-left: 26px;
}

.sidebar-nav a.active {
  background: var(--sidebar-active);
  color: #fff;
  font-weight: 500;
}

.sidebar-nav a.active::before {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 3px;
  background: var(--accent); /* dark orange indicator */
  border-radius: 0 3px 3px 0;
}

.sidebar-nav a .nav-icon {
  width: 20px;
  text-align: center;
  font-size: 15px;
  flex-shrink: 0;
  opacity: 0.85;
}

.sidebar-nav a.active .nav-icon,
.sidebar-nav a:hover .nav-icon { opacity: 1; }

/* Sidebar footer */
.sidebar-footer {
  padding: 12px 20px 18px;
  border-top: 1px solid rgba(255,255,255,0.06);
}

.sidebar-footer a {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--sidebar-muted);
  text-decoration: none !important;
  font-size: 13px;
  transition: color var(--transition);
  padding: 6px 0;
}

.sidebar-footer a:hover { color: #fff; }

/* ── Main Content ───────────────────────────────────────────── */
.app-main {
  margin-left: var(--sidebar-width);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  transition: margin-left var(--transition);
}

/* ── Topbar ─────────────────────────────────────────────────── */
.app-topbar {
  height: var(--topbar-height);
  background: var(--card-bg);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 999;
  box-shadow: var(--shadow-sm);
}

.topbar-left { display: flex; align-items: center; gap: 12px; }

.topbar-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
}

.topbar-breadcrumb {
  font-size: 12px;
  color: var(--text-muted);
}

.topbar-right { display: flex; align-items: center; gap: 16px; }

.topbar-badge {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px; height: 36px;
  border-radius: 50%;
  background: var(--body-bg);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition);
  text-decoration: none !important;
}
.topbar-badge:hover { background: var(--border-color); color: var(--accent); }

.topbar-user {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
}

.topbar-avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  display: flex; align-items: center; justify-content: center;
  font-size: 12px;
  font-weight: 600;
  color: #fff;
}

.topbar-user-name {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary);
}

/* ── Page Content ───────────────────────────────────────────── */
.app-content {
  flex: 1;
  padding: 24px;
}

/* ── Cards ──────────────────────────────────────────────────── */
.card {
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  margin-bottom: 24px;
  overflow: hidden;
}

.card-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--card-bg);
}

.card-header h3,
.card-header h4 {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0;
}

.card-body { padding: 20px; }
.card-footer {
  padding: 14px 20px;
  border-top: 1px solid var(--border-color);
  background: var(--body-bg);
}

/* Stat / KPI Cards */
.stat-card {
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow-sm);
  display: flex;
  align-items: flex-start;
  gap: 16px;
  transition: transform var(--transition), box-shadow var(--transition);
}

.stat-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.stat-icon {
  width: 48px; height: 48px;
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  font-size: 20px;
  flex-shrink: 0;
}

.stat-icon.indigo { background: rgba(0,137,123,.12);  color: var(--primary); }  /* teal */
.stat-icon.cyan   { background: rgba(212,88,15,.12);   color: var(--accent); }   /* dark orange */
.stat-icon.green  { background: rgba(16,185,129,.12);  color: var(--success); }
.stat-icon.amber  { background: rgba(212,88,15,.14);   color: var(--accent); }   /* dark orange */
.stat-icon.red    { background: rgba(239,68,68,.12);   color: var(--danger); }
.stat-icon.blue   { background: rgba(0,137,123,.10);   color: var(--primary); }  /* teal-tint */
.stat-icon.orange { background: rgba(212,88,15,.13);   color: var(--accent); }   /* explicit orange */

.stat-content { flex: 1; }

.stat-label {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.stat-value {
  font-size: 26px;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.2;
  margin: 4px 0 2px;
}

.stat-change {
  font-size: 12px;
  font-weight: 500;
}

.stat-change.up   { color: var(--success); }
.stat-change.down { color: var(--danger); }

/* ── Tables ─────────────────────────────────────────────────── */
.modern-table-wrap {
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.table {
  width: 100%;
  margin: 0;
  border-collapse: collapse;
}

.table thead tr {
  background: var(--body-bg);
  border-bottom: 2px solid var(--border-color);
}

.table thead th {
  padding: 12px 16px;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.6px;
  border: none;
  white-space: nowrap;
}

.table tbody tr {
  border-bottom: 1px solid var(--border-color);
  transition: background var(--transition);
}

.table tbody tr:last-child { border-bottom: none; }
.table tbody tr:hover { background: #f8fafc; }

.table tbody td {
  padding: 12px 16px;
  font-size: 13.5px;
  color: var(--text-primary);
  vertical-align: middle;
  border: none;
}

/* ── Badges / Chips ─────────────────────────────────────────── */
.badge-modern {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.3px;
}

.badge-modern.success { background: rgba(16,185,129,.12); color: var(--success); }
.badge-modern.danger  { background: rgba(239,68,68,.12);  color: var(--danger); }
.badge-modern.warning { background: rgba(245,158,11,.12); color: var(--warning); }
.badge-modern.info    { background: rgba(59,130,246,.12);  color: var(--info); }
.badge-modern.primary { background: rgba(0,137,123,.12);  color: var(--primary); }
.badge-modern.muted   { background: var(--body-bg); color: var(--text-muted); }

/* ── Buttons ────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all var(--transition);
  text-decoration: none !important;
  line-height: 1.4;
}

.btn:focus { outline: none; box-shadow: 0 0 0 3px rgba(0,137,123,.25); }

.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: var(--card-bg);
  color: var(--text-secondary);
  border-color: var(--border-color);
}
.btn-secondary:hover { background: var(--body-bg); color: var(--text-primary); }

.btn-success { background: var(--success); color: #fff; border-color: var(--success); }
.btn-success:hover { background: #059669; color: #fff; }

.btn-danger { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn-danger:hover { background: #dc2626; color: #fff; }

.btn-warning { background: var(--warning); color: #fff; border-color: var(--warning); }
.btn-warning:hover { background: #d97706; color: #fff; }

.btn-info { background: var(--info); color: #fff; border-color: var(--info); }
.btn-info:hover { background: #2563eb; color: #fff; }

.btn-sm { padding: 5px 11px; font-size: 12px; }
.btn-lg { padding: 11px 22px; font-size: 15px; }

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border-color: transparent;
}
.btn-ghost:hover { background: var(--body-bg); color: var(--text-primary); }

/* Override Bootstrap btn colors */
.btn-default { background: var(--card-bg); color: var(--text-secondary); border: 1px solid var(--border-color); }
.btn-default:hover { background: var(--body-bg); }

/* ── Forms ──────────────────────────────────────────────────── */
.form-control {
  height: 38px;
  padding: 7px 12px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  color: var(--text-primary);
  background: var(--card-bg);
  transition: border-color var(--transition), box-shadow var(--transition);
  font-family: var(--font-sans);
  width: 100%;
}

.form-control:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(0,137,123,.18);
  outline: none;
}

.form-control::placeholder { color: var(--text-muted); }

textarea.form-control { height: auto; min-height: 80px; resize: vertical; }

select.form-control {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 30px;
}

.form-label {
  display: block;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 5px;
}

.form-group { margin-bottom: 18px; }

.input-group .form-control { border-radius: var(--radius-sm) 0 0 var(--radius-sm); }
.input-group-btn .btn { border-radius: 0 var(--radius-sm) var(--radius-sm) 0; height: 38px; }
.input-group-addon {
  background: var(--body-bg);
  border: 1px solid var(--border-color);
  padding: 6px 12px;
  font-size: 13px;
  color: var(--text-muted);
  border-right: none;
  border-radius: var(--radius-sm) 0 0 var(--radius-sm);
  display: flex; align-items: center;
}

/* ── Alerts ─────────────────────────────────────────────────── */
.alert {
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  border: 1px solid transparent;
  margin-bottom: 16px;
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

.alert-success { background: rgba(16,185,129,.08); border-color: rgba(16,185,129,.25); color: #065f46; }
.alert-danger   { background: rgba(239,68,68,.08);  border-color: rgba(239,68,68,.25);  color: #7f1d1d; }
.alert-warning  { background: rgba(245,158,11,.08); border-color: rgba(245,158,11,.25); color: #78350f; }
.alert-info     { background: rgba(59,130,246,.08); border-color: rgba(59,130,246,.25); color: #1e3a5f; }

/* ── Modals ─────────────────────────────────────────────────── */
.modal-content {
  border: none;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
}

.modal-header {
  border-bottom: 1px solid var(--border-color);
  padding: 18px 24px;
  background: var(--card-bg);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}

.modal-title { font-size: 16px; font-weight: 600; color: var(--text-primary); }

.modal-body { padding: 20px 24px; }

.modal-footer {
  border-top: 1px solid var(--border-color);
  padding: 14px 24px;
  background: var(--body-bg);
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}

/* ── DataTables overrides ───────────────────────────────────── */
.dataTables_wrapper .dataTables_length select,
.dataTables_wrapper .dataTables_filter input {
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 5px 10px;
  font-size: 13px;
  color: var(--text-primary);
  background: var(--card-bg);
}

.dataTables_wrapper .dataTables_filter input:focus {
  border-color: var(--primary);
  outline: none;
  box-shadow: 0 0 0 3px rgba(0,137,123,.18);
}

.dataTables_wrapper .dataTables_paginate .paginate_button {
  border-radius: var(--radius-sm) !important;
  border: 1px solid var(--border-color) !important;
  background: var(--card-bg) !important;
  color: var(--text-secondary) !important;
  font-size: 12px !important;
  margin: 0 2px !important;
  padding: 5px 10px !important;
}

.dataTables_wrapper .dataTables_paginate .paginate_button.current,
.dataTables_wrapper .dataTables_paginate .paginate_button.current:hover {
  background: var(--primary) !important;
  border-color: var(--primary) !important;
  color: #fff !important;
}

.dataTables_wrapper .dataTables_paginate .paginate_button:hover {
  background: var(--body-bg) !important;
  border-color: var(--border-color) !important;
  color: var(--text-primary) !important;
}

/* ── Page Header ────────────────────────────────────────────── */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
}

.page-header-title {
  font-size: 20px;
  font-weight: 700;
  color: var(--text-primary);
  margin: 0;
}

.page-header-subtitle {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 2px;
}

/* ── Breadcrumb ─────────────────────────────────────────────── */
.breadcrumb-modern {
  display: flex;
  align-items: center;
  gap: 6px;
  list-style: none;
  padding: 0;
  margin: 0;
  font-size: 12.5px;
}

.breadcrumb-modern li { color: var(--text-muted); }
.breadcrumb-modern li a { color: var(--primary); text-decoration: none !important; }
.breadcrumb-modern li a:hover { text-decoration: underline !important; }
.breadcrumb-modern li::after { content: '/'; margin-left: 6px; color: var(--border-color); }
.breadcrumb-modern li:last-child::after { display: none; }
.breadcrumb-modern li:last-child { color: var(--text-primary); font-weight: 500; }

/* ── Panels → Cards bridge ──────────────────────────────────── */
.panel {
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  margin-bottom: 24px;
}

.panel-heading {
  padding: 14px 20px;
  border-bottom: 1px solid var(--border-color);
  background: var(--card-bg);
  border-radius: var(--radius) var(--radius) 0 0;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
}

.panel-body { padding: 20px; }
.panel-footer { padding: 12px 20px; border-top: 1px solid var(--border-color); background: var(--body-bg); }

/* Panel color variants */
.panel-default > .panel-heading { border-left: 3px solid var(--accent); } /* dark orange left-border accent */
.panel-primary > .panel-heading { background: var(--primary); color: #fff; border: none; }
.panel-success > .panel-heading { background: var(--success); color: #fff; border: none; }
.panel-warning > .panel-heading { background: var(--warning); color: #fff; border: none; }
.panel-danger  > .panel-heading { background: var(--danger);  color: #fff; border: none; }
.panel-info    > .panel-heading { background: var(--info);    color: #fff; border: none; }

/* ── Well override ──────────────────────────────────────────── */
.well {
  background: var(--body-bg);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 16px;
  box-shadow: none;
}

/* ── Footer ─────────────────────────────────────────────────── */
.app-footer {
  background: var(--card-bg);
  border-top: 1px solid var(--border-color);
  padding: 14px 24px;
  font-size: 12px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.app-footer a { color: var(--primary); text-decoration: none !important; }
.app-footer a:hover { color: var(--accent); text-decoration: underline !important; }

/* ── Row Grid Helper ────────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

/* ── Select2 overrides ──────────────────────────────────────── */
.select2-container--default .select2-selection--single {
  height: 38px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  background: var(--card-bg);
}

.select2-container--default .select2-selection--single .select2-selection__rendered {
  line-height: 36px;
  padding: 0 12px;
  font-size: 13.5px;
  color: var(--text-primary);
}

.select2-container--default .select2-selection--single .select2-selection__arrow {
  height: 36px;
  right: 8px;
}

.select2-container--default.select2-container--focus .select2-selection--single {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(0,137,123,.18);
}

.select2-dropdown {
  border: 1px solid var(--border-color) !important;
  border-radius: var(--radius-sm) !important;
  box-shadow: var(--shadow-md) !important;
}

.select2-container--default .select2-results__option--highlighted[aria-selected] {
  background-color: var(--primary) !important;
}

/* ── Misc Utilities ─────────────────────────────────────────── */
.separator {
  border: none;
  border-top: 1px solid var(--border-color);
  margin: 20px 0;
}

.text-primary-color { color: var(--primary) !important; }
.text-success-color { color: var(--success) !important; }
.text-danger-color  { color: var(--danger) !important; }
.text-warning-color { color: var(--warning) !important; }

.bg-primary-soft { background: rgba(0,137,123,.07)    !important; }
.bg-success-soft { background: rgba(16,185,129,.07)  !important; }
.bg-danger-soft  { background: rgba(239,68,68,.07)   !important; }
.bg-warning-soft { background: rgba(245,158,11,.07)  !important; }

/* ── Remove old horizontal navbar remnants ──────────────────── */
#cssmenu { display: none !important; }
.navbar    { display: none !important; }
.homepage > .container { padding-top: 0; }

/* ── Loading spinner ────────────────────────────────────────── */
.spinner {
  width: 20px; height: 20px;
  border: 2px solid var(--border-color);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin .7s linear infinite;
  display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Responsive ─────────────────────────────────────────────── */

/* ── Tablet & below (≤991px): off-canvas sidebar ── */
@media (max-width: 991px) {
  .app-sidebar {
    transform: translateX(-100%);
    width: var(--sidebar-width);
  }
  .app-sidebar.open {
    transform: translateX(0);
  }
  .app-main {
    margin-left: 0;
  }
  .mobile-overlay {
    display: block;
    position: fixed; inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 999;
  }

  /* Tables: always scrollable on tablets */
  .table-responsive,
  .modern-table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  /* Cards side-by-side → stack */
  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  /* Form columns collapse */
  .col-md-4, .col-md-3, .col-md-6 {
    width: 100% !important;
    float: none !important;
  }

  /* Modals: full-width with side margin */
  .modal-dialog {
    margin: 10px auto;
    max-width: calc(100% - 20px) !important;
    width: calc(100% - 20px) !important;
  }
}

/* ── Small tablet (≤768px) ── */
@media (max-width: 768px) {
  .app-content { padding: 16px; }

  /* All grid columns collapse to full width */
  [class*="col-sm-"], [class*="col-md-"], [class*="col-lg-"] {
    width: 100% !important;
    float: none !important;
  }

  /* Stats: 2 per row */
  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
  }

  /* Topbar: shrink padding, hide breadcrumb */
  .app-topbar { padding: 0 14px; }
  .topbar-breadcrumb { display: none; }

  /* Card headers: smaller padding */
  .card-header { padding: 12px 14px; }
  .card-body   { padding: 14px; }

  /* Panels */
  .panel-body    { padding: 14px; }
  .panel-heading { padding: 10px 14px; }

  /* Button rows: wrap */
  .btn-toolbar, .btn-group { flex-wrap: wrap; gap: 4px; }

  /* DataTables length + filter stack */
  .dataTables_wrapper .dataTables_length,
  .dataTables_wrapper .dataTables_filter {
    float: none !important;
    text-align: left !important;
    margin-bottom: 6px;
  }

  /* Ensure all tables scroll horizontally */
  .table-responsive {
    border: none;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  table {
    min-width: 480px; /* prevent columns squashing */
  }
}

/* ── Phone (≤575px) ── */
@media (max-width: 575px) {
  .app-content { padding: 12px; }

  /* Page header stacks */
  .page-header { flex-direction: column; align-items: flex-start; gap: 10px; }

  /* Stats: single column */
  .stats-grid {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  /* Larger readable stat value */
  .stat-value { font-size: 22px; }

  /* Topbar: compress */
  .app-topbar { padding: 0 10px; height: 52px; }
  .topbar-title { font-size: 14px; }
  .topbar-right { gap: 8px; }

  /* Touch-friendly buttons — minimum 44px tap target */
  .btn {
    min-height: 44px;
    padding: 10px 14px;
  }
  .btn-sm {
    min-height: 36px;
    padding: 6px 10px;
  }
  .btn-xs {
    min-height: 32px;
    padding: 4px 8px;
  }

  /* Modals: full-screen on phones */
  .modal-dialog {
    margin: 6px;
    max-width: calc(100% - 12px) !important;
    width: calc(100% - 12px) !important;
  }
  .modal-content {
    border-radius: var(--radius);
  }

  /* Form controls: taller for touch */
  .form-control, .input-sm {
    height: 44px;
    font-size: 15px;
  }
  textarea.form-control { height: auto; }

  /* Cards: no overflow rounding issues on phones */
  .card { border-radius: var(--radius-sm); }

  /* Stat card: compact */
  .stat-card { padding: 14px; gap: 12px; }
  .stat-icon  { width: 40px; height: 40px; font-size: 17px; }

  /* Table font: slightly smaller to fit more columns */
  .table tbody td { font-size: 12px; padding: 8px 10px; }
  .table thead th { font-size: 10px; padding: 8px 10px; }

  /* Well padding reduction */
  .well { padding: 10px; }

  /* Hide non-essential topbar items on tiny phones */
  .topbar-badge { width: 30px; height: 30px; }
}

/* ── Very small phones (≤360px) ── */
@media (max-width: 360px) {
  .app-content { padding: 8px; }
  .topbar-user-name { display: none !important; }
  .card-body { padding: 10px; }
  .stat-value { font-size: 20px; }
}

/* ── Smooth page transitions ────────────────────────────────── */
.app-content { animation: fadeIn .25s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ── Date picker overrides ──────────────────────────────────── */
.datepicker { border-radius: var(--radius); border: 1px solid var(--border-color); box-shadow: var(--shadow-md); }
.datepicker table tr td.active, .datepicker table tr td.active:hover { background: var(--primary); border-color: var(--primary-dark); }

/* ── Hamburger toggle button ────────────────────────────────── */
.sidebar-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  padding: 6px;
  cursor: pointer;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 20px;
  transition: background var(--transition);
}
.sidebar-toggle:hover { background: var(--body-bg); }

/* ═══════════════════════════════════════════════════════════
   LEGACY PAGE PATTERN OVERRIDES
   These neutralize the old Bootstrap/section markup that
   exists in every sub-module page.
═══════════════════════════════════════════════════════════ */

/* section#feature transparent-bg wrapper used in almost all sub-pages */
section#feature,
section.transparent-bg,
.transparent-bg {
  background: transparent !important;
  padding: 0 !important;
  margin: 0 !important;
}

/* Bootstrap container inside app-content — go full-width */
.app-content .container {
  width: 100% !important;
  max-width: 100% !important;
  padding-left: 0 !important;
  padding-right: 0 !important;
}

/* .features and .wow wrappers — just reset */
.features,
.wow { /* intentionally empty — let children style themselves */ }

/* Bootstrap page-header on <h2> / <h3> used as page titles */
.page-header,
h2.page-header,
h3.page-header,
h4.page-header {
  padding: 0;
  border-bottom: none;
  font-size: 18px;
  font-weight: 700;
  color: var(--text-primary);
  margin: 0 0 20px;
}

/* "Hi username! You are logged in as..." banner that user/list.php echoes */
.app-content > p:first-of-type,
.app-content > section p:first-of-type {
  font-size: 12.5px;
  color: var(--text-muted);
  margin-bottom: 8px;
}

/* Upgrade Bootstrap table classes to modern style */
.table-striped > tbody > tr:nth-of-type(odd) { background: #fafbfc; }
.table-bordered { border: 1px solid var(--border-color) !important; }
.table-bordered > thead > tr > th,
.table-bordered > tbody > tr > td { border-color: var(--border-color) !important; }
.table-hover > tbody > tr:hover { background: #e6f4f2 !important; }
.table-condensed > thead > tr > th,
.table-condensed > tbody > tr > td { padding: 8px 12px; }
.table-responsive { border: none; }

/* Modernize Bootstrap action buttons in tables */
.btn-xs {
  padding: 3px 8px;
  font-size: 11px;
  border-radius: 5px;
  font-weight: 500;
}

/* Well areas */
.well {
  background: var(--body-bg);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 16px;
  box-shadow: none;
  margin-bottom: 16px;
}

/* Bootstrap form-horizontal inside app-content */
.form-horizontal .control-label {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-secondary);
  padding-top: 9px;
}

.input-sm {
  height: 34px;
  padding: 5px 10px;
  font-size: 13px;
  border-radius: var(--radius-sm);
}

/* Center header that wraps the page title */
.center.wow.fadeInDown { margin-bottom: 20px; }

/* Role badges in user table */
td:nth-child(3) .badge,
.role-badge {
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
}

/* Content section top spacing fix */
.app-content section { margin-top: 0; }
.app-content .row { margin-left: 0; margin-right: 0; }

/* Override Bootstrap's default alert close button */
.alert .close { opacity: 0.6; }
.alert .close:hover { opacity: 1; }

/* Panels inside containers */
.app-content .panel { margin-bottom: 20px; }

/* DataTables search + length bar alignment */
.dataTables_wrapper .row { margin-bottom: 10px; }
.dataTables_wrapper .dataTables_length,
.dataTables_wrapper .dataTables_filter { padding: 4px 0; }

/* Timetable / attendance specific table overrides */
#dash-table_wrapper { margin-top: 0; }

/* Old .btn-success / btn-danger in content — make consistent */
.table .btn { margin: 1px; }

/* User info bar (echoed at top of user/list.php) */
.app-content > section:first-child > .container > p,
.app-content > section:first-child:not(.feature-block) {
  font-style: normal;
}

/* Remove background from body (old .homepage class) */
body.homepage { background: var(--body-bg) !important; }

/* Suppress old footer that could still render on some pages */
#footer { display: none !important; }

/* ═══════════════════════════════════════════════════════════
   MODULE-SPECIFIC OVERRIDES
   Neutralize old teal/green brand colors across modules
═══════════════════════════════════════════════════════════ */

/* student/list.php — current-db-badge */
.current-db-badge {
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%) !important;
  box-shadow: 0 2px 8px rgba(0,137,123,0.28) !important;
  border-radius: 20px !important;
  padding: 6px 14px !important;
  font-size: 13px !important;
  color: #fff !important;
  display: inline-flex !important;
  align-items: center !important;
  gap: 6px !important;
  margin-bottom: 14px !important;
}

/* table-selection-form → modern card */
.table-selection-form {
  background: var(--card-bg) !important;
  border: 1px solid var(--border-color) !important;
  border-radius: var(--radius) !important;
  padding: 16px !important;
  box-shadow: var(--shadow-sm) !important;
  margin-bottom: 16px !important;
}

/* Override teal links in student module */
.app-content a[style*="#008080"],
.app-content a[style*="color:#008080"],
.app-content a[style*="color: #008080"] {
  color: var(--primary) !important;
}

/* History cards (student module) */
.history-card-header,
.history-card {
  background: var(--card-bg) !important;
  border: 1px solid var(--border-color) !important;
  border-radius: var(--radius) !important;
}

.history-card-header {
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%) !important;
  border-radius: var(--radius) var(--radius) 0 0 !important;
  color: #fff !important;
}

/* Override hover for history rows */
.history-table tbody tr:hover {
  background-color: rgba(0,137,123,0.07) !important;
}

/* Download section */
.download-section {
  background: linear-gradient(135deg, #e0f2f1 0%, #b2dfdb 100%) !important;
  border-left: 4px solid var(--primary) !important;
}

/* Timetabling / report module headings */
.app-content .panel-teal,
.app-content .panel-success .panel-heading {
  background: var(--primary) !important;
}

/* Override Bootstrap's teal/green btn-success to use modern green */
.btn-success {
  background-color: var(--success) !important;
  border-color: var(--success) !important;
}
.btn-success:hover { background-color: #059669 !important; }

/* Page-level body bg override from student/list embedded style */
.app-main { background: var(--body-bg) !important; }

/* user/add.php and similar form-horizontal forms layout fix */
.col-md-8 > .form-group { margin-bottom: 14px; }

/* Ensure all tables have consistent styling regardless of inline font-size */
.table { font-size: 13.5px !important; }
.table thead th { font-size: 11px !important; }

/* Bellringer table — remove collapsed borders look */
.table-bordered.table { border-radius: var(--radius-sm); overflow: hidden; }

/* Override Bootstrap accordion/collapse colors */
.panel-group .panel { border-radius: var(--radius) !important; }

/* Override alert inside forms */
.form-group div[id^="errormsg"] {
  font-size: 12px;
  padding: 5px 8px;
  border-radius: 5px;
  margin-top: 4px;
}

/* Smooth appearance for injected alert error boxes */
.app-content div[id^="errormsg"]:not(:empty) {
  animation: fadeIn .2s ease;
}

/* ── Attendance/list.php inline-style override ──────────────────
   That page injects its own <style> block with hardcoded #009688
   values. Keep them aligned with our teal theme within .app-main.
   ──────────────────────────────────────────────────────────────── */
.app-main body,
.app-main {
  background: var(--body-bg) !important;
}

/* Hard-coded #009688 / teal text & borders */
.app-content [style*="color:#009688"],
.app-content [style*="color: #009688"],
.app-content [style*="border-left: 4px solid #009688"] {
  color: var(--primary) !important;
  border-left-color: var(--primary) !important;
}

/* Attendance page: nav tabs active state */
.app-content .nav-tabs > li.active > a,
.app-content .nav-tabs > li.active > a:focus,
.app-content .nav-tabs > li.active > a:hover {
  border-top-color: var(--primary) !important;
  color: var(--primary) !important;
}

/* Attendance section headers with teal border */
.app-content .panel-heading,
.app-content .stats-title,
.app-content .section-title {
  border-left-color: var(--primary) !important;
  color: var(--primary) !important;
}

/* Inline style gradient overrides (attendance progress bars, badges, buttons) */
.app-content [style*="#009688"] {
  background-color: var(--primary) !important;
  border-color: var(--primary) !important;
  color: #fff !important;
}
.app-content a[style*="#009688"],
.app-content span[style*="#009688"],
.app-content td[style*="#009688"],
.app-content th[style*="#009688"] {
  color: var(--primary) !important;
  background-color: transparent !important;
}

/* ── Attendance Table Polish ─────────────────────────────────── */

/* Wrapper */
#attendanceTable {
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
}

/* Table base */
#attendanceTable .table {
  margin-bottom: 0;
  font-size: 13px !important;
  background: var(--card-bg);
}

/* Header rows – teal gradient */
#attendanceTable thead tr:first-child th {
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
  color: #fff;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: .6px;
  text-transform: uppercase;
  border: none;
  padding: 10px 8px;
  text-align: center;
  white-space: nowrap;
}

#attendanceTable thead tr:nth-child(2) th {
  background: #e0f2f1;
  color: var(--primary-dark);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .4px;
  text-transform: uppercase;
  border-bottom: 2px solid #b2dfdb;
  padding: 9px 8px;
  white-space: nowrap;
}

/* Body rows */
#attendanceTable tbody tr.attendance-row {
  transition: background .15s ease, box-shadow .15s ease;
}

#attendanceTable tbody tr.attendance-row:hover {
  background: #e0f2f1 !important;
  box-shadow: inset 3px 0 0 var(--primary);
}

/* Neutralise loud PHP-injected date colors – override the inline style */
#attendanceTable tbody td b[style*="color:"],
#attendanceTable tbody td b[style] {
  color: var(--text-primary) !important;
  font-weight: 600;
}

/* Date cell */
#attendanceTable tbody td:nth-child(3) {
  white-space: nowrap;
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
}

/* Student ID pill */
#attendanceTable tbody td:first-child {
  font-family: monospace;
  font-size: 11px;
  color: var(--text-secondary);
  background: #f8fafc;
  font-weight: 600;
  white-space: nowrap;
}

/* Student name link */
#attendanceTable .student-name-link {
  color: var(--primary) !important;
  font-weight: 600;
  text-decoration: none !important;
  transition: color .15s;
}
#attendanceTable .student-name-link:hover {
  color: var(--primary-dark) !important;
  text-decoration: underline !important;
}

/* Time cells */
#attendanceTable tbody td:nth-child(4),
#attendanceTable tbody td:nth-child(5) {
  font-variant-numeric: tabular-nums;
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
  color: var(--text-primary);
}

/* Status: check-in / check-out  →  colored cell highlight */
#attendanceTable td.text-danger  { color: #b91c1c !important; background: #fef2f2 !important; font-size: 11.5px; font-weight: 700; white-space: nowrap; }
#attendanceTable td.text-warning { color: #92400e !important; background: #fffbeb !important; font-size: 11.5px; font-weight: 700; white-space: nowrap; }
#attendanceTable td.text-success { color: #065f46 !important; background: #ecfdf5 !important; font-size: 11.5px; font-weight: 700; white-space: nowrap; }
#attendanceTable td.text-muted   { color: #64748b !important; background: #f8fafc !important; font-size: 11.5px; font-weight: 500; white-space: nowrap; }
#attendanceTable td.text-info    { color: #1e40af !important; background: #eff6ff !important; font-size: 11.5px; font-weight: 700; white-space: nowrap; }
/* "On Time" — td has no status class; give it a subtle green tint via content match workaround */

/* Day-separator row */
#attendanceTable tr.day-separator td {
  padding: 3px 0 !important;
  border: none !important;
  background: transparent !important;
}
#attendanceTable tr.day-separator td > div {
  color: var(--text-muted) !important;
  letter-spacing: 4px;
}

/* Striped even rows */
#attendanceTable tbody tr.attendance-row:nth-child(even) {
  background: #fafafa;
}

/* History badge */
#attendanceTable .name-history-badge small {
  font-size: 9px;
  color: var(--text-muted);
  background: #f1f5f9;
  border-radius: 999px;
  padding: 1px 6px;
}

/* Responsive: allow horizontal scroll gracefully */
#attendanceTable { overflow-x: auto; }

/* ── Timetabling: floating menu button ── */
/* (removed – topbar ≡ button handles all pages) */

/* ── Timetabling: auto-hide sidebar for full-width table view ── */
.sidebar-auto-hidden .app-sidebar {
  transform: translateX(-100%);
}
.sidebar-auto-hidden .app-main {
  margin-left: 0;
  transition: margin-left var(--transition);
}
.sidebar-auto-hidden .app-sidebar.open {
  transform: translateX(0);
}
/* Push content right when sidebar opens so nothing is covered */
.sidebar-auto-hidden.sidebar-is-open .app-main {
  margin-left: var(--sidebar-width);
}
/* Overlay works at all screen sizes in auto-hidden mode */
.sidebar-auto-hidden .mobile-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  z-index: 999;
}
.sidebar-auto-hidden.sidebar-open-by-user .app-main {
  margin-left: 0;
}

