/* ===========================
   NPS Design Tokens
   =========================== */
:root {
  --nps-navy: #003366;      /* Primary brand – headers, navbar, footer */
  --nps-teal: #2C7C7D;      /* Primary accent – buttons, highlights */
  --nps-slate: #6E7B8B;     /* Neutral text/borders */
  --nps-white: #FFFFFF;     /* Contrast text/background */
  --nps-cool-50: #F5F7FA;   /* Light card/dashboard background */

  /* Optional accents */
  --nps-sky: #71A5D6;       /* Hovers / success-emphasis */
  --nps-coral: #E67C73;     /* Errors / alerts (sparingly) */
  --nps-yellow: #F8E9A1;    /* PTO / schedule highlights */

  /* Bootstrap theme overrides */
  --bs-primary: var(--nps-teal);
  --bs-secondary: var(--nps-slate);
  --bs-info: var(--nps-sky);
  --bs-danger: var(--nps-coral);
  --bs-warning: var(--nps-yellow);
  --bs-body-bg: var(--nps-cool-50);
  --bs-body-color: #1b2a3a;
}

/* ===========================
   Base layout
   =========================== */
html, body { height: 100%; }
body { background-color: var(--nps-cool-50); }

/* Keep Bootstrap container feel; don't force a white box for everything */
main.container { max-width: 1200px; }

/* Generic card polish */
.card {
  border: 1px solid rgba(0,0,0,0.06);
  border-radius: 0.75rem;
  background-color: var(--nps-white);
}

/* ===========================
   Navbar
   =========================== */
.nps-navbar {
  background: var(--nps-navy) !important;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}
.nps-navbar .nav-link { color: rgba(255,255,255,0.9) !important; }
.nps-navbar .nav-link:hover { color: var(--nps-sky) !important; }

.brand-logo {
  max-height: 28px; width: auto; display: block;
}
@media (min-width: 992px) { .brand-logo { max-height: 32px; } }

.brand-text { font-weight: 600; letter-spacing: .2px; }

.navbar-brand {
  display: flex; align-items: center; gap: .25rem; color: #fff;
}
/* SPEC-260: Doubled logo size (28px → 56px) */
.navbar-brand img.nps-logo {
  max-height: 56px; width: auto; display: block; filter: none;
}
/* Optional spacing from logo to left nav */
.navbar-nav.me-auto { margin-left: .25rem; }

/* ===========================
   Buttons
   =========================== */
.btn-primary { background-color: var(--nps-teal); border-color: var(--nps-teal); }
.btn-primary:hover, .btn-primary:focus { background-color: var(--nps-sky); border-color: var(--nps-sky); }
.btn-secondary { background-color: var(--nps-slate); border-color: var(--nps-slate); }

/* Optional explicit teal button */
.btn-nps {
  background-color: var(--nps-teal);
  border-color: var(--nps-teal);
  color: var(--nps-white);
}
.btn-nps:hover { background-color: var(--nps-sky); border-color: var(--nps-sky); }

/* ===========================
   Alerts to match palette
   =========================== */
