/* ОСНОВА™ ТБ — оформлення сайту.
   Палітра взята з застосунку ОСНОВА (ui/theme/Theme.kt): світла й темна теми
   повторюють фірмові кольори Material 3 із мобільного застосунку. */

:root {
  color-scheme: light;

  --primary: #43683d;
  --on-primary: #ffffff;
  --primary-container: #c4f0b8;
  --on-primary-container: #002200;
  --accent: #5ac134;           /* яскравий зелений з логотипа */

  --bg: #e4eee1;
  --surface: #f4f9f1;
  --surface-2: #ffffff;
  --ink: #1a1c19;
  --ink-soft: #434840;
  --line: #c3c8bc;
  --danger: #ba1a1a;
  --on-danger: #ffffff;
  --danger-container: #ffdad6;
  --on-danger-container: #410002;

  --panel: rgba(244, 249, 241, .96);
  /* Логотип має чорні елементи, тому в темній темі під нього кладемо світлу
     підкладку — інакше «сходинки» під написом зливаються з фоном. */
  --logo-plate: transparent;
  --logo-plate-pad: 0;
  --shadow: 0 1px 2px rgba(26, 28, 25, .10), 0 4px 16px rgba(26, 28, 25, .07);
  --shadow-lg: 0 8px 32px rgba(3, 26, 16, .28);

  --radius: 10px;
  --radius-lg: 16px;
  --header-h: 64px;
  --sidebar-w: 340px;
  --font: Roboto, "Segoe UI", "Helvetica Neue", Arial, "Noto Sans", sans-serif;
}

/* темна тема: системна (якщо користувач не обрав світлу вручну) */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --primary: #a9d39e;
    --on-primary: #133810;
    --primary-container: #2b5025;
    --on-primary-container: #c4f0b8;
    --accent: #7ede55;
    --bg: #031a10;
    --surface: #0b2317;
    --surface-2: #123021;
    --ink: #e2e3dd;
    --ink-soft: #c3c8bc;
    --line: #2c4434;
    --danger: #ffb4ab;
    --on-danger: #690005;
    --danger-container: #93000a;
    --on-danger-container: #ffdad6;
    --panel: rgba(3, 26, 16, .94);
    --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 4px 16px rgba(0, 0, 0, .3);
    --logo-plate: rgba(255, 255, 255, .92);
    --logo-plate-pad: 4px;
  }
}

/* темна тема: обрана вручну */
:root[data-theme="dark"] {
  color-scheme: dark;
  --primary: #a9d39e;
  --on-primary: #133810;
  --primary-container: #2b5025;
  --on-primary-container: #c4f0b8;
  --accent: #7ede55;
  --bg: #031a10;
  --surface: #0b2317;
  --surface-2: #123021;
  --ink: #e2e3dd;
  --ink-soft: #c3c8bc;
  --line: #2c4434;
  --danger: #ffb4ab;
  --on-danger: #690005;
  --danger-container: #93000a;
  --on-danger-container: #ffdad6;
  --panel: rgba(3, 26, 16, .94);
  --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 4px 16px rgba(0, 0, 0, .3);
  --logo-plate: rgba(255, 255, 255, .92);
  --logo-plate-pad: 4px;
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html, body { height: 100%; }

body {
  margin: 0;
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

button, input, select { font: inherit; color: inherit; }

.container {
  width: 100%;
  max-width: 1440px;
  margin: 0 auto;
  padding: 0 20px;
}

/* ---------- шапка ---------- */

.site-header {
  position: sticky;
  top: 0;
  z-index: 30;
  height: var(--header-h);
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}

.site-header .container {
  height: 100%;
  display: flex;
  align-items: center;
  gap: 16px;
}

.brand { display: flex; align-items: center; gap: 12px; text-decoration: none; color: inherit; }
.brand:hover { text-decoration: none; }
.brand img {
  height: 42px;
  width: auto;
  display: block;
  padding: var(--logo-plate-pad);
  background: var(--logo-plate);
  border-radius: 8px;
}
.brand span {
  padding-left: 12px;
  border-left: 1px solid var(--line);
  color: var(--ink-soft);
  font-size: 15px;
  white-space: nowrap;
}

.site-nav { margin-left: auto; display: flex; align-items: center; gap: 6px; }

.site-nav a,
.btn-ghost {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--ink-soft);
  cursor: pointer;
  white-space: nowrap;
}
.site-nav a:hover,
.btn-ghost:hover { background: var(--primary-container); color: var(--on-primary-container); text-decoration: none; }

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--ink-soft);
  cursor: pointer;
}
.icon-btn:hover { background: var(--primary-container); color: var(--on-primary-container); }
.icon-btn svg { width: 22px; height: 22px; fill: currentColor; }

