/* MSU-SOS shared theme tokens + header + flyout menu (reference: deepmind.google site header) */

/* ---------- Theme tokens: light (default) ---------- */
:root {
  color-scheme: light;
  --bg: #faf9fd;
  --surface: #ffffff;
  --surface-container: #f3f4f6;
  --surface-container-higher: #e6eaf0;
  --on-surface: #0a0a0a;
  --on-surface-variant: #4e4f56;
  --outline: #c4c7c5;
  --outline-variant: #e3e5e8;
  --primary: #1b1c1d;
  --on-primary: #ffffff;
  --accent: #005cbb;
  --on-accent: #ffffff;
  --hover: rgba(0, 0, 0, .05);
  --selected: #e3ecfa;
  --row-alt: #f7f7f8;
  --row-hover: #eef3fb;
  --muted: #9aa0a6;
  --btn-neutral: #e0e0e0;
  --btn-neutral-hover: #d0d0d0;
  --on-btn-neutral: #000000;
  --detail: #ffcc00;
  --detail-hover: #f0bf00;
  --on-detail: #000000;
  --st-cancel-bg: #eceff1; --st-cancel-fg: #455a64;
  --st-active-bg: #e3f2fd; --st-active-fg: #1565c0;
  --st-done-bg: #e8f5e9;   --st-done-fg: #2e7d32;
  --st-warn-bg: #fff3e0;   --st-warn-fg: #c25400;
  --st-red-bg: #fdecea;    --st-red-fg: #c62828;
  --danger: #d93025; --danger-hover: #c5221f; --on-danger: #ffffff;
  --success: #1e8e3e; --success-hover: #188038; --on-success: #ffffff;
  --warning: #f9ab00; --warning-hover: #e69d00; --on-warning: #000000;
  --chart-1: #1a73e8; --chart-grid: #e3e5e8;
  --shadow: rgba(0, 0, 0, .14);
  --scrim: rgba(0, 0, 0, .18);
  --toast-bg: #1b1c1d; --toast-fg: #ffffff;

  --brand-msu: #0a0a0a;
  --brand-sos: #d32f2f;
  --brand-cloud: #1565c0;
  --brand-services: #ef6c00;

  --hdr-height: 64px;
  --hdr-bg: rgba(255, 255, 255, .88);
  --hdr-bg-open: #ffffff;
  --hdr-font: "Google Sans Flex", Sarabun, Arial, Helvetica, sans-serif;
}

/* ---------- Theme tokens: dark ---------- */
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #121316;
  --surface: #1b1c1f;
  --surface-container: #232428;
  --surface-container-higher: #2f3034;
  --on-surface: #e8e9ec;
  --on-surface-variant: #a9acb4;
  --outline: #5c5f66;
  --outline-variant: #34363b;
  --primary: #e8e9ec;
  --on-primary: #121316;
  --accent: #8ab4f8;
  --on-accent: #0b1a33;
  --hover: rgba(255, 255, 255, .06);
  --selected: #233552;
  --row-alt: #202125;
  --row-hover: #26303f;
  --muted: #6f737b;
  --btn-neutral: #3a3c41;
  --btn-neutral-hover: #46484e;
  --on-btn-neutral: #e8e9ec;
  --detail: #ffcc00;
  --detail-hover: #ffd633;
  --on-detail: #000000;
  --st-cancel-bg: #2e3338; --st-cancel-fg: #b0bec5;
  --st-active-bg: #15304f; --st-active-fg: #90caf9;
  --st-done-bg: #173322;   --st-done-fg: #81c995;
  --st-warn-bg: #3a2a12;   --st-warn-fg: #ffb874;
  --st-red-bg: #3b1d1d;    --st-red-fg: #f28b82;
  --danger: #f28b82; --danger-hover: #f6aea9; --on-danger: #2a0b0b;
  --success: #81c995; --success-hover: #a8dab5; --on-success: #0b2913;
  --warning: #fdd663; --warning-hover: #fde293; --on-warning: #261c00;
  --chart-1: #8ab4f8; --chart-grid: #34363b;
  --shadow: rgba(0, 0, 0, .55);
  --scrim: rgba(0, 0, 0, .45);
  --toast-bg: #e8e9ec; --toast-fg: #121316;

  --brand-msu: #f1f2f4;
  --brand-sos: #ff6b6b;
  --brand-cloud: #6aa9ff;
  --brand-services: #ffa64d;

  --hdr-bg: rgba(18, 19, 22, .85);
  --hdr-bg-open: #121316;
}

