/* Sutra Bailout Plan PWA - Dark Theme for OR Environment */

:root {
  --bg-main: #1a1a2e;
  --bg-panel: #16213e;
  --bg-section: #0f3460;
  --bg-card: #1a1a2e;
  --text-primary: #FFFFFF;
  --text-secondary: #B8C5D0;
  --text-title: #769DF8;
  --abort-red: #e94560;
  --bailout-orange: #f39c12;
  --success-green: #00d9ff;
  --selection-blue: #0077b6;
  --selection-highlight: #00b4d8;
  --disabled-gray: #555555;
  --warning-yellow: #f1c40f;
  --standard-orange: #FFA500;
  --border-color: #2d4a6f;
  --btn-cap: #008B8B;
  --btn-flush: #AD9C6F;
  --btn-anchor: #2E8B57;
  --btn-second: #D883D0;
  --btn-topanchor: #8B5CF6;
  --btn-insertion: #4A90D9;
  --btn-lock-retrieval: #D97B4A;
  --nav-width: 250px;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html, body {
  height: 100%;
  overflow: hidden;
  font-family: Calibri, 'Segoe UI', sans-serif;
  background: var(--bg-main);
  color: var(--text-primary);
}

/* ========== APP LAYOUT ========== */
.app-container {
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}

.main-layout {
  display: flex;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

/* ========== NAVIGATION PANEL (Left Sidebar) ========== */
.nav-panel {
  width: var(--nav-width);
  min-width: var(--nav-width);
  background: var(--bg-panel);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  overflow-x: hidden;
  border-right: 1px solid var(--border-color);
  -webkit-overflow-scrolling: touch;
}

.nav-panel::-webkit-scrollbar {
  width: 6px;
}

.nav-panel::-webkit-scrollbar-track {
  background: var(--bg-panel);
}

.nav-panel::-webkit-scrollbar-thumb {
  background: var(--border-color);
  border-radius: 3px;
}

.nav-title {
  font-size: 20px;
  font-weight: bold;
  text-align: center;
  padding: 10px 10px 5px;
  color: var(--text-primary);
}

.nav-section-label {
  font-size: 18px;
  font-weight: bold;
  color: var(--text-title);
  padding: 5px 10px 3px;
}

/* Failure modes list */
.modes-list {
  list-style: none;
  padding: 0 10px 5px;
}

.modes-list li {
  font-size: 16px;
  font-weight: bold;
  padding: 6px 10px;
  cursor: pointer;
  border-radius: 4px;
  transition: background 0.15s;
}

.modes-list li:hover {
  background: var(--bg-section);
}

.modes-list li.active {
  background: var(--selection-blue);
  color: white;
}

/* Phase and stage buttons */
.nav-buttons {
  padding: 0 10px 5px;
}

.nav-btn {
  display: block;
  width: 100%;
  text-align: left;
  font-size: 14px;
  font-weight: bold;
  font-family: Calibri, 'Segoe UI', sans-serif;
  padding: 7px 10px;
  margin: 2px 0;
  border: none;
  border-radius: 4px;
  background: var(--bg-section);
  color: var(--text-primary);
  cursor: pointer;
  transition: background 0.15s;
}

.nav-btn:hover {
  background: var(--selection-highlight);
}

.nav-btn.active {
  background: var(--selection-blue);
  color: white;
}

.nav-section {
  display: none;
}

.nav-section.visible {
  display: block;
}

/* ========== CONTENT PANEL (Main Area) ========== */
.content-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding: 10px 15px 55px;
  gap: 5px;
  touch-action: auto;
}

/* Header */
.content-header {
  display: flex;
  align-items: baseline;
  gap: 10px;
  flex-shrink: 0;
}

.content-header .mode-name {
  font-size: 35px;
  font-weight: bold;
}

.content-header .phase-name {
  font-size: 20px;
  color: var(--text-secondary);
}

/* FACTS block */
.facts-block {
  background: var(--bg-section);
  border-radius: 6px;
  padding: 10px 15px;
  flex-shrink: 0;
  min-height: 80px;
  max-height: 140px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-y;
}

.facts-block::-webkit-scrollbar {
  width: 6px;
}

.facts-block::-webkit-scrollbar-thumb {
  background: var(--border-color);
  border-radius: 3px;
}

.block-title {
  font-size: 20px;
  font-weight: bold;
  color: var(--text-title);
  margin-bottom: 6px;
}

.facts-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px 20px;
}

