/* ============ DWIM TV — Stylesheet ============ */
:root {
  --bg: #0a0a0f;
  --bg-2: #12121a;
  --bg-3: #1a1a26;
  --card: #161622;
  --card-hover: #22222f;
  --accent: #e50914;
  --accent-2: #ff2d3f;
  --text: #f5f5f7;
  --text-dim: #9a9aa8;
  --text-faint: #5c5c6e;
  --border: rgba(255, 255, 255, 0.08);
  --radius: 12px;
  --shadow: 0 8px 32px rgba(0, 0, 0, 0.45);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html, body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  scroll-behavior: smooth;
}

body { min-height: 100vh; }

a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }
input { font-family: inherit; }

/* ---------- Top Bar ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 14px 28px;
  background: rgba(10, 10, 15, 0.92);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 22px;
  font-weight: 800;
  letter-spacing: 1px;
  flex-shrink: 0;
}

.brand .tv-icon {
  width: 34px;
  height: 34px;
  background: linear-gradient(135deg, var(--accent), #ff6a00);
  border-radius: 8px;
  display: grid;
  place-items: center;
  font-size: 17px;
  box-shadow: 0 0 18px rgba(229, 9, 20, 0.55);
  overflow: hidden;
}

.brand .tv-icon img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.brand b { color: var(--accent); }

/* Search */
.searchwrap {
  flex: 1;
  max-width: 480px;
  position: relative;
  margin-left: auto;
}

.searchwrap .icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-faint);
  font-size: 15px;
  pointer-events: none;
}

#search {
  width: 100%;
  padding: 11px 16px 11px 40px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--bg-3);
  color: var(--text);
  font-size: 14px;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

#search:focus {
  border-color: rgba(229, 9, 20, 0.6);
  box-shadow: 0 0 0 3px rgba(229, 9, 20, 0.15);
}

#search::placeholder { color: var(--text-faint); }

.live-dot {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 2px;
  color: var(--text-dim);
  flex-shrink: 0;
}

.live-dot .pulse {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--accent);
  animation: pulse 1.6s infinite;
}

@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(229, 9, 20, 0.6); }
  70% { box-shadow: 0 0 0 9px rgba(229, 9, 20, 0); }
  100% { box-shadow: 0 0 0 0 rgba(229, 9, 20, 0); }
}

/* ---------- Channel Rail ---------- */
.channels {
  display: flex;
  gap: 10px;
  padding: 18px 28px 6px;
  overflow-x: auto;
  scrollbar-width: none;
}

.channels::-webkit-scrollbar { display: none; }

.chip {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 18px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--bg-2);
  color: var(--text-dim);
  font-size: 13.5px;
  font-weight: 600;
  white-space: nowrap;
  transition: all 0.18s ease;
}

.chip:hover { border-color: rgba(255,255,255,0.25); color: var(--text); }

.chip.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  box-shadow: 0 4px 14px rgba(229, 9, 20, 0.4);
}

/* ---------- Hero ---------- */
.hero {
  margin: 18px 28px 8px;
  border-radius: var(--radius);
  overflow: hidden;
  position: relative;
  min-height: 300px;
  display: flex;
  align-items: flex-end;
  box-shadow: var(--shadow);
  cursor: pointer;
}

.hero .hero-img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.5s ease;
}

.hero:hover .hero-img { transform: scale(1.03); }

.hero::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(to top, rgba(10,10,15,0.96) 0%, rgba(10,10,15,0.55) 45%, rgba(10,10,15,0.05) 100%);
}

.hero-body {
  position: relative;
  z-index: 2;
  padding: 34px 36px;
  max-width: 640px;
}

.hero-cat {
  display: inline-block;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 2.5px;
  text-transform: uppercase;
  color: var(--accent-2);
  margin-bottom: 10px;
}

.hero-title {
  font-size: 34px;
  font-weight: 800;
  line-height: 1.15;
  margin-bottom: 10px;
  text-shadow: 0 2px 14px rgba(0,0,0,0.6);
}

.hero-desc {
  color: var(--text-dim);
  font-size: 14.5px;
  line-height: 1.6;
  margin-bottom: 18px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.hero-meta {
  display: flex;
  align-items: center;
  gap: 14px;
  font-size: 13px;
  color: var(--text-faint);
  font-weight: 600;
}

.btn-play {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  background: var(--accent);
  color: #fff;
  padding: 12px 26px;
  border-radius: 999px;
  font-weight: 700;
  font-size: 15px;
  transition: all 0.2s;
  box-shadow: 0 6px 20px rgba(229, 9, 20, 0.45);
}

.btn-play:hover {
  background: var(--accent-2);
  transform: translateY(-2px);
  box-shadow: 0 10px 26px rgba(229, 9, 20, 0.55);
}

/* ---------- Section Rows ---------- */
.section { padding: 26px 28px 6px; }

.section-title {
  display: flex;
  align-items: baseline;
  gap: 12px;
  margin-bottom: 16px;
}

.section-title h2 {
  font-size: 19px;
  font-weight: 800;
  letter-spacing: 0.3px;
}

.section-title .count { font-size: 12.5px; color: var(--text-faint); font-weight: 600; }

/* ---------- Video Grid ---------- */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 20px;
}

