/* Radio Admin Panel — tek tema dosyası (index.html + login.html).
   Renkler :root değişkenlerinde; açık tema sistem tercihini izler. */

:root {
  color-scheme: dark;
  --bg: #0b1018;
  --surface: #121925;
  --surface-2: #18212f;
  --border: #263244;
  --text: #e8eef7;
  --muted: #93a1b8;
  --accent: #2dd4bf;
  --accent-text: #04201c;
  --ok: #34d399;
  --warn: #fbbf24;
  --danger: #f87171;
  --info: #60a5fa;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 10px 30px -18px rgba(0, 0, 0, .7);
  --radio-col-width: 170px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

@media (prefers-color-scheme: light) {
  :root {
    color-scheme: light;
    --bg: #f4f6fa;
    --surface: #ffffff;
    --surface-2: #f1f4f9;
    --border: #d9e0ea;
    --text: #17202e;
    --muted: #5b6779;
    --accent: #0d9488;
    --accent-text: #ffffff;
    --ok: #059669;
    --warn: #b45309;
    --danger: #dc2626;
    --info: #2563eb;
    --shadow: 0 10px 30px -20px rgba(20, 30, 50, .35);
  }
}

/* ---------- Temel ---------- */
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.55 var(--font);
  -webkit-font-smoothing: antialiased;
}

h1, h2 { margin: 0; line-height: 1.25; }
p { margin: 0; }
a { color: var(--accent); }
b { font-weight: 600; }
small { font-size: 12px; }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.muted { color: var(--muted); font-size: 13px; }
.muted.ok { color: var(--ok); }
.muted.danger { color: var(--danger); }
.muted:empty { display: none; }

/* ---------- Form elemanları ---------- */
label { display: block; font-size: 13px; font-weight: 600; color: var(--muted); }

input:not([type="checkbox"]), select, textarea {
  display: block;
  width: 100%;
  margin-top: 6px;
  padding: 9px 12px;
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font: inherit;
}
input::placeholder, textarea::placeholder { color: var(--muted); opacity: .7; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); }
textarea { resize: vertical; }

