/* ---------- Theme palette ----------
   Stockbit-style: neutral greys, a green brand/accent (also the "up" colour)
   and red for "down". Every colour is an "R G B" triplet so Tailwind can still
   apply opacity (bg-slate-900/60). The Tailwind scales are mapped to these
   variables in theme.js; dark is the default, light swaps the values. The
   "slate" scale is a neutral grey scale that flips between modes (950 is the
   page background, 100 is the body text), and "indigo" holds the brand green. */

:root {
  color-scheme: dark;

  --slate-950: 11 13 16;
  --slate-900: 20 23 27;
  --slate-800: 35 39 45;
  --slate-700: 52 58 66;
  --slate-600: 74 81 89;
  --slate-500: 122 131 141;
  --slate-400: 154 163 173;
  --slate-300: 188 195 203;
  --slate-200: 216 221 226;
  --slate-100: 238 241 244;
  --slate-50: 248 249 250;

  /* Brand green (used as the accent) and the gain green */
  --indigo-200: 182 240 212;
  --indigo-300: 125 229 181;
  --indigo-400: 63 213 150;
  --indigo-500: 0 185 111;
  --indigo-700: 0 128 77;
  --indigo-800: 0 90 54;
  --emerald-300: 110 231 183;
  --emerald-400: 31 211 138;
  --emerald-500: 0 185 111;
  --emerald-700: 0 128 77;
  --emerald-800: 0 90 54;

  /* Loss red */
  --rose-300: 255 150 150;
  --rose-400: 255 99 99;
  --rose-500: 235 69 77;
  --rose-700: 159 36 48;

  --amber-200: 253 230 138;
  --amber-400: 251 191 36;
  --amber-500: 245 158 11;
  --sky-300: 125 211 252;
  --sky-400: 56 189 248;
  --sky-500: 14 165 233;
  --violet-300: 196 181 253;
  --violet-400: 167 139 250;
  --violet-500: 139 92 246;
  --fuchsia-400: 232 121 249;
  --fuchsia-500: 217 70 239;
  --cyan-400: 34 211 238;
  --cyan-500: 6 182 212;
  --teal-300: 94 234 212;
  --teal-400: 45 212 191;
  --teal-500: 20 184 166;
  --purple-400: 192 132 252;
  --purple-500: 168 85 247;
  --orange-400: 251 146 60;
  --orange-500: 249 115 22;

  /* Chart colours (see buildChartSvg / buildSparkline in stocks.js) */
  --c-up: 31 211 138;
  --c-down: 255 99 99;
  --c-ref: 154 163 173;
}

:root[data-theme="light"] {
  color-scheme: light;

  --slate-950: 244 246 248;
  --slate-900: 255 255 255;
  --slate-800: 227 231 235;
  --slate-700: 208 214 220;
  --slate-600: 180 188 197;
  --slate-500: 107 117 128;
  --slate-400: 86 96 107;
  --slate-300: 67 76 86;
  --slate-200: 43 50 58;
  --slate-100: 26 32 39;
  --slate-50: 14 18 22;

  --indigo-200: 0 92 56;
  --indigo-300: 0 122 75;
  --indigo-400: 0 133 77;
  --indigo-500: 0 155 89;
  --emerald-300: 0 122 75;
  --emerald-400: 0 133 77;
  --emerald-500: 0 155 89;

  --rose-300: 185 28 28;
  --rose-400: 200 30 40;
  --rose-500: 224 49 60;

  --amber-200: 120 53 15;
  --amber-400: 180 83 9;
  --amber-500: 217 119 6;
  --sky-300: 7 89 133;
  --sky-400: 3 105 161;
  --sky-500: 2 132 199;
  --violet-300: 91 33 182;
  --violet-400: 109 40 217;
  --violet-500: 124 58 237;
  --fuchsia-400: 162 28 175;
  --fuchsia-500: 192 38 211;
  --cyan-400: 14 116 144;
  --cyan-500: 8 145 178;
  --teal-300: 17 94 89;
  --teal-400: 15 118 110;
  --teal-500: 13 148 136;
  --purple-400: 126 34 206;
  --purple-500: 147 51 234;
  --orange-400: 194 65 12;
  --orange-500: 234 88 12;

  --c-up: 0 168 98;
  --c-down: 229 57 53;
  --c-ref: 107 117 128;
}