/* ---------- Header ---------- */
.msu-header {
  position: sticky; top: 0; z-index: 300;
  background: var(--hdr-bg);
  -webkit-backdrop-filter: blur(20px); backdrop-filter: blur(20px);
  border-bottom: 1px solid transparent;
  transition: border-color .2s, background-color .2s;
  font-family: var(--hdr-font);
}
.msu-header.is-scrolled, .msu-header.is-open { border-bottom-color: var(--outline-variant); }
.msu-header.is-open { background: var(--hdr-bg-open); }
.msu-header__bar {
  max-width: 1440px; height: var(--hdr-height); margin: 0 auto; padding: 0 24px;
  display: flex; align-items: center; gap: 8px;
}
.msu-header .material-icons { font-size: 20px; line-height: 1; }
/* Simulate + SIT Feedback in the top bar (assets/msu-sim.js, assets/msu-sit.js) */
.msu-hdr-tools { display: flex; align-items: center; gap: 8px; flex: none; }
.msu-hdr-tools:empty { display: none; }
/* tablets — iPad / iPad mini / Android tablet, 721–1023px (checked 2026-10-25: the bar was 8–23px wider than the screen):
   Simulate and Feedback show their icon only and the SIT pill hides its text, as up to 720px; the brand gives way if still too narrow */
@media (max-width: 1023px) {
  .msu-hdr-tools .sit-pill--top .sit-pill__txt, .msu-hdr-tools .sit-pill--top button span.sit-lbl { display: none; }
  .msu-hdr-tools .msu-sim--top .msu-sim__fab .lbl { display: none; }
  .msu-hdr-tools .msu-sim--top .msu-sim__fab { width: 36px; padding: 0; justify-content: center; }
  .msu-brand, .msu-brand__link { min-width: 0; overflow: hidden; }
  .msu-user, .msu-identity { flex: none; }
}
/* narrow phones: the brand gives way (clipped at the right) so the bar never scrolls sideways */
@media (max-width: 520px) {
  .msu-brand-wrap { flex: 1 1 0; }
  .msu-header__spacer { display: none; }
  .msu-user, .msu-identity { flex: none; }
  .msu-brand, .msu-brand__link { min-width: 0; overflow: hidden; }
  .msu-hdr-tools { gap: 4px; }
}

/* brand pill: [MSU-SOS Cloud Services ▾] */
.msu-brand-wrap { position: relative; min-width: 0; }
.msu-brand {
  display: inline-flex; align-items: center; height: 44px; border-radius: 9999px; max-width: 100%;
  transition: box-shadow .2s, background-color .2s;
}
.msu-brand:hover, .msu-header.is-open .msu-brand { box-shadow: 0 0 0 1px var(--outline); background: var(--surface); }
.msu-brand__link {
  display: inline-flex; align-items: center; height: 100%; padding: 0 4px 0 16px; white-space: nowrap;
  font: 700 22px/1 var(--hdr-font); letter-spacing: .02em; text-decoration: none; color: var(--brand-msu);
  border-radius: 9999px 0 0 9999px;
}
.msu-brand__link .msu, .msu-brand__link .dash { color: var(--brand-msu); }
.msu-brand__link .dash { margin: 0 1px; }
.msu-brand__link .sos { color: var(--brand-sos); }
.msu-brand__link .cloud { color: var(--brand-cloud); margin-left: .3em; }
.msu-brand__link .services { color: var(--brand-services); margin-left: .25em; }
.msu-brand__toggle {
  width: 36px; height: 100%; padding: 0 8px 0 2px; border: 0; background: transparent; cursor: pointer;
  display: grid; place-items: center; color: var(--on-surface); border-radius: 0 9999px 9999px 0;
}
.msu-brand__toggle .material-icons { font-size: 24px; transition: transform .25s ease; }
.msu-header.is-open .msu-brand__toggle .material-icons { transform: rotate(180deg); }
.msu-brand__link:focus-visible, .msu-brand__toggle:focus-visible { outline: 2px solid var(--on-surface); outline-offset: -2px; }

