:root {
  --bg-color: #080d13;
  --bg-soft: #0c121a;
  --surface-color: #121a24;
  --surface-raised: #182331;
  --surface-elevated: #202d3d;
  --border-soft: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.16);

  --primary-color: #66c7ff;
  --secondary-color: #31d7b8;
  --warning-color: #ffb454;
  --danger-color: #ff5f57;
  --success-color: #58d68d;

  --text-primary: #f2f6fa;
  --text-secondary: #a9b7c7;
  --text-muted: #718093;

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 18px;

  --shadow-card: 0 10px 30px rgba(0, 0, 0, 0.28);
  --shadow-modal: 0 25px 80px rgba(0, 0, 0, 0.65);
}

* {
  box-sizing: border-box;
}

html {
  margin: 0;
  padding: 0;
  min-height: 100%;
  background: #080d13;
  color-scheme: dark;
}

body {
  margin: 0;
  min-height: 100dvh;
  background: #080d13;
  color: var(--text-primary);
  font-family:
    -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial,
    sans-serif;
  overflow-x: hidden;
}

/* Fixed Safari-safe background layer */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    radial-gradient(
      circle at top left,
      rgba(102, 199, 255, 0.08),
      transparent 34rem
    ),
    linear-gradient(180deg, #071018 0%, #080d13 45%, #06090d 100%);
  pointer-events: none;
}

button,
input {
  font: inherit;
}
button {
  -webkit-tap-highlight-color: transparent;
}

.container {
  max-width: 1120px;
  margin: 0 auto;
  padding: 14px;
}

/* HEADER / CONTROLS */
header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(12, 18, 26, 0.96);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-lg);
  padding: 14px;
  margin-bottom: 18px;
  box-shadow: var(--shadow-card);
}

.header-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border-soft);
  margin-bottom: 14px;
}

h1 {
  margin: 0;
  font-size: clamp(1.35rem, 5vw, 2rem);
  letter-spacing: -0.04em;
  line-height: 1;
}

h1 cite {
  color: var(--primary-color);
  font-style: normal;
  font-weight: 700;
}

.menu-button {
  width: 46px;
  height: 42px;
  display: grid;
  place-items: center;
  background: var(--surface-raised);
  color: var(--text-primary);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  font-size: 1.45rem;
  cursor: pointer;
  line-height: 1;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

.menu-button:hover {
  background: var(--surface-elevated);
}

.controls {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.control-group {
  display: flex;
  flex-direction: column;
  width: 100%;
}

label {
  margin-bottom: 7px;
  font-size: 0.72rem;
  letter-spacing: 0.11em;
  text-transform: uppercase;
  color: var(--text-muted);
  font-weight: 800;
}

.search-container {
  width: 100%;
}

.search-input-wrapper {
  width: 100%;
  display: flex;
  background: var(--bg-soft);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-md);
  overflow: hidden;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.03);
}

input[type="search"] {
  width: 100%;
  min-width: 0;
  flex: 1 1 auto;
  padding: 14px 14px;
  font-size: 1rem;
  border: 0;
  background: transparent;
  color: var(--text-primary);
  outline: none;
}

input[type="search"]::placeholder {
  color: var(--text-muted);
}

input[type="search"]::-webkit-search-cancel-button {
  -webkit-appearance: none;
  height: 18px;
  width: 18px;
  background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="%23718093"><path d="M19 6.41L17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z"/></svg>');
  background-size: 100%;
  cursor: pointer;
  margin-right: 5px;
}

.btn-live-filter {
  flex: 0 0 74px;
  border: 0;
  border-left: 1px solid var(--border-soft);
  background: var(--surface-raised);
  color: var(--text-secondary);
  font-size: 0.78rem;
  font-weight: 900;
  letter-spacing: 0.08em;
  cursor: pointer;
}