.alert-info { background: #e6f1fb; border-color: #cfe4f8; color: #0d2b4a; }
.alert-danger { background: #fde9e7; border-color: #f7c8c2; color: #6b1f1a; }

/* ===========================
   Tables & DataTables
   =========================== */
.table thead th {
  background: #eaf0f6; color: #233447; border-bottom: 2px solid #d6e1ec;
}
.table-hover tbody tr:hover { background-color: #f1f6fb; }

/* DataTables search box styling */
#userTable_filter {
  float: none !important;
  text-align: left !important;
  padding: 10px;
  width: 100%;
}
#userTable_filter label { display: flex; gap: 8px; align-items: center; }
#userTable_filter input {
  width: 220px; padding: 6px 10px; border: 1px solid #cfd8e3; border-radius: 6px;
}
table.dataTable tr.selected { background-color: #e4f3ff !important; }

/* Generic table polish if you use plain tables elsewhere */
table {
  background: var(--nps-white);
  border-collapse: collapse;
  border-radius: 8px;
  overflow: hidden;
}
th, td { padding: 12px; border-bottom: 1px solid #e6edf4; }

/* ===========================
   Status labels
   =========================== */
.status {
  font-weight: 600; padding: 6px 10px; border-radius: 8px;
  display: inline-block; min-width: 110px; text-align: center;
}
.status.staged    { background: #ffecb3; color: #8a6d3b; }
.status.approved  { background: #d1ecf1; color: #0c5460; }
.status.published { background: #c3e6cb; color: #155724; }

/* ===========================
   Page-specific headlines (optional)
   =========================== */
h1, h2, h3, h4, .fc .fc-toolbar-title { color: var(--nps-navy); }

/* ===========================
   Schedule pages & calendar
   =========================== */
/* SPEC-267: Calendar should fill container without clipping */
#calendar {
  min-height: 600px;
  width: 100%;
  max-width: 100%; /* Remove old 900px limit */
}

/* FullCalendar button theming */
.fc .fc-button-primary { background: var(--nps-teal); border-color: var(--nps-teal); }
.fc .fc-button-primary:hover { background: var(--nps-sky); border-color: var(--nps-sky); }

/* Optional event accents by class (use className when creating events) */
.fc-event.shift-pto    { background: var(--nps-yellow) !important; border-color: var(--nps-yellow) !important; color: #5b4a00 !important; }
.fc-event.shift-oncall { background: var(--nps-sky) !important;    border-color: var(--nps-sky) !important;    color: #063253 !important; }
.fc-event.shift-off    { background: #e9eef3 !important;            border-color: #e9eef3 !important;            color: #4f5b66 !important; }

/* SPEC-233: Special shift type styling */
.fc-event.shift--holiday {
  background: #FFE5B4 !important;  /* Peach/light orange for holiday */
  border-color: #FFA500 !important;
  color: #663300 !important;
  font-weight: 600;
}

.fc-event.shift--training {
  background: #E6E6FA !important;  /* Lavender for training */
  border-color: #9370DB !important;
  color: #4B0082 !important;
  font-style: italic;
}

.fc-event.shift--coverage {
  background: #B0E0E6 !important;  /* Powder blue for coverage */
  border-color: #4682B4 !important;
  color: #1C4966 !important;
  position: relative;
}

/* Coverage shifts get a special indicator */
.fc-event.shift--coverage::before {
  content: "↔";
  margin-right: 4px;
  font-weight: bold;
}

/* SPEC-254: CANCELED shift type styling */
.fc-event.shift-canceled-shift,
.fc-event.shift-canceled {
  background: #D3D3D3 !important;  /* Light grey */
  border-color: #A9A9A9 !important; /* Dark grey border */
  color: #4a4a4a !important;
  font-style: italic;
  text-decoration: line-through;
  opacity: 0.85;
}

/* ===========================
   Schedule Grid / AG Grid
   =========================== */
/* SPEC-288: Consolidated grid layout rules - primary rules are in section 1B below */
/* This section handles AG Grid-specific styling only, not layout */

.ag-cell-editor-list {
    max-height: 200px !important;  /* ✅ Set max height */
    overflow-y: auto !important;  /* ✅ Enable vertical scroll */
}


/* Weekend highlight (clean, consistent) */
#scheduleGrid .weekend-col-header { background: #f8f9fa; font-weight: 600; }
#scheduleGrid .weekend-col        { background: #fafafa; }

/* Keep pinned columns readable */
#scheduleGrid .ag-pinned-left-header,
#scheduleGrid .ag-pinned-left-cols-container {
  background: #fff;
  z-index: 3;
}

/* Prevent header/cell text from overflowing; show ellipses */
#scheduleGrid .ag-header-cell-text,
#scheduleGrid .ag-cell {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* AG Grid alpine theme variables */
.ag-theme-alpine {
  --ag-foreground-color: #1b2a3a;
  --ag-background-color: var(--nps-white);
  --ag-data-color: #1b2a3a;

  --ag-header-foreground-color: #233447;
  --ag-header-background-color: #eaf0f6;
  --ag-header-column-separator-color: #d6e1ec;

  --ag-borders: #e5eaf0;
  --ag-row-hover-color: #f1f6fb;
  --ag-selected-row-background-color: #e4f3ff;

  --ag-checkbox-checked-color: var(--nps-teal);
  --ag-checkbox-unchecked-color: var(--nps-slate);
  --ag-range-selection-border-color: var(--nps-teal);
}

/* AG Grid zoom - simple font size adjustment */
.ag-theme-alpine.zoom-lg {
  --ag-font-size: 14px;
  --ag-row-height: 36px;
  --ag-header-height: 56px;
}

.ag-theme-alpine.zoom-sm {
  --ag-font-size: 12px;
  --ag-row-height: 28px;
  --ag-header-height: 44px;
}


/* Safety: no wrapping in headers/cells */
.ag-theme-alpine .ag-header .ag-header-cell-text,
.ag-theme-alpine .ag-cell {
  white-space: nowrap;
  line-height: 1.2; /* pairs with row-height to prevent clipping */
  overflow: hidden;
  text-overflow: ellipsis;
}


/* Ensure resizer stays at the far right and narrow */
.ag-theme-alpine .ag-header .ag-header-cell-resize {
  right: 0;
  width: 6px;
}

/* ===========================
   Schedule Grid - Minimal Styling
   =========================== */

/* Let AG Grid handle alignment - only override what's necessary */
#scheduleGrid.ag-theme-alpine .ag-header-cell::after {
  display: none; /* Remove AG Grid's built-in separator to avoid double lines */
}

/* Fix 2: Tighten dropdown/select width in grid cells to remove excess padding */
/* Scoped select width for grid editors only */
#scheduleGrid .ag-cell-editor select,
#gridView .ag-cell-editor select,
#scheduleGrid .ag-select .ag-picker-field-wrapper,
#gridView .ag-select .ag-picker-field-wrapper {
  width: auto !important;
  max-width: 140px !important;
}

#scheduleGrid .ag-cell-editor select,
#gridView .ag-cell-editor select {
  padding-right: 6px !important;
  box-sizing: border-box !important;
  background-position: right 6px center !important;
}

/* Fix dropdown picker wrapper width */
.ag-theme-alpine .ag-picker-field-wrapper {
  max-width: 140px !important;
}

/* Fix dropdown list to fit content */
.ag-theme-alpine .ag-list,
.ag-theme-alpine .ag-select-list {
  min-width: auto !important;
  width: max-content !important;
}

/* Fix 3: FullCalendar column minimum widths and borders */
.fc .fc-col-header-cell,
.fc .fc-timeline-slot,
.fc .fc-daygrid-day {
  min-width: 110px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  border-right: 1px solid #d9d9d9 !important;
}

.fc .fc-col-header-cell {
  background: #fafafa;
  border-bottom: 2px solid #d0d0d0;
}

/* ===========================
   Forms
   =========================== */
form label { font-weight: 600; }
form input, form select {
  border: 1px solid #cfd8e3;
  border-radius: 6px;
}

/* ===========================
   Hover helpers
   =========================== */
tbody tr:hover { background-color: #f1f6fb !important; cursor: pointer; }
tbody tr.selected { background-color: #e4f3ff !important; color: #0f2437 !important; }

/* ===========================
   Print / PDF
   =========================== */
@media print {
  body { color: #1d2a3a; }
  h1,h2,h3,h4 { color: var(--nps-navy); }
  .table thead th {
    background: #eef3f8 !important;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }
}

/* ===========================
   1B: Allocations layout & spacing polish
   SPEC-288: Fixed grid scroll behavior - consolidated all layout rules here
   =========================== */

/* Defaults that work well with Bootstrap's navbar height */
:root {
  --navbar-h: 56px;       /* tweak if your navbar is taller */
  --nps-card-pad: 1rem;   /* consistent card padding */
}

/* Make the Shifts area fill the viewport without page jitter */
#scheduleAllocationView {
  height: calc(100vh - var(--navbar-h) - 2rem); /* -2rem for container margins */
  min-height: 640px;                            /* safe floor */
  position: relative;                           /* SPEC-288: Prevent card from floating */
}

/* Ensure the Shifts card itself is a column layout with internal scroll */
#scheduleAllocationView .card {
  height: 100%;
  display: flex;
  flex-direction: column;
  padding: var(--nps-card-pad);
  overflow: hidden;                             /* SPEC-288: Contain children within card */
}

/* Sticky toolbar helper: add this class to any control row you want sticky */
.sticky-toolbar,
.alloc-sticky-toolbar {
  position: sticky;
  top: 0;
  z-index: 10;
  background: linear-gradient(180deg, var(--nps-white) 75%, rgba(255,255,255,0));
  padding-bottom: .5rem;
  margin-bottom: .5rem;
  border-bottom: 1px solid rgba(0,0,0,.06);
}

/* Calendar/Grid regions share the available height; children handle scroll */
#gridView,
#calendarView {
  flex: 1 1 auto;
  min-height: 0;          /* critical to allow children to size */
}

/* SPEC-288: Grid wrapper provides the outer sizing constraint */
/* AG Grid with domLayout: "normal" manages its own internal scrolling */
#gridWrapper {
  position: relative;
  /* DO NOT set overflow: hidden here - AG Grid needs to show its scrollbars */
}

/* SPEC-288: AG Grid container - inherits 100% from wrapper */
/* AG Grid handles its own internal scrolling with domLayout: "normal" */
/* The grid body scrolls vertically while header remains fixed (built into AG Grid) */
#scheduleGrid {
  width: 100%;
  height: 100%;
}

/* Calendar container sizing */
#calendar {
  height: 100%;
  min-height: 0;
  overflow: auto;
}

/* AG Grid headers are already sticky by default with domLayout: "normal" */
/* Only need to ensure proper z-index for pinned columns */
#scheduleGrid .ag-pinned-left-header {
  z-index: 3;
}

/* Style for ON Count summary row appended at end of data */
#scheduleGrid .on-count-row .ag-cell {
  font-weight: 600;
  background-color: #e8f4fd;
  border-top: 2px solid #3498db;
}

