/* ── Theme toggle button ── */
.theme-toggle {
  width: 32px; height: 32px; border-radius: var(--r);
  background: transparent; border: none;
  color: var(--muted); cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; transition: background .1s, color .1s;
}
.theme-toggle:hover { background: var(--bg); color: var(--text); }

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

/* Smooth scroll site-wide. Applies to anchor jumps, hash navigation, and
   every element.scrollTo / element.scrollIntoView call (the SPA does this
   for the pricing-calculator service-card jump and the al-list-panel
   active-row scroll-into-view). The reduced-motion query below already
   resets this back to auto for users who ask the OS for less motion. */
html { scroll-behavior: smooth; }
.al-list-panel, .al-detail-panel, .modal-card, .page,
.pc-select-popup, .sec-pick-popup,
[class*="-popup"], [class*="-list-panel"] {
  scroll-behavior: smooth;
}

/* ── Global smooth-transition baseline ──────────────────────────────────
   Interactive elements ease their color/background/border/shadow/transform
   changes site-wide so hovers, focus, theme switches, and state changes
   never "snap". We deliberately DO NOT use `* { transition: all }` — that
   animates layout-affecting props (width/height/top) and re-triggers on
   every reflow, which janks the charts and tables. Instead we target the
   paint-only properties on the elements that actually change, and let
   `transform` ride along for lifts/presses. */
a, button, input, select, textarea, label,
.btn, .icon-btn, .nav-item, .res-tile, .card, .data-table tr,
.lozenge, .al-row, .sec-radio, .pc-select-display, .pc-checkbox-row,
.pc-ws-row, .modal-card, .theme-toggle, [role="button"], [data-sec],
.kpi-card, .settings-list-row, .tab, .chip {
  transition:
    background-color .16s ease,
    color .16s ease,
    border-color .16s ease,
    box-shadow .16s ease,
    opacity .16s ease,
    transform .14s ease,
    filter .16s ease;
}

/* Theme flip: ease the big surfaces so dark/light toggling glides instead
   of flashing. Cheap because these are paint-only props on a few elements. */
body, #sidebar, #topbar, .card, .modal-card, .data-table th, .data-table td {
  transition: background-color .22s ease, border-color .22s ease, color .22s ease;
}

/* Respect users who ask the OS to minimise motion: kill transitions and
   animations rather than fighting them. */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    transition-duration: .001ms !important;
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
  }
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, 'Helvetica Neue', Arial, sans-serif;
  font-size: 14px; line-height: 1.5;
  background: var(--bg); color: var(--text);
  height: 100vh; overflow: hidden; display: flex;
}

/* ── Overlay ── */
#overlay {
  display: none; position: fixed; inset: 0;
  background: rgba(9,30,66,.54); z-index: 90;
}
#overlay.show { display: block; }

/* ── Sidebar ── */
#sidebar {
  box-sizing: border-box;
  position: fixed; top: 0; left: 0; height: 100vh;
  width: 240px;
  background: var(--card);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  z-index: 100;
  overflow: hidden;
  text-wrap: nowrap;
  transition: width 300ms ease-in-out;
}
#sidebar.close { width: 60px; }

/* Logo / header row */
.sb-logo {
  height: 52px; flex-shrink: 0;
  display: flex; align-items: center;
  padding: 0 0 0 12px;
  border-bottom: 1px solid var(--border);
  gap: 6px;
  position: relative;
}
.sb-logo-icon {
  width: 48px; height: 48px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  transition: opacity 200ms;
}
.sb-logo-icon img { width: 45px; height: 45px; object-fit: contain; display: block; }
.sb-logo-text { font-size: 13px; font-weight: 700; color: var(--text); line-height: 1.2; flex: 1; min-width: 0; overflow: hidden; transition: opacity 200ms; }
.sb-logo-sub  { font-size: 11px; color: var(--muted); font-weight: 400; }

/* Collapsed state: hide icon+text, reset toggle to fill the row */
#sidebar.close .sb-logo { padding: 0; justify-content: center; gap: 0; }
#sidebar.close .sb-logo-icon,
#sidebar.close .sb-logo-text { opacity: 0; width: 0; overflow: hidden; flex: none; }
#sidebar.close #sb-toggle-btn {
  position: static;
  width: 60px; height: 52px;
}