.btn-live-filter.active {
  background: linear-gradient(180deg, #ffcc66, #ff9f43);
  color: #111820;
}

/* SIDE MENU */
.side-menu {
  position: fixed !important;
  top: 0 !important;
  right: 0 !important;
  left: auto !important;
  bottom: 0 !important;
  width: min(320px, 86vw) !important;
  height: 100vh !important;
  min-height: 100vh !important;
  background: #121a24 !important;
  border-left: 1px solid var(--border-strong) !important;
  box-shadow: -24px 0 70px rgba(0, 0, 0, 0.65) !important;
  transform: translateX(105%) !important;
  transition: transform 0.25s ease !important;
  z-index: 10000 !important;
  padding: 20px !important;
  display: flex !important;
  flex-direction: column !important;
  gap: 11px !important;
}

.side-menu.open {
  transform: translateX(0) !important;
}

.menu-close-button {
  width: 46px !important;
  height: 46px !important;
  margin-left: auto !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  background: #0c121a !important;
  border: 1px solid var(--border-strong) !important;
  border-radius: 12px !important;
  color: white !important;
  font-size: 32px !important;
  font-weight: bold !important;
  line-height: 1 !important;
  cursor: pointer !important;
  margin-bottom: 10px !important;
}

.menu-item {
  padding: 14px;
  text-align: left;
  background: var(--bg-soft);
  color: var(--text-primary);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-md);
  cursor: pointer;
  font-weight: 700;
}

.menu-item:hover {
  border-color: var(--primary-color);
}

/* LOADER */
#loader {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.72);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 3000;
  visibility: hidden;
  opacity: 0;
  transition:
    opacity 0.25s,
    visibility 0.25s;
}

#loader.visible {
  visibility: visible;
  opacity: 1;
}

.spinner {
  border: 7px solid rgba(255, 255, 255, 0.12);
  border-top: 7px solid var(--primary-color);
  border-radius: 50%;
  width: 58px;
  height: 58px;
  animation: spin 0.9s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* GUIDE */
#guide-container h2,
.search-title {
  color: var(--text-primary);
  font-size: 0.9rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  border: 0;
  padding: 0;
  margin: 0 0 12px;
}

.group-wrapper {
  margin-bottom: 18px;
  border: 0;
}

.group-wrapper h2 {
  cursor: default;
  padding: 12px 14px;
  margin: 0 0 12px;
  background: rgba(18, 26, 36, 0.8);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-md);
  color: var(--primary-color);
}

.channel-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
}

/* CARDS */
.card {
  position: relative;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.035), transparent),
    var(--surface-color);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-lg);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-card);
  justify-content: space-between;
}

.channel-card {
  cursor: pointer;
}

.channel-card:hover {
  border-color: rgba(102, 199, 255, 0.35);
  background:
    linear-gradient(180deg, rgba(102, 199, 255, 0.06), transparent),
    var(--surface-color);
}

.card-main-content {
  display: grid;
  grid-template-columns: 64px 1fr;
  gap: 13px;
  align-items: center;
  width: 100%;
  padding: 14px;
}

.card-logo {
  width: 64px;
  height: 64px;
  background: var(--bg-soft);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-md);
  padding: 7px;
  display: grid;
  place-items: center;
  overflow: hidden;
}

.card-logo img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

.card-content {
  min-width: 0;
}

.card-content h3 {
  margin: 0 0 7px;
  color: var(--primary-color);
  font-size: 0.78rem;
  line-height: 1.1;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.card-content p {
  margin: 0;
}

.program-title {
  font-size: clamp(1rem, 4vw, 1.15rem);
  color: var(--text-primary);
  font-weight: 500;
  letter-spacing: -0.01em;
  line-height: 1.3;
  margin-bottom: 6px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.program-datetime {
  display: inline-flex;
  margin-top: 8px;
  padding: 5px 8px;
  border-radius: 999px;
  color: var(--primary-color);
  font-size: 0.78rem;
  font-weight: 800;
  white-space: normal;
}

.progress-bar {
  width: 100%;
  background: rgba(255, 255, 255, 0.08);
  height: 6px;
  border-radius: 999px;
  margin-top: 12px;
  overflow: hidden;
}

.progress {
  background: linear-gradient(
    90deg,
    var(--secondary-color),
    var(--primary-color)
  );
  height: 100%;
  width: 0%;
  border-radius: inherit;
}

.card-description-container {
  display: block;
  padding: 0 14px 14px;
}

.program-description {
  font-size: 0.84rem;
  color: var(--text-secondary);
  line-height: 1.45;
  margin: 0;
  max-height: 3.9em;
  overflow: hidden;
}

.program-subtitle {
  color: var(--text-primary);
  font-weight: 700;
  margin-bottom: 4px;
}

/* SEARCH RESULT VISIBILITY */
.card-book-container {
  display: none !important;
  padding: 0 14px 14px;
}

body.logged-in #guide-container.search-results .card-book-container {
  display: block !important;
}

.search-results .card .progress-bar {
  display: none;
}
#guide-container.search-results .card .program-datetime {
  display: inline-flex;
}

