/* Live Listener Dashboard — unified clean CSS */
:root {
  --bg: #0d111a;
  /* MOD: was #0b0e14 */
  --panel: #141b29;
  /* MOD: was #101521 */
  --panel-2: #182233;
  /* MOD: was #0f1420 */
  --border: #2a3550;
  /* MOD: was #1e2638 */
  --text: #eef3ff;
  /* MOD: was #e6ecff */
  --muted: #a8b5d3;
  /* MOD: was #9fb0d0 */
  --accent: #6ea8ff;
  --accent-2: #7ee787;
  --warn: #f9c74f;
  --danger: #ff7b7b;
  --chip: #1b2436;
  /* MOD: was #182033 */
  --shadow: 0 10px 30px rgba(0, 0, 0, .35);
  --radius: 16px;
}

* {
  box-sizing: border-box
}

html,
body {
  height: 100%
}

body {
  margin: 0;
  font: 14px/1.5 system-ui, -apple-system, Segoe UI, Roboto, Ubuntu, Cantarell, Noto Sans, Arial, "Apple Color Emoji", "Segoe UI Emoji";
  color: var(--text);
  background: radial-gradient(1200px 600px at 10% -10%, #162039 0, transparent 60%), var(--bg);
}

/* Header */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: linear-gradient(180deg, #0b0e14 0, #0b0e14ee 60%, #0b0e1400 100%);
  backdrop-filter: blur(6px);
  z-index: 99;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px
}

.logo {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow);
}

.titles h1 {
  margin: 0;
  font-size: 20px
}

.subtitle {
  margin: 0;
  color: var(--muted);
  font-size: 12px
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 12px
}

/* Layout */
main {
  padding: 16px 20px 80px
}

.controls {
  display: flex;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.search-wrap {
  flex: 1
}

#searchInput {
  width: 100%;
  background: var(--panel);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 12px;
  padding: 10px 12px;
  outline: none;
}

.chips {
  display: flex;
  gap: 8px;
  flex-wrap: wrap
}

.chip {
  background: var(--chip);
  color: var(--muted);
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
  cursor: pointer;
  transition: .2s;
}

.chip.active {
  background: var(--accent);
  color: #0b1220;
  border-color: transparent
}

/* Grid + Cards */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(360px, 1fr));
  gap: 14px;
  justify-items: stretch;
  /* normal card width */
}

.card {
  background: linear-gradient(180deg, #151d2b 0, #1a2537 100%);
  /* MOD: brighter */
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 14px 8px 14px
}

.card-title {
  display: flex;
  align-items: center;
  gap: 10px
}

.badge {
  min-width: 28px;
  height: 28px;
  padding: 0 8px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  background: #0b1220;
  border: 1px solid var(--border);
  color: var(--accent-2);
  font-weight: 700;
}

.channel-name {
  margin: 0;
  font-size: 16px
}

.card-actions {
  display: flex;
  gap: 8px
}

/* Buttons */
.btn {
  background: var(--accent);
  color: #0b1220;
  border: none;
  border-radius: 10px;
  padding: 8px 12px;
  cursor: pointer;
  font-weight: 600;
}

.btn:hover {
  filter: brightness(1.08)
}

.btn-secondary {
  background: #1f2a44;
  color: var(--text);
  border: 1px solid var(--border)
}

.btn-ghost {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--border)
}

/* Card Content */
.card-subhead {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 0 14px 8px 14px;
  color: var(--muted);
  font-size: 12px;
}

.content {
  padding: 12px 14px 14px 14px;
  border-top: 1px dashed var(--border)
}

.inline-controls {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 8px
}

.small {
  font-size: 12px;
  color: var(--muted)
}

/* Entry list */
.entry {
  display: grid;
  gap: 8px;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #0c1220;
}

.entry+.entry {
  margin-top: 8px
}

.entry-meta {
  display: flex;
  gap: 8px;
  flex-wrap: wrap
}

.pill {
  padding: 4px 8px;
  border-radius: 999px;
  background: #111a2e;
  border: 1px solid var(--border);
  color: var(--muted);
  font-size: 12px;
}

.entry-text {
  white-space: pre-wrap;
  overflow-wrap: break-word;
  word-break: break-word;
}