.user-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px 6px 14px;
  border-radius: 999px;
  background: var(--primary-container);
  color: var(--on-primary-container);
  font-size: 14px;
}
.user-chip strong { font-weight: 500; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 20px;
  border: 0;
  border-radius: 999px;
  background: var(--primary);
  color: var(--on-primary);
  font-weight: 500;
  cursor: pointer;
  transition: filter .15s ease;
}
.btn:hover { filter: brightness(1.08); text-decoration: none; }
.btn:disabled { opacity: .6; cursor: default; }
.btn-small { padding: 7px 14px; font-size: 14px; }

/* ---------- сітка сторінки ---------- */

.page { padding: 24px 0 40px; }

.page-title { margin: 0 0 4px; font-size: 26px; font-weight: 500; }
.page-subtitle { margin: 0 0 20px; color: var(--ink-soft); }

.notice {
  margin: 0 0 16px;
  padding: 12px 16px;
  border-left: 4px solid var(--primary);
  border-radius: var(--radius);
  background: var(--primary-container);
  color: var(--on-primary-container);
  font-size: 14px;
}
.notice.error {
  border-left-color: var(--danger);
  background: var(--danger-container);
  color: var(--on-danger-container);
}

/* ---------- сцена (плеєр + список каналів) ---------- */

.stage {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) var(--sidebar-w);
  gap: 16px;
}

.screen {
  position: relative;
  aspect-ratio: 16 / 9;
  background: #000;
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow);
}

.screen video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  background: #000;
  display: block;
}

.screen-state {
  position: absolute;
  inset: 0;
  display: none;
  pointer-events: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 24px;
  text-align: center;
  color: #fff;
  background: rgba(0, 0, 0, .62);
}
.screen-state.visible { display: flex; }
.screen-state .btn { pointer-events: auto; }
.screen-state h3 { margin: 0; font-size: 18px; font-weight: 500; }
.screen-state p { margin: 0; max-width: 440px; color: rgba(255, 255, 255, .78); font-size: 14px; }

