/*
  SCHEDULE — PAGE STYLES
  ───────────────────────
  Loaded after shared/site.css, which supplies the tokens, nav, footer, buttons and
  the modal shell. This file holds the Gantt chart, control bar, login panel, the
  sortie modal's contents and the "My Flights" widget. The page fills the viewport:
  shared nav on top, the schedule in the remaining height, shared footer underneath.
*/
:root {
  /* Gantt status colours (specific to the schedule) */
  --green: #00e676;  --grndim: rgba(0,230,118,0.09);
  --blue:  #7ba0e0;  --blued:  #6690d1;
  --red:   #ef4444;  --redd:   #dc2626;
  --slate: #64748b;  --slated: #475569;
  --muted: var(--ink-dim);   /* still referenced by inline styles in the page and its script */
  --cyan:  var(--accent);    /* ...and this one, in the My Flights time text the script builds */
  /* chart geometry */
  --header-h:  54px;
  --sidebar-w: 156px;
  --cell-w:    62px;
  --row-h:     58px;
}

*, *::before, *::after { margin: 0; padding: 0; }
html, body { height: 100%; overflow: hidden; }
body { font-family: var(--font-mono); height: 100dvh; }
.sched-main { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; }

/* ═══════════════════════════════════════
   TOP BAR — MFD Header
═══════════════════════════════════════ */
#topbar {
  height: var(--header-h);
  background: var(--bg-elevated);
  border-bottom: 1px solid rgba(139,127,214,0.22);
  box-shadow: 0 1px 0 rgba(0,0,0,0.5), 0 4px 20px rgba(0,0,0,0.4);
  display: flex; align-items: center; gap: 10px;
  padding: 0 14px; flex-shrink: 0; position: relative; z-index: 10;
}

/* Back button */

/* Logo / Ident */
.topbar-logo { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.topbar-logo svg { width: 20px; height: 20px; }
.topbar-title {
  font-family: var(--font-mono); font-size: 11px; font-weight: 600;
  letter-spacing: 0.14em; text-transform: uppercase;
}
.topbar-title .hi { color: var(--accent); }
.topbar-sub {
  font-size: 8px; color: var(--ink-dim); letter-spacing: 0.1em;
  text-transform: uppercase; display: none;
}

/* Divider */

/* Sun times */
#sun-times {
  display: flex; gap: 10px;
  font-size: 9px; color: var(--ink-muted); flex-shrink: 0;
}
.sun-item { display: flex; align-items: center; gap: 4px; }
.sun-item .ico { display: inline-flex; }
.sun-item .ico svg { width: 11px; height: 11px; }

.topbar-spacer { flex: 1; }

/* UTC Clock — G1000 clock display */
#utc-clock {
  font-size: 17px; font-weight: 600; letter-spacing: 0.05em;
  color: var(--accent);
  background: var(--accent-soft);
  border: 1px solid var(--accent-line);
  border-radius: 2px; padding: 4px 11px; flex-shrink: 0;
  /* Subtle inner shadow like a real display bezel */
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.04), inset 0 -1px 0 rgba(0,0,0,0.3);
}

/* ═══════════════════════════════════════
   STATS + CONTROL BAR
═══════════════════════════════════════ */
#controlbar {
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: stretch; gap: 0;
  flex-shrink: 0; overflow-x: auto; scrollbar-width: none;
  flex-wrap: wrap; position: relative; z-index: 9;
}
#controlbar::-webkit-scrollbar { display: none; }

/* Stats strip */
#stats-strip {
  display: flex; align-items: center; gap: 14px;
  padding: 7px 14px;
  border-right: 1px solid var(--border); flex-shrink: 0;
}
.stat-item { display: flex; align-items: center; gap: 4px; white-space: nowrap; }
.stat-lbl {
  font-size: 8px; color: var(--ink-dim); text-transform: uppercase; letter-spacing: 0.12em;
}
.stat-val { font-size: 14px; font-weight: 700; }
.stat-val.cyan { color: var(--accent); }
.stat-val.grn  { color: var(--green); }
.stat-val.red  { color: var(--red); }

/* Legend */
#legend-strip {
  display: flex; align-items: center; gap: 10px;
  padding: 7px 14px; border-right: 1px solid var(--border); flex-shrink: 0;
}
.leg-item {
  display: flex; align-items: center; gap: 5px;
  font-size: 8px; letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--ink-muted); white-space: nowrap;
}
.leg-dot { width: 9px; height: 9px; border-radius: 1px; flex-shrink: 0; }