/* Weekend shading (harmonized) */
#scheduleGrid .weekend-col        { background-color: rgba(0,0,0,.03); }
#scheduleGrid .weekend-col-header { background-color: rgba(0,0,0,.06); font-weight: 600; }

/* SPEC-249: Grid ON/OFF coloring */
#scheduleGrid.ag-theme-alpine .shift-cell-off {
  background-color: #f3f3f3; /* muted light gray */
  color: #333;
}

#scheduleGrid.ag-theme-alpine .shift-cell-on {
  background-color: #e7f4ff; /* light blue */
  color: #111;
}

/* SPEC-267: Improved grid header alignment to prevent overlap */
#scheduleGrid .ag-header-cell {
  min-width: 110px;
  box-sizing: border-box;
}

/* Ensure header text doesn't clip or overflow */
#scheduleGrid .ag-header-cell-text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Fix potential header/body column width mismatch */

/* SPEC-274: Enable horizontal scroll when content exceeds container */
#scheduleGrid .ag-root-wrapper {
  /* Let AG Grid manage its internal scroll; avoid wrapping scroll containers */
  width: 100%;
}

/* SPEC-274: Ensure horizontal scrollbar is always visible when needed */
#scheduleGrid .ag-body-horizontal-scroll {
  display: block !important;
  min-height: 15px;
}