body {
  transition: background-color 0.15s ease, color 0.15s ease;
}

html {
  scroll-behavior: smooth;
}

/* ---------- App shell / sidebar layout ---------- */

.app-container {
  display: flex;
  min-height: 100vh;
  width: 100%;
}

.sidebar {
  width: 240px;
  background-color: rgb(var(--slate-900));
  border-right: 1px solid rgb(var(--slate-800));
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  transition: width 0.2s ease;
  z-index: 40;
}

.sidebar-collapsed .sidebar {
  width: 68px;
}

.sidebar-logo-section {
  height: 64px;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 16px;
  border-bottom: 1px solid rgb(var(--slate-800));
  cursor: pointer;
  flex-shrink: 0;
}

.logo-box {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background-color: rgb(var(--indigo-500));
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: #ffffff;
}

.logo-text {
  font-weight: 700;
  font-size: 0.9rem;
  color: rgb(var(--slate-100));
  white-space: nowrap;
}

.sidebar-collapsed .logo-text,
.sidebar-collapsed .nav-label,
.sidebar-collapsed .nav-badge {
  display: none;
}

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 10px;
}

.sidebar-nav ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.menu-item {
  display: flex;
  align-items: center;
  gap: 12px;
  height: 42px;
  padding: 0 12px;
  border-radius: 8px;
  color: rgb(var(--slate-400));
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: background-color 0.15s ease, color 0.15s ease;
}

.menu-item:hover {
  background-color: rgb(var(--slate-100) / 0.06);
  color: rgb(var(--slate-200));
}

.menu-item.active {
  background-color: rgb(var(--indigo-500) / 0.12);
  color: rgb(var(--indigo-300));
}

.menu-item.disabled {
  cursor: not-allowed;
  color: rgb(var(--slate-600));
}

.menu-item.disabled:hover {
  background-color: transparent;
  color: rgb(var(--slate-600));
}

.nav-icon-wrapper {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  flex-shrink: 0;
}

.nav-label {
  white-space: nowrap;
  flex: 1;
}

.nav-badge {
  font-size: 0.625rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  background-color: rgb(var(--slate-800));
  color: rgb(var(--slate-500));
  padding: 2px 6px;
  border-radius: 4px;
  white-space: nowrap;
}

.main-panel {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.app-header {
  height: 64px;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 16px;
  border-bottom: 1px solid rgb(var(--slate-800));
  flex-shrink: 0;
}

.menu-toggle-btn {
  border: none;
  background: none;
  color: rgb(var(--slate-400));
  padding: 8px;
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background-color 0.15s ease, color 0.15s ease;
}

.menu-toggle-btn:hover,
.theme-toggle-btn:hover {
  background-color: rgb(var(--slate-100) / 0.08);
  color: rgb(var(--slate-100));
}

/* Light/dark switch, appended to the header by theme.js */
.theme-toggle-btn {
  margin-left: auto;
  border: none;
  background: none;
  color: rgb(var(--slate-400));
  padding: 8px;
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background-color 0.15s ease, color 0.15s ease;
}

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

.header-title {
  font-weight: 600;
  font-size: 0.95rem;
  color: rgb(var(--slate-100));
}

.page-content {
  flex: 1;
  overflow-y: auto;
}

.sidebar-backdrop {
  display: none;
}

/* ---------- Mobile: off-canvas drawer ---------- */

@media (max-width: 900px) {
  .sidebar {
    position: fixed;
    top: 0;
    left: -240px;
    height: 100vh;
    transition: left 0.2s ease;
  }

  .sidebar-collapsed .sidebar {
    width: 240px;
    left: -240px;
  }

  .app-container.sidebar-open-mobile .sidebar {
    left: 0;
  }

  .app-container.sidebar-open-mobile .logo-text,
  .app-container.sidebar-open-mobile .nav-label,
  .app-container.sidebar-open-mobile .nav-badge {
    display: initial;
  }

  .app-container.sidebar-open-mobile .sidebar-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    background-color: rgba(0, 0, 0, 0.6);
    z-index: 30;
  }
}