/* BUTTONS */
.btn-book,
.btn-booked,
.btn-cancel,
#login-form button[type="submit"],
#about-close-btn {
  border-radius: var(--radius-md);
  font-weight: 900;
  letter-spacing: 0.06em;
  cursor: pointer;
  text-transform: uppercase;
}

.btn-book {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: auto;
  min-width: 94px;
  min-height: 38px;
  padding: 9px 13px;
  border: 0;
  background: linear-gradient(180deg, #39e2c3, #18bfa4);
  color: #06110f;
  box-shadow: 0 10px 20px rgba(49, 215, 184, 0.16);
  font-size: 0.76rem;
}

.btn-book:hover {
  filter: brightness(1.06);
}

.btn-booked {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: auto;
  min-width: 104px;
  min-height: 38px;
  padding: 9px 13px;
  background: rgba(88, 214, 141, 0.12);
  color: var(--success-color);
  border: 1px solid rgba(88, 214, 141, 0.35);
  cursor: not-allowed;
  font-size: 0.76rem;
}

/* EXPANDED CHANNEL PROGRAMMES */
.channel-card:has(.channel-programmes) {
  grid-column: 1 / -1;
  border-color: rgba(102, 199, 255, 0.35);
}

.channel-programmes {
  margin: 0 12px 12px;
  padding: 8px;
  background:
    linear-gradient(180deg, rgba(102, 199, 255, 0.045), transparent),
    var(--bg-soft);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-lg);
  max-height: 620px;
  overflow-y: auto;
}

.channel-programme-item {
  display: grid;
  grid-template-columns: 92px 1fr;
  gap: 12px;
  padding: 13px 8px;
  border-bottom: 1px solid var(--border-soft);
  align-items: start;
}

.channel-programme-item:last-child {
  border-bottom: 0;
}

.channel-programme-left {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.channel-programme-time {
  color: var(--warning-color);
  font-weight: 900;
  line-height: 1.2;
  letter-spacing: 0.02em;
}

.programme-date,
.programme-clock {
  display: block;
}

.programme-date {
  font-size: 0.72rem;
}

.programme-clock {
  font-size: 0.86rem;
  white-space: nowrap;
}

.channel-programme-image {
  width: 100%;
  aspect-ratio: 16 / 10;
  object-fit: cover;
  border-radius: var(--radius-md);
  background-color: #0a0f15;
  border: 1px solid var(--border-soft);
}

.channel-programme-info {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.channel-programme-title {
  color: var(--text-primary);
  font-weight: 600;
  font-size: clamp(1rem, 4vw, 1.18rem);
  line-height: 1.2;
  letter-spacing: -0.015em;
}

.channel-programme-description {
  color: var(--text-secondary);
  font-size: 0.86rem;
  line-height: 1.4;
  max-height: 3.9em;
  overflow: hidden;
}

.channel-programme-book {
  margin-top: 2px;
}

.channel-programme-book .btn-book {
  min-width: 92px;
  min-height: 36px;
  padding: 8px 12px;
  font-size: 0.74rem;
}

.channel-programme-book .btn-booked {
  min-width: 104px;
  min-height: 36px;
  padding: 8px 12px;
  font-size: 0.74rem;
}

/* MODALS */
.modal {
  display: none;
  position: fixed;
  z-index: 3000;
  inset: 0;
  background: rgba(0, 0, 0, 0.72);
  justify-content: center;
  align-items: center;
  padding: 16px;
}

.modal.show {
  display: flex;
}

.modal-content {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.04), transparent),
    var(--surface-color);
  color: var(--text-primary);
  padding: 22px;
  border: 1px solid var(--border-strong);
  width: 100%;
  max-width: 620px;
  max-height: 86vh;
  overflow-y: auto;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-modal);
  text-align: left;
}