/* SPEC-274/288: Grid wrapper handles horizontal scroll, contained by flex parent */
#gridWrapper {
  width: 100%;
  flex: 1 1 auto;
  min-height: 0;
  /* Let AG Grid manage scrollbars; prevent double scroll containers */
  padding-bottom: 12px; /* small intentional gap below last row */
}

@media (min-width: 1280px) {
  #scheduleGrid .ag-header-cell {
    min-width: 120px;
  }
}

/* Consistent paddings & spacing in cards */
.card > :is(h1,h2,h3,.card-title) { margin-top: .25rem; margin-bottom: .75rem; }
.card .btn + .btn { margin-left: .5rem; }

/* Avoid layout jitter at ~1280px: ellipsize long cell/header text; prefer horizontal scroll */
#scheduleGrid .ag-header-cell-text,
#scheduleGrid .ag-cell {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
/* The scroller inside AG Grid */
/* Let AG Grid control viewport scrolling; avoid forcing overflow here */
#scheduleGrid .ag-center-cols-viewport {
}

/* ===========================
   Validation Panel (Fixed Overlay)
   =========================== */
.validation-panel {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  max-height: 38vh;
  transform: translateY(110%);
  transition: transform 0.2s ease;
  z-index: 1040;
  background: #fff;
  border-top: 1px solid #e5e7eb;
  box-shadow: 0 -6px 24px rgba(0, 0, 0, 0.12);
  overflow: auto;
}

