/* SCUBANINE admin panel */

:root {
  --ink: #070c16;
  --panel: #0e1626;
  --panel-2: #131f34;
  --line: rgba(148, 187, 233, .15);
  --line-2: rgba(148, 187, 233, .3);
  --text: #e9f1fb;
  --muted: #93a8c4;
  --dim: #647999;
  --brand: #17a3e0;
  --brand-2: #22d3ee;
  --ok: #34d399;
  --warn: #fbbf24;
  --bad: #f0544f;
  --r: 12px;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; background: var(--ink); color: var(--text);
  font-family: "Noto Sans Thai", -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
  font-size: 15px; line-height: 1.65; -webkit-font-smoothing: antialiased;
}
img { display: block; max-width: 100%; }
a { color: var(--brand-2); text-decoration: none; }
h1, h2, h3 { margin: 0 0 .5em; line-height: 1.3; }
:focus-visible { outline: 2px solid var(--brand-2); outline-offset: 2px; }
[hidden] { display: none !important; }

/* icons drawn by JS */
i[data-i] { display: inline-flex; width: 18px; height: 18px; flex: 0 0 auto; }
i[data-i] svg { width: 100%; height: 100%; }

/* ------------------------------------------------------------- controls -- */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 18px; border-radius: 999px; border: 1px solid transparent;
  font: inherit; font-weight: 600; font-size: .92rem; cursor: pointer; background: none;
  color: var(--text); transition: all .16s ease; white-space: nowrap;
}
.btn-primary { background: linear-gradient(135deg, var(--brand), var(--brand-2)); color: #04121d; }
.btn-primary:hover { filter: brightness(1.08); }
.btn-ghost { border-color: var(--line-2); background: rgba(255, 255, 255, .03); }
.btn-ghost:hover { border-color: var(--brand); background: rgba(23, 163, 224, .12); }
.btn-danger { border-color: rgba(240, 84, 79, .45); color: #ffb4b0; background: rgba(240, 84, 79, .08); }
.btn-danger:hover { background: rgba(240, 84, 79, .2); }
.btn-sm { padding: 7px 13px; font-size: .84rem; }
.btn-block { width: 100%; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.icon-btn {
  display: grid; place-items: center; width: 38px; height: 38px; border-radius: 10px;
  border: 1px solid var(--line); background: rgba(255, 255, 255, .03); cursor: pointer; color: var(--muted);
}
.icon-btn:hover { color: var(--text); border-color: var(--line-2); }

.inp, input[type="text"], input[type="password"], input[type="number"], input[type="date"],
input[type="search"], input[type="email"], input[type="url"], select, textarea {
  width: 100%; padding: 10px 13px; border-radius: 10px; border: 1px solid var(--line-2);
  background: rgba(4, 8, 15, .6); color: var(--text); font: inherit; font-size: .93rem;
}
textarea { resize: vertical; min-height: 92px; line-height: 1.6; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--brand); background: rgba(4, 8, 15, .85); }
.inp-sm { padding: 7px 11px; font-size: .86rem; max-width: 240px; }
select { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 17px) 50%, calc(100% - 12px) 50%; background-size: 5px 5px, 5px 5px; background-repeat: no-repeat; padding-right: 32px; }

.f { display: flex; flex-direction: column; gap: 6px; margin-bottom: 15px; }
.f > span { font-size: .84rem; color: var(--muted); font-weight: 500; }
.f .hint { font-size: .78rem; color: var(--dim); font-weight: 400; }
.f-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 0 14px; }
.f-check { flex-direction: row; align-items: center; gap: 10px; }
.f-check input { width: 18px; height: 18px; accent-color: var(--brand); }