/* Toggle: absolute so right:0 always anchors to sidebar's visible right edge */
#sb-toggle-btn {
  flex-shrink: 0;
  width: 44px; height: 52px; border: none;
  background: none; color: var(--muted); cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background 150ms, color 150ms;
}
#sb-toggle-btn svg { transition: rotate 250ms ease; fill: currentColor; }
#sb-toggle-btn:hover { background: var(--bg); color: var(--text); }
#sb-toggle-btn.rotated svg { rotate: 180deg; }

.sb-nav { flex: 1; overflow-y: auto; overflow-x: hidden; padding: 8px 8px; }
.sb-nav::-webkit-scrollbar { width: 3px; }
.sb-nav::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

.sb-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; border-radius: 8px;
  cursor: pointer; transition: background 150ms, color 150ms;
  color: var(--muted); font-size: 13px; font-weight: 500;
  margin-bottom: 2px; text-decoration: none;
  white-space: nowrap; overflow: hidden;
}
.sb-item:hover  { background: var(--bg); color: var(--text); }
.sb-item.active { background: var(--primary-lt); color: var(--primary); font-weight: 600; }
.sb-item svg { flex-shrink: 0; width: 20px; height: 20px; min-width: 20px; }
.sb-item span { flex: 1; overflow: hidden; text-overflow: ellipsis; }

.sb-footer {
  border-top: 1px solid var(--border);
  padding: 10px 12px; font-size: 11px; color: var(--subtle);
  flex-shrink: 0; line-height: 1.7; overflow: hidden;
}
.sb-footer strong { color: var(--muted); font-weight: 600; font-size: 11px; display: block; }
#sidebar.close .sb-footer { opacity: 0; pointer-events: none; }

/* Mobile: sidebar slides off canvas */
@media (max-width: 767px) {
  #sidebar { transform: translateX(-100%); transition: transform 300ms ease-in-out, width 300ms ease-in-out; }
  #sidebar.open { transform: translateX(0); }
}