.validation-panel.is-open {
  transform: translateY(0);
}

.validation-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.5rem 0.75rem;
  border-bottom: 1px solid #eee;
  background: #f8f9fa;
}

.validation-body {
  padding: 0.75rem;
}

/* Page wrapper padding adjustment when panel is open */
.page-wrap {
  transition: padding-bottom 0.2s ease;
}

/* SPEC-288: Removed duplicate #gridWrapper - consolidated above */

/* ===========================
   Calendar: Manual vs Autogenerated Shifts
   =========================== */
/* Manual shifts have a distinct outline and label - stronger specificity to beat FC defaults */
.fc .shift--manual,
.fc-event.shift--manual {
  outline: 2px solid var(--nps-navy) !important;
  outline-offset: -1px;
  opacity: 0.95;
  font-weight: 600;
}

.fc .shift--manual .fc-event-title::after,
.fc-event.shift--manual .fc-event-title::after {
  content: " • manual";
  font-weight: 600;
  font-size: 0.85em;
  opacity: 0.8;
}

/* Legend for calendar/grid view */
.calendar-legend {
  display: flex;
  gap: 1.5rem;
  align-items: center;
  padding: 0.75rem 1rem;
  background: var(--nps-cool-50);
  border-radius: 6px;
  margin-bottom: 1rem;
  font-size: 0.9rem;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.legend__swatch {
  width: 16px;
  height: 16px;
  border-radius: 3px;
  display: inline-block;
  background: var(--nps-teal);
}

.legend__swatch--manual {
  border: 2px solid var(--nps-navy);
  background: var(--nps-sky);  /* Blue background to match manual shift visual prominence */
}

.legend__swatch--auto {
  background: var(--nps-teal);  /* Teal for autogenerated */
  border: 1px solid rgba(0,0,0,0.1);
}

/* SPEC-249: Legend swatches for ON/OFF shifts in grid view */
.legend-swatch-on {
  width: 16px;
  height: 16px;
  border-radius: 3px;
  display: inline-block;
  background-color: #e7f4ff; /* matches shift-cell-on */
  border: 1px solid rgba(0,0,0,0.1);
}

.legend-swatch-off {
  width: 16px;
  height: 16px;
  border-radius: 3px;
  display: inline-block;
  background-color: #f3f3f3; /* matches shift-cell-off */
  border: 1px solid rgba(0,0,0,0.1);
}

/* Calendar Filters (Calendar v1) */
.calendar-filters {
  background: var(--nps-cool-50);
  border-radius: 6px;
  padding: 1rem;
  margin-bottom: 1rem;
}

.calendar-filters .form-label {
  font-weight: 600;
  color: var(--nps-navy);
  margin-bottom: 0.25rem;
}

.calendar-filters .form-select {
  font-size: 0.875rem;
  border: 1px solid var(--nps-cool-200);
}

.calendar-filters .btn {
  width: 100%;
}

#calendarHideOffToggle.active {
  background-color: var(--nps-teal);
  border-color: var(--nps-teal);
  color: white;
}