/* Controls strip */
#controls-strip {
  display: flex; align-items: center; gap: 7px;
  padding: 7px 14px; flex: 1; min-width: 0; flex-wrap: wrap;
}

/* Session badge */
#session-badge {
  font-size: 9px; font-weight: 700; padding: 3px 9px;
  border-radius: 2px; border: 1px solid var(--border);
  letter-spacing: 0.06em; white-space: nowrap; flex-shrink: 0;
}
#session-badge.ok  { background: var(--grndim); color: var(--green); border-color: rgba(0,230,118,0.25); }
#session-badge.bad { background: rgba(239,68,68,0.07); color: #f87171; border-color: rgba(239,68,68,0.2); }

/* Date input: a shared .input, made compact for the control bar */
input[type="date"] { width: 138px; padding: 4px 9px; font-size: 10px; flex-shrink: 0; }
input[type="date"]::-webkit-calendar-picker-indicator {
  filter: invert(0.6) sepia(1) hue-rotate(170deg) saturate(3);
}

/* Auto-refresh toggle (shared .btn-ghost + .active) */

.btn-ghost.active { background: var(--grndim); color: var(--green); border-color: rgba(0,230,118,0.3); }

#status-txt { font-size: 9px; white-space: nowrap; min-width: 90px; }
#status-txt.ok { color: var(--green); }
#status-txt.err { color: var(--red); }
#status-txt.loading { color: var(--accent); }
.divider-line { width: 1px; height: 26px; background: var(--border); flex-shrink: 0; }

/* ═══════════════════════════════════════
   MY FLIGHTS WIDGET
═══════════════════════════════════════ */
#my-flights-widget {
  position: fixed; bottom: calc(var(--footer-height) + 14px); right: 14px; z-index: 50;
  width: 275px; max-width: calc(100vw - 22px);
}
.mfw-toggle {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  background: var(--surface);
  border: 1px solid var(--accent-line); border-radius: 2px;
  padding: 9px 13px; cursor: pointer; user-select: none;
  box-shadow: 0 8px 28px rgba(0,0,0,0.6);
  transition: border-color 0.2s, box-shadow 0.2s;
}
.mfw-toggle:hover { border-color: var(--accent-line-strong); box-shadow: 0 8px 28px rgba(0,0,0,0.7), 0 0 18px var(--accent-soft); }
.mfw-left { display: flex; align-items: center; gap: 7px; }
.mfw-icon {
  width: 26px; height: 26px; background: var(--accent-soft);
  border: 1px solid var(--accent-line); border-radius: 2px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; color: var(--accent);
}
.mfw-icon svg { width: 14px; height: 14px; }
.mfw-label { font-size: 9px; font-weight: 700; letter-spacing: 0.10em; text-transform: uppercase; color: var(--accent); }
.mfw-sub { font-size: 8px; color: var(--ink-muted); margin-top: 1px; }
.mfw-badge { font-size: 9px; font-weight: 700; padding: 2px 7px; border-radius: 2px; flex-shrink: 0; }
.mfw-badge.yes { background: var(--grndim); color: var(--green); border: 1px solid rgba(0,230,118,0.25); }
.mfw-badge.no  { background: rgba(93,122,140,0.1); color: var(--ink-muted); border: 1px solid rgba(93,122,140,0.2); }
.mfw-badge.checking { background: var(--accent-soft); color: var(--accent); border: 1px solid var(--accent-line); animation: pulse-badge 1.5s infinite; }
@keyframes pulse-badge { 0%,100%{opacity:1} 50%{opacity:0.45} }
.mfw-chevron { color: var(--ink-dim); font-size: 11px; transition: transform 0.25s; }
.mfw-chevron.open { transform: rotate(180deg); }

.mfw-panel {
  background: var(--bg-elevated);
  border: 1px solid var(--accent-line); border-top: none; border-radius: 0 0 2px 2px;
  overflow: hidden; max-height: 0; transition: max-height 0.3s ease;
}
.mfw-panel.open { max-height: 380px; overflow-y: auto; }
.mfw-day { padding: 9px 13px; border-bottom: 1px solid var(--border); }
.mfw-day:last-child { border-bottom: none; }
.mfw-day-header { font-size: 8px; font-weight: 700; letter-spacing: 0.12em; text-transform: uppercase; color: var(--ink-dim); margin-bottom: 5px; }
.mfw-flight-row {
  display: flex; align-items: center; gap: 7px; margin-bottom: 3px;
  padding: 5px 7px; background: rgba(139,127,214,0.04);
  border: 1px solid var(--border); border-radius: 2px; cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}