/* ---------- Keterbukaan Informasi: Excel table viewer ---------- */
.disc-table-wrap {
  max-height: 28rem;
  max-width: 100%;
}
.disc-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 12px;
  color: rgb(var(--slate-200));
}
.disc-th,
.disc-td {
  padding: 5px 10px;
  border-bottom: 1px solid rgb(var(--slate-800));
  vertical-align: top;
}
.disc-th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: rgb(var(--slate-900));
  color: rgb(var(--slate-400));
  font-weight: 600;
  text-align: left;
  white-space: nowrap;
}
.disc-num {
  text-align: right;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.disc-label {
  min-width: 14rem;
  max-width: 28rem;
}
.disc-table td:not(.disc-label) {
  min-width: 6.5rem;
}
.disc-table tbody tr:hover td {
  background: rgb(var(--slate-800) / 0.5);
}
.disc-heading td {
  background: rgb(var(--slate-800) / 0.45);
  color: rgb(var(--slate-300));
  font-weight: 600;
}
.disc-total td {
  font-weight: 600;
  border-top: 1px solid rgb(var(--slate-700));
}

/* ---------- Floating feedback button (feedback.js) ---------- */
.fb-fab {
  position: fixed;
  right: 16px;
  bottom: calc(16px + env(safe-area-inset-bottom, 0px));
  z-index: 45;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 52px;
  height: 52px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: rgb(var(--indigo-500));
  color: #fff;
  cursor: pointer;
  box-shadow: 0 6px 20px rgb(0 0 0 / 0.35);
  transition: transform 0.15s, filter 0.15s;
}
.fb-fab:hover { filter: brightness(1.08); transform: translateY(-1px); }
.fb-fab:focus-visible,
.fb-face:focus-visible,
.fb-chip:focus-visible,
.fb-send:focus-visible,
.fb-close:focus-visible { outline: 2px solid rgb(var(--indigo-300)); outline-offset: 2px; }
.fb-panel {
  position: fixed;
  right: 16px;
  bottom: calc(80px + env(safe-area-inset-bottom, 0px));
  z-index: 45;
  width: min(360px, calc(100vw - 32px));
  max-height: calc(100vh - 110px);
  overflow-y: auto;
  padding: 14px;
  border: 1px solid rgb(var(--slate-700));
  border-radius: 14px;
  background: rgb(var(--slate-900));
  color: rgb(var(--slate-100));
  box-shadow: 0 12px 36px rgb(0 0 0 / 0.45);
}
.fb-panel.hidden { display: none; }
.fb-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.fb-title { font-size: 14px; font-weight: 700; }
.fb-close { border: 0; background: transparent; color: rgb(var(--slate-400)); cursor: pointer; font-size: 14px; padding: 2px 6px; border-radius: 6px; }
.fb-close:hover { color: rgb(var(--slate-100)); }
.fb-label { display: block; margin: 10px 0 5px; font-size: 11px; color: rgb(var(--slate-400)); }
.fb-faces { display: flex; gap: 6px; }
.fb-face { flex: 1; padding: 6px 0; font-size: 20px; line-height: 1; border: 1px solid rgb(var(--slate-700)); border-radius: 10px; background: transparent; cursor: pointer; filter: grayscale(0.7); opacity: 0.75; }
.fb-face.fb-on { border-color: rgb(var(--indigo-500)); background: rgb(var(--indigo-500) / 0.18); filter: none; opacity: 1; }
.fb-cats { display: flex; flex-wrap: wrap; gap: 6px; }
.fb-chip { padding: 5px 10px; font-size: 12px; border: 1px solid rgb(var(--slate-700)); border-radius: 999px; background: transparent; color: rgb(var(--slate-300)); cursor: pointer; }
.fb-chip.fb-on { border-color: rgb(var(--indigo-500)); background: rgb(var(--indigo-500) / 0.18); color: rgb(var(--indigo-300)); }
.fb-input { width: 100%; padding: 8px 10px; font-size: 13px; border: 1px solid rgb(var(--slate-700)); border-radius: 8px; background: rgb(var(--slate-950)); color: rgb(var(--slate-100)); resize: vertical; }
.fb-input:focus { outline: 2px solid rgb(var(--indigo-500)); outline-offset: 0; border-color: transparent; }
.fb-count { margin-top: 2px; text-align: right; font-size: 10px; color: rgb(var(--slate-500)); }
.fb-trap { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }
.fb-status { min-height: 16px; margin-top: 8px; font-size: 12px; color: rgb(var(--slate-400)); }
.fb-status-ok { color: rgb(var(--emerald-400)); }
.fb-status-error { color: rgb(var(--rose-400)); }
.fb-send { width: 100%; margin-top: 4px; padding: 9px; font-size: 13px; font-weight: 700; border: 0; border-radius: 8px; background: rgb(var(--indigo-500)); color: #fff; cursor: pointer; }
.fb-send:disabled { opacity: 0.6; cursor: default; }
.fb-note { margin-top: 8px; font-size: 10px; line-height: 1.4; color: rgb(var(--slate-500)); }

/* ---------- Weather map (weather.html / weather.js) ---------- */
.wx-page { position: relative; overflow: hidden; flex: none; height: calc(100vh - 64px); min-height: 440px; }
.wx-stage { position: absolute; inset: 0; background: #02060f; }
.wx-map { position: absolute; inset: 0; }
/* MapLibre's own stylesheet sets position:relative on the container; keep it filling the stage */
.wx-stage .wx-map.maplibregl-map { position: absolute; inset: 0; width: 100%; height: 100%; }
.wx-panels { position: absolute; top: 12px; left: 12px; z-index: 5; display: flex; flex-direction: column; gap: 8px; width: min(250px, calc(100vw - 24px)); max-height: calc(100% - 90px); overflow-y: auto; }
.wx-panel {
  border: 1px solid rgb(var(--slate-700) / 0.8);
  border-radius: 12px;
  background: rgb(var(--slate-900) / 0.86);
  color: rgb(var(--slate-100));
  backdrop-filter: blur(8px);
  box-shadow: 0 6px 22px rgb(0 0 0 / 0.35);
  font-size: 12px;
}
.wx-summary { cursor: pointer; user-select: none; padding: 9px 12px; font-weight: 700; font-size: 12px; list-style: none; }
.wx-summary::-webkit-details-marker { display: none; }
.wx-summary::after { content: "▾"; float: right; color: rgb(var(--slate-400)); }
details:not([open]) > .wx-summary::after { content: "▸"; }
.wx-body { padding: 0 12px 11px; display: flex; flex-direction: column; gap: 6px; }
.wx-row { display: flex; align-items: center; gap: 8px; cursor: pointer; }
.wx-row input { accent-color: rgb(var(--indigo-500)); }
.wx-sub { margin: -2px 0 0 24px; font-size: 10px; color: rgb(var(--slate-400)); min-height: 12px; }
.wx-sub-title { margin-top: 4px; font-size: 10px; text-transform: uppercase; letter-spacing: 0.04em; color: rgb(var(--slate-500)); }
.wx-btn { margin-left: 24px; padding: 4px 8px; font-size: 11px; text-align: left; border: 1px solid rgb(var(--slate-700)); border-radius: 8px; background: transparent; color: rgb(var(--slate-300)); cursor: pointer; }
.wx-btn:hover { background: rgb(var(--slate-800)); }
.wx-btn.wx-on { border-color: rgb(var(--indigo-500)); color: rgb(var(--indigo-300)); }
.wx-link { margin-top: 4px; font-size: 11px; color: rgb(var(--indigo-300)); text-decoration: underline; }
.wx-chips { flex-direction: row; flex-wrap: wrap; gap: 5px; }
.wx-chip { padding: 4px 9px; font-size: 11px; border: 1px solid rgb(var(--slate-700)); border-radius: 999px; background: transparent; color: rgb(var(--slate-300)); cursor: pointer; }
.wx-chip:hover { border-color: rgb(var(--indigo-500)); color: rgb(var(--indigo-300)); }
.wx-legend { position: absolute; right: 78px; bottom: 44px; z-index: 5; padding: 8px 10px; display: flex; flex-direction: column; gap: 7px; max-width: min(330px, calc(100vw - 24px)); }
.wx-legend:empty { display: none; }
.wx-legend-title { font-size: 10px; text-transform: uppercase; letter-spacing: 0.04em; color: rgb(var(--slate-400)); margin-bottom: 3px; }
.wx-bar { height: 8px; border-radius: 4px; }
.wx-bar-labels { display: flex; justify-content: space-between; font-size: 9px; color: rgb(var(--slate-400)); margin-top: 2px; }
.wx-swatches { display: flex; flex-wrap: wrap; gap: 4px 8px; }
.wx-swatch { display: inline-flex; align-items: center; gap: 4px; font-size: 10px; color: rgb(var(--slate-300)); }
.wx-swatch i { width: 10px; height: 10px; border-radius: 50%; display: inline-block; border: 1px solid rgb(0 0 0 / 0.4); }
.wx-status { position: absolute; top: 12px; left: 50%; transform: translateX(-50%); z-index: 6; margin: 0; padding: 6px 12px; border-radius: 999px; font-size: 12px; background: rgb(var(--slate-900) / 0.92); border: 1px solid rgb(var(--slate-700)); color: rgb(var(--slate-200)); }
.wx-status.wx-error { color: rgb(var(--rose-300)); border-color: rgb(var(--rose-700)); }
.wx-status.hidden { display: none; }
.wx-attrib { position: absolute; left: 12px; right: 12px; bottom: 8px; z-index: 4; margin: 0; width: fit-content; max-width: calc(100% - 100px); padding: 3px 8px; border-radius: 6px; font-size: 10px; line-height: 1.3; color: rgb(255 255 255 / 0.85); background: rgb(2 6 15 / 0.7); }
.wx-attrib a { color: inherit; text-decoration: underline; }
@media (max-width: 640px) { .wx-attrib { font-size: 9px; } .wx-legend { left: 12px; right: auto; bottom: 58px; } }

/* popup */
.wx-stage .maplibregl-popup-content { background: rgb(var(--slate-900)); color: rgb(var(--slate-100)); border: 1px solid rgb(var(--slate-700)); border-radius: 12px; padding: 12px 14px; font-size: 12px; max-height: 68vh; overflow-y: auto; box-shadow: 0 8px 28px rgb(0 0 0 / 0.5); }
.wx-stage .maplibregl-popup-anchor-top .maplibregl-popup-tip, .wx-stage .maplibregl-popup-anchor-top-left .maplibregl-popup-tip, .wx-stage .maplibregl-popup-anchor-top-right .maplibregl-popup-tip { border-bottom-color: rgb(var(--slate-900)); }
.wx-stage .maplibregl-popup-anchor-bottom .maplibregl-popup-tip, .wx-stage .maplibregl-popup-anchor-bottom-left .maplibregl-popup-tip, .wx-stage .maplibregl-popup-anchor-bottom-right .maplibregl-popup-tip { border-top-color: rgb(var(--slate-900)); }
.wx-stage .maplibregl-popup-anchor-left .maplibregl-popup-tip { border-right-color: rgb(var(--slate-900)); }
.wx-stage .maplibregl-popup-anchor-right .maplibregl-popup-tip { border-left-color: rgb(var(--slate-900)); }
.wx-stage .maplibregl-popup-close-button { color: rgb(var(--slate-400)); font-size: 18px; padding: 2px 8px; }
.wx-pop-head { display: flex; align-items: center; gap: 8px; }
.wx-pop-emoji { font-size: 30px; line-height: 1; }
.wx-pop-temp { font-size: 24px; font-weight: 700; line-height: 1; }
.wx-pop-cond { font-size: 12px; color: rgb(var(--slate-300)); }
.wx-pop-place { font-size: 10px; color: rgb(var(--slate-500)); margin-bottom: 8px; padding-right: 18px; }
.wx-pop-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 12px; margin-top: 10px; }
.wx-pop-grid p { margin: 0; }
.wx-pop-label { font-size: 10px; color: rgb(var(--slate-500)); }
.wx-pop-value { font-size: 12px; font-weight: 600; }
.wx-aqi { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 11px; font-weight: 700; color: #111; }
.wx-hours { display: flex; align-items: flex-end; gap: 3px; height: 56px; margin-top: 10px; }
.wx-hour { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; gap: 2px; min-width: 0; }
.wx-hour-bar { width: 100%; border-radius: 2px; background: rgb(var(--sky-400)); min-height: 2px; }
.wx-hour-t { font-size: 8px; color: rgb(var(--slate-400)); }
.wx-pop-note { margin: 6px 0 0; font-size: 9px; color: rgb(var(--slate-500)); }


.wx-slider { justify-content: space-between; }
.wx-slider input { flex: 1; max-width: 120px; accent-color: rgb(var(--indigo-500)); }