/* Weekly Hours Ribbon (Calendar v1) */
.calendar-weekly-hours {
  background: var(--nps-cool-50);
  border-radius: 6px;
  padding: 1rem;
  margin-top: 1.5rem;
}

.calendar-weekly-hours h5 {
  margin-bottom: 0.75rem;
  color: var(--nps-navy);
  font-size: 1rem;
  font-weight: 600;
}

.calendar-weekly-hours table {
  margin-bottom: 0;
  background: white;
}

.calendar-weekly-hours th {
  background: var(--nps-cool-100);
  font-weight: 600;
  font-size: 0.875rem;
  padding: 0.5rem;
}

.calendar-weekly-hours td {
  padding: 0.4rem 0.5rem;
  font-size: 0.875rem;
}

/* ===========================
   Full-Width Layout with Collapsible Sidebar
   =========================== */
/* Remove Bootstrap container max-width to allow full viewport usage */
.container, .container-md, .container-lg, .container-xl, .container-fluid {
  max-width: 100% !important;
}

/* Sidebar collapse mechanics */
#layout.layout--collapsed #sidebar {
  display: none;
}

#layout.layout--collapsed #content {
  flex: 0 0 100%;
  max-width: 100%;
}

/* Smooth transitions */
#sidebar, #content {
  transition: all 0.3s ease;
}

/* ===========================
   SPEC-269: Mobile Web Hardening
   Breakpoints:
   - Mobile: max-width 767px
   - Tablet: 768px - 1024px
   - Desktop: 1025px+
   =========================== */

