/* Stessi colori e stili di Video Review */
:root {
  --bg: #0e0e10;
  --panel: #18181b;
  --panel-2: #1f1f23;
  --border: #2c2c32;
  --text: #efeff1;
  --muted: #a1a1aa;
  --accent: #9147ff;
  --accent-2: #772ce8;
  --green: #22c55e;
  --green-bg: rgba(34, 197, 94, .14);
  --red: #ef4444;
  --red-bg: rgba(239, 68, 68, .14);
  --amber: #f5b301;
  --amber-bg: rgba(245, 179, 1, .12);
  --radius: 10px;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
a { color: #bf94ff; }
.muted { color: var(--muted); }
[hidden] { display: none !important; }

/* ---------- bottoni ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 1px solid transparent; border-radius: 8px;
  padding: 9px 16px; font: inherit; font-weight: 600;
  cursor: pointer; text-decoration: none; color: var(--text); background: var(--panel-2);
  transition: background .12s, border-color .12s, transform .05s;
}
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-sm { padding: 5px 10px; font-size: 13px; }
.btn-ghost { background: transparent; border-color: var(--border); }
.btn-ghost:hover { background: var(--panel-2); }
.btn-primary, .btn-twitch { background: var(--accent); color: #fff; }
.btn-primary:hover, .btn-twitch:hover { background: var(--accent-2); }
.btn-danger { background: var(--red-bg); border-color: rgba(239,68,68,.45); color: #fca5a5; }
.btn-danger:hover { background: var(--red); color: #fff; }

/* ---------- barra superiore ---------- */
.topbar {
  min-height: 56px; display: flex; flex-wrap: wrap; align-items: center; gap: 8px 20px;
  padding: 6px 16px; background: var(--panel); border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 16px; }
.brand-dot { width: 12px; height: 12px; border-radius: 3px; background: var(--accent); }
.view-switch { display: flex; gap: 4px; flex-wrap: wrap; }
.view-switch a {
  padding: 6px 12px; border-radius: 6px; color: var(--muted); text-decoration: none; font-weight: 600;
}
.view-switch a:hover { color: var(--text); }
.view-switch a.active { background: var(--panel-2); color: var(--text); }
.user { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.avatar { width: 26px; height: 26px; border-radius: 50%; object-fit: cover; }

/* menu utente (avatar Twitch): uguale in Video Review e ModTools */
.user-menu { position: relative; }
.user-btn {
  display: flex; align-items: center; gap: 8px; padding: 3px 8px 3px 3px; border-radius: 999px;
  border: 1px solid transparent; background: transparent; color: var(--text); font: inherit; font-weight: 600; cursor: pointer;
}
.user-btn:hover, .user-btn[aria-expanded="true"] { background: var(--panel-2); border-color: var(--border); }
.user-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.user-btn .avatar { width: 30px; height: 30px; }
.menu {
  position: absolute; top: calc(100% + 8px); right: 0; z-index: 20; min-width: 220px;
  display: flex; flex-direction: column; gap: 2px; padding: 6px;
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: 0 12px 32px rgba(0,0,0,.5);
}
.menu form { margin: 0; }
.menu-item {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; width: 100%;
  padding: 10px 12px; border: 0; border-radius: 6px; background: transparent;
  color: var(--text); font: inherit; font-weight: 600; text-align: left; text-decoration: none; cursor: pointer;
}
.menu-item:hover, .menu-item:focus-visible { background: var(--panel-2); outline: none; }
.menu-item.current { background: var(--panel-2); cursor: default; }
.menu-item.current small { color: var(--muted); font-weight: 500; }
.menu-item.danger { color: #fca5a5; }
.menu-sep { border: 0; border-top: 1px solid var(--border); margin: 4px 0; }

/* ---------- chat ---------- */
.chat-view { display: flex; flex-direction: column; height: calc(100vh - 56px); }
.chat-bar { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 8px 16px; border-bottom: 1px solid var(--border); }
.chat-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.chat-body { flex: 1; display: flex; min-height: 0; }
.player-frame { flex: 1; min-width: 0; border: 0; background: #000; }
.chat-frame { width: 100%; border: 0; background: var(--panel); }
.resizer { display: none; }
.player-frame:not([hidden]) + .resizer {
  display: block; flex: none; width: 6px; cursor: col-resize; touch-action: none;
  background: var(--border); transition: background .12s;
}
.resizer:hover, .resizer:focus-visible, .resizing .resizer { background: var(--accent); outline: none; }
.resizing { cursor: col-resize; user-select: none; }
.resizing iframe { pointer-events: none; }
.player-frame:not([hidden]) + .resizer + .chat-frame { width: var(--chat-width, 360px); flex: none; }

/* ---------- prossima live ---------- */
.page { max-width: 1200px; margin: 0 auto; padding: 24px 20px 48px; }
.page-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 20px; }
.page-head h1 { margin: 0; font-size: 22px; }
.page-head p { margin: 4px 0 0; }
.cols { margin-top: 20px; display: grid; grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); gap: 20px; align-items: start; }
.col { display: flex; flex-direction: column; gap: 20px; min-width: 0; }
.card {
  background: var(--panel); border: 1px solid var(--border); border-radius: 12px; padding: 20px;
  display: flex; flex-direction: column; gap: 14px;
}
.card h2 { margin: 0; font-size: 15px; }
.fields { display: flex; flex-wrap: wrap; gap: 16px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 12px; color: var(--muted); font-weight: 600; }
.input {
  font: inherit; font-size: 15px; color: var(--text); background: var(--bg);
  border: 1px solid var(--border); border-radius: 8px; padding: 9px 12px; min-height: 42px;
}
.input:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.message {
  font: 16px/1.4 ui-monospace, "Cascadia Mono", Consolas, monospace;
  background: var(--bg); border: 1px solid #3d2a66; border-radius: 10px; padding: 14px 16px; overflow-wrap: anywhere;
}
.message.small { font-size: 14px; border-color: var(--border); padding: 10px 12px; }
.targets { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.target {
  display: flex; align-items: flex-start; gap: 12px; padding: 12px 14px; border-radius: 10px;
  border: 1px solid var(--border); background: var(--bg); cursor: pointer;
}
.target:has(input:checked) { border-color: #3d2a66; }
.target.disabled { opacity: .55; cursor: not-allowed; }
.target input { width: 18px; height: 18px; margin: 2px 0 0; accent-color: var(--accent); flex: none; }
.target-body { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.target-body strong { font-size: 14px; }
.target-body span { font-size: 13px; color: var(--muted); }
.sub-options { display: flex; flex-direction: column; gap: 8px; margin: 8px 0 4px 44px; }
.sub-option { display: flex; align-items: center; gap: 8px; font-size: 13px; color: #d4d4d8; cursor: pointer; }
.sub-option input { width: 16px; height: 16px; accent-color: var(--accent); }
.sub-field { display: flex; flex-direction: column; gap: 6px; margin-top: 2px; }
.sub-field label { font-size: 12px; color: var(--muted); font-weight: 600; }
.with-count { display: flex; align-items: center; gap: 10px; }
.with-count .input { flex: 1; min-width: 0; }
.input-sm { font-size: 14px; min-height: 36px; padding: 7px 10px; }
.count, .hint { font-size: 12px; color: var(--muted); }
.actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 10px; }
.results { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.results li { display: flex; gap: 10px; align-items: baseline; }
.ok { color: var(--green); font-weight: 700; }
.ko { color: #fca5a5; font-weight: 700; }
.pill {
  display: inline-flex; align-items: center; gap: 8px; padding: 6px 12px; border-radius: 999px;
  font-size: 13px; font-weight: 600; border: 1px solid var(--border); background: var(--panel-2);
}
.pill .dot { width: 8px; height: 8px; border-radius: 50%; background: #52525b; }
.pill.offline { background: var(--green-bg); border-color: rgba(34,197,94,.45); color: #86efac; }
.pill.offline .dot { background: var(--green); }
.pill.live { background: var(--red-bg); border-color: rgba(239,68,68,.45); color: #fca5a5; }
.pill.live .dot { background: var(--red); }
.notice { padding: 12px 14px; border-radius: 10px; background: var(--amber-bg); color: var(--amber); display: flex; flex-wrap: wrap; gap: 10px; align-items: center; justify-content: space-between; }
.error-box { padding: 10px 12px; border-radius: 8px; background: var(--red-bg); color: #fca5a5; }

/* ---------- toast ---------- */
.toast {
  position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%);
  background: var(--panel-2); border: 1px solid var(--border); padding: 10px 16px; border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0,0,0,.4); font-weight: 600;
}
.toast.error { border-color: var(--red); color: #fca5a5; }

/* ---------- login ---------- */
.login-page { display: grid; place-items: center; padding: 16px; }
.login-card {
  width: 100%; max-width: 440px; text-align: center;
  background: var(--panel); border: 1px solid var(--border); border-radius: 14px; padding: 32px 24px;
}
.login-card h1 { margin: 8px 0 4px; }
.login-error { background: var(--red-bg); color: #fca5a5; padding: 10px; border-radius: 8px; }
.login-card .btn-twitch { width: 100%; padding: 12px; font-size: 15px; margin-top: 16px; }

/* ---------- schermi stretti ---------- */
@media (max-width: 860px) {
  .cols { grid-template-columns: minmax(0, 1fr); }
  .page { padding: 16px; }
  .chat-view { height: calc(100vh - 100px); }
  .chat-body { flex-direction: column; }
  .player-frame { flex: none; aspect-ratio: 16 / 9; width: 100%; }
  .player-frame:not([hidden]) + .resizer { display: none; }
  .player-frame:not([hidden]) + .resizer + .chat-frame { width: 100%; flex: 1; border-top: 1px solid var(--border); }
  #username { display: none; }
}
.card p { margin: 0; }