/* ── Main ── */
#main {
  flex: 1; display: flex; flex-direction: column; overflow: hidden;
  margin-left: 240px;
  transition: margin-left 300ms ease-in-out;
}
body.sb-collapsed #main { margin-left: 60px; }
@media (max-width: 767px) { #main { margin-left: 0; } }

/* ── Topbar ── */
.topbar {
  background: var(--card); border-bottom: 1px solid var(--border);
  height: 52px; flex-shrink: 0;
  display: flex; align-items: center; padding: 0 20px; gap: 10px;
  box-shadow: 0 1px 1px rgba(9,30,66,.1);
  position: relative; z-index: 10;
}
/* Narrower viewports: reduce padding and gap so the switcher + buttons
   don't overflow the row. */
@media (max-width: 900px) {
  .topbar { padding: 0 12px; gap: 6px; }
}
.hamburger {
  width: 28px; height: 28px; border-radius: var(--r);
  background: transparent; border: none;
  color: var(--muted); cursor: pointer;
  align-items: center; justify-content: center;
  flex-shrink: 0; transition: background .1s, color .1s;
  display: none;
}
.hamburger:hover { background: var(--bg); color: var(--text); }
@media (max-width: 767px) { .hamburger { display: flex; } }
.topbar-title {
  font-size: 15px; font-weight: 500; color: var(--text); flex: 1;
  letter-spacing: -.01em;
}
.topbar-badge {
  background: var(--primary-lt);
  border-radius: 2em; padding: 2px 8px;
  font-size: 11px; font-weight: 700; color: var(--primary);
  letter-spacing: .01em;
}

/* ── Page ── */
.page { flex: 1; overflow-y: auto; padding: 10px 12px 16px; }
.page::-webkit-scrollbar { width: 6px; }
.page::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
@media (max-width: 480px) { .page { padding: 8px; } }

/* ── Account switcher ── */
/*  Fixed width on the wrapper so button + dropdown are always identical width.
    Shrinks on narrower viewports so it doesn't push other topbar items off. */
.acct-switcher { position: relative; flex-shrink: 0; width: 300px; max-width: 100%; }
@media (max-width: 900px) { .acct-switcher { width: 240px; } }
@media (max-width: 600px) { .acct-switcher { width: 180px; } }
@media (max-width: 420px) { .acct-switcher { width: 140px; } }

.acct-btn {
  width: 100%; box-sizing: border-box;
  /* Fixed min-height so the button stays the same size while the account
     switcher is showing the skeleton and after the real logo + two-line
     name/id renders. Without this, the button visibly resizes at render. */
  min-height: 40px;
  display: flex; align-items: center; gap: 0;
  padding: 4px 6px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  transition: background 150ms, border-color 150ms, box-shadow 150ms;
  text-align: left;
}
.acct-btn:hover {
  background: var(--card);
  border-color: var(--muted);
  box-shadow: 0 2px 8px rgba(0,0,0,.10);
}

/* Shared cloud logo pill — same size everywhere */
.acct-logo {
  width: 28px; height: 28px; border-radius: 6px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; overflow: hidden; margin-right: 8px;
}
.acct-logo img { width: 21px; height: 21px; object-fit: contain; display: block; }
.acct-logo-aws   { background: #232F3E; }
.acct-logo-azure { background: #EBF3FB; }
.acct-logo-gcp   { background: #F1F3F4; }
.acct-logo-other { background: var(--border-sub); }

body.dark .acct-logo-azure { background: #1a2e45; }
body.dark .acct-logo-gcp   { background: #1e2030; }

.acct-btn-inner {
  display: flex; flex-direction: column; gap: 2px;
  flex: 1; min-width: 0; overflow: hidden;
}
.acct-btn-name {
  font-size: 11px; font-weight: 700; color: var(--text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  line-height: 1.2;
}
.acct-btn-id {
  font-size: 9px; font-family: 'SFMono-Regular', Consolas, monospace;
  color: var(--muted); white-space: nowrap; letter-spacing: .01em;
}

.acct-chevron {
  flex-shrink: 0; color: var(--muted); margin-left: 6px;
  transition: transform 200ms ease;
}
.acct-btn[aria-expanded="true"] .acct-chevron { transform: rotate(180deg); }

/* Dropdown — exact same width as the button via left:0/right:0 */
.acct-dropdown {
  display: none;
  position: absolute; top: calc(100% + 6px); left: 0; right: 0;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0,0,0,.16), 0 2px 6px rgba(0,0,0,.08);
  z-index: 300; overflow: hidden;
}
.acct-dropdown.open { display: block; animation: dropIn 140ms ease; }
@keyframes dropIn { from { opacity:0; transform:translateY(-5px); } to { opacity:1; transform:translateY(0); } }

.acct-drop-header {
  padding: 9px 10px 7px 10px;
  font-size: 10px; font-weight: 700; color: var(--muted);
  text-transform: uppercase; letter-spacing: .08em;
  border-bottom: 1px solid var(--border-sub);
}

/* Drop items: same horizontal padding + logo margin as the button */
.acct-drop-item {
  display: flex; align-items: center; gap: 0;
  padding: 9px 10px; cursor: pointer;
  transition: background 100ms;
  border-bottom: 1px solid var(--border-sub);
  position: relative;
}
.acct-drop-item:last-child { border-bottom: none; }
.acct-drop-item:hover { background: var(--bg); }
.acct-drop-item.selected { background: var(--primary-lt); }
.acct-drop-item.selected::after {
  content: '';
  position: absolute; right: 12px; top: 50%; transform: translateY(-50%);
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--primary);
}

.acct-drop-info { flex: 1; min-width: 0; }
.acct-drop-name {
  font-size: 13px; font-weight: 700; color: var(--text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; line-height: 1.2;
}
.acct-drop-id {
  font-size: 10px; font-family: 'SFMono-Regular', Consolas, monospace;
  color: var(--muted); margin-top: 2px; letter-spacing: .01em;
}

.acct-drop-footer {
  display: flex; align-items: center; justify-content: center; gap: 6px;
  padding: 10px; cursor: pointer;
  font-size: 12px; font-weight: 600; color: var(--primary);
  background: var(--bg);
  border-top: 1px solid var(--border);
  transition: background 120ms, color 120ms;
}
.acct-drop-footer:hover { background: var(--primary-lt); color: var(--primary); }
body.dark .acct-drop-footer { background: #17171c; color: var(--primary); }
body.dark .acct-drop-footer:hover { background: #1f2838; }