.card {
  background: var(--card);
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--border);
  transition: transform 0.22s ease, border-color 0.22s ease, background 0.22s;
  cursor: pointer;
}

.card:hover {
  transform: translateY(-5px);
  background: var(--card-hover);
  border-color: rgba(255, 255, 255, 0.16);
}

.thumbwrap {
  position: relative;
  aspect-ratio: 16/9;
  background: var(--bg-3);
  overflow: hidden;
}

.thumbwrap img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.35s ease;
}

.card:hover .thumbwrap img { transform: scale(1.06); }

.duration {
  position: absolute;
  right: 8px;
  bottom: 8px;
  background: rgba(0, 0, 0, 0.82);
  padding: 3px 8px;
  border-radius: 5px;
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: 0.4px;
}

.play-overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(0, 0, 0, 0.32);
  opacity: 0;
  transition: opacity 0.22s;
}

.card:hover .play-overlay { opacity: 1; }

.play-overlay .circle {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: rgba(229, 9, 20, 0.95);
  display: grid;
  place-items: center;
  font-size: 17px;
  box-shadow: 0 0 0 8px rgba(229, 9, 20, 0.25);
}

.card-body { padding: 13px 14px 15px; }

.card-title {
  font-size: 14.5px;
  font-weight: 700;
  line-height: 1.35;
  margin-bottom: 6px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.card-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--text-faint);
  font-weight: 600;
}

.card-meta .cat { color: var(--accent-2); }

/* ---------- Player Modal ---------- */
.player-modal {
  position: fixed;
  inset: 0;
  z-index: 500;
  background: rgba(5, 5, 8, 0.94);
  backdrop-filter: blur(8px);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

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

.player-box {
  width: 100%;
  max-width: 1020px;
  background: var(--bg-2);
  border-radius: 16px;
  overflow: hidden;
  border: 1px solid var(--border);
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.7);
  animation: rise 0.28s ease;
}

@keyframes rise {
  from { opacity: 0; transform: translateY(26px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

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

.player-head h3 {
  font-size: 16px;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: calc(100% - 120px);
}

.btn-close {
  font-size: 21px;
  color: var(--text-dim);
  width: 38px;
  height: 38px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  transition: all 0.15s;
  flex-shrink: 0;
}

.btn-close:hover { background: var(--bg-3); color: var(--text); }

.player-frame {
  position: relative;
  aspect-ratio: 16/9;
  background: #000;
}

.player-frame iframe,
.player-frame video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: none;
}

.player-info {
  padding: 18px 22px 22px;
}

.player-info .meta-row {
  display: flex;
  gap: 14px;
  align-items: center;
  font-size: 12.5px;
  color: var(--text-faint);
  font-weight: 700;
  margin-bottom: 10px;
  flex-wrap: wrap;
}

.player-info .meta-row .cat { color: var(--accent-2); letter-spacing: 1px; text-transform: uppercase; }

.player-info p {
  color: var(--text-dim);
  font-size: 14px;
  line-height: 1.65;
  max-width: 720px;
}

/* ---------- Empty / Loading ---------- */
.loading, .empty {
  text-align: center;
  padding: 70px 20px;
  color: var(--text-faint);
  font-size: 15px;
  font-weight: 600;
}

.loading .spinner {
  width: 42px;
  height: 42px;
  border: 3px solid var(--bg-3);
  border-top-color: var(--accent);
  border-radius: 50%;
  margin: 0 auto 16px;
  animation: spin 0.8s linear infinite;
}

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

/* ---------- Footer ---------- */
.footer {
  margin-top: 50px;
  padding: 26px 28px 30px;
  border-top: 1px solid var(--border);
  text-align: center;
  color: var(--text-faint);
  font-size: 12.5px;
  line-height: 1.8;
}

.footer b { color: var(--text-dim); }

.footer .admin-link a {
  color: var(--text-dim);
  text-decoration: underline;
  font-weight: 700;
}
.footer .admin-link a:hover { color: var(--accent); }

/* ---------- Responsive ---------- */
@media (max-width: 720px) {
  .topbar { padding: 12px 16px; gap: 12px; }
  .brand { font-size: 18px; }
  .live-dot span.word { display: none; }
  .channels { padding: 14px 16px 4px; }
  .hero { margin: 14px 16px 6px; min-height: 220px; }
  .hero-body { padding: 22px; }
  .hero-title { font-size: 24px; }
  .section { padding: 22px 16px 4px; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 14px; }
  .card-title { font-size: 13px; }
  .searchwrap { max-width: none; }
}