.modal-content h2 {
  color: var(--text-primary);
  margin-top: 0;
  letter-spacing: -0.03em;
}

.close-button {
  color: var(--text-muted);
  float: right;
  font-size: 30px;
  font-weight: bold;
  cursor: pointer;
}

.close-button:hover {
  color: var(--text-primary);
}

.error-message {
  color: var(--danger-color);
  font-weight: 800;
  margin-bottom: 10px;
  text-align: center;
}

/* LOGIN */
#login-form label {
  display: block;
  margin-top: 15px;
}

#login-form input[type="text"],
#login-form input[type="password"] {
  display: block;
  width: 100%;
  padding: 14px;
  margin: 6px 0 14px;
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-md);
  background-color: var(--bg-soft);
  color: var(--text-primary);
  font-size: 16px;
  outline: none;
}

#login-form input:focus {
  border-color: var(--primary-color);
}

#login-form button[type="submit"] {
  width: 100%;
  margin-top: 16px;
  padding: 14px;
  border: 0;
  background: var(--secondary-color);
  color: #06110f;
}

/* BOOKINGS MODAL */
.bookings-grid {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 18px;
  max-height: 70vh;
  overflow-y: auto;
  padding-right: 4px;
}

.booking-card {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
  padding: 14px;
  background:
    linear-gradient(90deg, rgba(102, 199, 255, 0.06), transparent),
    var(--bg-soft);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-soft);
}

.booking-details {
  display: grid;
  grid-template-columns: 70px 1fr;
  gap: 12px;
  align-items: start;
  min-width: 0;
}

.booking-icon {
  width: 100%;
  height: auto;
  object-fit: cover;
  object-position: center top;
  border-radius: var(--radius-md);
  background-color: #0a0f15;
  border: 1px solid var(--border-soft);
}

.booking-text {
  min-width: 0;
}
.booking-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.btn-watch {
  flex: 1;
  padding: 10px 13px;
  border-radius: var(--radius-md);
  border: 1px solid rgba(102, 199, 255, 0.35);
  background: rgba(102, 199, 255, 0.12);
  color: var(--primary-color);
  font-size: 0.76rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  cursor: pointer;
  text-transform: uppercase;
}

.btn-watch:hover {
  background: rgba(102, 199, 255, 0.2);
}

.booking-channel {
  display: inline-flex;
  align-items: center;
  width: 100%;
  height: 30px;
  margin: 0;
  padding: 4px 8px;
  border-radius: 999px;
  background: rgba(102, 199, 255, 0.1);
  color: var(--primary-color);
  font-size: 0.72rem;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.booking-stream-label {
  display: inline-flex;
  width: fit-content;
  margin-left: auto;
  margin-bottom: 6px;
  margin-top: 6px;
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(49, 215, 184, 0.12);
  border: 1px solid rgba(49, 215, 184, 0.35);
  color: var(--secondary-color);
  font-size: 0.68rem;
  font-weight: 500;
  letter-spacing: 0.08em;
}

.booking-program {
  display: flex;
  align-items: center;
  font-size: 1.02rem;
  color: var(--text-primary);
  font-weight: 500;
  margin: 0px;
  line-height: 1.2;
  height: 40px;
}

.booking-times {
  font-size: 0.92rem;
  color: var(--warning-color);
  margin: 0 0 0px;
  font-weight: 850;
  height: 32px;
  display: flex;
  align-items: center;
}

.booking-description-summary {
  color: var(--text-secondary);
  font-size: 0.85rem;
  line-height: 1.4;
  margin-left: -74px;
  width: calc(100% + 74px);
  margin-top: 0;
  margin-bottom: 0;
  padding: 0;

  overflow: hidden;
  display: -webkit-box;
  -webkit-box-orient: vertical;

  line-clamp: 3;
  -webkit-line-clamp: 3;
}

.btn-cancel {
  justify-self: stretch;
  padding: 10px 13px;
  background: rgba(255, 95, 87, 0.12);
  color: #ff918b;
  border: 1px solid rgba(255, 95, 87, 0.35);
  font-size: 0.76rem;
}

.btn-cancel:hover {
  background: rgba(255, 95, 87, 0.2);
}

/* ABOUT MODAL */
.full-screen-modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.84);
  z-index: 9999;
  display: none;
  justify-content: center;
  align-items: center;
  padding: 18px;
}