.entry-media {
  display: grid;
  place-items: center;
  gap: 10px
}

.entry-media video,
.entry-media audio {
  max-width: 900px;
  width: 80%;
  border: 1px solid var(--border);
  border-radius: 12px;
  outline: none;
  background: #000;
}

/* Footer */
.app-footer {
  position: sticky;
  bottom: 0;
  display: flex;
  gap: 20px;
  align-items: center;
  justify-content: space-between;
  padding: 10px 20px;
  border-top: 1px solid var(--border);
  background: linear-gradient(0deg, #0b0e14 0, #0b0e14f0 60%, #0b0e1400 100%);
  backdrop-filter: blur(6px);
}

.muted {
  color: var(--muted);
  font-size: 12px
}

code {
  background: #0c1220;
  padding: 2px 6px;
  border: 1px solid var(--border);
  border-radius: 6px;
}

/* Modal Focus View */
.modal {
  position: fixed;
  inset: 0;
  display: block
}

.modal[hidden] {
  display: none
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: #0008;
  backdrop-filter: blur(4px)
}

.modal-card {
  position: absolute;
  left: 50%;
  top: 80px;
  transform: translateX(-50%);
  width: min(1400px, 96vw);
  height: min(90vh, 1000px);
  background: linear-gradient(180deg, #121a29 0, #172233 100%);
  /* MOD */
  border: 1px solid var(--border);
  border-color: #2b3852;
  /* MOD */
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border)
}

.modal-title-wrap {
  display: flex;
  align-items: center;
  gap: 10px
}

.modal-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap
}

.modal-subhead {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 6px 14px;
  border-bottom: 1px dashed var(--border)
}

.modal-body {
  padding: 14px;
  overflow: auto;
  height: 100%;
  background: #111827;
}

/* MOD */
.entry-focus {
  min-height: calc(100% - 10px);
  display: grid;
  grid-template-rows: auto auto 1fr;
  gap: 10px
}

.entry-focus .entry-text {
  font-size: 16px
}

.entry-focus .entry-media {
  align-content: start
}

.date-select {
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px 10px;
  outline: none;
}

/* Modal toolbar */
.modal-toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-bottom: 1px dashed var(--border);
  background: #0b1220;
  flex-wrap: wrap;
}

/* ─────────────────────────────────────────────
   SIDE MENU
───────────────────────────────────────────── */
.side-menu {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  z-index: 1000;
  display: flex;
  justify-content: flex-start;
}

.side-menu.hidden {
  display: none;
}

.side-menu-content {
  width: 260px;
  height: 100%;
  background: var(--panel);
  border-left: 1px solid var(--border);
  padding: 20px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.side-menu-content h3 {
  margin: 0 0 12px 0;
  font-size: 16px;
}

.side-btn {
  padding: 10px 14px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--panel-2);
  color: var(--text);
  text-align: left;
  cursor: pointer;
  font-weight: 600;
}

.side-btn:hover {
  filter: brightness(1.1);
}

.side-btn.danger {
  background: #3a1f1f;
  border-color: #5a2a2a;
  color: #ffb4b4;
}


.timebar {
  flex: 2 1 480px
}

.time-input {
  width: 120px;
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 6px 8px;
  outline: none;
}

#kwNav {
  flex: 1 1 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  justify-content: flex-end
}

.kw {
  background: #f9c74f66;
  padding: 2px 4px;
  border-radius: 4px;
  color: var(--text);
}

/* Notifications */
.notifications {
  margin: 1rem;
  background: #1a1f2d;
  /* MOD */
  border: 1px solid #2c3448;
  /* MOD */
  border-radius: 10px;
  padding: 1rem;
}

.notifications h2 {
  margin-bottom: 0.5rem;
  font-size: 1.1rem;
}

/* Mentions Filter Bar */
.mentions-filter-bar {
  display: flex;
  gap: 10px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}

.mentions-search-input {
  flex: 1 1 200px;
  min-width: 140px;
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  outline: none;
  font-size: 14px;
}

.mentions-search-input::placeholder {
  color: var(--muted);
}

.mentions-search-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(110, 168, 255, 0.15);
}

.mentions-lang-select {
  flex: 0 0 auto;
  min-width: 140px;
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  outline: none;
  font-size: 14px;
  cursor: pointer;
}

