/* =============================================================================
   VZF Overlay Studio — gaya dashboard
   ============================================================================= */

:root {
  --bg: #0f1115;
  --panel: #171a21;
  --panel-2: #1e222b;
  --line: #2a2f3a;
  --text: #e8ebf0;
  --muted: #9aa3b2;
  --accent: #3ea6ff;
  --accent-ink: #05131f;
  --danger: #ef4444;
  --warn: #f59e0b;
  --ok: #22c55e;
  --radius: 10px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  font-size: 15px;
  line-height: 1.5;
}

h1, h2, h3 { margin: 0 0 .4rem; line-height: 1.25; }
h1 { font-size: 1.5rem; }
h2 { font-size: 1.2rem; }
h3 { font-size: 1.05rem; }

code { font-family: 'Cascadia Code', 'Consolas', monospace; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .4rem;
  padding: .55rem 1rem;
  border: 1px solid transparent;
  border-radius: 8px;
  font-size: .9rem;
  font-weight: 600;
  cursor: pointer;
  background: var(--panel-2);
  color: var(--text);
  transition: filter .15s, background .15s, border-color .15s;
  white-space: nowrap;
}
.btn:hover { filter: brightness(1.14); }
.btn:disabled { opacity: .55; cursor: not-allowed; filter: none; }

.btn-primary { background: var(--accent); color: var(--accent-ink); }
.btn-ghost { background: transparent; border-color: var(--line); color: var(--text); }
.btn-danger { background: transparent; border-color: #6b2530; color: #ff8b8b; }
.btn-warning { background: transparent; border-color: #6b4c15; color: #fbbf24; }
.btn-sm { padding: .35rem .7rem; font-size: .82rem; }

/* ---------- Inputs ---------- */
input, select, textarea {
  width: 100%;
  padding: .55rem .7rem;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  font-size: .92rem;
  font-family: inherit;
}
input:focus, select:focus { outline: 2px solid var(--accent); outline-offset: -1px; }

label {
  display: block;
  font-size: .82rem;
  font-weight: 600;
  color: var(--muted);
  margin: .75rem 0 .3rem;
}

.msg { font-size: .85rem; min-height: 1.2em; margin: .6rem 0 0; color: var(--muted); }
.msg.ok { color: var(--ok); }
.msg.err { color: #ff8b8b; }

.hint { font-size: .8rem; color: var(--muted); margin: .6rem 0 0; }
.empty-note { font-size: .85rem; color: var(--muted); padding: .5rem; }

/* ---------- Auth ---------- */
.auth-view {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 1.5rem;
}
.auth-card {
  width: 100%;
  max-width: 400px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 1.75rem;
}
.auth-sub { color: var(--muted); font-size: .88rem; margin: 0 0 1rem; }
.auth-actions { display: flex; gap: .5rem; margin-top: 1.25rem; }
.auth-actions .btn { flex: 1; }
.auth-foot { font-size: .78rem; color: var(--muted); margin: 1rem 0 0; }

/* ---------- Topbar ---------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: .8rem 1.25rem;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 20;
}
.brand { font-weight: 800; letter-spacing: .3px; }
.brand span { color: var(--accent); font-weight: 600; }
.topbar-right { display: flex; align-items: center; gap: .8rem; }
.user-email { font-size: .82rem; color: var(--muted); }

/* ---------- Layout ---------- */
.layout {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
  gap: 1.25rem;
  padding: 1.25rem;
  align-items: start;
  max-width: 1400px;
  margin: 0 auto;
}

@media (max-width: 860px) {
  .layout { grid-template-columns: 1fr; }
}

/* ---------- Sidebar ---------- */
.sidebar {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: .9rem;
  position: sticky;
  top: 4.4rem;
}
.sidebar-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .5rem;
  font-size: .8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: var(--muted);
  margin-bottom: .7rem;
}

.overlay-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: .35rem; }

.overlay-item {
  display: flex;
  align-items: center;
  gap: .5rem;
  padding: .55rem .65rem;
  border-radius: 8px;
  cursor: pointer;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text);
  width: 100%;
  text-align: left;
  font: inherit;
}
.overlay-item:hover { background: var(--panel-2); }
.overlay-item.is-active { background: var(--panel-2); border-color: var(--accent); }
.overlay-item.is-off .overlay-name { opacity: .5; }