.fact-item {
  font-size: 16px;
  line-height: 1.35;
  color: var(--text-primary);
}

.fact-item::before {
  content: "\2022 ";
  color: var(--text-title);
}

/* DECISION + ACTION ITEMS row */
.decision-action-row {
  display: flex;
  gap: 5px;
  flex-shrink: 0;
  min-height: 100px;
  max-height: 180px;
}

/* DECISION block */
.decision-block {
  background: var(--bg-section);
  border-radius: 6px;
  padding: 10px 15px;
  min-width: 180px;
  display: flex;
  flex-direction: column;
}

.decision-banner {
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 1;
  font-size: 22px;
  font-weight: bold;
  border-radius: 6px;
  color: white;
  margin-top: 5px;
}

.decision-banner.abort {
  background: var(--abort-red);
}

.decision-banner.bailout {
  background: var(--bailout-orange);
}

.decision-buttons {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 5px;
  flex: 1;
  justify-content: center;
}

.decision-btn {
  font-size: 17px;
  font-weight: bold;
  font-family: Calibri, 'Segoe UI', sans-serif;
  padding: 8px 10px;
  border: none;
  border-radius: 6px;
  color: white;
  cursor: pointer;
  transition: opacity 0.15s, filter 0.15s;
}

.decision-btn:hover {
  filter: brightness(1.1);
}

.decision-btn.abort {
  background: var(--abort-red);
}

.decision-btn.bailout {
  background: var(--bailout-orange);
}

.decision-btn.selected {
  outline: 3px solid white;
  outline-offset: -3px;
}

.decision-btn.dimmed {
  opacity: 0.35;
}

/* ACTION ITEMS block */
.action-block {
  background: var(--bg-section);
  border-radius: 6px;
  padding: 10px 15px;
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-y;
}

.action-block::-webkit-scrollbar {
  width: 6px;
}

.action-block::-webkit-scrollbar-thumb {
  background: var(--border-color);
  border-radius: 3px;
}

.action-item {
  font-size: 16px;
  line-height: 1.4;
  padding: 2px 0;
}

.action-item.warning {
  color: var(--warning-yellow);
  font-weight: bold;
}

/* PROCEDURE STEPS + DEVICE PREP row */
.content-bottom-row {
  display: flex;
  gap: 6px;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

.steps-block, .prep-block {
  background: var(--bg-section);
  border-radius: 6px;
  padding: 10px 15px;
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-y;
  display: flex;
  flex-direction: column;
}

.steps-block::-webkit-scrollbar,
.prep-block::-webkit-scrollbar {
  width: 6px;
}

.steps-block::-webkit-scrollbar-thumb,
.prep-block::-webkit-scrollbar-thumb {
  background: var(--border-color);
  border-radius: 3px;
}

.step-item {
  font-size: 16px;
  line-height: 1.4;
  padding: 3px 0;
  white-space: pre-wrap;
}

.step-item.indent-1 {
  padding-left: 25px;
}

.step-item.indent-2 {
  padding-left: 50px;
}

.step-item.standard {
  color: var(--standard-orange);
}

.step-item.header-text {
  font-weight: bold;
}

.step-image {
  max-width: 100%;
  height: auto;
  margin: 6px 0;
  border-radius: 4px;
}

.step-image.indent-1 {
  margin-left: 25px;
  max-width: calc(100% - 25px);
}

/* Device prep items */
.prep-item {
  font-size: 16px;
  line-height: 1.4;
  padding: 3px 0;
}

.prep-item.is-header {
  font-weight: bold;
  font-size: 18px;
  margin-top: 8px;
}

.prep-item.indent-1 {
  padding-left: 25px;
}

.prep-item.standard {
  color: var(--standard-orange);
}

.prep-item .header-prefix {
  font-weight: bold;
  color: var(--text-primary);  /* Always white bold, even for standard (orange) items */
}

/* Table in procedure steps */
.step-table {
  border-collapse: collapse;
  margin: 8px 0;
  font-size: 14px;
  width: 100%;
  table-layout: fixed;
}

.step-table th {
  background: var(--bg-panel);
  color: var(--text-title);
  font-weight: bold;
  padding: 6px 8px;
  border: 1px solid var(--border-color);
  text-align: center;
}

.step-table td {
  padding: 6px 8px;
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  vertical-align: top;
  white-space: pre-wrap;
}

.step-table td.span-all {
  text-align: center;
}

/* ========== BOTTOM PANEL ========== */
.bottom-panel {
  background: var(--bg-panel);
  padding: 8px 15px;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: center;
  border-top: 1px solid var(--border-color);
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 100;
}

.std-btn {
  font-size: 14px;
  font-weight: bold;
  font-family: Calibri, 'Segoe UI', sans-serif;
  padding: 8px 16px;
  border: none;
  border-radius: 6px;
  color: white;
  cursor: pointer;
  transition: filter 0.15s;
  white-space: nowrap;
}

.std-btn:hover {
  filter: brightness(1.15);
}

.std-btn.cap { background: var(--btn-cap); }
.std-btn.flush { background: var(--btn-flush); }
.std-btn.anchor { background: var(--btn-anchor); }
.std-btn.second { background: var(--btn-second); }
.std-btn.topanchor { background: var(--btn-topanchor); }
.std-btn.insertion { background: var(--btn-insertion); }
.std-btn.lock-retrieval { background: var(--btn-lock-retrieval); }

/* ========== MOBILE HAMBURGER ========== */
.hamburger {
  display: none;
  position: fixed;
  top: 10px;
  left: 10px;
  z-index: 1000;
  background: var(--bg-section);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  color: white;
  font-size: 24px;
  width: 44px;
  height: 44px;
  cursor: pointer;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

.nav-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0,0,0,0.5);
  z-index: 998;
}