.btn, .icon-btn, .login button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 14px;
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font: inherit;
  font-weight: 600;
  line-height: 1.2;
  white-space: nowrap;
  text-decoration: none;
  cursor: pointer;
  transition: background .15s, border-color .15s, opacity .15s;
}
.btn:hover, .icon-btn:hover { border-color: var(--accent); }
.btn:disabled, .icon-btn:disabled { opacity: .55; cursor: not-allowed; }
.btn.ghost { background: transparent; }
.btn.primary, .login button { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.btn.primary:hover, .login button:hover { opacity: .9; }
.btn.small { padding: 6px 10px; font-size: 13px; }
.icon-btn { width: 34px; height: 34px; padding: 0; }
.icon-btn.delete:hover { border-color: var(--danger); }
.field-actions { margin-top: 6px; }

/* Aç/kapat anahtarı: <label class="toggle"><input><span.track><span.thumb> */
.toggle { position: relative; display: inline-block; flex: none; width: 38px; height: 22px; vertical-align: middle; }
.toggle input { position: absolute; inset: 0; z-index: 1; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: pointer; }
.toggle .track { position: absolute; inset: 0; background: var(--border); border-radius: 999px; transition: background .15s; }
.toggle .thumb { position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; background: #fff; border-radius: 50%; box-shadow: 0 1px 2px rgba(0, 0, 0, .35); transition: transform .15s; }
.toggle input:checked ~ .track { background: var(--accent); }
.toggle input:checked ~ .thumb { transform: translateX(16px); }
.toggle input:focus-visible ~ .track { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- İskelet ---------- */
.top {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 24px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 10px; color: var(--text); text-decoration: none; }
.brand h1 { font-size: 17px; font-weight: 700; }
.brain-logo { display: grid; place-items: center; width: 34px; height: 34px; border-radius: var(--radius-sm); background: var(--accent); }
.brain-logo svg { width: 22px; height: 22px; fill: none; stroke: var(--accent-text); stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; }
.top-actions { display: flex; align-items: center; gap: 8px; }
.top-actions .search, .top-actions .filter { margin: 0; width: 200px; }

.layout {
  display: grid;
  grid-template-columns: 210px minmax(0, 1fr);
  gap: 24px;
  align-items: start;
  max-width: 1600px;
  margin: 0 auto;
  padding: 24px;
}
.side-nav { position: sticky; top: 84px; display: flex; flex-direction: column; gap: 4px; }
.tab {
  padding: 10px 14px;
  background: none;
  color: var(--muted);
  border: 0;
  border-radius: var(--radius-sm);
  font: inherit;
  font-weight: 600;
  text-align: left;
  cursor: pointer;
}
.tab:hover { background: var(--surface); color: var(--text); }
.tab.active { background: var(--surface-2); color: var(--text); box-shadow: inset 3px 0 0 var(--accent); }

.panel {
  padding: 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.panel > * + * { margin-top: 16px; }
.panel-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; }
.panel-head-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.section-title { font-size: 19px; font-weight: 700; }
.section-desc { color: var(--muted); font-size: 14px; }
.station-count, .pill {
  display: inline-block;
  margin-left: 6px;
  padding: 2px 9px;
  background: var(--surface-2);
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  vertical-align: middle;
}

/* ---------- Radyolar ---------- */
.status-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.status-card, .notice-card, .notice-list-card, .info-card {
  padding: 14px 16px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.status-title { margin-bottom: 6px; color: var(--muted); font-size: 12px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; }
.status-row { display: flex; justify-content: space-between; gap: 12px; padding: 4px 0; font-size: 14px; }
.status-row span { color: var(--muted); }
.status-row b { font-variant-numeric: tabular-nums; }

.live-status { display: inline-flex; align-items: center; gap: 8px; color: var(--muted); font-size: 13px; }
.live-status::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--muted); }
.live-status.ok::before { background: var(--ok); }
.live-status.warn::before { background: var(--warn); }
.live-status.off::before { background: var(--danger); }

.table { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); }
.row {
  display: grid;
  grid-template-columns: var(--radio-col-width) 44px 44px 136px repeat(8, minmax(58px, 1fr)) 92px 42px 42px 42px;
  align-items: center;
  gap: 6px;
  min-width: max-content;
  padding: 8px 14px;
  border-top: 1px solid var(--border);
}
.row > div { display: flex; align-items: center; justify-content: center; min-width: 0; }
.row > div:first-child { justify-content: flex-start; }
.row:not(.head):hover { background: var(--surface-2); }
.row.head {
  position: sticky;
  top: 0;
  border-top: 0;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .04em;
  text-transform: uppercase;
}
.row .name { font-weight: 600; overflow-wrap: anywhere; }
.panel-link { text-decoration: none; font-size: 16px; }
.status { gap: 4px; }
.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 28px;
  padding: 2px 6px;
  border: 1px solid transparent;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 700;
}
.badge.ok { background: color-mix(in srgb, var(--ok) 18%, transparent); border-color: var(--ok); color: var(--ok); }
.badge.off { background: color-mix(in srgb, var(--danger) 14%, transparent); border-color: var(--danger); color: var(--danger); }
.row > .trial-wrap { flex-direction: column; gap: 2px; }
.news-trial-info { font-size: 11px; }

/* ---------- Formlar: yeni radyo, düzenle, paketler, bildirimler ---------- */
.create-grid, .grid2, .notice-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.notice-grid { grid-template-columns: 2fr 1fr 1fr; align-items: start; }
.create-options { grid-column: 1 / -1; display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 10px; }
.create-option, .pkg-ai-switch { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.create-option { padding: 10px 12px; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm); color: var(--text); }
.create-submit { grid-column: 1 / -1; justify-self: start; }
.info-card { display: none; line-height: 1.8; overflow-wrap: anywhere; }