.overlay-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ok); flex: 0 0 auto; }
.overlay-item.is-off .overlay-dot { background: #556; }

.overlay-name {
  flex: 1 1 auto;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: .9rem;
  font-weight: 600;
}
.overlay-kind {
  font-size: .68rem;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: var(--muted);
  flex: 0 0 auto;
}

/* ---------- Detail ---------- */
.detail { min-width: 0; }
.placeholder {
  background: var(--panel);
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  padding: 3rem 1.5rem;
  text-align: center;
  color: var(--muted);
}

.detail-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}
.detail-head-actions { display: flex; gap: .5rem; flex-wrap: wrap; }

.badge {
  display: inline-block;
  font-size: .7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .6px;
  padding: .2rem .5rem;
  border-radius: 5px;
  background: var(--panel-2);
  color: var(--muted);
  border: 1px solid var(--line);
  margin-right: .35rem;
}
.badge-ok { color: #86efac; border-color: #1e4d31; background: #10251a; }
.badge-off { color: #fca5a5; border-color: #6b2530; background: #261214; }

/* ---------- Card ---------- */
.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  margin-bottom: 1rem;
  overflow: hidden;
}
.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .75rem;
  padding: .7rem 1rem;
  background: var(--panel-2);
  border-bottom: 1px solid var(--line);
  font-size: .85rem;
  font-weight: 700;
}
.card-body { padding: 1rem; }

.url-box {
  display: block;
  padding: .6rem .75rem;
  background: #0a0c10;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: .8rem;
  color: #9ad1ff;
  word-break: break-all;
}

/* ---------- Preview ---------- */
.preview-frame {
  width: 100%;
  aspect-ratio: 16 / 9;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid var(--line);
  background-color: #0b0d11;
  background-image:
    linear-gradient(45deg, #15181f 25%, transparent 25%, transparent 75%, #15181f 75%),
    linear-gradient(45deg, #15181f 25%, transparent 25%, transparent 75%, #15181f 75%);
  background-size: 20px 20px;
  background-position: 0 0, 10px 10px;
}
.preview-frame iframe { width: 100%; height: 100%; border: 0; display: block; }

/* ---------- Chat form ---------- */
.chat-form {
  display: grid;
  grid-template-columns: 160px minmax(0, 1fr) auto;
  gap: .5rem;
}
@media (max-width: 640px) {
  .chat-form { grid-template-columns: 1fr; }
}

.chat-recent {
  list-style: none;
  margin: .9rem 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: .3rem;
  max-height: 220px;
  overflow-y: auto;
}
.chat-recent li {
  font-size: .84rem;
  padding: .4rem .6rem;
  background: var(--panel-2);
  border-radius: 6px;
  border-left: 3px solid var(--accent);
}
.chat-recent b { color: #9ad1ff; }

/* ---------- Milestone ---------- */
.ms-summary {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: .6rem;
  margin-bottom: .9rem;
}
.ms-num {
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: .6rem .75rem;
}
.ms-num-label {
  display: block;
  font-size: .72rem;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: var(--muted);
}
.ms-num strong { font-size: 1.1rem; font-variant-numeric: tabular-nums; }

.row-inline { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }
.row-inline input { flex: 1 1 160px; }
.row-inline.mt { margin-top: .6rem; }

.ms-empty {
  background: var(--panel-2);
  border: 1px dashed var(--line);
  border-radius: 8px;
  padding: 1rem;
  text-align: center;
}
.ms-empty p { margin: 0 0 .7rem; color: var(--muted); font-size: .88rem; }

.history { margin-top: 1rem; border-top: 1px solid var(--line); padding-top: .8rem; }
.history summary {
  cursor: pointer;
  font-size: .84rem;
  font-weight: 700;
  color: var(--muted);
}
.history-list {
  list-style: none;
  margin: .6rem 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: .3rem;
  font-size: .82rem;
  color: var(--muted);
}
.history-list li {
  display: flex;
  justify-content: space-between;
  gap: .6rem;
  padding: .35rem .55rem;
  background: var(--panel-2);
  border-radius: 6px;
}

/* ---------- Settings form ---------- */
.settings-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: .9rem 1rem;
}
.field { display: flex; flex-direction: column; }
.field label { margin-top: 0; }
.field-wide { grid-column: 1 / -1; }

input[type="color"] {
  padding: .2rem;
  height: 38px;
  cursor: pointer;
}
input[type="range"] { padding: 0; accent-color: var(--accent); }

.check-row {
  display: flex;
  align-items: center;
  gap: .5rem;
  font-size: .88rem;
}
.check-row input[type="checkbox"] { width: auto; }

/* ---------- Modal ---------- */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .65);
  display: grid;
  place-items: center;
  padding: 1.25rem;
  z-index: 100;
}