.msg { min-height: 1.2em; font-size: .88rem; margin: 10px 0 0; }
.msg.err { color: #ffb4b0; }
.msg.ok { color: var(--ok); }

/* ---------------------------------------------------------------- login -- */

.login { min-height: 100dvh; display: grid; place-items: center; padding: 24px;
  background: radial-gradient(700px 500px at 50% -10%, rgba(23, 163, 224, .2), transparent 60%), var(--ink); }
.login-card { width: min(100%, 380px); padding: 34px 30px; border-radius: 20px;
  background: var(--panel); border: 1px solid var(--line); text-align: center; }
.login-logo { width: 52px; height: 52px; margin: 0 auto 14px; color: var(--brand-2); }
.login-card h1 { font-size: 1.5rem; letter-spacing: .08em; margin-bottom: .1em; }
.login-card .sub { color: var(--dim); font-size: .86rem; margin: 0 0 26px; }
.login-card .f { text-align: left; }

/* ------------------------------------------------------------------ app -- */

.app { display: grid; grid-template-columns: 246px minmax(0, 1fr); min-height: 100dvh; }

.side { display: flex; flex-direction: column; background: var(--panel); border-right: 1px solid var(--line);
  position: sticky; top: 0; height: 100dvh; z-index: 40; }
.side-top { display: flex; align-items: center; gap: 11px; padding: 18px 20px 16px; border-bottom: 1px solid var(--line); }
.side-logo { width: 34px; height: 34px; object-fit: contain; flex: 0 0 auto; }
.side-name { min-width: 0; }
.side-top strong { display: block; font-size: 1.16rem; letter-spacing: .07em; }
.side-top small { color: var(--dim); font-size: .74rem; }
.login-logo img { width: 64px; height: 64px; object-fit: contain; }
.side-nav { flex: 1; overflow-y: auto; padding: 12px 10px; display: flex; flex-direction: column; gap: 2px; }
.side-nav button {
  display: flex; align-items: center; gap: 11px; width: 100%; padding: 10px 13px; border: 0;
  border-radius: 10px; background: none; color: var(--muted); font: inherit; font-size: .92rem;
  cursor: pointer; text-align: start; transition: all .15s ease;
}
.side-nav button:hover { background: rgba(255, 255, 255, .05); color: var(--text); }
.side-nav button.is-active { background: rgba(23, 163, 224, .15); color: var(--brand-2); font-weight: 600; }
.side-nav .badge { margin-inline-start: auto; background: var(--brand); color: #04121d; border-radius: 99px;
  padding: 1px 8px; font-size: .74rem; font-weight: 700; }
.side-nav .badge:empty { display: none; }
.side-foot { padding: 12px 10px; border-top: 1px solid var(--line); display: grid; gap: 7px; }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 30; display: flex; align-items: center; gap: 14px;
  padding: 14px 24px; background: rgba(7, 12, 22, .9); backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line); min-height: 66px;
}
.topbar h1 { font-size: 1.22rem; margin: 0; }
.topbar-actions { margin-inline-start: auto; display: flex; gap: 9px; flex-wrap: wrap; }
.only-mobile { display: none; }

.view { padding: 24px; max-width: 1180px; width: 100%; }

/* ---------------------------------------------------------------- pieces -- */

.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 14px; margin-bottom: 26px; }
.stat { padding: 20px; border-radius: var(--r); background: var(--panel); border: 1px solid var(--line); }
.stat b { display: block; font-size: 2rem; line-height: 1.1; color: var(--brand-2); }
.stat span { color: var(--muted); font-size: .88rem; }

