/* =========================================================================
   TECHNICAL DELIVERY PORTAL — INTERACTIVE SPA STYLES (app.css)
   Complements web/dist/prototype-base.css for Desktop (1440px) & Mobile (390px)
   in both Light Mode (data-theme="light") and Dark Mode (data-theme="dark").
   ========================================================================= */

html, body {
  margin: 0 !important;
  padding: 0 !important;
  width: 100% !important;
  max-width: 100vw !important;
  min-height: 100vh !important;
  min-height: 100dvh !important;
  overflow-x: hidden;
  box-sizing: border-box;
  background-color: var(--ground) !important;
  touch-action: manipulation;
}

body[data-page="login"][data-theme="light"],
html[data-page="login"][data-theme="light"] {
  background-color: #f4f7fb !important;
}

body[data-theme="dark"],
html[data-theme="dark"] {
  background-color: #0b0d11 !important;
}

body {
  transition: background-color 0.16s ease, color 0.16s ease;
}
#portal-root {
  max-width: none !important;
  width: 100% !important;
  min-height: 100vh !important;
  min-height: 100dvh !important;
  margin: 0 !important;
  padding: 0 !important;
}

/* Alias Login classes requested by DESIGN.md / ADR-007 to exact HAR prototype classes */
.login-container {
  position: relative;
  display: flex;
  flex-direction: column;
  width: 100% !important;
  max-width: none !important;
  min-height: 100vh !important;
  min-height: 100dvh !important;
  margin: 0 !important;
  align-items: center;
  justify-content: center;
  padding: 40px 20px;
  border-radius: 0 !important;
  background: #f4f7fb;
  border: 0 !important;
  box-sizing: border-box;
  gap: 18px;
}

body[data-theme="dark"] .login-container {
  background: #0b0d11;
  border-color: #262f42;
}

.theme-toggle-btn,
.login-container .theme-toggle-btn {
  position: absolute;
  z-index: 20;
  top: max(14px, env(safe-area-inset-top)) !important;
  right: max(14px, env(safe-area-inset-right)) !important;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 44px !important;
  height: 44px !important;
  min-height: 44px !important;
  padding: 0 !important;
  border: 1px solid #dbe2ea;
  border-radius: 12px !important;
  background: #ffffff;
  color: #111827;
  font-family: var(--font-sans);
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.08);
}

.theme-toggle-btn:hover {
  background: #f8fafc;
}

body[data-theme="dark"] .theme-toggle-btn {
  background: #101116;
  border-color: #262f42;
  color: #f3f4f6;
  box-shadow: none;
}

.theme-toggle-btn .icon-sun {
  display: none;
}
.theme-toggle-btn .icon-moon {
  display: inline-block;
}
body[data-theme="dark"] .theme-toggle-btn .icon-sun {
  display: inline-block;
}
body[data-theme="dark"] .theme-toggle-btn .icon-moon {
  display: none;
}

.login-card-simple {
  display: flex;
  width: 100%;
  max-width: 428px;
  min-width: 0;
  flex-direction: column;
  padding: 36px 30px 32px;
  border-radius: 16px;
  background: #ffffff;
  outline: 1px solid #cbd5e1;
  outline-offset: -1px;
  text-align: left;
  box-shadow: 0 12px 32px rgba(15, 23, 42, 0.06);
}

body[data-theme="dark"] .login-card-simple {
  background: #141824;
  outline: 1px solid #262f42;
  box-shadow: 0 14px 36px rgba(0, 0, 0, 0.45);
}

.login-brand-inline {
  display: flex;
  align-items: center;
  gap: 14px;
}

.login-brand-text-col {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}

.login-field {
  position: relative;
  display: flex;
  width: 100%;
  min-width: 0;
  align-items: center;
}

.btn-gradient-continue {
  width: 100%;
  min-height: 48px;
  margin-top: 4px;
  padding: 13px 20px;
  border-radius: 10px;
  border: 0;
  background: #0b1c30;
  color: #ffffff;
  font-family: var(--font-sans);
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  transition: opacity 0.15s ease;
}