/* ----- Mobile (≤767px) ----- */
@media (max-width: 767px) {
  /* === Header/Navbar === */
  /* Ensure navbar doesn't overlap with page content */
  .nps-navbar {
    position: sticky;
    top: 0;
    z-index: 1030;
  }

  /* Shrink logo on mobile for more nav space */
  .navbar-brand img.nps-logo {
    max-height: 36px;
  }

  /* Improve nav link tap targets */
  .nps-navbar .nav-link {
    padding: 12px 16px !important;
    min-height: 44px;
    display: flex;
    align-items: center;
  }

  /* Mode toggle buttons - larger tap targets */
  .nps-navbar .btn-group-sm .btn {
    padding: 8px 12px;
    min-height: 36px;
    font-size: 12px;
  }

  /* Collapsed navbar menu - full width, better spacing */
  .navbar-collapse {
    background: var(--nps-navy);
    padding: 10px;
    margin: 0 -12px;
  }

  /* === Main content === */
  main.container {
    padding-left: 12px;
    padding-right: 12px;
    margin-top: 16px !important;
  }

  /* === Schedule Edit Page - Toggle Menu Fix === */
  /* Move Toggle Menu below navbar, not overlapping */
  #sidebar-toggle {
    position: relative !important;
    top: auto !important;
    right: auto !important;
    width: 100%;
    margin-bottom: 12px;
    padding: 12px 16px;
    min-height: 44px;
    font-size: 14px;
  }

  /* Stack sidebar and content vertically on mobile */
  #layout .row {
    flex-direction: column;
  }

  #layout #sidebar {
    order: 2;
    width: 100%;
    margin-top: 16px;
  }

  #layout #content {
    order: 1;
    width: 100%;
  }

  /* Sidebar card - full width, collapse by default on mobile */
  #sidebar .card {
    margin-bottom: 12px;
  }

  /* Sidebar buttons - full width with better tap targets */
  #sidebar .btn {
    width: 100%;
    padding: 12px 16px;
    min-height: 44px;
    margin-bottom: 8px;
    font-size: 14px;
  }

  /* === Buttons - Universal tap targets (44px minimum) === */
  .btn {
    min-height: 44px;
    padding: 10px 16px;
  }

  .btn-sm {
    min-height: 38px;
    padding: 8px 12px;
  }

  /* === Schedule Context Header === */
  .d-flex.justify-content-between.align-items-center {
    flex-direction: column;
    align-items: flex-start !important;
    gap: 12px;
  }

  /* Schedule title - readable on mobile */
  .h3, h3 {
    font-size: 1.25rem;
  }

  /* === Tables - Horizontal scroll on mobile === */
  .table-responsive {
    -webkit-overflow-scrolling: touch;
    overflow-x: auto;
  }

  /* Wrap all tables in scrollable container */
  table:not(.fc-scrollgrid) {
    min-width: 600px;
  }

  /* Ensure critical columns stay readable */
  table th,
  table td {
    white-space: nowrap;
    padding: 10px 12px;
    font-size: 13px;
  }

  /* === Cards === */
  .card {
    border-radius: 8px;
  }

  .card-body {
    padding: 12px;
  }

  /* === Forms === */
  .form-control,
  .form-select {
    min-height: 44px;
    font-size: 16px; /* Prevents iOS zoom on focus */
  }

  /* Stack form rows on mobile */
  .row > [class*="col-md-"] {
    margin-bottom: 12px;
  }

  /* === Alerts === */
  .alert {
    padding: 12px;
    font-size: 14px;
  }

  /* === Dashboard specific === */
  /* Dashboard cards - single column */
  .dashboard-card,
  .col-lg-6,
  .col-lg-4 {
    width: 100%;
    padding-left: 0;
    padding-right: 0;
    margin-bottom: 12px;
  }

  /* Next Shifts list - better touch targets */
  .list-group-item {
    padding: 14px 12px;
  }

  /* === Invites page === */
  /* Search box - full width on mobile */
  #teamSearch,
  .form-control.w-25 {
    width: 100% !important;
    margin-top: 8px;
  }

  /* Invite button - full width */
  .btn[data-bs-target="#newInviteModal"] {
    width: 100%;
    margin-top: 12px;
  }

  /* Avatar circles - keep visible but compact */
  .avatar-circle {
    width: 32px;
    height: 32px;
    font-size: 12px;
  }

  /* === PTO pages === */
  /* Approve/Deny buttons - larger tap targets */
  .btn-success,
  .btn-danger {
    min-width: 80px;
    padding: 10px 14px;
  }

  /* === Modals === */
  .modal-dialog {
    margin: 8px;
    max-width: calc(100% - 16px);
  }

  .modal-body {
    padding: 16px;
  }

  /* === Typography for readability === */
  h1 { font-size: 1.5rem; }
  h2 { font-size: 1.25rem; }
  h4, h5 { font-size: 1rem; }

  body {
    font-size: 14px;
    line-height: 1.5;
  }

  /* Small text - ensure minimum readable size */
  small, .small, .text-muted.small {
    font-size: 12px;
  }

  /* === Login page === */
  .login-container,
  .card.login-card {
    margin: 16px;
    padding: 20px;
  }

  /* === Grid View === */
  /* Ensure AG Grid scrolls horizontally */
  #scheduleGrid {
    min-height: 300px;
  }

  /* Grid toolbar - stack controls */
  .alloc-sticky-toolbar,
  .sticky-toolbar {
    flex-wrap: wrap;
    gap: 8px;
  }

  .alloc-sticky-toolbar .btn,
  .sticky-toolbar .btn {
    flex: 1 1 auto;
    min-width: 120px;
  }

  /* === Calendar view === */
  #calendar {
    min-height: 400px;
  }

  .fc .fc-toolbar {
    flex-wrap: wrap;
    gap: 8px;
  }

  .fc .fc-toolbar-title {
    font-size: 1rem;
  }

  .fc .fc-button {
    padding: 8px 12px;
    min-height: 38px;
  }

  /* === Validation panel === */
  .validation-panel {
    max-height: 50vh;
  }
}