.mentions-lang-select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(110, 168, 255, 0.15);
}

/* Day separator inside notifications */
.notif-day {
  display: flex;
  align-items: center;
  gap: 12px;

  margin: 18px 0 10px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.02em;

  color: var(--muted);
  text-transform: uppercase;
}

/* Horizontal rule effect */
.notif-day::before,
.notif-day::after {
  content: "";
  flex: 1;
  height: 1px;
  background: linear-gradient(to right,
      transparent,
      var(--border),
      transparent);
}

.notif-item {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  padding: 0.7rem 1rem;
  margin-bottom: 0.5rem;
  border-radius: 8px;
  background: #1f2738;
  /* MOD */
  border: 1px solid #2e374d;
  /* MOD */
  cursor: pointer;
}

.notif-item:hover {
  background: #263043;
  /* MOD */
  border-color: #3a4760;
  /* MOD */
}

.notif-header {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  color: #ddd;
  flex-wrap: wrap;
}

.notif-time {
  color: #777;
  font-size: 0.8rem;
  white-space: nowrap;
}

.notif-snippet {
  color: #d8e0f8;
  /* MOD */
}

.notif-snippet[dir="rtl"],
.notif-snippet:dir(rtl),
.notif-item[dir="rtl"] .notif-snippet {
  direction: rtl;
  text-align: right;
}

.notif-item:dir(ltr),
.notif-item[dir="ltr"] {
  direction: ltr;
  text-align: left;
}

.notif-logo-wrap {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  background: #0c1220;
  border: 1px solid var(--border);
}

.notif-logo-wrap img {
  max-width: 80%;
  max-height: 80%;
  object-fit: contain;
  display: block;
  filter: drop-shadow(0 0 1px rgba(255, 255, 255, 0.25));
}

.notif-title {
  font-weight: 600;
  margin-inline: 0.3rem;
}

/* RTL support */
/* RTL support */
[dir="rtl"] .entry-text,
[dir="rtl"] .modal-body,
[dir="rtl"] .modal-card,
[dir="rtl"] .side-menu-content,
[dir="rtl"] .notif-list,
[dir="rtl"] .mentions-filter-bar {
  direction: rtl;
  text-align: right;
}

[dir="rtl"] .brand,
[dir="rtl"] .header-actions,
[dir="rtl"] .card-head,
[dir="rtl"] .card-subhead,
[dir="rtl"] .modal-head,
[dir="rtl"] .modal-subhead,
[dir="rtl"] .modal-actions,
[dir="rtl"] .mentions-filter-bar,
[dir="rtl"] .kw-toolbar {
  flex-direction: row-reverse;
}

[dir="rtl"] .side-menu {
  justify-content: flex-end;
}

[dir="rtl"] .side-menu-content {
  border-left: none;
  border-right: 1px solid var(--border);
  text-align: right;
}

[dir="rtl"] .side-btn {
  text-align: right;
}

[dir="rtl"] .notif-header {
  flex-direction: row-reverse;
}

[dir="rtl"] .notif-logo-wrap {
  margin-left: 10px;
  margin-right: 0;
}

[dir="rtl"] .entry-meta {
  flex-direction: row-reverse;
}

/* Fix for icons/badges in RTL */
[dir="rtl"] .modal-title-wrap,
[dir="rtl"] .card-title {
  flex-direction: row-reverse;
}

/* Toolbar */
.kw-toolbar {
  display: flex;
  align-items: center;
  gap: 10px
}

/* Media Queries */
@media (min-width:1600px) {
  .modal-card {
    width: min(1400px, 96vw)
  }
}

@media (max-width:520px) {
  .modal-card {
    width: 96vw;
    height: 88vh
  }
}

.toast-item {
  animation: fade-in .25s ease;
}

