/* Coverage Scheduler — shared design system.
   Class inventory (use these in module templates):
   layout: .page .page-head .grid .grid-2 .grid-3 .card .card-title .toolbar .filter-bar
   tables: .table .schedule-table .cal-table .nowrap .cell-clip .pager
   badges: .badge .badge-critical .badge-high .badge-medium .badge-low .badge-info .badge-ok
   status: .pill .pill-draft .pill-needs_review .pill-ready .pill-sent .pill-revised .pill-archived
   cells:  .gap-cell .pto-cell .conflict-cell .orient-cell .call-cell
   misc:   .btn .btn-primary .btn-danger .btn-sm .btn-block .tag .muted .flash .empty
*/
:root {
  --navy: #1e3a5f;
  --navy-dark: #16283f;
  --teal: #0f766e;
  --teal-light: #e6f2f1;
  --bg: #f4f6f9;
  --card: #ffffff;
  --line: #dde3ea;
  --text: #23303f;
  --muted: #6b7a8c;
  --critical: #c0392b;
  --critical-bg: #fdecea;
  --high: #d97706;
  --high-bg: #fef3e2;
  --medium: #b7791f;
  --medium-bg: #fdf6e3;
  --low: #64748b;
  --low-bg: #eef2f6;
  --ok: #15803d;
  --ok-bg: #e8f5ec;
  --info: #1d4ed8;
  --info-bg: #e8eefc;
  --radius: 8px;
}
* { box-sizing: border-box; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 14px/1.45 -apple-system, "Segoe UI", Helvetica, Arial, sans-serif;
}
h1 { font-size: 22px; margin: 0 0 4px; color: var(--navy); }
h2 { font-size: 17px; margin: 18px 0 8px; color: var(--navy); }
h3 { font-size: 15px; margin: 12px 0 6px; color: var(--navy); }
a { color: var(--teal); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------- top nav ---------- */
.topnav {
  display: flex; align-items: center; gap: 18px;
  background: var(--navy); color: #fff; padding: 0 18px; height: 52px;
  position: sticky; top: 0; z-index: 50;
}
.topnav .brand { color: #fff; font-weight: 700; font-size: 16px; white-space: nowrap; }
.topnav .brand:hover { text-decoration: none; }
.nav-drawer { display: flex; align-items: center; gap: 18px; flex: 1; min-width: 0; }
.nav-links { display: flex; align-items: center; gap: 4px; flex: 1; flex-wrap: wrap; }
.nav-links .nav-item, .nav-links summary {
  color: #dbe4ee; padding: 6px 10px; border-radius: 6px; cursor: pointer;
  list-style: none; user-select: none; white-space: nowrap;
}
.nav-links .nav-item:hover, .nav-links summary:hover { background: var(--navy-dark); color: #fff; text-decoration: none; }
details.dd { position: relative; }
details.dd summary::-webkit-details-marker { display: none; }
.dd-menu {
  position: absolute; top: 34px; left: 0; background: #fff; min-width: 190px;
  border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: 0 8px 24px rgba(20,32,50,.18); padding: 6px; z-index: 100;
}
.dd-menu a { display: block; padding: 7px 10px; color: var(--text); border-radius: 6px; }
.dd-menu a:hover { background: var(--teal-light); text-decoration: none; }
.nav-user { display: flex; align-items: center; gap: 10px; color: #dbe4ee; white-space: nowrap; }
.nav-user a { color: #9fc1d8; }
.role-chip {
  background: var(--teal); color: #fff; border-radius: 99px;
  padding: 2px 9px; font-size: 11px; text-transform: uppercase; letter-spacing: .04em;
}

/* ---------- page / cards ---------- */
.page { max-width: 1280px; margin: 0 auto; padding: 20px 22px 60px; }
.page-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.page-head .sub { color: var(--muted); }
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px; margin-bottom: 16px;
}
.card-title { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.card-title h2, .card-title h3 { margin: 0; }
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: 1fr 1fr; }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
@media (max-width: 900px) { .grid-2, .grid-3 { grid-template-columns: 1fr; } }

/* ---------- toolbar & forms ---------- */
.toolbar, .filter-bar { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; }
label { display: flex; flex-direction: column; gap: 3px; font-weight: 600; font-size: 12.5px; color: var(--navy); }
label.inline { flex-direction: row; align-items: center; gap: 6px; font-weight: 500; }
input[type=text], input[type=email], input[type=password], input[type=date],
input[type=time], input[type=number], select, textarea {
  font: inherit; padding: 7px 9px; border: 1px solid var(--line); border-radius: 6px;
  background: #fff; min-width: 120px;
}
textarea { min-width: 260px; }
input:focus, select:focus, textarea:focus { outline: 2px solid rgba(15,118,110,.35); border-color: var(--teal); }
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; }
.form-actions { margin-top: 14px; display: flex; gap: 8px; }
.checks { display: flex; flex-direction: column; gap: 4px; font-weight: 500; }

.btn {
  display: inline-block; font: inherit; font-weight: 600; cursor: pointer;
  background: #fff; color: var(--navy); border: 1px solid var(--line);
  padding: 7px 14px; border-radius: 6px;
}
.btn-block {
  width: 100%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}
.btn:hover { background: var(--low-bg); text-decoration: none; }
.btn-primary { background: var(--teal); border-color: var(--teal); color: #fff; }
.btn-primary:hover { background: #0c5f59; }
.btn-danger { background: var(--critical); border-color: var(--critical); color: #fff; }
.btn-danger:hover { background: #992d22; }
.btn-sm { padding: 3px 9px; font-size: 12px; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.btn-spinner {
  display: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, .35);
  border-top-color: #fff;
  animation: btn-spin 0.8s linear infinite;
}
.btn.is-loading .btn-spinner { display: inline-block; }
.btn.is-loading .btn-label { opacity: .95; }
@keyframes btn-spin {
  to { transform: rotate(360deg); }
}

/* ---------- tables ---------- */
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { text-align: left; padding: 7px 9px; border-bottom: 1px solid var(--line); vertical-align: top; }
.table thead th {
  background: var(--low-bg); color: var(--navy); font-size: 12px;
  text-transform: uppercase; letter-spacing: .03em; position: sticky; top: 52px;
}
.table tbody tr:hover { background: #fafcff; }
.nowrap { white-space: nowrap; }
.cell-clip { max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pager { display: flex; gap: 12px; align-items: center; margin-top: 10px; }

/* schedule grid: facility/specialty rows x weekday columns */
.schedule-table { width: 100%; border-collapse: collapse; }
.schedule-table th, .schedule-table td {
  border: 1px solid var(--line); padding: 6px 8px; vertical-align: top; min-width: 96px;
}
.schedule-table thead th { background: var(--navy); color: #fff; font-size: 12.5px; }
.schedule-table .fac-col { background: var(--low-bg); font-weight: 700; color: var(--navy); min-width: 150px; }
.schedule-table .spec-col { background: #f8fafc; font-weight: 600; min-width: 120px; }
.schedule-table td.today-col { background: #fbfdf4; }
.asg { display: block; margin: 1px 0; }
.asg .src-manual { color: var(--info); }
.asg .src-exception { color: var(--high); }

/* monthly calendar */
.cal-table { width: 100%; border-collapse: collapse; table-layout: fixed; }
.cal-table th, .cal-table td { border: 1px solid var(--line); padding: 6px; vertical-align: top; height: 92px; }
.cal-table th { background: var(--navy); color: #fff; height: auto; }
.cal-table .cal-date { font-weight: 700; color: var(--navy); font-size: 12px; margin-bottom: 3px; }
.cal-table .other-month { background: #f4f6f9; color: var(--muted); }

/* semantic cells */
.gap-cell { background: var(--critical-bg); color: var(--critical); font-weight: 700; }
.pto-cell { background: var(--medium-bg); color: var(--medium); }
.conflict-cell { background: var(--high-bg); }
.orient-cell { background: var(--info-bg); color: var(--info); }
.call-cell { background: var(--teal-light); }

/* ---------- badges / pills / tags ---------- */
.badge {
  display: inline-block; padding: 2px 8px; border-radius: 99px;
  font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .03em;
}
.badge-critical { background: var(--critical-bg); color: var(--critical); }
.badge-high { background: var(--high-bg); color: var(--high); }
.badge-medium { background: var(--medium-bg); color: var(--medium); }
.badge-low { background: var(--low-bg); color: var(--low); }
.badge-info { background: var(--info-bg); color: var(--info); }
.badge-ok { background: var(--ok-bg); color: var(--ok); }

.pill { display: inline-block; padding: 3px 11px; border-radius: 99px; font-size: 12px; font-weight: 700; }
.pill-draft { background: var(--low-bg); color: var(--low); }
.pill-needs_review { background: var(--medium-bg); color: var(--medium); }
.pill-ready { background: var(--ok-bg); color: var(--ok); }
.pill-sent { background: var(--info-bg); color: var(--info); }
.pill-revised { background: var(--high-bg); color: var(--high); }
.pill-archived { background: var(--low-bg); color: var(--low); }

.tag {
  display: inline-block; background: var(--low-bg); color: var(--navy);
  border-radius: 5px; padding: 1px 7px; font-size: 12px; font-family: ui-monospace, Menlo, monospace;
}
.muted { color: var(--muted); }
.empty { color: var(--muted); text-align: center; padding: 22px; }

/* ---------- flash & alerts ---------- */
.flash { padding: 10px 14px; border-radius: var(--radius); margin-bottom: 12px; border: 1px solid; }
.flash-success, .flash-info { background: var(--ok-bg); border-color: #bfe3cc; color: var(--ok); }
.flash-warning { background: var(--medium-bg); border-color: #ecd9a8; color: var(--medium); }
.flash-danger, .flash-error { background: var(--critical-bg); border-color: #f2c4be; color: var(--critical); }

.alert-row { display: flex; gap: 10px; align-items: baseline; padding: 8px 4px; border-bottom: 1px solid var(--line); }
.alert-row:last-child { border-bottom: none; }

/* ---------- stat tiles (dashboard) ---------- */
.stat-tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; margin-bottom: 16px; }
.stat-tile { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.stat-tile .num { font-size: 28px; font-weight: 800; color: var(--navy); }
.stat-tile .lbl { color: var(--muted); font-size: 12.5px; text-transform: uppercase; letter-spacing: .04em; }
.stat-tile.tile-critical .num { color: var(--critical); }
.stat-tile.tile-high .num { color: var(--high); }
.stat-tile.tile-ok .num { color: var(--ok); }

/* ---------- login ---------- */
.login-wrap { display: flex; justify-content: center; padding-top: 9vh; }
.login-card { width: 360px; max-width: 100%; text-align: center; }
.login-card form { display: flex; flex-direction: column; gap: 12px; text-align: left; margin-top: 14px; }

/* ---------- hamburger toggle ---------- */
/* Hidden on desktop; shown as flex on mobile */
.nav-toggle {
  display: none;
  background: none; border: none; cursor: pointer;
  align-items: center; justify-content: center;
  flex-direction: column; gap: 5px;
  padding: 10px 8px; margin-left: auto; min-height: 48px; min-width: 44px;
}
.nav-toggle span {
  display: block; width: 22px; height: 2px; background: #fff;
  border-radius: 2px; transition: transform .28s ease, opacity .2s ease;
  pointer-events: none;
}

/* ---------- mobile responsive ---------- */
@media (max-width: 768px) {

  /* ====== NAVIGATION ====== */
  .topnav {
    display: flex;
    flex-wrap: nowrap;
    align-items: center;
    height: 52px;
    min-height: 52px;
    padding: 0 10px;
    position: sticky; top: 0; z-index: 100;
    gap: 0;
  }

  /* Brand takes all available space, toggle sits at the right */
  .topnav .brand {
    font-size: 15px;
    padding: 14px 0;
    flex: 1;          /* push toggle to the far right */
    white-space: nowrap;
  }

  /* Show the hamburger button */
  .nav-toggle {
    display: flex;
  }

  /* Nav links + user hidden by default — occupy full width below the top row */
  .nav-drawer {
    display: none;
    position: absolute;
    top: 52px;
    left: 10px;
    right: 10px;
    max-height: calc(100vh - 64px);
    overflow-y: auto;
    background: var(--navy-dark);
    border: 1px solid rgba(255,255,255,.12);
    border-radius: var(--radius);
    box-shadow: 0 18px 38px rgba(10,18,32,.28);
    z-index: 140;
  }

  .nav-open .nav-drawer { display: block; }

  /* Animated X on open */
  .nav-open .nav-toggle span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
  .nav-open .nav-toggle span:nth-child(2) { opacity: 0; transform: scaleX(0); }
  .nav-open .nav-toggle span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

  /* Nav links: vertical list */
  .nav-links {
    flex-direction: column;
    align-items: stretch;
    gap: 0;
    background: transparent;
    border-top: 0;
    padding: 6px 0 8px;
    width: 100%;
  }
  .nav-links .nav-item {
    display: block;
    padding: 13px 18px;
    font-size: 15px;
    border-radius: 0;
    color: #dbe4ee;
    white-space: normal;
  }
  .nav-links .nav-item:hover { background: rgba(255,255,255,.07); text-decoration: none; }

  /* Details / dropdown becomes an inline accordion */
  details.dd { position: static; }
  details.dd summary::-webkit-details-marker { display: none; }
  .nav-links summary {
    display: block;
    padding: 13px 18px;
    font-size: 15px;
    color: #dbe4ee;
    list-style: none;
    cursor: pointer;
  }
  .nav-links summary:hover { background: rgba(255,255,255,.07); }
  .dd-menu {
    position: static;
    background: rgba(0,0,0,.25);
    box-shadow: none; border: none; border-radius: 0;
    padding: 2px 0 6px 22px;
    min-width: 0;
  }
  .dd-menu a {
    display: block;
    padding: 10px 14px;
    color: #b0c4d8;
    border-radius: 0;
    font-size: 14px;
  }
  .dd-menu a:hover { background: rgba(255,255,255,.06); text-decoration: none; }

  /* User row at the bottom of the drawer */
  #nav-user {
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    padding: 10px 18px 14px;
    background: var(--navy-dark);
    border-top: 1px solid rgba(255,255,255,.08);
    font-size: 13px;
    color: #dbe4ee;
  }
  .nav-user { white-space: normal; }

  /* ====== PAGE LAYOUT ====== */
  .page { padding: 12px 10px 48px; }
  h1 { font-size: 18px; }
  h2 { font-size: 15px; margin: 12px 0 6px; }
  h3 { font-size: 13px; margin: 10px 0 5px; }
  .page-head { flex-direction: column; align-items: flex-start; gap: 8px; }
  .page-head .sub { font-size: 12px; }

  /* ====== CARDS ====== */
  .card { padding: 12px; margin-bottom: 12px; overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .mob-card-wrap { overflow-x: visible; }   /* card-list doesn't need h-scroll */
  .card-title { flex-direction: column; align-items: flex-start; gap: 6px; }

  /* ====== STAT TILES ====== */
  .stat-tiles { grid-template-columns: repeat(2, 1fr); gap: 8px; }
  .stat-tile { padding: 10px 12px; }
  .stat-tile .num { font-size: 22px; }
  .stat-tile .lbl { font-size: 11px; }

  /* ====== TABLES — scroll on mobile ====== */
  .table th, .table td { padding: 6px 7px; font-size: 13px; }
  .table thead th { font-size: 11px; position: static; }

  /* Schedule grid */
  .schedule-table th, .schedule-table td { padding: 5px 6px; font-size: 12px; min-width: 80px; }
  .schedule-table thead th { font-size: 11px; }
  .schedule-table .fac-col { min-width: 110px; }
  .schedule-table .spec-col { min-width: 90px; }

  /* Calendar table */
  .cal-table th, .cal-table td { padding: 4px; font-size: 11px; height: auto; min-height: 60px; }
  .cal-table .cal-date { font-size: 11px; }

  /* ====== MOBILE CARD-LIST (replaces wide tables on mobile) ====== */
  /* On mobile, rows that use .mob-card hide the <table> and show
     a stacked card for each data row instead. */
  .mob-card-wrap table { display: none; }
  .mob-card-wrap .mob-empty { display: block; }
  .mob-card-list { display: flex; flex-direction: column; gap: 10px; }
  .mob-card-item {
    background: #fff;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 12px 14px;
    display: flex;
    flex-direction: column;
    gap: 5px;
  }
  .mob-card-item .mc-title {
    font-weight: 700;
    font-size: 15px;
    color: var(--navy);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
  }
  .mob-card-item .mc-title a { color: var(--navy); }
  .mob-card-item .mc-row {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    color: var(--muted);
    flex-wrap: wrap;
  }
  .mob-card-item .mc-row strong { color: var(--text); font-weight: 600; }
  .mob-card-item .mc-actions {
    display: flex;
    gap: 8px;
    margin-top: 6px;
    flex-wrap: wrap;
  }
  .mob-card-item .mc-actions .btn,
  .mob-card-item .mc-actions button {
    flex: 1; text-align: center;
  }
  /* On desktop, hide the mobile card lists */

  /* ====== FILTER BARS & TOOLBARS ====== */
  .filter-bar, .toolbar { flex-direction: column; align-items: stretch; gap: 8px; }
  .filter-bar label, .toolbar label { width: 100%; }
  .filter-bar select, .toolbar select,
  .filter-bar input[type=date], .toolbar input[type=date],
  .filter-bar input[type=time], .toolbar input[type=time],
  .filter-bar input[type=text], .toolbar input[type=text],
  .filter-bar input[type=email], .toolbar input[type=email],
  .filter-bar input[type=month] { width: 100%; min-width: 0; }
  .filter-bar .btn, .toolbar .btn { width: 100%; text-align: center; }
  .filter-bar .checks, .toolbar .checks { width: 100%; }

  /* ====== FORMS ====== */
  .form-grid { grid-template-columns: 1fr; gap: 10px; }
  .form-actions { flex-wrap: wrap; }
  .form-actions .btn { flex: 1 1 auto; text-align: center; }
  textarea { min-width: 0; width: 100%; }
  input[type=text], input[type=email], input[type=password], input[type=date],
  input[type=time], input[type=number], select { min-width: 0; width: 100%; }

  /* ====== BUTTONS (touch targets) ====== */
  .btn { padding: 10px 14px; min-height: 44px; font-size: 14px; }
  .btn-sm { padding: 8px 12px; font-size: 13px; min-height: 40px; }

  /* ====== MISC ====== */
  .alert-row { flex-wrap: wrap; gap: 6px; font-size: 13px; padding: 8px 2px; }
  .login-wrap { padding-top: 5vh; padding-left: 16px; padding-right: 16px; }
  .login-card { width: 100%; }
  .pager { flex-wrap: wrap; justify-content: center; }
  .cell-clip { max-width: 140px; }
  .nowrap { white-space: normal; }
  .asg { font-size: 12px; }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .toolbar form { width: 100%; }
  .toolbar form.toolbar { flex-direction: column; align-items: stretch; }
}

/* Desktop: hide the mob-card elements */
.mob-card-list { display: none; }
.mob-card-wrap .mob-empty { display: none; }

/* Extra small devices (< 400px) */
@media (max-width: 400px) {
  .stat-tiles { grid-template-columns: 1fr; }
  .topnav .brand { font-size: 13px; }
}

/* ---------- print ---------- */
@media print {
  .no-print, .topnav, .flash, .toolbar, .filter-bar, .btn { display: none !important; }
  body { background: #fff; }
  .page { max-width: none; padding: 0; }
  .card { border: none; padding: 0; }
  .table thead th { position: static; }
}