.btn-gradient-continue:hover {
  opacity: 0.92;
}

body[data-theme="dark"] .btn-gradient-continue {
  background: #ffffff;
  color: #0b1c30;
}


.login-error-banner {
  padding: 10px 12px;
  margin-bottom: 16px;
  border-radius: 10px;
  background: var(--pill-negative-bg);
  color: var(--pill-negative-ink);
  border: 1px solid rgba(225, 29, 72, 0.3);
  font-size: 12.5px;
  font-weight: 600;
}

/* Authenticated Framed Shell Layout */
.framed-shell,
.framed-shell.portal-shell {
  width: 100% !important;
  max-width: none !important;
  min-height: 100vh !important;
  min-height: 100dvh !important;
  margin: 0 !important;
  padding: 0 !important;
  border-radius: 0 !important;
  border: 0 !important;
  box-sizing: border-box;
  position: relative;
}

.framed-shell.portal-shell .shell-right {
  flex: 1;
  min-width: 0;
  width: 100% !important;
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0 !important;
  padding: 0 !important;
  display: flex;
  flex-direction: column;
}

.framed-shell.portal-shell .shell-topbar {
  width: 100% !important;
  margin: 0 !important;
  padding: 10px 24px !important;
  border-bottom: 1px solid var(--border);
  box-sizing: border-box;
}

.framed-shell.portal-shell .white-sheet {
  flex: 1 !important;
  min-width: 0;
  width: 100% !important;
  margin: 0 !important;
  border: 0 !important;
  border-radius: 0 !important;
  padding: 20px 24px !important;
  box-sizing: border-box;
}

/* Change Password Modal Overlay Aliases (.cpu-stage-backdrop + .cpu-modal-card & .cpw-*) */
.modal-overlay-fixed,
.cpu-stage-backdrop {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(15, 23, 42, 0.48);
  backdrop-filter: blur(2px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

body[data-theme="dark"] .modal-overlay-fixed,
body[data-theme="dark"] .cpu-stage-backdrop {
  background: rgba(0, 0, 0, 0.68);
}

.cpu-modal-card {
  width: 100%;
  max-width: 440px;
  background: #ffffff;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  padding: 24px 26px 22px;
  box-shadow: 0 18px 40px rgba(15, 23, 42, 0.25);
  display: flex;
  flex-direction: column;
  gap: 14px;
  color: #111827;
}

body[data-theme="dark"] .cpu-modal-card {
  background: #181c24;
  border-color: #2e3646;
  color: #f8fafc;
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.65);
}

/* Interactive Chart SVG Hover & Crosshair */
.chart-svg-wrap {
  width: 100%;
  overflow-x: auto;
  position: relative;
}

.chart-bucket-hitbox {
  cursor: pointer;
  fill: transparent;
}

.chart-bucket-hitbox:hover {
  fill: rgba(79, 70, 229, 0.05);
}

body[data-theme="dark"] .chart-bucket-hitbox:hover {
  fill: rgba(148, 163, 184, 0.07);
}

/* Overview Breakdown Row Interactive Pinning */
tr.breakdown-row-clickable {
  cursor: pointer;
  transition: background-color 0.12s ease;
}

tr.breakdown-row-clickable:hover td {
  background-color: var(--raised);
}

tr.breakdown-row-clickable.pinned-row td {
  background-color: var(--active);
}

/* Popover positioning container */
.rel-anchor {
  position: relative;
  display: inline-flex;
}

.floating-popover {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  z-index: 60;
  box-shadow: 0 12px 28px rgba(15, 23, 42, 0.16);
}

body[data-theme="dark"] .floating-popover {
  box-shadow: 0 14px 32px rgba(0, 0, 0, 0.6);
}

/* Sub-view header bar (e.g. + Log Activity, Import .xlsx, + Add New User) */
.subview-top-nav {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}

/* Toast & Session Idle Warning Banner */
#portal-toast-root {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 140;
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-width: 380px;
}