@keyframes fade-in {
  from {
    opacity: 0;
    transform: translateY(10px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.entry-epg {
  margin: 8px 0 10px 0;
  padding: 10px;
  border-radius: 8px;
  background: #0c1220;
  border: 1px solid var(--border);
}

.entry-epg .epg-title {
  font-weight: 600;
  color: var(--text);
  margin-bottom: 4px;
  font-size: 14px;
}

.entry-epg .epg-desc {
  color: var(--muted);
  font-size: 12px;
  white-space: pre-wrap;
}

.btn-highlighted {
  background-color: #ffd54f !important;
  color: #000 !important;
  border-color: #ffb300 !important;
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}

.btn-highlighted:active {
  transform: scale(0.95);
  box-shadow: 0 0 0 6px rgba(255, 179, 0, 0.35);
}

.channels-section {
  margin-top: 24px;
}

.channels-section h2 {
  margin: 12px 4px;
  font-weight: 600;
}

/* --------------------------------------------------
   DARK THEME  (Default)
-------------------------------------------------- */
/* ==================================================
   MOBILE MODE — FULLSCREEN MODAL + GESTURES
   ================================================== */
@media (max-width: 768px) {

  /* -------------------------------
     Modal becomes a screen
  -------------------------------- */
  .modal-backdrop {
    display: none;
  }

  .modal {
    position: fixed;
    inset: 0;
    z-index: 999;
  }

  .modal-card {
    position: fixed;
    inset: 0;
    width: 100vw;
    height: 100dvh;
    max-width: none;
    max-height: none;

    transform: none;
    border-radius: 0;
    border: none;
    box-shadow: none;
  }

  /* -------------------------------
     ONE scroll surface
  -------------------------------- */
  .modal-body {
    overflow: visible;
    height: auto;
  }

  .modal-card {
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  /* -------------------------------
     Header behaves like app bar
  -------------------------------- */
  .modal-head {
    position: sticky;
    top: 0;
    z-index: 10;

    background: linear-gradient(180deg,
        #0d111a 0%,
        #0d111ae6 70%,
        transparent 100%);
    padding-bottom: 8px;
  }

  /* -------------------------------
     SIMPLIFY CONTROLS
  -------------------------------- */

  /* Ensure toolbar actions are visible */
  .modal-toolbar {
    display: flex;
    position: sticky;
    top: 56px;
    /* below header */
    z-index: 9;
    background: #0b1220;
  }


  /* -------------------------------
     Content-first layout
  -------------------------------- */
  .entry-focus .entry-text {
    font-size: 17px;
    line-height: 1.6;
  }

  .entry-media video,
  .entry-media audio {
    width: 100%;
    max-width: none;
  }

  /* -------------------------------
     Touch-friendly spacing
  -------------------------------- */
  .entry {
    padding: 14px;
  }

  /* Force header to be SOLID in light mode */
  body[data-theme="light"] .modal-head {
    background: #ffffff !important;
    backdrop-filter: none !important;
    border-bottom: 1px solid var(--border);
  }

  /* Remove dark-mode gradient leakage */
  body[data-theme="light"] .modal-head::before,
  body[data-theme="light"] .modal-head::after {
    display: none !important;
  }

  /* Ensure text contrast */
  body[data-theme="light"] .modal-head,
  body[data-theme="light"] .modal-head * {
    color: var(--text);
  }

  /* Slight spacing polish */
  body[data-theme="light"] .modal-head {
    padding-top: env(safe-area-inset-top);
  }
}

:root[data-theme="dark"] {
  --bg: #0d111a;
  --panel: #141b29;
  --panel-2: #182233;
  --border: #2a3550;
  --text: #eef3ff;
  --muted: #a8b5d3;
  --accent: #6ea8ff;
  --accent-2: #7ee787;
  --warn: #f9c74f;
  --danger: #ff7b7b;
  --chip: #1b2436;
  --shadow: 0 10px 30px rgba(0, 0, 0, .35);
}

/* --------------------------------------------------
   LIGHT THEME
-------------------------------------------------- */

/* --------------------------------------------------
   LIGHT THEME — COMPLETE & POLISHED
-------------------------------------------------- */

:root[data-theme="light"] {
  /* Base */
  --bg: #f4f5f7;
  --panel: #ffffff;
  --panel-2: #ffffff;
  --border: #dcdde1;
  --text: #1f1f21;
  --muted: #6f7784;

  /* Accents (muted, premium look) */
  --accent: #3b7ddd;
  /* soft blue */
  --accent-2: #2ba96b;
  /* gentle green */
  --warn: #e6a23c;
  --danger: #d9534f;

  /* Surfaces + Chips */
  --chip: #eef1f5;

  /* Shadow */
  --shadow: 0 4px 12px rgba(0, 0, 0, 0.06);
}

/* Root background */
body[data-theme="light"] {
  background: var(--bg);
  color: var(--text);
}

/* Header */
body[data-theme="light"] .app-header {
  background: #ffffff !important;
  border-bottom: 1px solid var(--border);
  backdrop-filter: none !important;
}

/* Global sections */
body[data-theme="light"] .panel,
body[data-theme="light"] .panel-2 {
  background: #ffffff !important;
  border: 1px solid var(--border) !important;
  box-shadow: var(--shadow);
}

/* Mentions / Alerts container */
body[data-theme="light"] .notifications {
  background: #ffffff !important;
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}

/* Notification items */
body[data-theme="light"] .notif-item {
  background: #fafbfc !important;
  border: 1px solid #e4e7eb !important;
  color: var(--text);
}

body[data-theme="light"] .notif-item:hover {
  background: #f1f3f6 !important;
  border-color: #d6d9df !important;
}

body[data-theme="light"] .notif-snippet {
  color: #2b2f33;
}

/* Cards */
body[data-theme="light"] .card {
  background: #ffffff !important;
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}

body[data-theme="light"] .card-head,
body[data-theme="light"] .card-subhead {
  background: #ffffff !important;
  border-color: var(--border) !important;
  color: var(--text);
}

/* Chips */
body[data-theme="light"] .chip {
  background: #eef1f5 !important;
  border-color: var(--border) !important;
  color: var(--muted);
}

/* Entry blocks */
body[data-theme="light"] .btn {
  color: #e5eeff !important;
}

/* Entry blocks */
body[data-theme="light"] .entry {
  background: #ffffff !important;
  border: 1px solid var(--border);
}



body[data-theme="light"] .entry-text {
  color: var(--text);
}

body[data-theme="light"] .entry-media video,
body[data-theme="light"] .entry-media audio {
  background: #f3f4f6;
  border: 1px solid #d1d5db;
}

/* Entry EPG box */
body[data-theme="light"] .entry-epg {
  background: #ffffff;
  border: 1px solid var(--border);
}

/* Pills */
body[data-theme="light"] .pill {
  background: #f0f2f5 !important;
  border: 1px solid #d9dce1 !important;
  color: #59606d;
}

/* Badge */
body[data-theme="light"] .badge {
  background: #eef2f7;
  border-color: #d8dde4;
  color: #3366cc;
}

/* Modal */
body[data-theme="light"] .modal-card {
  background: #ffffff !important;
  border: 1px solid var(--border);
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.10);
}

body[data-theme="light"] .modal-subhead {
  background: #fafafa !important;
  border-bottom: 1px solid var(--border);
}

body[data-theme="light"] .modal-body {
  background: #ffffff !important;
}

body[data-theme="light"] .modal-toolbar {
  background: #f6f7f9;
  border-bottom: 1px solid var(--border);
}

/* Buttons */
body[data-theme="light"] .btn-secondary {
  background: #eef1f5 !important;
  border-color: #d0d4db !important;
  color: #1f1f21 !important;
}

body[data-theme="light"] .btn-highlighted {
  background: #ffd54f !important;
  border-color: #000 !important;
}


body[data-theme="light"] .btn-secondary:hover {
  filter: brightness(1.03);
}

/* Code blocks */
body[data-theme="light"] code {
  background: #f3f4f6;
  color: #333;
  border-color: #d7dae0;
}

/* Main content background */
body[data-theme="light"] main {
  background: #f4f5f7 !important;
}

/* Notification header channel label (e.g., tv-12) */
body[data-theme="light"] .notif-header {
  color: #4a4f57 !important;
  /* strengthen text */
}

body[data-theme="light"] .notif-header .notif-time {
  color: #7d8590 !important;
  /* readable but secondary */
}

body[data-theme="light"] .notif-header span {
  color: #4a4f57 !important;
  /* channel label */
}

body[data-theme="light"] .notif-logo-wrap {
  background: #f1f3f6;
  border: 1px solid #d6d9df;
}

body[data-theme="light"] .notif-logo-wrap img {
  filter: none;
}