/* ========== RESPONSIVE: TABLET (768-1023px) ========== */
@media (max-width: 1023px) {
  :root {
    --nav-width: 220px;
  }

  .content-header .mode-name {
    font-size: 28px;
  }

  .content-header .phase-name {
    font-size: 17px;
  }

  .facts-grid {
    grid-template-columns: 1fr;
  }

  .step-item, .prep-item, .action-item, .fact-item {
    font-size: 15px;
  }

}

/* ========== RESPONSIVE: PHONE (<768px) ========== */
@media (max-width: 767px) {
  html, body {
    overflow: auto;
    height: auto;
  }

  .app-container {
    height: auto;
    min-height: 100vh;
    overflow: visible;
  }

  .main-layout {
    display: block;
    overflow: visible;
  }

  .hamburger {
    display: flex;
  }

  .nav-panel {
    position: fixed;
    top: 0;
    left: -280px;
    width: 280px;
    min-width: 280px;
    height: 100%;
    z-index: 999;
    transition: left 0.25s ease;
  }

  .nav-panel.open {
    left: 0;
  }

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

  .content-panel {
    display: block;
    overflow: visible;
    padding: 56px 10px 70px;
  }

  .content-panel > * {
    margin-bottom: 5px;
  }

  .content-header .mode-name {
    font-size: 22px;
  }

  .content-header .phase-name {
    font-size: 15px;
  }

  .decision-action-row {
    display: flex;
    flex-direction: column;
    max-height: none;
  }

  .decision-block {
    min-width: unset;
  }

  .decision-buttons {
    flex-direction: row;
  }

  .decision-btn {
    flex: 1;
  }

  .content-bottom-row {
    display: block;
    overflow: visible;
  }

  .steps-block, .prep-block {
    display: block;
    overflow: visible;
    margin-bottom: 5px;
  }

  .facts-block {
    max-height: none;
  }

  .facts-grid {
    grid-template-columns: 1fr;
  }

  .step-item, .prep-item, .action-item, .fact-item {
    font-size: 14px;
  }

  .block-title {
    font-size: 17px;
  }

  .bottom-panel {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 100;
    flex-wrap: wrap;
    gap: 4px;
    padding: 6px 8px;
    padding-bottom: max(6px, env(safe-area-inset-bottom));
  }

  .std-btn {
    font-size: 11px;
    padding: 5px 8px;
  }

  .step-table {
    font-size: 12px;
    table-layout: auto;
  }
}

/* ========== SCROLLBAR GENERAL ========== */
::-webkit-scrollbar {
  width: 8px;
}

::-webkit-scrollbar-track {
  background: var(--bg-main);
}

::-webkit-scrollbar-thumb {
  background: var(--border-color);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--selection-blue);
}

/* Firefox scrollbar */
* {
  scrollbar-width: thin;
  scrollbar-color: var(--border-color) var(--bg-main);
}