.msu-header__spacer { flex: 1; }
.msu-identity { display: flex; align-items: center; gap: 8px; color: var(--on-surface-variant); font: 13px/1.2 var(--hdr-font); min-width: 0; padding: 4px 6px 4px 4px; border: 0; border-radius: 9999px; background: transparent; cursor: pointer; text-decoration: none; transition: background-color .15s; }
.msu-identity:hover, .msu-identity.is-open { background: var(--hover); color: var(--on-surface); }
.msu-identity__chev { font-size: 20px !important; transition: transform .2s; }
.msu-identity.is-open .msu-identity__chev { transform: rotate(180deg); }
.msu-identity:focus-visible { outline: 2px solid var(--on-surface); outline-offset: 1px; }
.msu-identity__avatar { width: 32px; height: 32px; border-radius: 50%; overflow: hidden; background: var(--surface-container-higher); display: grid; place-items: center; color: var(--on-surface); flex: none; }
.msu-identity__avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }
.msu-identity__name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.msu-icon-btn { width: 40px; height: 40px; border: 0; border-radius: 50%; background: transparent; display: grid; place-items: center; cursor: pointer; flex: none; color: var(--on-surface); }
.msu-icon-btn:hover { background: var(--hover); }
.msu-icon-btn:focus-visible { outline: 2px solid var(--on-surface); }