.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; margin-bottom: 22px; }
.panel-head { display: flex; align-items: center; gap: 12px; padding: 15px 18px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.panel-head h2 { margin: 0; font-size: 1.02rem; }
.panel-head .btn { margin-inline-start: auto; }
.panel-body { padding: 18px; }
.panel-body > .f:last-child { margin-bottom: 0; }

.rows { display: flex; flex-direction: column; }
.row {
  display: flex; align-items: center; gap: 14px; padding: 12px 18px; border-bottom: 1px solid var(--line);
}
.row:last-child { border-bottom: 0; }
.row:hover { background: rgba(255, 255, 255, .022); }
.row-thumb { width: 62px; height: 46px; border-radius: 8px; object-fit: cover; flex: 0 0 auto; background: var(--panel-2); }
.row-main { flex: 1; min-width: 0; }
.row-main strong { display: block; font-size: .96rem; font-weight: 600; }
.row-main small { color: var(--dim); font-size: .8rem; display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-tags { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 3px; }
.row-acts { display: flex; gap: 7px; flex: 0 0 auto; }

.tag { display: inline-block; padding: 2px 9px; border-radius: 99px; font-size: .73rem; font-weight: 600;
  background: rgba(148, 187, 233, .12); color: var(--muted); }
.tag-on { background: rgba(52, 211, 153, .15); color: var(--ok); }
.tag-off { background: rgba(240, 84, 79, .14); color: #ffb4b0; }
.tag-star { background: rgba(251, 191, 36, .15); color: var(--warn); }
.tag-brand { background: rgba(23, 163, 224, .16); color: var(--brand-2); }

.empty { padding: 40px; text-align: center; color: var(--dim); }
.note { padding: 13px 16px; border-radius: 10px; background: rgba(23, 163, 224, .08);
  border: 1px solid rgba(23, 163, 224, .25); color: var(--muted); font-size: .87rem; margin-bottom: 18px; }
.note b { color: var(--text); }

/* --------------------------------------------------------------- drawer -- */

.scrim { position: fixed; inset: 0; background: rgba(3, 6, 12, .7); backdrop-filter: blur(3px); z-index: 50;
  opacity: 0; pointer-events: none; transition: opacity .2s ease; }
.scrim.is-on { opacity: 1; pointer-events: auto; }

.drawer {
  position: fixed; top: 0; inset-inline-end: 0; height: 100dvh; width: min(100%, 740px); z-index: 60;
  background: var(--panel); border-inline-start: 1px solid var(--line);
  display: flex; flex-direction: column; transform: translateX(100%);
  transition: transform .25s ease; box-shadow: -20px 0 60px -20px rgba(0, 0, 0, .8);
}
.drawer.is-open { transform: none; }
.drawer-head { display: flex; align-items: center; gap: 14px; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.drawer-head h2 { margin: 0; font-size: 1.08rem; flex: 1; }
.drawer-body { flex: 1; overflow-y: auto; padding: 20px; }
.drawer-foot { display: flex; gap: 10px; justify-content: flex-end; padding: 14px 20px;
  border-top: 1px solid var(--line); background: rgba(7, 12, 22, .6); }

fieldset.grp { border: 1px solid var(--line); border-radius: var(--r); padding: 16px; margin: 0 0 18px; }
fieldset.grp > legend { padding: 0 8px; font-size: .82rem; color: var(--brand-2); font-weight: 600; }

details.grp-en {
  border: 1px solid rgba(52, 211, 153, .3); border-radius: var(--r);
  background: rgba(52, 211, 153, .05); margin: 0 0 18px; overflow: hidden;
}
details.grp-en > summary {
  padding: 13px 16px; cursor: pointer; font-size: .87rem; font-weight: 600; color: var(--ok);
  list-style: none;
}
details.grp-en > summary::-webkit-details-marker { display: none; }
details.grp-en > summary::before { content: "▸ "; }
details.grp-en[open] > summary::before { content: "▾ "; }
details.grp-en[open] > summary { border-bottom: 1px solid rgba(52, 211, 153, .22); }
.grp-en-body { padding: 16px; }
.grp-en-body > .f:last-child { margin-bottom: 0; }

/* repeaters */
.rep { display: flex; flex-direction: column; gap: 10px; }
.rep-i { display: flex; gap: 10px; align-items: flex-start; padding: 12px; border-radius: 10px;
  border: 1px solid var(--line); background: rgba(4, 8, 15, .35); }
.rep-i .grow { flex: 1; min-width: 0; display: grid; gap: 8px; }
.rep-i .handle { color: var(--dim); cursor: grab; padding-top: 8px; }
.rep-add { align-self: flex-start; }
.rep-thumb { width: 76px; height: 60px; border-radius: 8px; object-fit: cover; background: var(--panel-2); flex: 0 0 auto; cursor: pointer; }

.img-field { display: flex; gap: 12px; align-items: center; }
.img-field img { width: 96px; height: 72px; border-radius: 10px; object-fit: cover; background: var(--panel-2); border: 1px solid var(--line); }
.img-field .img-acts { display: grid; gap: 6px; }

/* ---------------------------------------------------------------- modal -- */

.modal { position: fixed; inset: 0; z-index: 70; display: grid; place-items: center; padding: 24px;
  background: rgba(3, 6, 12, .82); backdrop-filter: blur(5px); }
.modal-card { width: min(100%, 1000px); max-height: 88dvh; display: flex; flex-direction: column;
  background: var(--panel); border: 1px solid var(--line); border-radius: 18px; overflow: hidden; }
.modal-head { display: flex; align-items: center; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.modal-head h2 { margin: 0; font-size: 1.05rem; flex: 1; }
.modal-tools { display: flex; align-items: center; gap: 12px; padding: 13px 20px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.modal-body { flex: 1; overflow-y: auto; padding: 18px 20px; }
.upload-btn { position: relative; overflow: hidden; }
.up-status { font-size: .84rem; color: var(--muted); }

.picker-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(132px, 1fr)); gap: 12px; align-content: start; }
.pk {
  position: relative; border-radius: 10px; overflow: hidden; border: 2px solid transparent; cursor: pointer;
  background: var(--panel-2); padding: 0;
}
.pk img { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; }
.pk:hover { border-color: var(--brand); }
.pk-del { position: absolute; top: 5px; inset-inline-end: 5px; width: 26px; height: 26px; border-radius: 7px;
  border: 0; background: rgba(3, 6, 12, .75); color: #ffb4b0; display: grid; place-items: center; cursor: pointer; }
.pk-del i { width: 14px; height: 14px; }
.pk-lbl { position: absolute; inset-inline: 0; bottom: 0; padding: 4px 7px; font-size: .68rem;
  background: linear-gradient(transparent, rgba(3, 6, 12, .9)); color: var(--muted);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-align: start; }
.pk-group { grid-column: 1 / -1; font-size: .8rem; color: var(--dim); font-weight: 600;
  letter-spacing: .04em; text-transform: uppercase; margin-top: 6px; }

/* ---------------------------------------------------------------- toast -- */

.toast {
  position: fixed; inset-inline: 0; bottom: 24px; margin: auto; width: max-content; max-width: 90vw; z-index: 90;
  padding: 12px 22px; border-radius: 999px; background: var(--panel-2); border: 1px solid var(--line-2);
  box-shadow: 0 14px 40px -14px rgba(0, 0, 0, .9); font-size: .9rem; font-weight: 500;
  opacity: 0; transform: translateY(12px); pointer-events: none; transition: all .22s ease;
}
.toast.is-on { opacity: 1; transform: none; }
.toast.ok { border-color: rgba(52, 211, 153, .5); color: var(--ok); }
.toast.err { border-color: rgba(240, 84, 79, .5); color: #ffb4b0; }

/* table-ish leads */
.lead-card { padding: 15px 18px; border-bottom: 1px solid var(--line); display: grid; gap: 6px; }
.lead-card:last-child { border-bottom: 0; }
.lead-top { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.lead-top strong { font-size: .98rem; }
.lead-top time { color: var(--dim); font-size: .8rem; margin-inline-start: auto; }
.lead-meta { display: flex; gap: 16px; flex-wrap: wrap; color: var(--muted); font-size: .87rem; }
.lead-meta a:hover { text-decoration: underline; }
.lead-msg { color: var(--muted); font-size: .89rem; white-space: pre-wrap; background: rgba(4, 8, 15, .4);
  padding: 10px 13px; border-radius: 9px; border: 1px solid var(--line); }


/* ---------------------------------------------------------- live preview -- */

.live-bar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }
.live-bar #livePage { min-width: 240px; max-width: 340px; }
.seg { display: inline-flex; border: 1px solid var(--line-2); border-radius: 10px; overflow: hidden; }
.seg button {
  border: 0; background: transparent; color: var(--muted); font: inherit; font-size: .85rem;
  padding: 8px 14px; cursor: pointer; display: inline-flex; align-items: center; gap: 6px;
}
.seg button + button { border-inline-start: 1px solid var(--line); }
.seg button:hover { color: var(--text); }
.seg button.is-on { background: var(--brand); color: #04121d; font-weight: 600; }
.seg .ic, .seg svg { width: 17px; height: 17px; }

.live-stage {
  display: flex; justify-content: center; height: calc(100vh - 232px); min-height: 460px;
  background: rgba(4, 8, 15, .45); border: 1px solid var(--line); border-radius: 14px; padding: 12px;
}
.live-frame { width: 100%; height: 100%; border: 0; border-radius: 10px; background: #04080f; }
.live-tablet .live-frame { max-width: 834px; }
.live-mobile .live-frame { max-width: 414px; }

@media (max-width: 900px) {
  .live-stage { height: calc(100vh - 300px); padding: 8px; }
  .live-bar #livePage { min-width: 0; width: 100%; max-width: none; }
}

@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; }
  .side { position: fixed; inset-inline-start: 0; top: 0; width: 262px; transform: translateX(-100%);
    transition: transform .22s ease; }
  .side.is-open { transform: none; }
  .only-mobile { display: grid; }
  .view { padding: 16px; }
  .topbar { padding: 12px 16px; }
  .row { flex-wrap: wrap; }
  .row-acts { width: 100%; justify-content: flex-end; }
}
