/* css/fixes.css -- Solus production fixes */

/*
  Z-INDEX HIERARCHY
  -----------------
  1    : screen content
  50   : home screen-foot
  100  : bottom-nav
  150  : checkin-ov
  229  : settings-backdrop
  230  : card-clip-wrap (settings panel inside at z-index: 1 relative)
  260  : modal overlays -- confirm, add-exam, schedule sheet, SR review
  500  : toast
  1000 : app-loader
*/


/* ================================================================
   MODAL OVERLAYS
   Must sit above the settings panel (card-clip-wrap z-index 230)
   so confirm dialogs, the schedule sheet, and SR review render
   correctly even when settings is open in the background.
   ================================================================ */

.overlay  { z-index: 260; }
.sr-ov    { z-index: 260; }
#sched-ov { z-index: 260; }


/* ================================================================
   CARD CLIP WRAP
   Centres the settings panel container on every viewport.
   ================================================================ */

.card-clip-wrap {
  position: fixed;
  top: 0;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 100vw;
  z-index: 230;
  pointer-events: none;
  overflow: hidden;
}

@media (min-width: 1024px) {
  .card-clip-wrap {
    width: var(--card-w);
    max-width: var(--card-w);
  }
}


/* ================================================================
   SETTINGS BACKDROP
   Full-viewport dimmer behind the settings panel.
   ================================================================ */

.settings-backdrop {
  position: fixed;
  inset: 0;
  z-index: 229;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: none;
  opacity: 0;
  transition: opacity 0.3s;
}

.settings-backdrop.open {
  display: block;
  opacity: 1;
}


/* ================================================================
   SETTINGS PANEL
   Correct sizing across all screen widths; never clips content.
   ================================================================ */

.settings-panel {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  height: 100%;
  width: clamp(260px, 80vw, 320px);
  max-width: calc(100% - 40px);
  transform: translateX(100%);
  background: var(--s1);
  border-left: 1px solid var(--border);
  z-index: 1;
  transition: transform 0.35s cubic-bezier(0.22, 0.8, 0.3, 1);
  overflow-y: auto;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
  pointer-events: auto;
  box-shadow: var(--shadow-lg);
}

.settings-panel.open {
  transform: translateX(0);
}

/* Fixed width on desktop -- never collapses */
@media (min-width: 1024px) {
  .settings-panel {
    width: 300px;
    min-width: 300px;
    max-width: 300px;
  }
}

/* Very small screens: leave 32 px visible to hint at closability */
@media (max-width: 360px) {
  .settings-panel {
    width: calc(100vw - 32px);
    max-width: calc(100vw - 32px);
  }
}


/* ================================================================
   SETTINGS PANEL -- STICKY HEAD
   Stays visible while the panel scrolls; respects the notch.
   ================================================================ */

.settings-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: max(var(--sat), 18px) 20px 14px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  position: sticky;
  top: 0;
  background: var(--s1);
  z-index: 2;
}


/* ================================================================
   SETTINGS PANEL -- INNER LAYOUT
   Consistent margins and border-radii for all child components.
   ================================================================ */

.settings-panel .settings-section-lbl {
  padding: 16px 14px 6px;
}

.settings-panel .settings-wrap {
  margin: 0 14px;
  border-radius: var(--r);
  overflow: hidden;
  border: 1px solid var(--border);
  background: var(--s0);
}

.settings-panel .setting-row {
  padding: 12px 14px;
}

.settings-panel .danger-zone {
  margin: 0 14px;
}

.settings-panel .admin-section {
  padding: 0 14px 14px;
}

/* Bottom spacer respects the home-indicator on iOS */
.settings-panel > div:last-child {
  padding-bottom: max(var(--sab), 16px);
  flex-shrink: 0;
}


/* ================================================================
   SETTINGS PANEL -- SCROLLBAR
   ================================================================ */

.settings-panel::-webkit-scrollbar        { width: 3px; }
.settings-panel::-webkit-scrollbar-track  { background: transparent; }
.settings-panel::-webkit-scrollbar-thumb  { background: var(--s3); border-radius: 2px; }


/* ================================================================
   OVERLAY SHEETS -- DESKTOP CENTERING
   Mirrors the bottom-nav pattern:
     left: 0; right: 0; max-width: var(--card-w); margin: 0 auto
   so every sheet is pinned to the card column, not the viewport.
   ================================================================ */

@media (min-width: 1024px) {
  .overlay .sheet {
    max-width: var(--card-w);
    margin: 0 auto;
  }

  .sched-ios-sheet {
    max-width: var(--card-w);
    margin: 0 auto;
  }

  .sr-sheet {
    max-width: var(--card-w);
    margin: 0 auto;
  }
}


/* ================================================================
   DANGER ZONE
   ================================================================ */

.danger-body.open {
  padding: 12px 14px 14px;
}


/* ================================================================
   ADMIN ACTIVE ROW
   ================================================================ */

.admin-active-row {
  border-radius: var(--r);
}


/* ================================================================
   START SESSION CONFIRM SHEET -- safe-area bottom padding
   ================================================================ */

#start-confirm-ov .sheet {
  padding-bottom: calc(var(--sab) + 20px);
}


/* ================================================================
   SESSION CONFIRM OVERLAY (reserved)
   ================================================================ */

#session-confirm-ov {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 300;
  align-items: flex-end;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

#session-confirm-ov.open {
  display: flex;
}