.mfw-flight-row:hover { background: rgba(139,127,214,0.08); border-color: var(--accent-line); }
.mfw-status-dot { width: 6px; height: 6px; border-radius: 50%; flex-shrink: 0; }
.mfw-time { font-size: 9px; font-weight: 700; color: var(--accent); white-space: nowrap; }
.mfw-mission { font-size: 9px; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex: 1; }
.mfw-ac { font-size: 8px; color: var(--ink-muted); white-space: nowrap; }
.mfw-no-flights { padding: 9px 13px; font-size: 10px; color: var(--ink-dim); text-align: center; }

/* ═══════════════════════════════════════
   SCHEDULE AREA
═══════════════════════════════════════ */
#schedule-outer { flex: 1; overflow: hidden; position: relative; display: flex; flex-direction: column; }
#schedule-scroll { flex: 1; overflow: auto; position: relative; }

/* Empty state — a shared .notice, centred in the chart area */
#empty-state {
  display: flex; flex-direction: column; align-items: center; gap: 10px;
  max-width: 420px; margin: var(--space-8) auto; padding: var(--space-5);
  text-align: center; border-left-width: 1px; border-left-color: var(--border-strong);
}
.empty-icon svg { width: 36px; height: 36px; color: var(--ink-dim); }
.empty-title { font-size: 12px; font-weight: 700; letter-spacing: 0.14em; text-transform: uppercase; color: var(--ink-muted); }
.empty-hint { font-size: 11px; color: var(--ink-dim); max-width: 300px; line-height: 1.65; }
.empty-hint b { color: var(--accent); font-weight: 600; }

/* ── TABLE ── */
#schedule-table { border-collapse: collapse; table-layout: fixed; background: transparent; min-width: max-content; }

/* Header */
#schedule-table thead th {
  background: var(--bg-elevated);
  border-right: 1px solid rgba(139,127,214,0.07);
  border-bottom: 1px solid var(--accent-line);
  color: var(--ink-muted); font-size: 9px; font-weight: 600;
  text-align: center; padding: 6px 2px;
  position: sticky; top: 0; z-index: 20; white-space: nowrap; letter-spacing: 0.07em;
}
#schedule-table thead th.half {
  color: rgba(93,122,140,0.4); font-size: 8px; background: var(--bg);
}
th.ac-th {
  background: var(--bg) !important;
  width: var(--sidebar-w); min-width: var(--sidebar-w);
  position: sticky !important; left: 0; z-index: 30 !important;
  font-size: 8px; letter-spacing: 0.18em; text-transform: uppercase;
  color: var(--ink-dim); border-right: 1px solid var(--accent-line-strong) !important;
}

/* Body rows */
#schedule-table tbody tr:hover td { background: rgba(139,127,214,0.025) !important; }
#schedule-table tbody tr:hover td.ac-td { background: rgba(139,127,214,0.055) !important; }
#schedule-table tbody tr.gs-row td { background: rgba(139,92,246,0.035) !important; }
#schedule-table tbody tr.gs-row:hover td { background: rgba(139,92,246,0.07) !important; }

/* Section divider */
tr.sec-div td {
  background: var(--bg-elevated) !important;
  color: var(--ink-muted); font-size: 8px; font-weight: 700;
  letter-spacing: 0.2em; text-transform: uppercase;
  padding: 5px 14px;
  border-top: 1px solid var(--accent-line); border-bottom: 1px solid var(--border);
}

