/* =========================
   BASE / THEME
   ========================= */
:root{
  --bg: #0b0f14;
  --frame: #161c24;
  --panel: #1b222c;
  --panel2:#151b23;
  --edge: #2a3442;
  --edge2:#0f131a;

  --text: #d7dde7;
  --muted:#9aa6b6;

  --gold: #d2a24a;
  --amber:#d5852f;

  --p1: #d24b3a;
  --p2: #d58b2f;
  --p3: #c7b14a;
  --p4: #6fb0d6;

  --ok: #4bb36d;

  --shadow: 0 18px 40px rgba(0,0,0,.55);
  --inner: inset 0 1px 0 rgba(255,255,255,.05), inset 0 -1px 0 rgba(0,0,0,.55);
  --bevel: linear-gradient(180deg, rgba(255,255,255,.07), rgba(255,255,255,0) 45%, rgba(0,0,0,.25));
  --metal: linear-gradient(180deg, #232b36, #151b23 60%, #10151c);
  --metal2: linear-gradient(180deg, #202833, #121820);
  --warnGlow: 0 0 0 1px rgba(210,75,58,.30), 0 0 18px rgba(210,75,58,.25);

  --controlBg: #0f151e;
  --controlBg2:#0b1118;
  --controlEdge: rgba(255,255,255,.12);
  --controlEdgeHover: rgba(210,162,74,.28);
  --controlText: #e8eef9;
}

*{ box-sizing:border-box; }
html,body{ height:100%; }

body{
  margin:0;
  background: radial-gradient(1200px 700px at 20% 0%, #101826 0%, var(--bg) 55%) fixed;
  color: var(--text);
  font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Arial, "Noto Sans", "Helvetica Neue", sans-serif;
}

/* =========================
   FRAME + LAYOUT (FIXED HEIGHT CHAIN)
   ========================= */
.app{
  display:flex;
  align-items:stretch;
  justify-content:center;
  min-height:100vh;
}

.frame{
  width:min(1400px, 100%);
  margin: 18px;
  background: var(--metal);
  border: 1px solid var(--edge);
  box-shadow: var(--shadow);
  border-radius: 10px;
  overflow:hidden;

  /* IMPORTANT: constrain height so inner panels can scroll */
  height: calc(100vh - 36px); /* 18px top + 18px bottom margin */
  display:flex;
  flex-direction:column;
  min-height:0; /* critical for nested scrolling */
}

/* =========================
   TOPBAR
   ========================= */
.topbar{
  flex: 0 0 auto;
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:16px;
  padding: 14px 16px;
  background: linear-gradient(180deg, #232c38, #121821);
  border-bottom: 1px solid var(--edge);
  box-shadow: var(--inner);
}

.topbar__left{ display:flex; flex-direction:column; gap:2px; }
.topbar__title{
  font-weight: 900;
  letter-spacing: 1.2px;
  color: #f0c77a;
  font-size: 34px;
  text-transform:uppercase;
}
.topbar__subtitle{
  color: #b6c2d3;
  font-size: 14px;
  letter-spacing: .8px;
  text-transform:uppercase;
  opacity:.9;
}

.topbar__right{
  display:flex;
  gap:22px;
  align-items:flex-end;
}
.metric{
  display:grid;
  grid-template-columns: auto auto;
  gap: 6px 10px;
  align-items:end;
}
.metric__label{
  color: #b8c3d1;
  font-weight:700;
  font-size: 14px;
  letter-spacing:.5px;
}
.metric__value{
  font-weight:900;
  font-size: 20px;
  letter-spacing:.4px;
  color:#e8eef9;
}
.metric__value .unit{
  font-size: 14px;
  color:#d8b06d;
  font-weight:900;
  margin-left: 4px;
}

/* =========================
   GRID (FILL REMAINDER UNDER TOPBAR)
   ========================= */
.grid{
  flex: 1 1 auto;
  min-height: 0; /* critical */
  display:grid;
  grid-template-columns: 360px 1fr;
}

/* =========================
   PANELS
   ========================= */
.panel{
  background: var(--metal2);
  border-right: 1px solid var(--edge);
  box-shadow: var(--inner);
  min-height:0; /* critical */
}

.panel--main{
  border-right: none;
  display:flex;
  flex-direction:column;
  min-height:0; /* critical */
}

.panel__hdr{
  padding: 14px 14px 10px;
  border-bottom: 1px solid rgba(255,255,255,.06);
  flex: 0 0 auto;
}
.panel__hdr--minor{ padding-top: 10px; }
.panel__title{
  font-weight: 900;
  letter-spacing: .8px;
  text-transform:uppercase;
  color:#cdd7e6;
  font-size: 16px;
}
.panel__title--minor{ font-size: 14px; opacity:.85; }

.panel__sep{
  height: 12px;
  background: linear-gradient(180deg, rgba(0,0,0,.25), rgba(255,255,255,.03));
  border-top: 1px solid rgba(255,255,255,.05);
  border-bottom: 1px solid rgba(0,0,0,.35);
  flex: 0 0 auto;
}

.panel__footer{
  padding: 12px;
  margin-top:auto;
  border-top: 1px solid rgba(255,255,255,.06);
  flex: 0 0 auto;
}

/* =========================
   LEFT: MAKE PANEL A COLUMN + SCROLLABLE LIST
   ========================= */
.panel--left{
  display:flex;
  flex-direction:column;
  height:100%;
  min-height:0;     /* critical */
  overflow:hidden;  /* prevents panel from growing taller */
}

/* Active list scroll container */
.queueScroll{
  flex: 1 1 auto;
  min-height: 0;       /* critical */
  overflow-y: auto;
  padding-right: 6px;
}

/* Queue list */
.queue{
  padding: 8px 10px 12px;
  display:flex;
  flex-direction:column;
  gap:10px;
}

/* Recent list (optional) */
.recentScroll{
  flex: 0 0 auto;
  max-height: 220px;
  overflow-y: auto;
  min-height: 0;
  padding-right: 6px;
}

.recentEmpty{
  padding: 10px 12px 18px;
  color: var(--muted);
  font-style: italic;
}

/* Optional scrollbar styling */
.queueScroll::-webkit-scrollbar,
.recentScroll::-webkit-scrollbar{ width:8px; }
.queueScroll::-webkit-scrollbar-thumb,
.recentScroll::-webkit-scrollbar-thumb{ border-radius:8px; background: rgba(255,255,255,.12); }
.queueScroll::-webkit-scrollbar-track,
.recentScroll::-webkit-scrollbar-track{ background: rgba(0,0,0,.10); }

/* =========================
   QUEUE ITEMS
   ========================= */
.queueItem{
  width:100%;
  text-align:left;
  border: 1px solid rgba(255,255,255,.07);
  background: linear-gradient(180deg, rgba(255,255,255,.04), rgba(0,0,0,.18));
  box-shadow: inset 0 1px 0 rgba(255,255,255,.05);
  border-radius: 6px;
  padding: 10px 10px;
  cursor:pointer;
  color: var(--text);
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap: 12px;
  position:relative;
}
.queueItem:hover{ border-color: rgba(210,162,74,.25); }
.queueItem.is-selected{
  border-color: rgba(210,75,58,.55);
  box-shadow: var(--warnGlow);
  background: linear-gradient(180deg, rgba(210,75,58,.20), rgba(0,0,0,.20));
}

.queueItem__name{
  font-weight: 900;
  letter-spacing: .4px;
  text-transform:uppercase;
  font-size: 14px;
}
.queueItem__desc{
  margin-top: 2px;
  color: #c3cfde;
  font-size: 13px;
  opacity:.95;
}
.queueItem__meta{ display:flex; align-items:center; gap:10px; }

.badge{
  min-width: 30px;
  height: 26px;
  padding: 0 10px;
  display:flex;
  align-items:center;
  justify-content:center;
  border-radius: 5px;
  font-weight: 900;
  border: 1px solid rgba(255,255,255,.10);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.08);
}
.badge--p1{ background: rgba(210,75,58,.30) !important; border-color: rgba(210,75,58,.75) !important; color:#ffe0db !important; }
.badge--p2{ background: rgba(213,133,47,.28) !important; border-color: rgba(213,133,47,.75) !important; color:#ffe7cf !important; }
.badge--p3{ background: rgba(199,177,74,.24) !important; border-color: rgba(199,177,74,.75) !important; color:#fff4c9 !important; }
.badge--p4{ background: rgba(111,176,214,.18) !important; border-color: rgba(111,176,214,.55) !important; color:#d9f0ff !important; }
}
.speaker{
  width: 0; height:0;
  border-left: 14px solid rgba(213,139,47,.9);
  border-top: 10px solid transparent;
  border-bottom: 10px solid transparent;
  filter: drop-shadow(0 0 6px rgba(213,139,47,.35));
}

/* Blinking for NEW alarms */
.is-blink{ animation: blink 1s steps(2,end) infinite; }
@keyframes blink{ 50%{ filter: brightness(1.25); } }

/* =========================
   MAIN: ALARM BANNER
   ========================= */
.alarmBanner{
  margin: 14px 14px 0;
  background: linear-gradient(180deg, rgba(210,75,58,.35), rgba(0,0,0,.22));
  border: 1px solid rgba(210,75,58,.55);
  box-shadow: var(--warnGlow), inset 0 1px 0 rgba(255,255,255,.06);
  border-radius: 8px;
  display:flex;
  align-items:center;
  gap: 12px;
  padding: 12px 12px;
  flex: 0 0 auto;
}
.alarmBanner__icon{
  width: 28px; height: 28px;
  border-radius: 6px;
  display:flex;
  align-items:center;
  justify-content:center;
  font-weight: 1000;
  background: rgba(0,0,0,.28);
  border: 1px solid rgba(255,255,255,.10);
  color:#ffe1dd;
}
.alarmBanner__title{
  font-weight: 1000;
  letter-spacing: .7px;
  text-transform:uppercase;
  color:#ffd4ce;
}

/* =========================
   INSTRUCTIONS AREA
   ========================= */
.instructions{
  padding: 12px 18px 20px;
  overflow:auto;
  flex: 1 1 auto;
  min-height:0;
}
.section{
  padding: 10px 0 14px;
  border-bottom: 1px solid rgba(255,255,255,.06);
}
.section:last-child{ border-bottom:none; }
.section__title{
  color: #e1c07f;
  font-weight: 1000;
  letter-spacing:.3px;
  font-size: 22px;
  margin-bottom: 8px;
}
.section__time{
  font-size: 16px;
  color:#bfa06d;
  font-weight: 900;
  opacity:.9;
}
.steps{
  margin: 0;
  padding-left: 24px;
  display:flex;
  flex-direction:column;
  gap: 8px;
  font-size: 18px;
  line-height: 1.25;
}
.steps li{ color:#d7dde7; }
.muted{ color: var(--muted); font-size: 16px; }

.hl{ font-weight:1000; letter-spacing:.2px; }
.hl--warn{ color:#ffcf8b; }
.hl--crit{ color:#ffb1a7; text-shadow: 0 0 10px rgba(210,75,58,.25); }

.chip{
  display:inline-flex;
  align-items:center;
  padding: 2px 8px;
  border-radius: 999px;
  margin-left: 6px;
  font-size: 14px;
  font-weight: 900;
  color:#ffe6c9;
  border: 1px solid rgba(213,139,47,.45);
  background: rgba(213,139,47,.15);
}
.chip--crit{
  color:#ffd8d3;
  border-color: rgba(210,75,58,.55);
  background: rgba(210,75,58,.18);
}

/* =========================
   ACTION BAR (BOTTOM)
   ========================= */
.actionBar{
  display:flex;
  gap: 12px;
  justify-content:flex-end;
  align-items:center;
  padding: 12px 14px;
  border-top: 1px solid rgba(255,255,255,.06);
  background: linear-gradient(180deg, rgba(0,0,0,.18), rgba(255,255,255,.03));
  flex: 0 0 auto;
}

.btn{
  appearance:none;
  border: 1px solid rgba(255,255,255,.12);
  background: linear-gradient(180deg, rgba(255,255,255,.06), rgba(0,0,0,.20));
  color: #e8eef9;
  font-weight: 1000;
  letter-spacing:.4px;
  border-radius: 8px;
  padding: 12px 14px;
  cursor:pointer;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.08);
}
.btn:hover{ filter: brightness(1.1); }
.btn:active{ transform: translateY(1px); }

.btn--ack{
  background: linear-gradient(180deg, rgba(180,160,70,.25), rgba(0,0,0,.22));
  border-color: rgba(199,177,74,.55);
  color:#fff3c8;
}
.btn--done{
  background: linear-gradient(180deg, rgba(75,179,109,.22), rgba(0,0,0,.22));
  border-color: rgba(75,179,109,.55);
  color:#d9ffe6;
}

.btn--ghost{
  width:100%;
  background: transparent;
  border-color: rgba(255,255,255,.10);
  color:#cfd9e8;
}

/* =========================
   FORM CONTROLS (FIX: SELECT TEXT + OPTIONS)
   ========================= */
input, select, textarea, button{
  font: inherit;
}

select,
input[type="text"],
input[type="search"],
input[type="number"],
textarea{
  width: 100%;
  color: var(--controlText);
  background: linear-gradient(180deg, rgba(255,255,255,.06), rgba(0,0,0,.25));
  border: 1px solid var(--controlEdge);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.08);
  border-radius: 8px;
  padding: 10px 12px;
  outline: none;
}

select{
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  padding-right: 34px; /* room for arrow */
  background-image:
    linear-gradient(45deg, transparent 50%, rgba(232,238,249,.8) 50%),
    linear-gradient(135deg, rgba(232,238,249,.8) 50%, transparent 50%),
    linear-gradient(180deg, rgba(255,255,255,.06), rgba(0,0,0,.25));
  background-position:
    calc(100% - 18px) 55%,
    calc(100% - 12px) 55%,
    0 0;
  background-size:
    6px 6px,
    6px 6px,
    100% 100%;
  background-repeat: no-repeat;
}

/* This is the main fix for “text not appearing” in dropdown lists */
select option{
  color: #e8eef9;          /* visible text */
  background: #0f151e;     /* dark menu */
}

/* Some browsers highlight selected option with system colors; keep readable */
select option:checked{
  background: #1c2633;
  color: #ffffff;
}

select:focus,
input:focus,
textarea:focus{
  border-color: var(--controlEdgeHover);
  box-shadow: 0 0 0 3px rgba(210,162,74,.12), inset 0 1px 0 rgba(255,255,255,.08);
}

/* placeholder color */
input::placeholder,
textarea::placeholder{
  color: rgba(154,166,182,.75);
}

/* =========================
   RESPONSIVE
   ========================= */
@media (max-width: 980px){
  .frame{ height: calc(100vh - 36px); }
  .grid{ grid-template-columns: 1fr; }
  .panel{ border-right: none; }
}

/* =========================
   HARD SCROLL FIX (OVERRIDES)
   Put this at the VERY END of app.css
   ========================= */

/* Stop page scroll; scroll only inside panels */
html, body { height: 100% !important; }
body { overflow: hidden !important; }

/* Body has class="app" */
body.app{
  height: 100vh !important;
  min-height: 100vh !important;
  display: flex !important;
  align-items: stretch !important;
  justify-content: center !important;
}

/* Frame must be a fixed-height flex column */
.frame{
  height: calc(100vh - 36px) !important; /* margin 18px top+bottom */
  max-height: calc(100vh - 36px) !important;
  display: flex !important;
  flex-direction: column !important;
  min-height: 0 !important;
}

/* Grid must fill the remaining height under topbar */
.grid{
  flex: 1 1 auto !important;
  min-height: 0 !important;
  height: 100% !important;
}

/* Left panel must NOT grow; it must clip and let inner scroll */
.panel--left{
  height: 100% !important;
  min-height: 0 !important;
  display: flex !important;
  flex-direction: column !important;
  overflow: hidden !important;
}

/* This is the actual scroll container */
.queueScroll{
  flex: 1 1 auto !important;
  min-height: 0 !important;
  overflow-y: auto !important;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

/* Optional: keep recent list scrollable too */
.recentScroll{
  max-height: 220px !important;
  overflow-y: auto !important;
  min-height: 0 !important;
}

/* Selected item should not force RED */
.queueItem.is-selected{
  border-color: rgba(255,255,255,.14) !important;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.10) !important;
  background: linear-gradient(180deg, rgba(255,255,255,.06), rgba(0,0,0,.18)) !important;
}

/* High Priority box: show max ~5 items, scroll inside */
.panel__title--hot{
  color:#ffd4ce;
}

.hotScroll{
  flex: 0 0 auto;
  max-height: 340px;  /* ~5 items (adjust if your items taller/shorter) */
  overflow-y: auto;
  min-height: 0;
  padding: 8px 6px 8px 0;
}

.hotQueue{
  padding: 0 10px 4px;
  display:flex;
  flex-direction:column;
  gap:10px;
}

/* optional scrollbar styling */
.hotScroll::-webkit-scrollbar{ width:8px; }
.hotScroll::-webkit-scrollbar-thumb{ border-radius:8px; background: rgba(255,255,255,.12); }
.hotScroll::-webkit-scrollbar-track{ background: rgba(0,0,0,.10); }

/* =========================
   v2 ADDITIONS
   ========================= */

/* Field labels */
.fieldLabel {
  display: block;
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
  letter-spacing: .4px;
  margin-bottom: 4px;
  text-transform: uppercase;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: 6px;
  border: 1px solid var(--edge);
  background: var(--panel);
  color: var(--controlText);
  font-weight: 800;
  font-size: 12px;
  letter-spacing: .5px;
  cursor: pointer;
  text-decoration: none;
  transition: filter .15s;
}
.btn:hover { filter: brightness(1.15); }
.btn--sm   { padding: 5px 10px; font-size: 11px; }
.btn--ghost{ background: transparent; border-color: rgba(255,255,255,.12); }
.btn--warn { background: rgba(210,162,74,.15); border-color: var(--gold); color: var(--gold); }
.btn--ok   { background: rgba(75,179,109,.15); border-color: var(--ok);   color: var(--ok);  }
.btn--p1   { background: rgba(210,75,58,.15);  border-color: var(--p1);   color: var(--p1);  }

/* Input / textarea */
.input {
  background: var(--controlBg);
  border: 1px solid var(--controlEdge);
  border-radius: 6px;
  color: var(--controlText);
  padding: 7px 10px;
  font-size: 13px;
  width: 100%;
}
.input:focus { outline: none; border-color: var(--gold); }
.input.small { width: auto; max-width: 80px; padding: 4px 6px; font-size: 12px; }
.textarea {
  background: var(--controlBg);
  border: 1px solid var(--controlEdge);
  border-radius: 6px;
  color: var(--controlText);
  padding: 7px 10px;
  font-size: 13px;
  width: 100%;
  resize: vertical;
}
.textarea:focus { outline: none; border-color: var(--gold); }

/* Chips */
.chip {
  display: inline-block;
  padding: 2px 7px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .3px;
}
.chip--crit {
  background: rgba(210,75,58,.2);
  color: var(--p1);
  border: 1px solid rgba(210,75,58,.35);
}

/* Checkbox wrap */
.chkWrap {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
  letter-spacing: .3px;
}
.chkWrap input[type="checkbox"] {
  width: 14px;
  height: 14px;
  accent-color: var(--gold);
  cursor: pointer;
}

/* Mini button */
.miniBtn {
  padding: 3px 8px;
  border-radius: 4px;
  border: 1px solid var(--edge);
  background: var(--panel2);
  color: var(--muted);
  font-size: 10px;
  font-weight: 800;
  cursor: pointer;
  letter-spacing: .3px;
}
.miniBtn.danger {
  border-color: rgba(210,75,58,.4);
  color: var(--p1);
  background: rgba(210,75,58,.1);
}
.miniBtn:hover { filter: brightness(1.2); }

/* Scenario list items */
.scenarioItem {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  border-bottom: 1px solid rgba(255,255,255,.04);
  cursor: pointer;
  transition: background .12s;
}
.scenarioItem:hover    { background: rgba(255,255,255,.03); }
.scenarioItem.is-selected { background: rgba(210,162,74,.08); border-left: 2px solid var(--gold); }
.scenarioItem__title   { font-weight: 700; font-size: 13px; color: var(--text); }
.scenarioItem__sub     { font-size: 11px; color: var(--muted); margin-top: 2px; }
.pill {
  display: inline-block;
  background: rgba(255,255,255,.06);
  border-radius: 4px;
  padding: 1px 6px;
  font-size: 10px;
  font-weight: 700;
  color: var(--muted);
  margin-left: 4px;
}

/* Queue items */
.queue, .hotQueue { overflow-y: auto; }
.queueItem {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 10px 12px;
  border: none;
  border-bottom: 1px solid rgba(255,255,255,.04);
  background: transparent;
  color: var(--text);
  cursor: pointer;
  text-align: left;
  transition: background .12s;
}
.queueItem:hover       { background: rgba(255,255,255,.03); }
.queueItem.is-selected { background: rgba(210,162,74,.08); border-left: 2px solid var(--gold); }
.queueItem.is-blink    { animation: blink 1s ease-in-out infinite; }
@keyframes blink {
  0%,100% { background: transparent; }
  50%      { background: rgba(210,75,58,.12); }
}
.queueItem__name { font-weight: 800; font-size: 13px; letter-spacing: .3px; }
.queueItem__desc { font-size: 11px; color: var(--muted); margin-top: 2px; }
.queueItem__meta { flex-shrink: 0; margin-left: 8px; }

/* Badges */
.badge {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 5px;
  font-size: 11px;
  font-weight: 900;
  letter-spacing: .4px;
  background: var(--panel2);
  color: var(--muted);
}
.badge--p1 { background: rgba(210,75,58,.2);  color: var(--p1); border: 1px solid rgba(210,75,58,.4); }
.badge--p2 { background: rgba(213,133,47,.2); color: var(--p2); border: 1px solid rgba(213,133,47,.4); }
.badge--p3 { background: rgba(199,177,74,.2); color: var(--p3); border: 1px solid rgba(199,177,74,.4); }
.badge--p4 { background: rgba(111,176,214,.15);color: var(--p4);border: 1px solid rgba(111,176,214,.3); }

/* Section blocks (instructions) */
.section { margin-bottom: 20px; }
.section__title {
  font-weight: 900;
  font-size: 13px;
  letter-spacing: .6px;
  text-transform: uppercase;
  color: var(--gold);
  margin-bottom: 8px;
  padding-bottom: 6px;
  border-bottom: 1px solid rgba(210,162,74,.2);
}
.steps {
  list-style: none;
  margin: 0;
  padding: 0;
}
.muted { color: var(--muted); font-size: 13px; }

/* Tab bar (dept tabs) */
.tab {
  padding: 6px 14px;
  border: 1px solid var(--edge);
  border-radius: 6px;
  background: var(--panel2);
  color: var(--muted);
  font-weight: 800;
  font-size: 12px;
  cursor: pointer;
  letter-spacing: .4px;
  transition: all .15s;
}
.tab.is-active {
  background: rgba(210,162,74,.15);
  border-color: var(--gold);
  color: var(--gold);
}