.glass-panel {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.045), transparent),
    rgba(18, 26, 36, 0.96);
  backdrop-filter: blur(14px);
}

.about-header {
  text-align: center;
  margin-bottom: 20px;
  border-bottom: 1px solid var(--border-soft);
  padding-bottom: 15px;
}

.about-header h2 {
  margin: 0;
  color: var(--primary-color);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 1.15rem;
}

.about-header p {
  color: var(--text-muted);
  font-size: 0.82rem;
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  margin-top: 6px;
}

.tech-section {
  margin-bottom: 20px;
}

.tech-section h4 {
  color: var(--text-primary);
  border-left: 4px solid var(--primary-color);
  padding-left: 10px;
  margin-bottom: 8px;
  text-transform: uppercase;
  font-size: 0.82rem;
  letter-spacing: 0.1em;
}

.tech-section p {
  font-size: 0.94rem;
  line-height: 1.55;
  color: var(--text-secondary);
}

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

.tag {
  background: rgba(102, 199, 255, 0.08);
  border: 1px solid rgba(102, 199, 255, 0.22);
  padding: 5px 10px;
  border-radius: 999px;
  font-size: 0.7rem;
  color: var(--primary-color);
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  text-transform: uppercase;
}

#about-close-btn {
  display: block;
  width: 100%;
  margin-top: 20px;
  padding: 14px;
  background: var(--surface-raised);
  border: 1px solid var(--primary-color);
  color: var(--primary-color);
}

/* HLS PLAYER MODAL */
.player-modal {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 12000;
  background: #000;
}

.player-modal.show {
  display: flex;
}

.player-shell {
  position: relative;
  width: 100%;
  height: 100%;
  background: #000;
  display: flex;
  flex-direction: column;
}

.player-header {
  position: absolute;
  top: env(safe-area-inset-top, 0);
  left: 0;
  right: 0;
  z-index: 2;
  padding: 14px 56px 10px 16px;
  color: white;
  font-size: 0.85rem;
  font-weight: 800;
  background: linear-gradient(180deg, rgba(0, 0, 0, 0.75), transparent);
  pointer-events: none;
}

.player-close-button {
  position: absolute;
  top: calc(env(safe-area-inset-top, 0) + 10px);
  right: 12px;
  z-index: 3;
  width: 42px;
  height: 42px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.25);
  background: rgba(0, 0, 0, 0.65);
  color: white;
  font-size: 30px;
  line-height: 1;
  cursor: pointer;
}

.hls-video {
  width: 100%;
  height: 100%;
  background: #000;
  object-fit: contain;
}

/* RESPONSIVE */
@media (min-width: 600px) {
  .container {
    padding: 20px;
  }

  .controls {
    flex-direction: row;
    align-items: flex-end;
  }

  .control-group,
  .search-container {
    flex-grow: 1;
    width: 100%;
  }

  .channel-grid {
    grid-template-columns: 1fr;
  }

  .booking-card {
    grid-template-columns: 1fr auto;
    align-items: center;
  }

  .btn-cancel {
    justify-self: end;
  }
  .btn-watch {
    font-size: 0.56rem;
  }
}

@media (min-width: 900px) {
  .channel-grid {
    grid-template-columns: 1fr;
  }

  .channel-card:has(.channel-programmes) {
    grid-column: 1 / -1;
  }

  .channel-programmes {
    max-height: 760px;
    padding: 10px 14px;
  }

  .channel-programme-item {
    grid-template-columns: 130px 1fr;
    gap: 16px;
    padding: 16px 8px;
  }

  .channel-programme-time {
    font-size: 0.9rem;
  }
  .channel-programme-title {
    font-size: 1.28rem;
  }

  .channel-programme-description {
    font-size: 1rem;
    max-height: 2.8em;
    overflow: hidden;
  }
}