/* Sticky aircraft cell */
td.ac-td {
  background: var(--bg);
  position: sticky; left: 0; z-index: 10;
  width: var(--sidebar-w); min-width: var(--sidebar-w);
  padding: 5px 9px;
  border-right: 1px solid var(--accent-line-strong);
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
  box-shadow: 3px 0 10px rgba(0,0,0,0.45);
  transition: background 0.15s;
}
.ac-reg { font-size: 12px; font-weight: 700; color: var(--ink); letter-spacing: 0.02em; line-height: 1.2; }
.ac-type { font-size: 8px; color: var(--accent); letter-spacing: 0.07em; margin-top: 1px; }
.ac-num { font-size: 8px; color: var(--ink-muted); }
.gs-lbl { font-size: 11px; font-weight: 700; color: #a78bfa; letter-spacing: 0.02em; }

/* Slot cell */
td.slot-td {
  padding: 0; position: relative; height: var(--row-h);
  border-bottom: 1px solid var(--border); background: transparent;
}

/* ── FLIGHT BLOCKS ── */
.fb {
  position: absolute; border-radius: 2px;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  overflow: hidden; cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s, filter 0.15s;
  z-index: 5; border-width: 1px; border-style: solid;
}
.fb::before {
  content: ''; position: absolute; inset: 0;
  background: linear-gradient(180deg, rgba(255,255,255,0.14) 0%, transparent 55%);
  pointer-events: none;
}
/* Status indicator bar at left edge */
.fb::after {
  content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 2px;
  background: rgba(255,255,255,0.35);
}
.fb:hover { transform: translateY(-2px); z-index: 15; filter: brightness(1.14); box-shadow: 0 6px 20px rgba(0,0,0,0.5); }
.fb.completed { background: rgba(0,230,118,0.72);  border-color: rgba(0,180,90,0.8); color: #001a0a; }
.fb.flying    { background: rgba(123,160,224,0.82);  border-color: rgba(102,144,209,0.9); color: white; animation: pulse-fly 2s infinite; }
.fb.planned   { background: rgba(93,122,140,0.65);  border-color: rgba(71,100,120,0.8); color: white; }
.fb.cancelled { background: rgba(239,68,68,0.68);   border-color: rgba(200,38,38,0.8); color: white; opacity: 0.85; }
@keyframes pulse-fly { 0%,100%{box-shadow:0 0 0 0 rgba(123,160,224,0.45)} 50%{box-shadow:0 0 0 3px rgba(123,160,224,0)} }

.fb-student {
  font-size: 10px; font-weight: 800; white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis;
  width: 100%; text-align: center; padding: 0 4px;
  text-shadow: 0 1px 3px rgba(0,0,0,0.5); line-height: 1.3;
}
.fb-inst {
  font-size: 9px; font-weight: 600; opacity: 0.9;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  width: 100%; text-align: center; padding: 0 3px;
  text-shadow: 0 1px 2px rgba(0,0,0,0.4);
}
.fb-mission {
  font-size: 8px; opacity: 0.72;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  width: 100%; text-align: center; padding: 0 3px;
}

/* ── NOW LINE ── */
.now-line {
  position: absolute; top: 0; bottom: 0; width: 2px;
  background: var(--red); z-index: 12; pointer-events: none;
  box-shadow: 0 0 8px rgba(239,68,68,0.7);
}
.now-line::before {
  content: ''; position: absolute; top: 0; left: -4px;
  width: 10px; height: 10px;
  background: var(--red); border-radius: 50%;
  box-shadow: 0 0 6px rgba(239,68,68,0.8);
}

/* ═══════════════════════════════════════
   MODAL — Flight detail
═══════════════════════════════════════ */

#modal-header {
  padding: 15px 18px; display: flex; align-items: center; gap: 11px;
  border-bottom: 1px solid var(--border);
}
#modal-header.completed { background: linear-gradient(135deg, rgba(0,230,118,0.12), rgba(0,180,90,0.06)); border-bottom-color: rgba(0,230,118,0.2); }
#modal-header.flying    { background: linear-gradient(135deg, rgba(123,160,224,0.14), rgba(102,144,209,0.07)); border-bottom-color: rgba(123,160,224,0.2); }
#modal-header.planned   { background: linear-gradient(135deg, rgba(93,122,140,0.12), rgba(71,100,120,0.06)); border-bottom-color: rgba(93,122,140,0.2); }
#modal-header.cancelled { background: linear-gradient(135deg, rgba(239,68,68,0.12), rgba(200,38,38,0.06)); border-bottom-color: rgba(239,68,68,0.2); }

.modal-hicon {
  width: 38px; height: 38px; border-radius: 2px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; color: var(--ink);
  border: 1px solid rgba(255,255,255,0.1);
  background: rgba(255,255,255,0.06);
}
.modal-hicon svg { width: 18px; height: 18px; }
#modal-fid { font-family: var(--font-display); font-size: 18px; font-weight: 700; color: var(--ink); line-height: 1.1; }
#modal-fstatus { font-size: 8px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--ink-muted); margin-top: 2px; }
#modal-close {
  margin-left: auto;
  background: rgba(255,255,255,0.06); border: 1px solid rgba(255,255,255,0.09);
  color: var(--ink-muted); font-size: 15px; cursor: pointer;
  width: 28px; height: 28px; border-radius: 2px;
  display: flex; align-items: center; justify-content: center;
  transition: all 0.18s;
}
#modal-close:hover { background: rgba(255,255,255,0.11); color: var(--ink); }