.pkg-table { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); }
.pkg-row, .pkg-add { display: grid; grid-template-columns: 2fr 1fr 1fr 1fr 70px 80px; align-items: center; gap: 10px; }
.pkg-row { min-width: 640px; padding: 8px 14px; border-top: 1px solid var(--border); }
.pkg-row.head { border-top: 0; background: var(--surface-2); color: var(--muted); font-size: 11px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; }
.pkg-row input:not([type="checkbox"]) { margin-top: 0; }
.pkg-add { align-items: end; }
.pkg-ai-switch { justify-content: flex-start; padding-bottom: 9px; }

.notice-card > * + *, .notice-list-card > * + * { margin-top: 14px; }
.notice-title { font-weight: 700; }
.notice-sub { color: var(--muted); font-size: 13px; }
.notice-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.notice-list-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.notice-list { display: grid; gap: 10px; }
.notice-item { padding: 10px 14px; background: var(--surface); border: 1px solid var(--border); border-left: 3px solid var(--info); border-radius: var(--radius-sm); }
.notice-item-success { border-left-color: var(--ok); }
.notice-item-warning { border-left-color: var(--warn); }
.notice-item-danger { border-left-color: var(--danger); }
.notice-item-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.notice-item-msg { margin: 4px 0; overflow-wrap: anywhere; }
.notice-item-meta { color: var(--muted); font-size: 12px; }

/* ---------- Modal ve toast ---------- */
.modal {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: none; /* JS: style.display = 'flex' */
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(0, 0, 0, .6);
}
.modal-card {
  display: flex;
  flex-direction: column;
  gap: 16px;
  width: min(760px, 100%);
  max-height: calc(100vh - 32px);
  padding: 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.modal-body { overflow-y: auto; padding-right: 4px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; }

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  z-index: 60;
  transform: translateX(-50%);
  padding: 10px 16px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
  font-weight: 600;
}

/* ---------- Giriş sayfası ---------- */
.login-page { display: grid; place-items: center; min-height: 100vh; padding: 16px; }
.login {
  width: min(380px, 100%);
  padding: 28px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.login > * + *, .login form > * + * { margin-top: 16px; }
.login-head { display: flex; align-items: center; gap: 12px; }
.login-title { font-size: 19px; }
.login-sub { color: var(--muted); font-size: 13px; }
.login button { width: 100%; padding: 11px 14px; }
.flash { padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--radius-sm); font-size: 14px; }
.flash.danger { border-color: var(--danger); color: var(--danger); }

/* ---------- Dar ekran ---------- */
@media (max-width: 900px) {
  .top { flex-wrap: wrap; padding: 12px 16px; }
  .top-actions { flex: 1 1 100%; }
  .top-actions .search, .top-actions .filter { flex: 1 1 0; width: auto; min-width: 0; }
  .layout { grid-template-columns: minmax(0, 1fr); gap: 16px; padding: 16px; }
  .side-nav { position: static; flex-direction: row; overflow-x: auto; }
  .tab { white-space: nowrap; }
  .tab.active { box-shadow: inset 0 -3px 0 var(--accent); }
  .panel { padding: 16px; }
  .status-grid, .create-grid, .grid2, .notice-grid { grid-template-columns: minmax(0, 1fr); }
  .pkg-add { grid-template-columns: repeat(2, minmax(0, 1fr)); }

  /* Radyo tablosu → kartlar; hücre etiketleri data-label'dan gelir */
  .table { overflow: visible; border: 0; }
  .row.head { display: none; }
  .row {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 12px 8px;
    min-width: 0;
    margin-top: 12px;
    padding: 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
  }
  .row > div { flex-direction: column; gap: 4px; }
  .row > div[data-label]::before { content: attr(data-label); color: var(--muted); font-size: 11px; font-weight: 600; }
  .row > .name { grid-column: 1 / -1; flex-direction: row; font-size: 16px; }
  .row > .status { grid-column: span 2; flex-direction: row; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
