/* ============================================================
   SIOD Shift Scheduler — main.css
   ============================================================ */

/* --- Reset & Base ---------------------------------------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --blue:       #1a4f8a;
  --blue-light: #2563b0;
  --blue-bg:    #e8f0fb;
  --green:      #1a7a4a;
  --green-bg:   #e6f5ee;
  --red:        #b91c1c;
  --red-bg:     #fde8e8;
  --orange:     #c2570a;
  --orange-bg:  #fdf3e7;
  --gray-50:    #f9fafb;
  --gray-100:   #f3f4f6;
  --gray-200:   #e5e7eb;
  --gray-300:   #d1d5db;
  --gray-500:   #6b7280;
  --gray-700:   #374151;
  --gray-900:   #111827;
  --white:      #ffffff;
  --shadow-sm:  0 1px 3px rgba(0,0,0,.12);
  --shadow-md:  0 4px 12px rgba(0,0,0,.15);
  --radius:     6px;
  --nav-w:      220px;
  --top-h:      52px;
  --font:       'Segoe UI', system-ui, -apple-system, sans-serif;
}

html, body { height: 100%; }
body { font-family: var(--font); font-size: 14px; color: var(--gray-900); background: var(--gray-50); }

/* --- Login page ------------------------------------------ */
.login-body {
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  min-height: 100vh; background: linear-gradient(135deg, #0f2952 0%, #1a4f8a 100%);
}
.login-wrapper { width: 100%; max-width: 400px; padding: 16px; }
.login-card {
  background: var(--white); border-radius: 10px;
  padding: 36px 32px; box-shadow: var(--shadow-md);
}
.login-logo { text-align: center; margin-bottom: 28px; }
.login-icon { font-size: 40px; margin-bottom: 8px; }
.login-logo h1 { font-size: 20px; color: var(--blue); font-weight: 700; }
.login-subtitle { color: var(--gray-500); font-size: 12px; margin-top: 4px; }
.login-footer { color: rgba(255,255,255,.5); font-size: 12px; text-align: center; margin-top: 20px; }

/* --- App layout ------------------------------------------ */
.app-body { display: flex; flex-direction: column; height: 100vh; overflow: hidden; }

.topnav {
  position: fixed; top: 0; left: 0; right: 0; z-index: 100;
  height: var(--top-h); background: var(--blue);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 16px; color: var(--white); box-shadow: var(--shadow-sm);
}
.topnav-left, .topnav-right { display: flex; align-items: center; gap: 12px; }
.app-title { font-weight: 700; font-size: 15px; }
.hamburger { background: none; border: none; color: #ffffff; font-size: 22px; cursor: pointer; padding: 4px; text-shadow: 0 1px 3px rgba(0,0,0,.5); opacity: 1; }
.hamburger:hover { color: #ffffff; opacity: .85; }
.user-badge { font-size: 13px; }
.role-tag { font-size: 10px; font-weight: 700; padding: 2px 6px; border-radius: 10px; letter-spacing: .5px; }
.role-admin     { background: #fef08a; color: #713f12; }
.role-scheduler { background: #bfdbfe; color: #1e3a5f; }
.role-viewer    { background: #d1fae5; color: #064e3b; }

.sidebar {
  position: fixed; top: var(--top-h); left: 0; bottom: 0; z-index: 90;
  width: var(--nav-w); background: var(--white);
  border-right: 1px solid var(--gray-200);
  overflow-y: auto; transform: translateX(0);
  transition: transform .25s ease;
}
.sidebar-overlay {
  display: none; position: fixed; inset: 0; z-index: 89;
  background: rgba(0,0,0,.4);
}

.nav-list { list-style: none; padding: 12px 0; }
.nav-list li { margin: 0; }
.nav-link {
  display: block; padding: 10px 20px; color: var(--gray-700);
  text-decoration: none; font-size: 13.5px; transition: background .15s, color .15s;
  border-left: 3px solid transparent;
}
.nav-link:hover { background: var(--blue-bg); color: var(--blue); }
.nav-link.active { background: var(--blue-bg); color: var(--blue); border-left-color: var(--blue); font-weight: 600; }
.nav-sep { height: 1px; background: var(--gray-200); margin: 8px 0; }
.badge {
  display: inline-block; background: var(--red); color: var(--white);
  font-size: 10px; font-weight: 700; padding: 1px 6px;
  border-radius: 10px; margin-left: 6px;
}

.main-content {
  position: fixed; top: var(--top-h); left: var(--nav-w); right: 0; bottom: 0;
  overflow: hidden; display: flex; flex-direction: column;
  transition: left .25s ease;
}

/* Sidebar collapsed state (desktop toggle) */
body.sidebar-collapsed .sidebar { transform: translateX(-220px); }
body.sidebar-collapsed .main-content { left: 0; }

.view { display: none; flex-direction: column; height: 100%; overflow: hidden; }
.view.active { display: flex; }

/* All non-schedule views scroll independently */
#view-employees .data-table-wrap,
#view-users .data-table-wrap,
#view-holidays .data-table-wrap,
#view-logs .data-table-wrap {
  overflow-y: auto;
  overflow-x: auto;
  flex: 1;
  padding: 12px;
}

/* Make the views themselves fill and scroll */
#view-employees,
#view-users,
#view-holidays,
#view-logs,
#view-requests,
#view-my-requests,
#view-password,
#view-updates {
  overflow-y: auto;
}

/* Ensure data tables don't force page zoom */
.data-table {
  min-width: 100%;
  table-layout: auto;
}

/* On smaller screens, allow horizontal scroll on tables */
.data-table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

/* Fix view sections to properly fill height and scroll */
#view-employees > div,
#view-users > div,
#view-holidays > div,
#view-logs > div {
  flex: 1;
  overflow-y: auto;
  overflow-x: auto;
}

.view-header {
  display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 6px;
  padding: 8px 16px; border-bottom: 1px solid var(--gray-200); background: var(--white);
  flex-shrink: 0; min-height: 0;
}
.view-header h2 { font-size: 15px; font-weight: 700; color: var(--gray-900); margin: 0; }
.view-controls { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.month-label { font-size: 15px; font-weight: 600; min-width: 140px; text-align: center; }

/* --- Schedule grid --------------------------------------- */
.schedule-scroll { flex: 1; overflow: auto; padding: 12px; }

.schedule-section { margin-bottom: 24px; }
.section-header {
  font-size: 12px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .8px; color: var(--blue); margin-bottom: 6px; padding-left: 2px;
}

.schedule-table {
  border-collapse: collapse; width: 100%; table-layout: fixed;
  font-size: 12px; background: var(--white);
  border-radius: var(--radius); box-shadow: var(--shadow-sm);
  overflow: hidden;
}
.schedule-table th, .schedule-table td {
  border: 1px solid var(--gray-200); padding: 0; text-align: center;
  vertical-align: middle;
}
.schedule-table td {
  min-width: 20px; height: 32px;
}
.schedule-table th {
  background: var(--blue); color: var(--white);
  padding: 6px 4px; white-space: nowrap; position: sticky; top: 0; z-index: 2;
  font-size: 11px;
}
.schedule-table th.name-col { text-align: left; padding-left: 10px; width: 130px; min-width: 130px; max-width: 130px; position: sticky; left: 0; z-index: 3; }
.schedule-table td.name-col {
  text-align: left; padding: 0 8px; white-space: nowrap;
  font-weight: 600; background: var(--gray-50); width: 130px; min-width: 130px; max-width: 130px;
  position: sticky; left: 0; z-index: 1;
}
.schedule-table tr.vacant-row td { color: var(--gray-500); font-style: italic; }
.schedule-table tr:hover td { filter: brightness(1.15); }
.schedule-table tr:hover td.name-col { background: #b0caf0 !important; color: #1a3a6a !important; filter: none; }
.schedule-table tr:hover td.code-off { background: #c5d8f5 !important; filter: none; }

th.weekend-col { background: #374f70 !important; }
th.holiday-col { background: #5b3060 !important; }

/* Weekend full column shading */
td.weekend-col { background: #2a3a52 !important; }
td.holiday-col { background: #3a2050 !important; }
body:not(.dark-mode) td.weekend-col { background: #e8edf5 !important; }
body:not(.dark-mode) td.holiday-col { background: #f0e8f5 !important; }

.cell-input {
  width: 100%; height: 32px; border: none; text-align: center;
  font-size: 11px; font-weight: 600; background: transparent;
  cursor: default; padding: 0; outline: none; display: block; color: inherit;
}

/* Shift color coding */
.code-staff   { background: #eff6ff; color: #1e3a5f; }
.code-ops-day { background: #ecfdf5; color: #065f46; }
.code-ops-mid { background: #1e1e2e; color: #a5b4fc; }
.code-ops-swg { background: #fffbeb; color: #92400e; }
.code-emi     { background: #f0fdf4; color: #14532d; }
.code-leave   { background: #fef9c3; color: #713f12; }
.code-tdy     { background: #f0f4ff; color: #3730a3; }
.code-hd      { background: #fdf4ff; color: #6b21a8; }
.code-off     { background: var(--gray-100); color: var(--gray-400); }
.code-weekend { background: var(--gray-100); }
.code-pd      { background: #e0e7ff; color: #3730a3; font-style: italic; }

/* Shift picker dropdown */
.cell-select {
  width: 100%; height: 32px; border: none;
  font-size: 11px; font-weight: 600; background: transparent; cursor: pointer;
  -webkit-appearance: none; appearance: none; text-align: center; text-align-last: center;
  padding: 0; outline: none;
}
.cell-select:focus { outline: 2px solid var(--blue-light); outline-offset: -2px; }

/* Legend */
.legend {
  display: flex; flex-wrap: wrap; gap: 6px; padding: 10px 12px;
  background: var(--white); border-top: 1px solid var(--gray-200);
  flex-shrink: 0;
}
.legend-item {
  font-size: 11px; padding: 2px 8px; border-radius: 10px; white-space: nowrap;
}

/* --- Tables (employees, users, etc.) --------------------- */
.data-table-wrap { overflow-x: auto; padding: 12px; }
.data-table {
  width: 100%; border-collapse: collapse; background: var(--white);
  border-radius: var(--radius); box-shadow: var(--shadow-sm); overflow: hidden;
}
.data-table th {
  background: var(--blue); color: var(--white);
  padding: 10px 14px; text-align: left; font-size: 12px; font-weight: 600;
  text-transform: uppercase; letter-spacing: .5px;
}
.data-table td { padding: 10px 14px; border-bottom: 1px solid var(--gray-100); font-size: 13px; }
.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: var(--blue-bg); }
.data-table .action-btns { display: flex; gap: 6px; }

/* --- Forms ----------------------------------------------- */
.form-card { padding: 20px; max-width: 480px; }
.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-size: 12px; font-weight: 600; color: var(--gray-700); margin-bottom: 5px; }
.form-group input, .form-group select, .form-group textarea {
  width: 100%; padding: 8px 12px; border: 1px solid var(--gray-300); border-radius: var(--radius);
  font-size: 14px; font-family: var(--font); background: var(--white); color: var(--gray-900);
  transition: border-color .15s, box-shadow .15s;
}
.form-group input:focus, .form-group select:focus, .form-group textarea:focus {
  outline: none; border-color: var(--blue-light); box-shadow: 0 0 0 3px rgba(37,99,176,.15);
}
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

/* --- Buttons -------------------------------------------- */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 16px; border-radius: var(--radius);
  font-size: 13px; font-weight: 600; cursor: pointer; border: none;
  transition: background .15s, opacity .15s; white-space: nowrap;
}
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary  { background: var(--blue); color: var(--white); }
.btn-primary:hover:not(:disabled) { background: var(--blue-light); }
.btn-success  { background: var(--green); color: var(--white); }
.btn-danger   { background: var(--red); color: var(--white); }
.btn-outline  { background: transparent; border: 1.5px solid var(--blue); color: var(--blue); }
.btn-outline:hover:not(:disabled) { background: var(--blue-bg); }
.btn-ghost    { background: transparent; color: rgba(255,255,255,.85); }
.btn-ghost:hover { color: var(--white); }

/* Month nav arrows — visible on light backgrounds */
#prev-month, #next-month {
  background: var(--blue); color: var(--white);
  font-size: 20px; font-weight: 700; padding: 4px 12px;
  border-radius: var(--radius); border: none; cursor: pointer; line-height: 1;
}
#prev-month:hover, #next-month:hover { background: var(--blue-light); }
.btn-sm       { padding: 5px 10px; font-size: 12px; }
.btn-full     { width: 100%; justify-content: center; }
.btn-link     { background: none; border: none; color: var(--blue); cursor: pointer; padding: 2px 4px; font-size: 12px; text-decoration: underline; }
.btn-link.danger { color: var(--red); }
.select-sm    { padding: 5px 8px; border: 1px solid var(--gray-300); border-radius: var(--radius); font-size: 13px; background: var(--white); }

/* --- Alerts -------------------------------------------- */
.alert { padding: 10px 14px; border-radius: var(--radius); font-size: 13px; margin-bottom: 14px; }
.alert-error  { background: var(--red-bg); color: var(--red); border: 1px solid #fca5a5; }
.alert-warn   { background: var(--orange-bg); color: var(--orange); border: 1px solid #fed7aa; }
.alert-ok     { background: var(--green-bg); color: var(--green); border: 1px solid #86efac; }

/* --- Modal --------------------------------------------- */
.modal-overlay {
  position: fixed; inset: 0; z-index: 200;
  background: rgba(0,0,0,.5); display: flex; align-items: center; justify-content: center; padding: 16px;
}
.modal {
  background: var(--white); border-radius: 10px; width: 100%; max-width: 520px;
  max-height: 90vh; display: flex; flex-direction: column; box-shadow: var(--shadow-md);
}
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px; border-bottom: 1px solid var(--gray-200);
}
.modal-header h3 { font-size: 16px; font-weight: 700; }
.modal-close { background: none; border: none; font-size: 20px; cursor: pointer; color: var(--gray-500); padding: 2px 6px; }
.modal-close:hover { color: var(--gray-900); }
.modal-body { padding: 20px; overflow-y: auto; flex: 1; }
.modal-footer { padding: 14px 20px; border-top: 1px solid var(--gray-200); display: flex; justify-content: flex-end; gap: 10px; }

/* --- Request cards ------------------------------------- */
.request-list { padding: 12px; display: flex; flex-direction: column; gap: 10px; overflow-y: auto; flex: 1; }
.request-card {
  background: var(--white); border-radius: var(--radius); padding: 14px 16px;
  box-shadow: var(--shadow-sm); border-left: 4px solid var(--gray-300);
  display: flex; flex-wrap: wrap; align-items: flex-start; gap: 12px;
}
.request-card.pending  { border-left-color: var(--orange); }
.request-card.approved { border-left-color: var(--green); }
.request-card.denied   { border-left-color: var(--red); }
.request-info { flex: 1; min-width: 180px; }
.request-info h4 { font-size: 14px; font-weight: 700; margin-bottom: 4px; }
.request-info p  { font-size: 12px; color: var(--gray-500); margin-bottom: 2px; }
.request-actions { display: flex; gap: 8px; align-items: center; }
.status-pill {
  font-size: 11px; font-weight: 700; padding: 2px 10px; border-radius: 10px; text-transform: uppercase;
}
.status-pending  { background: var(--orange-bg); color: var(--orange); }
.status-approved { background: var(--green-bg);  color: var(--green); }
.status-denied   { background: var(--red-bg);    color: var(--red); }

/* --- Loading / Empty states ----------------------------- */
.loading-msg, .empty-msg { text-align: center; color: var(--gray-500); padding: 40px; font-size: 14px; }


/* ============================================================
   DARK MODE
   ============================================================ */
body.dark-mode {
  --blue:       #3b82f6;
  --blue-light: #60a5fa;
  --blue-bg:    #1e2a3a;
  --green:      #34d399;
  --green-bg:   #064e3b;
  --red:        #f87171;
  --red-bg:     #450a0a;
  --orange:     #fb923c;
  --orange-bg:  #431407;
  --gray-50:    #0f1117;
  --gray-100:   #1a1d27;
  --gray-200:   #2a2d3a;
  --gray-300:   #3a3d4a;
  --gray-500:   #9ca3af;
  --gray-700:   #d1d5db;
  --gray-900:   #f3f4f6;
  --white:      #1e2130;
  background:   #0f1117;
  color:        #f3f4f6;
}

body.dark-mode .topnav { background: #0d1321; border-bottom: 1px solid #2a2d3a; }
body.dark-mode .sidebar { background: #1a1d27; border-right: 1px solid #2a2d3a; }
body.dark-mode .nav-link { color: #d1d5db; }
body.dark-mode .nav-link:hover { background: #1e2a3a; color: #60a5fa; }
body.dark-mode .nav-link.active { background: #1e2a3a; color: #60a5fa; border-left-color: #3b82f6; }
body.dark-mode .view-header { background: #1a1d27; border-bottom-color: #2a2d3a; }
body.dark-mode .view-header h2 { color: #f3f4f6; }
body.dark-mode .schedule-table { background: #1e2130; }
body.dark-mode .schedule-table th { background: #0d1321; }
body.dark-mode .schedule-table td { border-color: #2a2d3a; }
body.dark-mode .schedule-table td.name-col { background: #1a1d27; color: #f3f4f6; }
body.dark-mode .schedule-table tr:hover td { background: #1e2a3a !important; }
body.dark-mode .schedule-table tr:hover td.name-col { background: #1e2a3a !important; }
body.dark-mode .legend { background: #1a1d27; border-top-color: #2a2d3a; }
body.dark-mode .data-table { background: #1e2130; }
body.dark-mode .data-table td { border-bottom-color: #2a2d3a; color: #d1d5db; }
body.dark-mode .data-table tr:hover td { background: #1e2a3a; }
body.dark-mode .form-card { color: #d1d5db; }
body.dark-mode .form-group input,
body.dark-mode .form-group select,
body.dark-mode .form-group textarea {
  background: #2a2d3a; border-color: #3a3d4a; color: #f3f4f6;
}
body.dark-mode .modal { background: #1e2130; }
body.dark-mode .modal-header { border-bottom-color: #2a2d3a; }
body.dark-mode .modal-header h3 { color: #f3f4f6; }
body.dark-mode .modal-footer { border-top-color: #2a2d3a; }
body.dark-mode .request-card { background: #1e2130; }
body.dark-mode .cell-select { color: #f3f4f6; }
body.dark-mode .code-off { background: #2a2d3a; color: #6b7280; }
body.dark-mode .code-staff { background: #1e2a3a; color: #93c5fd; }
body.dark-mode .code-ops-day { background: #064e3b; color: #6ee7b7; }
body.dark-mode .code-ops-mid { background: #1e1e3a; color: #a5b4fc; }
body.dark-mode .code-emi { background: #052e16; color: #86efac; }
body.dark-mode .code-leave { background: #422006; color: #fcd34d; }
body.dark-mode .code-tdy { background: #1e1b4b; color: #a5b4fc; }
body.dark-mode .code-hd { background: #2e1065; color: #d8b4fe; }
body.dark-mode .code-pd { background: #1e1b4b; color: #818cf8; }
body.dark-mode .section-header { color: #60a5fa; }
body.dark-mode #prev-month,
body.dark-mode #next-month { background: #2a3a5a; color: #93c5fd; }
body.dark-mode #prev-month:hover,
body.dark-mode #next-month:hover { background: #3b82f6; color: #fff; }
body.dark-mode .btn-outline { border-color: #3b82f6; color: #60a5fa; }
body.dark-mode .btn-outline:hover { background: #1e2a3a; }
body.dark-mode .nav-sep { background: #2a2d3a; }
body.dark-mode .select-sm { background: #2a2d3a; border-color: #3a3d4a; color: #f3f4f6; }
body.dark-mode .month-label { color: #f3f4f6; }

/* Dark mode toggle button */
.dark-toggle {
  background: none; border: 1.5px solid rgba(255,255,255,.4);
  color: rgba(255,255,255,.85); border-radius: 20px;
  padding: 4px 10px; font-size: 12px; cursor: pointer;
  transition: all .2s; white-space: nowrap;
}
.dark-toggle:hover { background: rgba(255,255,255,.1); color: #fff; border-color: #fff; }

/* ============================================================
   DARK MODE — CONTRAST FIXES
   ============================================================ */
body.dark-mode { color: #e5e7eb; }

/* Sidebar */
body.dark-mode .sidebar { background: #13151f; border-right: 1px solid #2a2d3a; }
body.dark-mode .nav-link { color: #c9cdd8; }
body.dark-mode .nav-link:hover { background: #1e2a3a; color: #93c5fd; }
body.dark-mode .nav-link.active { background: #1e2a3a; color: #93c5fd; border-left-color: #60a5fa; }
body.dark-mode .nav-sep { background: #2a2d3a; }

/* Top nav */
body.dark-mode .topnav { background: #0a0e1a; }
body.dark-mode .app-title { color: #e5e7eb; }

/* View header */
body.dark-mode .view-header { background: #13151f; border-bottom: 1px solid #2a2d3a; }
body.dark-mode .view-header h2 { color: #f0f2f8; }
body.dark-mode .month-label { color: #f0f2f8; }

/* Schedule table */
body.dark-mode .schedule-table { background: #1a1d2e; box-shadow: none; }
body.dark-mode .schedule-table th { background: #0d1120; color: #c9d1e8; border-color: #2a2d3a; }
body.dark-mode .schedule-table th.weekend-col { background: #1a1f35 !important; }
body.dark-mode .schedule-table th.holiday-col { background: #2d1f45 !important; }
body.dark-mode .schedule-table td { border-color: #252838; }
body.dark-mode .schedule-table td.name-col { 
  background: #13151f !important; color: #e5e7eb !important; 
  border-right: 2px solid #2a2d3a;
}
body.dark-mode .schedule-table tr.vacant-row td.name-col { color: #6b7280 !important; }
body.dark-mode .schedule-table tr:hover td { background: #1e2a3a !important; }
body.dark-mode .schedule-table tr:hover td.name-col { background: #1e2a3a !important; color: #93c5fd !important; }

/* Section headers */
body.dark-mode .section-header { color: #60a5fa; }

/* Shift cells */
body.dark-mode .cell-select { color: #e5e7eb; }
body.dark-mode .cell-select option { background: #1a1d2e; color: #e5e7eb; }

/* Shift color codes — dark mode versions */
body.dark-mode .code-off     { background: #1e2130; color: #4b5563; }
body.dark-mode .code-staff   { background: #172554; color: #93c5fd; }
body.dark-mode .code-ops-day { background: #052e16; color: #6ee7b7; }
body.dark-mode .code-ops-mid { background: #1e1b4b; color: #a5b4fc; }
body.dark-mode .code-emi     { background: #14532d; color: #86efac; }
body.dark-mode .code-leave   { background: #422006; color: #fde68a; }
body.dark-mode .code-tdy     { background: #1e1b4b; color: #c7d2fe; }
body.dark-mode .code-hd      { background: #3b0764; color: #e9d5ff; }
body.dark-mode .code-pd      { background: #1e1b4b; color: #a5b4fc; font-style: italic; }
body.dark-mode .code-weekend { background: #161820; }

/* Legend */
body.dark-mode .legend { background: #13151f; border-top: 1px solid #2a2d3a; }
body.dark-mode .legend-item { opacity: 0.9; }

/* Nav arrows */
body.dark-mode #prev-month,
body.dark-mode #next-month { background: #1e2a4a; color: #93c5fd; border: 1px solid #2a3a5a; }
body.dark-mode #prev-month:hover,
body.dark-mode #next-month:hover { background: #2563b0; color: #fff; }

/* Buttons */
body.dark-mode .btn-outline { border-color: #3b82f6; color: #93c5fd; background: transparent; }
body.dark-mode .btn-outline:hover { background: #1e2a3a; }
body.dark-mode .btn-primary { background: #2563b0; }

/* Role tags */
body.dark-mode .role-admin     { background: #713f12; color: #fef08a; }
body.dark-mode .role-scheduler { background: #1e3a5f; color: #bfdbfe; }
body.dark-mode .role-viewer    { background: #064e3b; color: #d1fae5; }

/* Data tables */
body.dark-mode .data-table { background: #1a1d2e; }
body.dark-mode .data-table th { background: #0d1120; color: #c9d1e8; }
body.dark-mode .data-table td { border-bottom-color: #252838; color: #d1d5db; }
body.dark-mode .data-table tr:hover td { background: #1e2a3a; }

/* Forms */
body.dark-mode .form-group label { color: #c9cdd8; }
body.dark-mode .form-group input,
body.dark-mode .form-group select,
body.dark-mode .form-group textarea {
  background: #1a1d2e; border-color: #2a2d3a; color: #e5e7eb;
}
body.dark-mode .form-group input::placeholder { color: #4b5563; }

/* Modal */
body.dark-mode .modal { background: #13151f; }
body.dark-mode .modal-header { border-bottom-color: #2a2d3a; }
body.dark-mode .modal-header h3 { color: #f0f2f8; }
body.dark-mode .modal-footer { border-top-color: #2a2d3a; }
body.dark-mode .modal-close { color: #9ca3af; }

/* Request cards */
body.dark-mode .request-card { background: #1a1d2e; }
body.dark-mode .request-info h4 { color: #e5e7eb; }
body.dark-mode .request-info p { color: #9ca3af; }

/* Select filter */
body.dark-mode .select-sm { background: #1a1d2e; border-color: #2a2d3a; color: #e5e7eb; }

/* Alerts */
body.dark-mode .alert-error  { background: #450a0a; color: #fca5a5; border-color: #7f1d1d; }
body.dark-mode .alert-warn   { background: #431407; color: #fdba74; border-color: #7c2d12; }
body.dark-mode .alert-ok     { background: #052e16; color: #6ee7b7; border-color: #065f46; }

/* Status pills */
body.dark-mode .status-pending  { background: #431407; color: #fb923c; }
body.dark-mode .status-approved { background: #052e16; color: #34d399; }
body.dark-mode .status-denied   { background: #450a0a; color: #f87171; }

/* Scrollbars in dark mode */
body.dark-mode ::-webkit-scrollbar { width: 8px; height: 8px; }
body.dark-mode ::-webkit-scrollbar-track { background: #13151f; }
body.dark-mode ::-webkit-scrollbar-thumb { background: #2a2d3a; border-radius: 4px; }
body.dark-mode ::-webkit-scrollbar-thumb:hover { background: #3b82f6; }

/* ====================================================
   RESPONSIVE
   ==================================================== */
@media (max-width: 768px) {
  :root { --nav-w: 0px; }

  .sidebar {
    transform: translateX(-220px);
    width: 220px;
  }
  .sidebar.open {
    transform: translateX(0);
    box-shadow: var(--shadow-md);
  }
  .sidebar-overlay.open { display: block; }

  .main-content { left: 0; }

  /* Allow horizontal scroll on schedule for mobile */
  .schedule-scroll {
    overflow-x: auto !important;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch;
  }

  .schedule-table {
    width: max-content !important;
    min-width: 100%;
    table-layout: auto !important;
  }

  .schedule-table th, .schedule-table td { min-width: 32px; }
  .cell-input, .cell-select { width: 100%; }

  .view-header { padding: 10px 14px; }
  .form-row { grid-template-columns: 1fr; }
  .modal { max-height: 95vh; }

  .topnav-right .user-badge { display: none; }
}

@media (max-width: 480px) {
  .view-header h2 { font-size: 15px; }
  .app-title { font-size: 14px; }
  .schedule-table { font-size: 11px; }
  .data-table th, .data-table td { padding: 8px 10px; font-size: 12px; }
}

/* ============================================================
   DARK MODE — READABILITY PASS 2
   ============================================================ */

/* Cell text contrast */
body.dark-mode .cell-select { color: #cbd5e1; font-weight: 600; }
body.dark-mode .cell-input  { color: #cbd5e1; font-weight: 600; }

/* Off cells — make the 0-Off text visible */
body.dark-mode .code-off { background: #1a1d2e; color: #4b5775; }

/* Name column — brighter text */
body.dark-mode .schedule-table td.name-col { 
  color: #e2e8f0 !important; font-weight: 700;
  background: #0f1219 !important;
}
body.dark-mode .schedule-table tr.vacant-row td.name-col { 
  color: #64748b !important; font-style: italic;
}

/* Date/day header text */
body.dark-mode .schedule-table th { 
  color: #c8d3e8 !important; font-weight: 600;
}
body.dark-mode .schedule-table th.weekend-col { 
  background: #1c2035 !important; color: #8899bb !important;
}
body.dark-mode .schedule-table th.holiday-col { 
  background: #2d1f45 !important; color: #c4b5fd !important;
}

/* Section labels MISSION SUPPORT / OPERATIONS */
body.dark-mode .section-header { 
  color: #7eb3ff; font-size: 13px; letter-spacing: 1px;
}

/* Legend pills — ensure all are readable */
body.dark-mode .legend { padding: 10px 14px; }
body.dark-mode .code-off.legend-item { 
  background: #252a3a; color: #8899bb; border: 1px solid #3a3f52;
}

/* Hover row — keep name visible */
body.dark-mode .schedule-table tr:hover td.name-col { 
  color: #7eb3ff !important; background: #1a2540 !important;
}
body.dark-mode .schedule-table tr:hover td { 
  background: #1a2540 !important;
}

/* Today highlight — make it visible in dark mode */
body.dark-mode .schedule-table th[data-today] { 
  background: #1e3a5f !important; color: #60a5fa !important;
}


/* Hide text when Off — blank cell */
.cell-select[data-code="0"],
body.dark-mode .cell-select[data-code="0"] { color: transparent; }
.cell-select[data-code="0"]:focus,
body.dark-mode .cell-select[data-code="0"]:focus { color: inherit; }

/* Context menu styling */
#ctx-menu { font-family: var(--font); }
body:not(.dark-mode) #ctx-menu {
  background: var(--white); border-color: var(--gray-200);
  box-shadow: 0 8px 24px rgba(0,0,0,.15);
}
body:not(.dark-mode) .ctx-item { color: var(--gray-700) !important; }
body:not(.dark-mode) .ctx-item:hover { background: var(--blue-bg) !important; color: var(--blue) !important; }

/* Topnav user name — ensure readable in both modes */
.user-badge { color: #ffffff; font-weight: 500; text-shadow: 0 1px 2px rgba(0,0,0,.4); }
body.dark-mode .user-badge { color: #e2e8f0; }

/* Show only the shift code in cells — no label text */
.cell-select {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .3px;
}

/* ============================================================
   COMPACT VIEW HEADERS — fix large header on small screens
   ============================================================ */
.view-header {
  padding: 6px 14px !important;
  min-height: 0 !important;
  flex-wrap: wrap !important;
}
.view-header h2 {
  font-size: 14px !important;
  font-weight: 700 !important;
  white-space: nowrap;
  margin: 0 !important;
  padding: 0 !important;
  line-height: 1.2 !important;
}
.view-controls {
  flex-shrink: 0;
  flex-wrap: wrap;
  gap: 6px;
}
body.dark-mode .view-header {
  padding: 6px 14px !important;
}

/* Sort/filter table controls */
body.dark-mode #employees-search,
body.dark-mode #users-search {
  background: #1a1d2e !important;
  border-color: #2a2d3a !important;
  color: #e5e7eb !important;
}
th[style*="cursor: pointer"]:hover { background: #1a3a6a !important; }
body.dark-mode th[style*="cursor: pointer"]:hover { background: #1e2a3a !important; }

/* Dark mode weekend/holiday full column */
body.dark-mode td.weekend-col { background: #1c2235 !important; }
body.dark-mode td.holiday-col { background: #2a1840 !important; }

/* Dark mode row hover — more visible */
body.dark-mode .schedule-table tr:hover td { background: #1e3050 !important; }
body.dark-mode .schedule-table tr:hover td.name-col { background: #1e3050 !important; color: #7eb3ff !important; }
body.dark-mode .schedule-table tr:hover td.weekend-col { background: #243060 !important; }

/* Hamburger — always bright white */
.hamburger { color: #ffffff !important; font-weight: 700; }

/* ============================================================
   SHIFT COLOR CODES — single authoritative section
   All shift colors defined here, dark mode overrides here too
   ============================================================ */

/* ---- Light mode shift colors — deeper for readability ---- */
.code-staff    { background: #bfdbfe; color: #1e3a5f; }  /* Blue */
.code-ops-day  { background: #86efac; color: #14532d; }  /* Green */
.code-ops-mid  { background: #c4b5fd; color: #3b0764; }  /* Purple */
.code-ops-mid-e{ background: #c4b5fd; color: #3b0764; }  /* Same purple */
.code-emi      { background: #86efac; color: #14532d; }  /* Same green as day */
.code-swing    { background: #fb923c; color: #7c2d12; }  /* Orange */
.code-swing-e  { background: #fb923c; color: #7c2d12; }  /* Same orange */
.code-leave    { background: #fde047; color: #713f12; }  /* Yellow — distinct from orange */
.code-tdy      { background: #93c5fd; color: #1e3a8a; }  /* Deeper blue — distinct from staff */
.code-hd       { background: #f9a8d4; color: #831843; }  /* Pink */
.code-pd       { background: #a5b4fc; color: #312e81; font-style: italic; } /* Indigo */
.code-off      { background: transparent; color: transparent; }

/* ---- Dark mode shift colors ---- */
body.dark-mode .code-staff    { background: #0c2a4a; color: #93c5fd; }   /* Steel blue */
body.dark-mode .code-ops-day  { background: #064e3b; color: #6ee7b7; }   /* Dark teal green */
body.dark-mode .code-ops-mid  { background: #2e1065; color: #c4b5fd; }   /* Deep purple */
body.dark-mode .code-ops-mid-e{ background: #2e1065; color: #c4b5fd; }   /* Same as mid */
body.dark-mode .code-emi      { background: #064e3b; color: #6ee7b7; }   /* Same as day */
body.dark-mode .code-swing    { background: #431407; color: #fb923c; }   /* Dark orange */
body.dark-mode .code-swing-e  { background: #431407; color: #fb923c; }   /* Same as swing */
body.dark-mode .code-leave    { background: #3a2d00; color: #fcd34d; }   /* Dark amber */
body.dark-mode .code-tdy      { background: #1e3a5f; color: #93c5fd; }   /* Navy — distinct from staff */
body.dark-mode .code-hd       { background: #831843; color: #fbcfe8; }   /* Deep pink/rose */
body.dark-mode .code-pd       { background: #14532d; color: #86efac; }   /* Dark green */
body.dark-mode .code-off      { background: transparent; color: transparent; }

/* ---- Weekend/Holiday column headers ---- */
th.weekend-col { background: #2d4270 !important; color: #c8d3e8 !important; }
th.holiday-col { background: #5b3060 !important; color: #e9d5ff !important; }

/* ---- Weekend/Holiday empty cells ---- */
td.weekend-col { background: #d8e2f0; }
td.holiday-col { background: #ede0f5; }
body.dark-mode td.weekend-col { background: #1a1f2e; }
body.dark-mode td.holiday-col { background: #2a1520; }

/* ---- Filled cells on weekend/holiday — shift color ALWAYS wins ---- */
/* Using attribute selector trick: td with BOTH a shift class AND column class */
/* Light mode */
td.code-staff.weekend-col,   td.code-staff.holiday-col   { background: #bfdbfe !important; color: #1e3a5f !important; }
td.code-ops-day.weekend-col, td.code-ops-day.holiday-col { background: #86efac !important; color: #14532d !important; }
td.code-ops-mid.weekend-col, td.code-ops-mid.holiday-col { background: #c4b5fd !important; color: #3b0764 !important; }
td.code-ops-mid-e.weekend-col,td.code-ops-mid-e.holiday-col{ background: #c4b5fd !important; color: #3b0764 !important; }
td.code-emi.weekend-col,     td.code-emi.holiday-col     { background: #86efac !important; color: #14532d !important; }
td.code-swing.weekend-col,   td.code-swing.holiday-col   { background: #fb923c !important; color: #7c2d12 !important; }
td.code-swing-e.weekend-col, td.code-swing-e.holiday-col { background: #fb923c !important; color: #7c2d12 !important; }
td.code-leave.weekend-col,   td.code-leave.holiday-col   { background: #fde047 !important; color: #713f12 !important; }
td.code-tdy.weekend-col,     td.code-tdy.holiday-col     { background: #93c5fd !important; color: #1e3a8a !important; }
td.code-hd.weekend-col,      td.code-hd.holiday-col      { background: #f9a8d4 !important; color: #831843 !important; }
td.code-pd.weekend-col,      td.code-pd.holiday-col      { background: #a5b4fc !important; color: #312e81 !important; }

/* Dark mode */
body.dark-mode td.code-staff.weekend-col,    body.dark-mode td.code-staff.holiday-col    { background: #0c2a4a !important; color: #93c5fd !important; }
body.dark-mode td.code-ops-day.weekend-col,  body.dark-mode td.code-ops-day.holiday-col  { background: #064e3b !important; color: #6ee7b7 !important; }
body.dark-mode td.code-ops-mid.weekend-col,  body.dark-mode td.code-ops-mid.holiday-col  { background: #2e1065 !important; color: #c4b5fd !important; }
body.dark-mode td.code-ops-mid-e.weekend-col,body.dark-mode td.code-ops-mid-e.holiday-col{ background: #2e1065 !important; color: #c4b5fd !important; }
body.dark-mode td.code-emi.weekend-col,      body.dark-mode td.code-emi.holiday-col      { background: #064e3b !important; color: #6ee7b7 !important; }
body.dark-mode td.code-swing.weekend-col,    body.dark-mode td.code-swing.holiday-col    { background: #431407 !important; color: #fb923c !important; }
body.dark-mode td.code-swing-e.weekend-col,  body.dark-mode td.code-swing-e.holiday-col  { background: #431407 !important; color: #fb923c !important; }
body.dark-mode td.code-leave.weekend-col,    body.dark-mode td.code-leave.holiday-col    { background: #3a2d00 !important; color: #fcd34d !important; }
body.dark-mode td.code-tdy.weekend-col,      body.dark-mode td.code-tdy.holiday-col      { background: #1e3a5f !important; color: #93c5fd !important; }
body.dark-mode td.code-hd.weekend-col,       body.dark-mode td.code-hd.holiday-col       { background: #831843 !important; color: #fbcfe8 !important; }
body.dark-mode td.code-pd.weekend-col,       body.dark-mode td.code-pd.holiday-col       { background: #14532d !important; color: #86efac !important; }
body.dark-mode td.code-off.weekend-col  { background: #1a1f2e !important; }
body.dark-mode td.code-off.holiday-col  { background: #2a1520 !important; }

/* ---- Row hover using filter — preserves shift colors ---- */
.schedule-table tr:hover td { filter: brightness(1.2); }
.schedule-table tr:hover td.name-col { background: #b0caf0 !important; color: #1a3a6a !important; filter: none; }
body.dark-mode .schedule-table tr:hover td { filter: brightness(1.3); }
body.dark-mode .schedule-table tr:hover td.name-col { background: #1e3050 !important; color: #7eb3ff !important; filter: none; }

/* ---- Cell full coverage ---- */
.schedule-table td select,
.schedule-table td input {
  display: block !important;
  width: 100% !important;
  height: 32px !important;
}
.cell-select[data-code="0"],
body.dark-mode .cell-select[data-code="0"] { color: transparent; }
.cell-select[data-code="0"]:focus,
body.dark-mode .cell-select[data-code="0"]:focus { color: inherit; }

/* ---- Weekend/Holiday cell children fill fully ---- */
td.weekend-col > *,
td.holiday-col > * {
  display: block;
  width: 100% !important;
  height: 32px !important;
  background: transparent !important;
}

/* ---- Compact view headers ---- */
.view-header {
  padding: 6px 14px !important;
  min-height: 0 !important;
  max-height: 48px !important;
  flex-wrap: nowrap !important;
}
.view-header h2 {
  font-size: 14px !important;
  font-weight: 700 !important;
  white-space: nowrap;
  margin: 0 !important;
  line-height: 1.2 !important;
}
body.dark-mode .view-header { padding: 6px 14px !important; max-height: 48px !important; }

/* ---- Dark mode search inputs ---- */
body.dark-mode #employees-search,
body.dark-mode #users-search {
  background: #1a1d2e !important;
  border-color: #2a2d3a !important;
  color: #e5e7eb !important;
}

/* ---- Topnav ---- */
.user-badge { color: #ffffff; font-weight: 500; }
.hamburger { color: #ffffff !important; font-size: 22px; font-weight: 700; }
#prev-month, #next-month {
  background: var(--blue); color: var(--white);
  font-size: 20px; font-weight: 700; padding: 4px 12px;
  border-radius: var(--radius); border: none; cursor: pointer;
}
#prev-month:hover, #next-month:hover { background: var(--blue-light); }
body.dark-mode #prev-month,
body.dark-mode #next-month { background: #1e2a4a; color: #93c5fd; }

/* ---- Context menu ---- */
#ctx-menu { font-family: var(--font); }
body:not(.dark-mode) #ctx-menu {
  background: var(--white); border-color: var(--gray-200);
  box-shadow: 0 8px 24px rgba(0,0,0,.15);
}
body:not(.dark-mode) .ctx-item { color: var(--gray-700) !important; }
body:not(.dark-mode) .ctx-item:hover { background: var(--blue-bg) !important; }

/* ---- Sidebar attribution footer ---- */
.sidebar { display: flex; flex-direction: column; }
.nav-list { flex: 1; }
.sidebar > div:last-child { margin-top: auto; }

/* ---- Print styles ---- */
@media print {
  .topnav, .sidebar, .sidebar-overlay,
  .view-header, .legend, #modal-overlay { display: none !important; }
  .main-content { position: static !important; left: 0 !important; top: 0 !important; }
  .view.active { overflow: visible !important; height: auto !important; }
  .schedule-scroll { overflow: visible !important; height: auto !important; }
  body { background: #fff !important; }
  @page { size: landscape; margin: 8mm; }
}

/* ---- My Schedule view ---- */
.my-schedule-view { margin-bottom: 0; }
.my-schedule-row td.name-col { background: var(--blue-bg) !important; color: var(--blue) !important; font-weight: 700 !important; }
body.dark-mode .my-schedule-row td.name-col { background: #1a2a4a !important; color: #93c5fd !important; }

/* My Schedule button spacing */
#my-schedule-btn { margin-right: 8px; }