#modal-body { padding: 16px 18px; }
.m-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 11px; margin-bottom: 13px; }
.m-field label { display: block; font-size: 8px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.14em; color: var(--ink-dim); margin-bottom: 3px; }
.m-field .val { font-size: 13px; font-weight: 600; color: var(--ink); }
.m-field.full { grid-column: 1/-1; }

.t-box {
  background: rgba(139,127,214,0.03); border: 1px solid var(--border);
  border-radius: 2px; padding: 11px 13px; margin-bottom: 9px;
}
.t-box-h {
  font-size: 8px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.12em;
  color: var(--ink-dim); margin-bottom: 9px;
  display: flex; justify-content: space-between; align-items: center;
}
.dur-badge {
  font-size: 8px; font-weight: 700; padding: 2px 7px; border-radius: 2px;
  background: var(--accent-soft); color: var(--accent); border: 1px solid var(--accent-line);
}
.dur-badge.actual { background: var(--grndim); color: var(--green); border-color: rgba(0,230,118,0.25); }

.t-row { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.t-col { display: flex; flex-direction: column; gap: 2px; }
.t-col.right { align-items: flex-end; }
.t-lbl { font-size: 8px; color: var(--ink-dim); letter-spacing: 0.1em; text-transform: uppercase; }
.t-time-utc { font-family: var(--font-display); font-size: 22px; font-weight: 700; color: var(--ink); line-height: 1; }
.t-time-local { font-size: 10px; color: var(--accent); opacity: 0.85; margin-top: 1px; }
.t-arrow { color: var(--ink-dim); font-size: 17px; }

.cancel-box {
  background: rgba(239,68,68,0.05);
  border: 1px solid rgba(239,68,68,0.2);
  border-radius: 2px; padding: 11px 13px; margin-top: 9px;
}
.cancel-box-h { font-size: 8px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.12em; color: var(--red); margin-bottom: 5px; }
.cancel-reason { font-size: 13px; font-weight: 600; color: #fca5a5; }
.cancel-remarks { font-size: 11px; color: #f87171; margin-top: 3px; }

#modal-footer {
  padding: 11px 18px; border-top: 1px solid var(--border);
  display: flex; justify-content: flex-end;
}

/* ═══════════════════════════════════════
   LOADING OVERLAY — G1000 init style
═══════════════════════════════════════ */
#loading-overlay {
  display: none; position: fixed; inset: 0;
  background: rgba(0,0,0,0.75);
  backdrop-filter: blur(5px); z-index: 200;
  align-items: center; justify-content: center;
  flex-direction: column; gap: 18px;
}
#loading-overlay.open { display: flex; }

/* G1000-style animated arc */
.spinner {
  position: relative; width: 44px; height: 44px;
}
.spinner::before {
  content: ''; position: absolute; inset: 0;
  border: 1.5px solid rgba(139,127,214,0.15);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.75s linear infinite;
}
.spinner::after {
  content: ''; position: absolute; inset: 6px;
  border: 1px solid rgba(139,127,214,0.08);
  border-right-color: rgba(139,127,214,0.4);
  border-radius: 50%;
  animation: spin 1.2s linear infinite reverse;
}
@keyframes spin { to{ transform:rotate(360deg); } }

#loading-txt {
  font-size: 9px; font-weight: 600; letter-spacing: 0.28em;
  text-transform: uppercase; color: var(--ink-muted);
}

/* ═══════════════════════════════════════
   MOBILE
═══════════════════════════════════════ */
@media (max-width: 640px) {
  :root { --header-h:46px; --sidebar-w:108px; --cell-w:50px; --row-h:52px; }
  #utc-clock { font-size: 13px; padding: 3px 8px; }
  #sun-times { display: none; }
  #stats-strip { gap: 9px; padding: 6px 10px; }
  .stat-val { font-size: 13px; }
  #legend-strip { display: none; }
  #controls-strip { padding: 6px 10px; gap: 5px; }
  
  input[type="date"] { width: 118px; font-size: 9px; }
  #my-flights-widget { width: 252px; bottom: calc(var(--footer-height) + 10px); right: 10px; }
  .ac-reg { font-size: 10px; }
  .ac-type { font-size: 7px; }
  .fb-student { font-size: 9px; }
  .fb-inst { font-size: 8px; }
  
  .m-grid { grid-template-columns: 1fr; }
  .t-time-utc { font-size: 18px; }
}
@media (min-width: 641px) {
  .topbar-sub { display: block; }
}