.spinner {
  width: 38px;
  height: 38px;
  border: 3px solid rgba(255, 255, 255, .25);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 900ms linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.osd {
  position: absolute;
  top: 16px;
  left: 16px;
  right: 16px;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 16px;
  border-radius: var(--radius);
  background: rgba(3, 26, 16, .78);
  color: #fff;
  opacity: 0;
  transform: translateY(-8px);
  transition: opacity .2s ease, transform .2s ease;
  pointer-events: none;
  backdrop-filter: blur(6px);
}
.osd.visible { opacity: 1; transform: none; }
.osd img { width: 46px; height: 46px; object-fit: contain; border-radius: 8px; background: rgba(255, 255, 255, .9); padding: 4px; }
.osd-number { min-width: 44px; font-size: 26px; font-weight: 500; color: var(--accent); text-align: center; }
.osd-text { min-width: 0; }
.osd-name { font-size: 18px; font-weight: 500; }
.osd-now { font-size: 13px; color: rgba(255, 255, 255, .75); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.dialpad {
  position: absolute;
  top: 16px;
  right: 16px;
  padding: 10px 18px;
  border-radius: var(--radius);
  background: rgba(3, 26, 16, .85);
  color: #fff;
  font-size: 30px;
  font-weight: 500;
  letter-spacing: 3px;
  display: none;
}
.dialpad.visible { display: block; }

.controls {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 28px 14px 12px;
  background: linear-gradient(to top, rgba(0, 0, 0, .8), rgba(0, 0, 0, 0));
  opacity: 1;
  transition: opacity .25s ease;
}
.screen.idle .controls { opacity: 0; pointer-events: none; }
.screen.idle { cursor: none; }

.ctrl {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: #fff;
  cursor: pointer;
  transition: background .15s ease;
}
.ctrl:hover { background: rgba(255, 255, 255, .18); }
.ctrl svg { width: 22px; height: 22px; fill: currentColor; }
.ctrl.wide { width: auto; padding: 0 14px; border-radius: 999px; gap: 8px; font-size: 14px; }

.ctrl-title {
  flex: 1;
  min-width: 0;
  padding: 0 10px;
  color: #fff;
  font-size: 14px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.ctrl-title b { font-weight: 500; }
.ctrl-title span { color: rgba(255, 255, 255, .7); }

.live-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  border-radius: 999px;
  background: #ba1a1a;
  color: #fff;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .5px;
}
.live-badge::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #fff;
  animation: pulse 1.6s ease-in-out infinite;
}
@keyframes pulse { 50% { opacity: .3; } }

.volume { width: 92px; accent-color: var(--accent); cursor: pointer; }

/* ---------- список каналів ---------- */

.channels {
  display: flex;
  flex-direction: column;
  min-height: 0;
  max-height: calc(100vh - var(--header-h) - 90px);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow);
}

.channels-head {
  padding: 12px;
  border-bottom: 1px solid var(--line);
  display: grid;
  gap: 8px;
}
.channels-head h2 {
  margin: 0;
  font-size: 15px;
  font-weight: 500;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.channels-head .count { color: var(--ink-soft); font-size: 13px; font-weight: 400; }

.field {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 12px;
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--bg);
}
.field:focus-within { border-color: var(--primary); background: var(--surface-2); }
.field input,
.field select { flex: 1; min-width: 0; border: 0; outline: 0; background: transparent; }
.field svg { width: 18px; height: 18px; fill: var(--ink-soft); flex: none; }

.channel-list { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; scrollbar-width: thin; }

.group-label {
  position: sticky;
  top: 0;
  z-index: 1;
  padding: 8px 14px;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
  color: var(--ink-soft);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .6px;
}