.portal-toast {
  background: #0f172a;
  color: #f8fafc;
  border: 1px solid #334155;
  border-left: 4px solid #0284c7;
  border-radius: 10px;
  padding: 12px 14px;
  font-size: 12.5px;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.3);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.portal-toast.toast-error {
  border-left-color: #e11d48;
}

.portal-toast.toast-warn {
  border-left-color: #d97706;
}

/* Live SSE status dot in topbar */
.sse-live-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 9px;
  border-radius: 999px;
  background: var(--raised);
  border: 1px solid var(--border);
  font-size: 11px;
  font-weight: 500;
  color: var(--muted);
}

.sse-live-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #10b981;
}

/* Form input width & mobile overflow fixes (Item #6) */
.form-row-2 > div,
.form-stack > div,
.field-input,
.field-select,
.field-textarea,
.custom-date-trigger {
  width: 100% !important;
  max-width: 100% !important;
  min-width: 0 !important;
  box-sizing: border-box !important;
}

.custom-date-trigger {
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 40px;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
  text-align: left;
  transition: border-color 0.14s ease, box-shadow 0.14s ease;
}

.custom-date-trigger:hover,
.custom-date-trigger:focus-visible {
  border-color: var(--accent, #3b82f6);
  outline: none;
}

.custom-date-trigger .custom-date-icon {
  color: var(--muted);
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
}

/* Custom Calendar Popover (Item #5 - IMG_3694.png) */
.custom-calendar-backdrop {
  position: fixed;
  inset: 0;
  z-index: 160;
  background: rgba(15, 23, 42, 0.42);
  backdrop-filter: blur(2px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.custom-calendar-card {
  background: #3a3a3c;
  color: #ffffff;
  border-radius: 24px;
  padding: 20px 18px;
  width: min(340px, calc(100vw - 32px));
  box-shadow: 0 20px 48px rgba(0, 0, 0, 0.45);
  display: flex;
  flex-direction: column;
  gap: 14px;
  user-select: none;
  box-sizing: border-box;
}

.custom-calendar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 4px;
}

.custom-calendar-month-title {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 16px;
  font-weight: 700;
  color: #ffffff;
}

.custom-calendar-month-title .month-chevron {
  color: #d4d4d8;
  font-size: 15px;
  font-weight: 700;
}

.custom-calendar-nav {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.custom-calendar-nav-btn {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 0;
  background: transparent;
  color: #ffffff;
  font-size: 18px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background-color 0.14s ease;
}

.custom-calendar-nav-btn:hover {
  background: rgba(255, 255, 255, 0.12);
}

.custom-calendar-weekdays {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  text-align: center;
  font-size: 11px;
  color: #a1a1aa;
  font-weight: 700;
  letter-spacing: 0.04em;
}

.custom-calendar-days {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  row-gap: 4px;
  justify-items: center;
}

.custom-calendar-day-empty {
  width: 40px;
  height: 40px;
}

.custom-calendar-day {
  width: 40px;
  height: 40px;
  border: 0;
  background: transparent;
  color: #ffffff;
  font-size: 17px;
  font-weight: 500;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background-color 0.12s ease, color 0.12s ease;
}

.custom-calendar-day:hover {
  background: rgba(255, 255, 255, 0.14);
}

.custom-calendar-day.today {
  color: #60a5fa;
  font-weight: 700;
}

.custom-calendar-day.selected {
  background: #ffffff !important;
  color: #09090b !important;
  font-weight: 700 !important;
}

.custom-calendar-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 6px;
}

.custom-calendar-reset-btn {
  border: 0;
  background: #4b4b4e;
  color: #ffffff;
  border-radius: 999px;
  padding: 10px 22px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 0.14s ease;
}

.custom-calendar-reset-btn:hover {
  background: #5a5a5e;
}

.custom-calendar-confirm-btn {
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 50%;
  background: #3b82f6;
  color: #ffffff;
  font-size: 18px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(59, 130, 246, 0.4);
  transition: background-color 0.14s ease;
}

.custom-calendar-confirm-btn:hover {
  background: #2563eb;
}

/* Locked Desktop Sidebar (Item #1 - @media (min-width: 1024px)) */
@media (min-width: 1024px) {
  .framed-shell.portal-shell {
    display: grid !important;
    grid-template-columns: 256px minmax(0, 1fr) !important;
    min-height: 100vh !important;
    min-height: 100dvh !important;
    padding-left: 0 !important;
  }

  .framed-shell.portal-shell .hamburger-menu-panel {
    display: flex !important;
    position: sticky !important;
    top: 0 !important;
    left: 0 !important;
    height: 100vh !important;
    height: 100dvh !important;
    width: 256px !important;
    box-shadow: none !important;
    z-index: 20 !important;
  }

  .framed-shell.portal-shell .shell-topbar .hamburger-btn,
  .framed-shell.portal-shell .hm-brand-btn {
    display: none !important;
  }
}

/* Desktop Action Menu Overflow Fix */
@media (min-width: 769px) {
  .table-scroll {
    overflow: visible !important;
  }
}

/* Mobile & Tablet Anti-Zoom (Item #8 - @media (max-width: 1023px)) */
@media (max-width: 1023px) {
  input,
  select,
  textarea,
  .field-input,
  .field-select,
  .field-textarea,
  .har-login-field-input,
  .cpw-input,
  .pg-goto-input,
  .pg-size-select,
  .search-box input,
  .custom-date-trigger {
    font-size: 16px !important;
  }
}

/* Responsive Mobile (<= 640px / 390px) */
@media (max-width: 768px) {
  body {
    padding: 0 !important;
  }

  .login-container {
    min-height: 100vh !important;
    min-height: 100dvh !important;
    padding: 16px !important;
  }

  .login-card-simple {
    max-width: 100% !important;
    padding: 24px 18px !important;
  }

  .framed-shell.portal-shell .shell-topbar {
    padding: 8px 14px !important;
  }

  .framed-shell.portal-shell .white-sheet {
    padding: 14px !important;
  }

  .hamburger-menu-panel {
    height: 100vh !important;
    height: 100dvh !important;
    max-width: min(300px, 86vw) !important;
  }

  .table-scroll {
    overflow-x: auto !important;
    padding-bottom: 160px;
  }

  .har-login-title {
    font-size: 19px;
    white-space: normal;
  }

  .kpi-strip.cols-4,
  .kpi-strip.cols-3 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .kpi-cell:nth-child(2) {
    border-right: none;
  }

  .kpi-cell:nth-child(1),
  .kpi-cell:nth-child(2) {
    border-bottom: 1px solid var(--border);
  }

  .form-row-2 {
    grid-template-columns: 1fr;
  }

  /* Mobile Hamburger Drawer slides over shell instead of pushing 244px column */
  .framed-shell:has(.hamburger-menu-panel.open) {
    display: flex !important;
    padding-left: 0 !important;
  }

  .framed-shell:has(.hamburger-menu-panel.open) .hamburger-menu-panel.open {
    position: fixed !important;
    top: 0;
    left: 0;
    bottom: 0;
    width: 264px;
    z-index: 95;
    border-radius: 0 14px 14px 0;
    box-shadow: 12px 0 32px rgba(0, 0, 0, 0.35);
  }

  .framed-shell:has(.hamburger-menu-panel.open) .shell-topbar .hamburger-btn {
    display: inline-flex !important;
  }

  .gcp-billing-tooltip {
    position: static;
    width: 100%;
    margin-bottom: 8px;
  }

  .mfa-method-row {
    grid-template-columns: minmax(0, 1fr) auto 20px !important;
    gap: 8px;
    padding: 12px;
  }

  .mfa-method-status {
    display: none;
  }
}
