/* =====================================================================
   Helpdesk Gangguan — Dashboard
   Identitas visual: panel depan modem. Status tiket = lampu indikator.
   ===================================================================== */
:root {
  --petrol: #0f3b4c;
  --petrol-2: #16505f;
  --paper: #eef2f3;
  --surface: #ffffff;
  --ink: #15232c;
  --muted: #5e707b;
  --line: #d6dfe3;
  --led-green: #1fa971;
  --led-red: #d93a34;
  --led-amber: #d9921e;
  --led-blue: #2f7fc1;
  --led-off: #b9c5cb;
  --radius-s: 4px;
  --radius-m: 8px;
  --font: "Figtree", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --paper: #0d1a20;
    --surface: #142730;
    --ink: #e4ecef;
    --muted: #93a6b0;
    --line: #25404b;
    --led-off: #3a525c;
    --petrol: #0a2a36;
    --petrol-2: #123a48;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; font-family: var(--font); font-size: 15px; line-height: 1.5;
  color: var(--ink); background: var(--paper);
  font-variant-numeric: tabular-nums;
}
a { color: var(--led-blue); }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--led-blue); outline-offset: 2px; }
[hidden] { display: none !important; }

/* ---------- Login ---------- */
.login {
  min-height: 100%; display: grid; grid-template-columns: minmax(0, 1fr) minmax(320px, 440px);
}
.login-panel {
  background: var(--petrol); color: #dce9ee; padding: 48px;
  display: flex; flex-direction: column; justify-content: space-between;
}
.login-panel h1 { font-size: 34px; line-height: 1.15; font-weight: 700; margin: 0 0 12px; max-width: 16ch; color: #fff; }
.login-panel p { max-width: 44ch; margin: 0; color: #a9c3cc; }
.login-leds { display: flex; gap: 22px; margin-top: 40px; }
.login-leds span { display: flex; flex-direction: column; align-items: center; gap: 6px; font-size: 12px; color: #a9c3cc; }
.login-form { padding: 48px 40px; display: flex; flex-direction: column; justify-content: center; gap: 18px; background: var(--surface); }
.login-form img { max-height: 48px; max-width: 180px; object-fit: contain; align-self: flex-start; }
.login-form h2 { margin: 0; font-size: 22px; }
@media (max-width: 760px) {
  .login { grid-template-columns: 1fr; }
  .login-panel { padding: 28px; }
  .login-panel h1 { font-size: 26px; }
}

/* ---------- LED ---------- */
.led {
  width: 10px; height: 10px; border-radius: 50%; display: inline-block; flex: none;
  background: var(--led-off); box-shadow: inset 0 -1px 1px rgba(0,0,0,.25);
}
.led.green { background: var(--led-green); box-shadow: 0 0 6px var(--led-green); }
.led.red { background: var(--led-red); box-shadow: 0 0 6px var(--led-red); }
.led.amber { background: var(--led-amber); box-shadow: 0 0 6px var(--led-amber); }
.led.blue { background: var(--led-blue); box-shadow: 0 0 6px var(--led-blue); }
.led.blink { animation: blink 1s steps(2, jump-none) infinite; }
@keyframes blink { 50% { opacity: .2; box-shadow: none; } }
@media (prefers-reduced-motion: reduce) { .led.blink { animation: none; outline: 2px solid var(--led-red); outline-offset: 2px; } }

/* ---------- Shell ---------- */
.shell { display: grid; grid-template-columns: 232px minmax(0, 1fr); min-height: 100%; }
.side {
  background: var(--petrol); color: #cfe0e6; display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh; padding: 20px 12px;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 0 8px 20px; }
.brand img { max-height: 34px; max-width: 150px; object-fit: contain; background: #fff; border-radius: var(--radius-s); padding: 3px; }
.brand strong { color: #fff; font-size: 15px; line-height: 1.2; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  color: #cfe0e6; text-decoration: none; padding: 9px 12px; border-radius: var(--radius-s);
}
.nav a:hover { background: var(--petrol-2); color: #fff; }
.nav a.active { background: #fff; color: var(--petrol); font-weight: 600; }
.nav .count { font-size: 12px; background: var(--led-red); color: #fff; border-radius: 10px; padding: 0 7px; min-width: 20px; text-align: center; }
.side-foot { margin-top: auto; padding: 12px 8px 0; border-top: 1px solid var(--petrol-2); font-size: 13px; }
.side-foot .who { color: #fff; font-weight: 600; }
.side-foot button { background: none; border: 0; color: #a9c3cc; padding: 6px 0; cursor: pointer; text-decoration: underline; }

main { padding: 28px 32px 48px; min-width: 0; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 20px; }
.page-head h1 { margin: 0; font-size: 26px; line-height: 1.2; }
.page-head p { margin: 4px 0 0; color: var(--muted); }

@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: fixed; inset: 0 auto 0 0; width: 240px; z-index: 40; transform: translateX(-100%); transition: transform .2s; }
  .side.open { transform: none; }
  .btn.menu-btn { display: inline-flex; margin-bottom: 12px; }
  main { padding: 16px; }
}

/* ---------- Modem panel (signature) ---------- */
.modem {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-m);
  display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); margin-bottom: 24px; overflow: hidden;
}
.modem button {
  all: unset; cursor: pointer; padding: 18px 20px; display: grid; gap: 4px;
  border-right: 1px solid var(--line);
}
.modem button:last-child { border-right: 0; }
.modem button:hover { background: var(--paper); }
.modem button:focus-visible { outline: 2px solid var(--led-blue); outline-offset: -2px; }
.modem .lab { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 13px; }
.modem .num { font-size: 32px; font-weight: 700; line-height: 1.1; }

/* ---------- Generic blocks ---------- */
.grid-2 { display: grid; grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); gap: 20px; }
@media (max-width: 1100px) { .grid-2 { grid-template-columns: 1fr; } }
.box { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-m); padding: 18px 20px; min-width: 0; }
.box h2 { font-size: 16px; margin: 0 0 14px; }
.box + .box { margin-top: 20px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }

.bars { display: grid; gap: 10px; }
.bar { display: grid; grid-template-columns: 170px 1fr 36px; align-items: center; gap: 10px; font-size: 14px; }
.bar .track { height: 10px; background: var(--paper); border-radius: 5px; overflow: hidden; }
.bar .fill { height: 100%; background: var(--petrol-2); }
@media (prefers-color-scheme: dark) { .bar .fill { background: var(--led-blue); } }
.spark { display: flex; align-items: flex-end; gap: 4px; height: 90px; }
.spark div { flex: 1; background: var(--led-blue); opacity: .75; border-radius: 2px 2px 0 0; min-height: 2px; position: relative; }
.spark-labels { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); margin-top: 6px; }

/* ---------- Table ---------- */
.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-m); }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 10px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; white-space: nowrap; }
th { font-weight: 600; color: var(--muted); font-size: 13px; background: var(--surface); position: sticky; top: 0; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr.click { cursor: pointer; }
tbody tr.click:hover { background: var(--paper); }
td.wrap { white-space: normal; min-width: 200px; }
.tno { font-weight: 600; }
.status { display: inline-flex; align-items: center; gap: 7px; }
.prio { font-size: 13px; padding: 1px 8px; border-radius: 10px; border: 1px solid var(--line); }
.prio.critical { background: var(--led-red); color: #fff; border-color: var(--led-red); }
.prio.high { color: var(--led-red); border-color: currentColor; }
.prio.medium { color: var(--led-amber); border-color: currentColor; }
.late { color: var(--led-red); font-weight: 600; }

/* ---------- Forms ---------- */
.filters { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 14px; }
label.f { display: grid; gap: 5px; font-size: 13px; color: var(--muted); }
label.f > span { font-weight: 600; }
input[type=text], input[type=email], input[type=password], input[type=time], input[type=date], input[type=url], input[type=search], select, textarea {
  width: 100%; padding: 9px 11px; border: 1px solid var(--line); border-radius: var(--radius-s);
  background: var(--surface); color: var(--ink); font-size: 15px;
}
textarea { min-height: 90px; resize: vertical; }
.filters input, .filters select { width: auto; min-width: 150px; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px; }
.form-grid .full { grid-column: 1 / -1; }
.days { display: flex; flex-wrap: wrap; gap: 8px; }
.days label { display: inline-flex; align-items: center; gap: 5px; color: var(--ink); font-size: 14px; }

.btn {
  display: inline-flex; align-items: center; gap: 6px; padding: 9px 16px; border-radius: var(--radius-s);
  border: 1px solid var(--petrol); background: var(--petrol); color: #fff; font-weight: 600; cursor: pointer; text-decoration: none;
}
.btn:hover { background: var(--petrol-2); }
.btn.ghost { background: transparent; color: var(--ink); border-color: var(--line); }
.btn.ghost:hover { background: var(--paper); }
.btn.danger { background: var(--led-red); border-color: var(--led-red); }
.btn:disabled { opacity: .55; cursor: progress; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.err { color: var(--led-red); font-size: 14px; min-height: 1.2em; }

/* Tombol menu hanya untuk layar kecil (didefinisikan setelah .btn agar menang) */
.btn.menu-btn { display: none; }
@media (max-width: 900px) { .btn.menu-btn { display: inline-flex; margin-bottom: 12px; } }
.side-foot .muted { color: #a9c3cc; }

/* ---------- Ticket detail ---------- */
.detail { display: grid; grid-template-columns: minmax(0, 2fr) minmax(260px, 1fr); gap: 20px; }
@media (max-width: 1000px) { .detail { grid-template-columns: 1fr; } }
dl.kv { display: grid; grid-template-columns: 130px 1fr; gap: 8px 12px; margin: 0; font-size: 14px; }
dl.kv dt { color: var(--muted); }
dl.kv dd { margin: 0; }
.desc { white-space: pre-wrap; background: var(--paper); border-radius: var(--radius-s); padding: 12px 14px; margin: 14px 0 0; max-width: 72ch; }
.thumbs { display: flex; flex-wrap: wrap; gap: 10px; }
.thumbs a { display: grid; gap: 4px; font-size: 12px; color: var(--muted); text-decoration: none; }
.thumbs img { width: 132px; height: 100px; object-fit: cover; border-radius: var(--radius-s); border: 1px solid var(--line); }
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { position: relative; padding: 0 0 14px 20px; font-size: 14px; }
.timeline li::before { content: ""; position: absolute; left: 4px; top: 7px; width: 7px; height: 7px; border-radius: 50%; background: var(--led-off); }
.timeline li::after { content: ""; position: absolute; left: 7px; top: 16px; bottom: 0; width: 1px; background: var(--line); }
.timeline li:last-child::after { display: none; }
.timeline .when { color: var(--muted); font-size: 12px; }

/* ---------- Inbox ---------- */
.inbox { display: grid; grid-template-columns: 300px minmax(0, 1fr); height: calc(100vh - 150px); min-height: 460px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-m); overflow: hidden; }
.conv-list { border-right: 1px solid var(--line); overflow-y: auto; }
.conv { all: unset; box-sizing: border-box; display: grid; gap: 2px; width: 100%; padding: 12px 14px; border-bottom: 1px solid var(--line); cursor: pointer; }
.conv:hover, .conv.active { background: var(--paper); }
.conv .top { display: flex; justify-content: space-between; gap: 8px; font-weight: 600; font-size: 14px; }
.conv .snip { color: var(--muted); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.conv .unread { background: var(--led-green); color: #fff; border-radius: 10px; padding: 0 7px; font-size: 12px; }
.chat { display: grid; grid-template-rows: auto 1fr auto; min-height: 0; }
.chat-head { padding: 12px 16px; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; align-items: center; }
.msgs { overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 8px; background: var(--paper); }
.msg { max-width: min(560px, 80%); padding: 8px 12px; border-radius: var(--radius-m); white-space: pre-wrap; font-size: 14px; background: var(--surface); border: 1px solid var(--line); align-self: flex-start; }
.msg.out { align-self: flex-end; background: #dff1e8; border-color: #bfe3cf; }
.msg.bot { background: #e6eef6; border-color: #cddbe9; }
@media (prefers-color-scheme: dark) { .msg.out { background: #173f30; border-color: #22573f; } .msg.bot { background: #1a3345; border-color: #24465c; } }
.msg .meta { display: block; font-size: 11px; color: var(--muted); margin-top: 4px; }
.msg img { max-width: 240px; border-radius: var(--radius-s); display: block; margin-bottom: 4px; }
.composer { display: flex; gap: 10px; padding: 12px; border-top: 1px solid var(--line); }
.composer textarea { min-height: 44px; height: 44px; }
@media (max-width: 800px) { .inbox { grid-template-columns: 1fr; height: auto; } .conv-list { max-height: 240px; } .chat { min-height: 480px; } }

/* ---------- Dialog / toast ---------- */
dialog { border: 1px solid var(--line); border-radius: var(--radius-m); padding: 0; width: min(640px, calc(100vw - 32px)); background: var(--surface); color: var(--ink); }
dialog::backdrop { background: rgba(10, 30, 38, .55); }
dialog form { padding: 22px 24px; display: grid; gap: 14px; }
dialog h2 { margin: 0; font-size: 19px; }
.toasts { position: fixed; right: 16px; bottom: 16px; display: grid; gap: 8px; z-index: 60; }
.toast { background: var(--ink); color: var(--paper); padding: 12px 16px; border-radius: var(--radius-m); max-width: 360px; display: flex; gap: 10px; align-items: center; box-shadow: 0 6px 20px rgba(0,0,0,.25); cursor: pointer; }
.pager { display: flex; gap: 8px; align-items: center; justify-content: flex-end; margin-top: 12px; font-size: 14px; }
.empty { padding: 32px; text-align: center; color: var(--muted); }
.stars { color: var(--led-amber); letter-spacing: 1px; }