.channel {
  width: 100%;
  display: grid;
  grid-template-columns: 34px 44px minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  padding: 9px 14px;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: transparent;
  color: inherit;
  text-align: left;
  cursor: pointer;
}
.channel:hover { background: var(--primary-container); color: var(--on-primary-container); }
.channel.active { background: var(--primary-container); color: var(--on-primary-container); box-shadow: inset 3px 0 0 var(--primary); }
.channel-number { color: var(--ink-soft); font-size: 13px; text-align: center; }
.channel.active .channel-number,
.channel:hover .channel-number,
.channel.active .channel-now,
.channel:hover .channel-now { color: inherit; }
.channel-logo { width: 44px; height: 32px; object-fit: contain; background: #fff; border-radius: 6px; }
.channel-body { min-width: 0; }
.channel-name { font-size: 14px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.channel-now { color: var(--ink-soft); font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.channel-progress { margin-top: 4px; height: 3px; border-radius: 2px; background: var(--line); overflow: hidden; }
.channel-progress i { display: block; height: 100%; background: var(--primary); }

.channels-empty { padding: 24px 16px; color: var(--ink-soft); text-align: center; }

.channels-close { display: none; }

/* ---------- повноекранний режим ---------- */

.stage:fullscreen,
.stage:-webkit-full-screen {
  display: block;
  width: 100%;
  height: 100%;
  gap: 0;
  background: #000;
}
.stage:fullscreen .screen,
.stage:-webkit-full-screen .screen {
  width: 100%;
  height: 100%;
  aspect-ratio: auto;
  border-radius: 0;
  box-shadow: none;
}
.stage:fullscreen .channels,
.stage:-webkit-full-screen .channels {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(400px, 88vw);
  max-height: none;
  border: 0;
  border-radius: 0;
  background: rgba(3, 26, 16, .93);
  color: #fff;
  transform: translateX(100%);
  transition: transform .22s ease;
  backdrop-filter: blur(10px);
  box-shadow: var(--shadow-lg);
}
.stage:fullscreen .channels.open,
.stage:-webkit-full-screen .channels.open { transform: none; }
.stage:fullscreen .channels-close,
.stage:-webkit-full-screen .channels-close { display: inline-flex; }
.stage:fullscreen .channels-head,
.stage:-webkit-full-screen .channels-head { border-bottom-color: rgba(255, 255, 255, .14); }
.stage:fullscreen .field,
.stage:-webkit-full-screen .field { background: rgba(255, 255, 255, .1); border-color: rgba(255, 255, 255, .18); color: #fff; }
.stage:fullscreen .field svg,
.stage:-webkit-full-screen .field svg { fill: rgba(255, 255, 255, .7); }
.stage:fullscreen .field input,
.stage:fullscreen .field select,
.stage:-webkit-full-screen .field input,
.stage:-webkit-full-screen .field select { color: #fff; }
.stage:fullscreen .field select option,
.stage:-webkit-full-screen .field select option { color: #1a1c19; }
.stage:fullscreen .group-label,
.stage:-webkit-full-screen .group-label { background: rgba(3, 26, 16, .97); color: rgba(255, 255, 255, .6); border-bottom-color: rgba(255, 255, 255, .12); }
.stage:fullscreen .channel,
.stage:-webkit-full-screen .channel { border-bottom-color: rgba(255, 255, 255, .08); color: #fff; }
.stage:fullscreen .channel:hover,
.stage:-webkit-full-screen .channel:hover { background: rgba(90, 193, 52, .28); color: #fff; }
.stage:fullscreen .channel.active,
.stage:-webkit-full-screen .channel.active { background: rgba(90, 193, 52, .4); color: #fff; }
.stage:fullscreen .channel-number,
.stage:-webkit-full-screen .channel-number { color: rgba(255, 255, 255, .6); }
.stage:fullscreen .channel-now,
.stage:-webkit-full-screen .channel-now { color: rgba(255, 255, 255, .68); }
.stage:fullscreen .channel-progress,
.stage:-webkit-full-screen .channel-progress { background: rgba(255, 255, 255, .18); }
.stage:fullscreen .channel-progress i,
.stage:-webkit-full-screen .channel-progress i { background: var(--accent); }
.stage:fullscreen .channels-head h2,
.stage:-webkit-full-screen .channels-head h2 { color: #fff; }
.stage:fullscreen .channels-empty,
.stage:-webkit-full-screen .channels-empty { color: rgba(255, 255, 255, .7); }

/* ---------- інформація під плеєром ---------- */

.below {
  display: grid;
  grid-template-columns: minmax(0, 1fr) var(--sidebar-w);
  gap: 16px;
  margin-top: 16px;
}

.card {
  padding: 16px 18px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
}
.card h2 { margin: 0 0 10px; font-size: 17px; font-weight: 500; }
.card h3 { margin: 0 0 8px; font-size: 14px; font-weight: 500; color: var(--ink-soft); }

.current { display: flex; align-items: center; gap: 14px; }
.current img { width: 60px; height: 44px; object-fit: contain; background: #fff; border-radius: 6px; }
.current-name { font-size: 19px; font-weight: 500; }
.current-meta { color: var(--ink-soft); font-size: 14px; }

.schedule { margin: 0; padding: 0; list-style: none; max-height: 260px; overflow-y: auto; }
.schedule li {
  display: grid;
  grid-template-columns: 52px minmax(0, 1fr);
  gap: 10px;
  padding: 7px 0;
  border-bottom: 1px solid var(--line);
  font-size: 14px;
}
.schedule li:last-child { border-bottom: 0; }
.schedule time { color: var(--ink-soft); }
.schedule li.on-air { color: var(--primary); font-weight: 500; }
.schedule li.on-air time { color: var(--primary); }

.hints { margin: 0; padding: 0; list-style: none; font-size: 13.5px; color: var(--ink-soft); }
.hints li { padding: 4px 0; display: flex; gap: 10px; align-items: baseline; }
kbd {
  display: inline-block;
  min-width: 24px;
  padding: 2px 7px;
  border: 1px solid var(--line);
  border-bottom-width: 2px;
  border-radius: 6px;
  background: var(--bg);
  color: var(--ink);
  font-family: inherit;
  font-size: 12px;
  text-align: center;
  white-space: nowrap;
}

/* ---------- підвал ---------- */

.site-footer {
  padding: 20px 0 32px;
  border-top: 1px solid var(--line);
  color: var(--ink-soft);
  font-size: 13.5px;
}
.site-footer .container { display: flex; flex-wrap: wrap; gap: 8px 20px; align-items: center; }
.site-footer .spacer { margin-left: auto; }

/* ---------- сторінка входу ---------- */

.login-page {
  min-height: 100%;
  display: flex;
  flex-direction: column;
  background: var(--bg);
}
.login-main { flex: 1; display: flex; align-items: center; justify-content: center; padding: 40px 20px; }
.login-card {
  width: 100%;
  max-width: 400px;
  padding: 32px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
}
.login-card > img {
  height: 88px;
  display: block;
  margin: 0 auto 18px;
  padding: calc(var(--logo-plate-pad) * 2);
  background: var(--logo-plate);
  border-radius: 12px;
}
.login-card h1 { margin: 0 0 6px; font-size: 22px; font-weight: 500; text-align: center; }
.login-card p.lead { margin: 0 0 22px; color: var(--ink-soft); font-size: 14px; text-align: center; }
.login-card label { display: block; margin-bottom: 6px; font-size: 13px; color: var(--ink-soft); }
.login-card .field { height: 44px; margin-bottom: 14px; border-radius: var(--radius); }
.login-card .btn { width: 100%; }
.form-error {
  display: none;
  margin-bottom: 14px;
  padding: 10px 12px;
  border-radius: var(--radius);
  background: var(--danger-container);
  color: var(--on-danger-container);
  font-size: 14px;
}
.form-error.visible { display: block; }
.login-help { margin: 20px 0 0; font-size: 13px; color: var(--ink-soft); text-align: center; }

/* ---------- адаптивність ---------- */

@media (max-width: 1100px) { :root { --sidebar-w: 300px; } }

@media (max-width: 900px) {
  .stage { grid-template-columns: minmax(0, 1fr); }
  .below { grid-template-columns: minmax(0, 1fr); }
  .channels { max-height: 60vh; }
  .brand span { display: none; }
  .site-nav a.desktop-only { display: none; }
}

@media (max-width: 560px) {
  .container { padding: 0 12px; }
  .page { padding: 12px 0 24px; }
  .screen { border-radius: 0; margin: 0 -12px; }
  .osd { top: 10px; left: 10px; right: 10px; padding: 8px 12px; }
  .osd img { width: 36px; height: 36px; }
  .osd-name { font-size: 15px; }
  .volume { display: none; }
  .ctrl { width: 36px; height: 36px; }
  .brand img { height: 36px; }
}