/* ----- Tablet (768px - 1024px) ----- */
@media (min-width: 768px) and (max-width: 1024px) {
  /* Adjust sidebar to be narrower */
  #sidebar {
    flex: 0 0 30%;
    max-width: 30%;
  }

  #content {
    flex: 0 0 70%;
    max-width: 70%;
  }

  /* Buttons - slightly larger tap targets */
  .btn {
    min-height: 40px;
  }

  /* Tables - allow horizontal scroll if needed */
  .table-responsive {
    overflow-x: auto;
  }

  /* Grid toolbar - wrap if needed */
  .alloc-sticky-toolbar {
    flex-wrap: wrap;
    gap: 8px;
  }
}

/* ----- Desktop enhancements (1025px+) ----- */
@media (min-width: 1025px) {
  /* Restore sidebar to full width */
  #sidebar {
    flex: 0 0 25%;
    max-width: 25%;
  }

  #content {
    flex: 0 0 75%;
    max-width: 75%;
  }
}

/* ===========================
   SPEC-270: PWA Install Prompt Styles
   =========================== */

/* Install Banner */
.pwa-install-banner {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: white;
  box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.15);
  padding: 12px 16px;
  z-index: 9999;
  transform: translateY(100%);
  transition: transform 0.3s ease;
}

.pwa-install-banner.visible {
  transform: translateY(0);
}

.pwa-install-content {
  display: flex;
  align-items: center;
  gap: 12px;
  max-width: 600px;
  margin: 0 auto;
}

.pwa-install-icon {
  width: 48px;
  height: 48px;
  border-radius: 10px;
  flex-shrink: 0;
}

.pwa-install-text {
  flex: 1;
  min-width: 0;
}

.pwa-install-text strong {
  display: block;
  font-size: 14px;
  color: var(--nps-navy, #1a365d);
}

.pwa-install-text span {
  font-size: 12px;
  color: #666;
}

.pwa-install-actions {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}

/* iOS Instructions Modal */
.pwa-ios-modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10000;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s, visibility 0.3s;
  padding: 20px;
}

.pwa-ios-modal.visible {
  opacity: 1;
  visibility: visible;
}

.pwa-ios-content {
  background: white;
  border-radius: 16px;
  padding: 24px;
  max-width: 320px;
  text-align: center;
  position: relative;
}

.pwa-ios-close {
  position: absolute;
  top: 12px;
  right: 12px;
  background: none;
  border: none;
  font-size: 24px;
  color: #999;
  cursor: pointer;
  line-height: 1;
}

.pwa-ios-icon {
  width: 64px;
  height: 64px;
  border-radius: 14px;
  margin-bottom: 16px;
}

.pwa-ios-content h3 {
  margin: 0 0 12px;
  color: var(--nps-navy, #1a365d);
}

.pwa-ios-content p {
  margin: 0 0 16px;
  color: #666;
}

.pwa-ios-content ol {
  text-align: left;
  padding-left: 20px;
  margin: 0 0 20px;
}

.pwa-ios-content ol li {
  margin-bottom: 8px;
  color: #333;
}

@media (max-width: 480px) {
  .pwa-install-content {
    flex-wrap: wrap;
  }

  .pwa-install-actions {
    width: 100%;
    justify-content: flex-end;
  }
}