/* ---------- Flyout: vertical dropdown (DeepMind subnav--1-column) ---------- */
.msu-flyout {
  position: absolute; top: calc(100% + 10px); left: 0; width: 400px;
  max-height: calc(100vh - var(--hdr-height) - 24px); max-height: calc(100dvh - var(--hdr-height) - 24px); overflow-y: auto; overscroll-behavior: contain;
  padding: 8px; border-radius: 24px;
  background: var(--surface); border: 1px solid var(--outline-variant);
  box-shadow: 0 16px 40px -12px var(--shadow);
  display: none;
}
.msu-header.is-open .msu-flyout { display: block; animation: msu-flyout-in .2s ease; }
@keyframes msu-flyout-in { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }
.msu-subnav {
  display: flex; flex-direction: column;
  padding: 12px; border-radius: 16px; background: var(--surface-container);
}
.msu-subnav__title { padding: 4px 8px 10px; font: 500 12px/1.4 var(--hdr-font); letter-spacing: .06em; text-transform: uppercase; color: var(--on-surface-variant); }
.msu-subnav__link {
  display: flex; align-items: center; gap: 14px; padding: 8px; border-radius: 16px;
  text-decoration: none; color: inherit; transition: background-color .15s;
}
.msu-subnav__link:hover { background: var(--hover); }
.msu-subnav__link:focus-visible { outline: 2px solid var(--on-surface); outline-offset: -2px; }
.msu-subnav__link[aria-current="page"] { background: var(--selected); }
.msu-icon-tile { width: 48px; height: 48px; border-radius: 16px; display: grid; place-items: center; color: #fff; flex: none; }
.msu-icon-tile .material-icons { font-size: 26px; }
.msu-subnav__text { min-width: 0; }
.msu-subnav__label { display: flex; align-items: center; gap: 8px; font: 500 14.5px/1.45 var(--hdr-font); color: var(--on-surface); }
.msu-subnav__desc { display: block; font: 400 12.5px/1.45 var(--hdr-font); color: var(--on-surface-variant); }
/* the menu in use: highlighted row + a green status dot at its end (2026-10-22, was the "กำลังใช้งาน" label) */
.msu-current-dot { flex: none; width: 10px; height: 10px; margin: 0 6px 0 auto; border-radius: 50%; background: #1e8e3e; box-shadow: 0 0 0 3px rgba(30,142,62,.18); }

.msu-scrim { position: fixed; inset: 0; z-index: 250; background: var(--scrim); display: none; }
.msu-scrim.is-on { display: block; }

.msu-toast {
  position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 20px); z-index: 400;
  background: var(--toast-bg); color: var(--toast-fg); padding: 12px 20px; border-radius: 9999px; font: 14px/1.4 var(--hdr-font);
  opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; max-width: calc(100% - 32px);
}
.msu-toast.is-on { opacity: 1; transform: translate(-50%, 0); }

/* tablet / phone: full-width vertical sheet under the header */
@media (max-width: 1023px) {
  .msu-flyout {
    position: fixed; top: var(--hdr-height); left: 0; right: 0; width: auto;
    border-radius: 0 0 24px 24px; border-width: 0 0 1px; padding: 8px 12px 16px;
    max-height: calc(100vh - var(--hdr-height)); max-height: calc(100dvh - var(--hdr-height)); overflow-y: auto;
  }
  .msu-header.is-open .msu-flyout { animation-name: msu-sheet-in; }
  @keyframes msu-sheet-in { from { opacity: 0; } to { opacity: 1; } }
}
@media (max-width: 720px) {
  .msu-header__bar { padding: 0 8px 0 12px; gap: 4px; }
  .msu-brand__link { font-size: 17px; padding-left: 12px; }
  .msu-identity__name { max-width: 30vw; }
}
@media (max-width: 480px) {
  .msu-identity__name { display: none; }
  .msu-identity { padding: 4px; }
}
@media (max-width: 400px) {
  .msu-brand__link { font-size: 15.5px; padding-left: 10px; }
}

/* ---------- Footer: copyright · developer · mockup version (filled by msu-theme.js) ---------- */
footer.msu-footer, .msu-footer { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 4px 16px; line-height: 1.5; text-align: left; }
.msu-footer__copy a { color: inherit; font-weight: 500; text-decoration: underline; text-decoration-color: color-mix(in srgb, currentColor 35%, transparent); text-underline-offset: 2px; }
.msu-footer__copy a:hover { color: var(--accent); text-decoration-color: currentColor; }
.msu-footer__copy a:focus-visible { outline: 2px solid var(--on-surface); outline-offset: 2px; border-radius: 2px; }
.login-foot.msu-footer, .foot.msu-footer { max-width: 1440px; width: 100%; margin: 0 auto; padding-left: 24px; padding-right: 24px; }
/* left edge lines up with the page content; extra bottom space keeps the text above the bottom-left "Simulate" button */
body:has(.msu-sim) .msu-footer { padding-bottom: 76px; }
@media (max-width: 720px) {
  footer.msu-footer, .msu-footer { flex-direction: column; align-items: flex-start; justify-content: flex-start; gap: 2px; }
  .msu-footer__sep { display: none; }                  /* v0.3.70 (user): "Developed by …" on its own line on phones */
  .msu-footer__dev { display: block; }
  .login-foot.msu-footer, .foot.msu-footer { padding-left: 16px; padding-right: 16px; }
  body:has(.msu-sim) .msu-footer { padding-bottom: 68px; }
}

/* ---------- user menu (Profile · Theme · Manual · Logout) ---------- */
.msu-user { position: relative; min-width: 0; }
.msu-usermenu {
  position: absolute; top: calc(100% + 8px); right: 0; z-index: 320; min-width: 264px; padding: 6px;
  background: var(--surface); border: 1px solid var(--outline-variant); border-radius: 16px;
  box-shadow: 0 16px 40px -12px var(--shadow); animation: msu-flyout-in .15s ease;
}
.msu-usermenu__head { display: flex; align-items: center; gap: 10px; padding: 8px 10px 10px; margin-bottom: 4px; border-bottom: 1px solid var(--outline-variant); font: 500 13.5px/1.3 var(--hdr-font); color: var(--on-surface); overflow-wrap: anywhere; }
.msu-usermenu__role { display: block; margin-top: 2px; font: 400 12px/1.3 var(--hdr-font); color: var(--on-surface-variant); }
.msu-usermenu__item {
  display: flex; align-items: center; gap: 12px; width: 100%; padding: 10px 12px; border: 0; border-radius: 10px;
  background: transparent; color: var(--on-surface); font: 400 14px/1.3 var(--hdr-font); text-align: left; text-decoration: none; cursor: pointer;
}
.msu-usermenu__item .material-icons { font-size: 20px; color: var(--on-surface-variant); }
.msu-usermenu__item:hover, .msu-usermenu__item:focus-visible { background: var(--hover); outline: none; }
.msu-usermenu__item:focus-visible { box-shadow: inset 0 0 0 2px var(--on-surface); }
.msu-usermenu__item[aria-current="page"] { background: var(--selected); }
.msu-usermenu__item--danger, .msu-usermenu__item--danger .material-icons { color: var(--danger); }
.msu-usermenu__sep { height: 1px; margin: 6px 4px; background: var(--outline-variant); }
/* Theme: Auto / Light / Dark */
.msu-theme { padding: 4px 4px 6px; }
.msu-theme__lbl { display: flex; align-items: center; gap: 12px; padding: 6px 8px 8px; font: 400 14px/1.3 var(--hdr-font); color: var(--on-surface); }
.msu-theme__lbl .material-icons { font-size: 20px; color: var(--on-surface-variant); }
.msu-theme__now { margin-left: auto; font-size: 12px; color: var(--on-surface-variant); }
.msu-theme__opts { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); gap: 4px; }   /* Theme 3 · Language 2 */
.msu-langbox { padding-top: 0; } .msu-lang-opt { font: 600 13px/1 var(--hdr-font); letter-spacing: .5px; }
.msu-theme__opt { justify-content: center; padding: 8px 0; border: 1px solid var(--outline-variant); font-size: 13px; }   /* icon only */
.msu-theme__opt .material-icons { font-size: 20px; margin: 0; }
.msu-theme__opt[aria-checked="true"] { background: var(--selected); border-color: var(--accent); color: var(--accent); font-weight: 500; }
.msu-theme__opt[aria-checked="true"] .material-icons { color: var(--accent); }
.msu-theme__hint { padding: 6px 8px 0; font: 400 12px/1.4 var(--hdr-font); color: var(--on-surface-variant); }
.msu-theme__time { display: flex; gap: 8px; padding: 6px 4px 0; }
.msu-theme__time label { flex: 1; display: flex; flex-direction: column; gap: 4px; font: 400 12px/1.3 var(--hdr-font); color: var(--on-surface-variant); }
.msu-theme__time input { height: 34px; padding: 0 8px; border: 1px solid var(--outline); border-radius: 8px; background: var(--surface); color: var(--on-surface); font: inherit; font-size: 13.5px; color-scheme: light dark; }
/* theme switch */
.msu-switch { position: relative; flex: none; width: 36px; height: 20px; margin-left: auto; border-radius: 10px; background: var(--surface-container-higher); box-shadow: inset 0 0 0 1px var(--outline); transition: background-color .15s; }
.msu-switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 14px; height: 14px; border-radius: 50%; background: var(--on-surface-variant); transition: transform .15s, background-color .15s; }
[aria-checked="true"] > .msu-switch { background: var(--accent); box-shadow: none; }
[aria-checked="true"] > .msu-switch::after { transform: translateX(16px); background: var(--on-accent); }
@media (max-width: 480px) {
  .msu-usermenu { position: fixed; top: calc(var(--hdr-height) + 4px); right: 8px; left: auto; min-width: 0; width: min(280px, calc(100vw - 16px)); }
}
.msu-newtab { font-size: 15px; margin-left: 6px; vertical-align: -2px; color: var(--on-surface-variant); }