/* [hidden] harus menang atas display:grid/flex di atas. */
[hidden] { display: none !important; }
.modal-card {
  width: 100%;
  max-width: 420px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 1.35rem;
}
.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: .5rem;
  margin-top: 1.25rem;
}

/* =============================================================================
   Milestone editor
   ============================================================================= */

.ms-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: .9rem 1rem;
}

.label-note {
  font-weight: 500;
  text-transform: none;
  letter-spacing: 0;
  opacity: .7;
}

textarea {
  width: 100%;
  padding: .55rem .7rem;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  font-size: .92rem;
  font-family: inherit;
  line-height: 1.45;
  resize: vertical;
}
textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; }

.ms-progress-readout {
  display: flex;
  align-items: baseline;
  gap: .6rem;
  padding: .55rem .7rem;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 8px;
}
.ms-progress-readout strong { font-size: 1.1rem; color: var(--accent); }
.ms-progress-readout span { font-size: .8rem; color: var(--muted); }

.hint-inline {
  font-size: .78rem;
  color: var(--muted);
  flex: 1 1 auto;
}

.history-empty {
  color: var(--muted);
  font-size: .82rem;
  padding: .5rem;
  display: block !important;
}

/* Pratinjau lebih pendek untuk overlay milestone (kartu lebar & tipis) */
.preview-frame.is-milestone { aspect-ratio: 840 / 240; }

/* =============================================================================
   Tema editor
   ============================================================================= */

.theme-picker { margin-bottom: .9rem; }
.theme-picker label { margin-top: 0; }

.theme-toolbar {
  display: flex;
  gap: .5rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
  padding-bottom: .9rem;
  border-bottom: 1px solid var(--line);
}

.vars-form { display: flex; flex-direction: column; gap: 1.1rem; }

.vars-group-head {
  font-size: .72rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .7px;
  color: var(--muted);
  margin-bottom: .5rem;
}

.vars-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: .7rem .9rem;
  align-items: start;
}

.vars-grid .field label {
  font-size: .76rem;
  margin-bottom: .25rem;
}

.vars-grid input[type="number"],
.vars-grid input[type="text"],
.vars-grid select {
  padding: .4rem .55rem;
  font-size: .85rem;
}

.vars-grid input[type="color"] { height: 32px; }

.color-alpha-row {
  display: flex;
  align-items: center;
  gap: .45rem;
}
.color-alpha-row input[type="color"] { flex: 0 0 44px; }
.color-alpha-row input[type="range"] { flex: 1 1 auto; }

.alpha-label {
  font-size: .72rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  min-width: 34px;
  text-align: right;
}

/* Daftar tema tersimpan */
.theme-list {
  list-style: none;
  margin: 0 0 .5rem;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: .45rem;
  max-height: 46vh;
  overflow-y: auto;
}

.theme-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .75rem;
  padding: .6rem .75rem;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.theme-item-info { display: flex; flex-direction: column; gap: .1rem; min-width: 0; }
.theme-item-info strong { font-size: .9rem; }
.theme-item-meta { font-size: .74rem; color: var(--muted); }

.modal-wide { max-width: 560px; }
