@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700&display=swap');

/* Default Midnight Theme Root Variables */
:root {
  --bg-color: #0c0d14;
  --bg-gradient: linear-gradient(135deg, #07080c 0%, #0e111d 100%);
  --card-bg: rgba(255, 255, 255, 0.03);
  --text-color-primary: #ffffff;
  --text-color-secondary: #8e94a5;
  --accent-color: #ff5722;
  --accent-glow: rgba(255, 87, 34, 0.4);
  --border-radius: 12px;
  --grid-padding-left: 80px;
  --card-width: 320px;
  --thumb-height: 180px;
}

/* Preset Themes Variables mapping */
body.theme-default {
  --bg-color: #0c0d14;
  --bg-gradient: linear-gradient(135deg, #07080c 0%, #0e111d 100%);
  --card-bg: rgba(255, 255, 255, 0.03);
  --text-color-primary: #ffffff;
  --text-color-secondary: #8e94a5;
}

body.theme-neon {
  --bg-color: #080512;
  --bg-gradient: linear-gradient(135deg, #04020a 0%, #17092c 100%);
  --card-bg: rgba(192, 132, 252, 0.04);
  --text-color-primary: #ffffff;
  --text-color-secondary: #c084fc;
}

body.theme-slate {
  --bg-color: #12131a;
  --bg-gradient: linear-gradient(135deg, #0b0c10 0%, #1c1d27 100%);
  --card-bg: rgba(255, 255, 255, 0.02);
  --text-color-primary: #ffffff;
  --text-color-secondary: #94a3b8;
}

body.theme-crimson {
  --bg-color: #0a0404;
  --bg-gradient: linear-gradient(135deg, #050202 0%, #1c0a0a 100%);
  --card-bg: rgba(239, 68, 68, 0.03);
  --text-color-primary: #ffffff;
  --text-color-secondary: #f87171;
}

body.theme-forest {
  --bg-color: #040a08;
  --bg-gradient: linear-gradient(135deg, #020504 0%, #0a1c14 100%);
  --card-bg: rgba(16, 185, 129, 0.03);
  --text-color-primary: #ffffff;
  --text-color-secondary: #34d399;
}

/* Card Layout Densities */
body.layout-compact {
  --card-width: 260px;
  --thumb-height: 146px;
}

body.layout-standard {
  --card-width: 320px;
  --thumb-height: 180px;
}

body.layout-cinematic {
  --card-width: 400px;
  --thumb-height: 225px;
}

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

body {
  font-family: 'Outfit', sans-serif;
  background-color: var(--bg-color);
  background-image: var(--bg-gradient);
  color: var(--text-color-primary);
  width: 1920px;
  height: 1080px;
  overflow: hidden;
  position: relative;
  user-select: none;
  -webkit-user-select: none;
}

@media (max-width: 1920px), (max-height: 1080px) {
  body {
    width: 100vw;
    height: 100vh;
  }
}

/* App Container */
.app-container {
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100%;
  padding: 40px 0;
  position: relative;
  z-index: 1;
}

/* Header */
.app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 var(--grid-padding-left);
  height: 100px;
  margin-bottom: 20px;
}

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

.app-logo {
  height: 60px;
  width: 60px;
  object-fit: cover;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.1);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
}

#app-name {
  font-size: 36px;
  font-weight: 700;
  letter-spacing: -0.5px;
}

.header-widgets {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 5px;
}

.time-widget {
  font-size: 28px;
  font-weight: 600;
  letter-spacing: 0.5px;
  color: var(--text-color-primary);
}

.nav-help {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-color-secondary);
  text-transform: uppercase;
  letter-spacing: 1px;
  opacity: 0.8;
}

/* Loading Spinner */
.app-loader {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  height: calc(100vh - 200px);
  gap: 20px;
}

.spinner {
  width: 50px;
  height: 50px;
  border: 4px solid rgba(255, 255, 255, 0.1);
  border-radius: 50%;
  border-top-color: var(--accent-color);
  animation: spin 1s ease-in-out infinite;
}

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

.app-loader p {
  font-size: 20px;
  color: var(--text-color-secondary);
  font-weight: 500;
}

/* Main Grid Container */
.grid-container {
  position: relative;
  flex: 1;
  overflow-y: hidden;
  scroll-behavior: smooth;
  padding: 20px 0;
}

/* Channel Row */
.channel-row {
  margin-bottom: 50px;
  display: flex;
  flex-direction: column;
  transition: transform 0.4s cubic-bezier(0.25, 0.8, 0.25, 1), opacity 0.4s;
}

.channel-row.inactive {
  opacity: 0.35;
  transform: scale(0.98);
}

.row-title {
  font-size: 24px;
  font-weight: 600;
  margin-bottom: 20px;
  color: var(--text-color-primary);
  letter-spacing: -0.2px;
  padding-left: var(--grid-padding-left);
}

/* Carousels */
.video-list {
  position: relative;
  display: flex;
  gap: 28px;
  overflow-x: hidden;
  padding: 24px var(--grid-padding-left) 32px var(--grid-padding-left);
  margin-top: -14px;
  margin-bottom: -12px;
  scroll-behavior: smooth;
  width: 100%;
}

/* Video Card */
.video-card {
  width: var(--card-width);
  flex-shrink: 0;
  background: var(--card-bg);
  border: 2px solid transparent;
  border-radius: var(--border-radius);
  overflow: hidden;
  cursor: pointer;
  transition: transform 0.3s cubic-bezier(0.25, 0.8, 0.25, 1), 
              border-color 0.3s, 
              box-shadow 0.3s,
              background-color 0.3s;
}

.thumbnail-container {
  position: relative;
  width: var(--card-width);
  height: var(--thumb-height);
  background: #000;
  overflow: hidden;
}

.thumbnail-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.5s ease;
}

.duration-tag {
  position: absolute;
  bottom: 10px;
  right: 10px;
  background: rgba(0, 0, 0, 0.85);
  color: #fff;
  padding: 3px 6px;
  font-size: 11px;
  font-weight: 600;
  border-radius: 4px;
}

/* live card indicators */
.live-badge-card {
  position: absolute;
  top: 10px;
  left: 10px;
  background: #ef4444;
  color: #fff;
  padding: 3px 6px;
  font-size: 10px;
  font-weight: 700;
  border-radius: 4px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  box-shadow: 0 2px 5px rgba(0,0,0,0.5);
  animation: cardPulse 1.5s infinite;
}

@keyframes cardPulse {
  0% { transform: scale(1); }
  50% { transform: scale(1.05); }
  100% { transform: scale(1); }
}

.video-info {
  padding: 15px;
}

.video-title {
  font-size: 15px;
  font-weight: 500;
  line-height: 1.4;
  color: var(--text-color-secondary);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  height: 42px;
  transition: color 0.3s;
}

/* Card Focus Outline (D-pad & Hover) */
.video-card.focused {
  transform: scale(1.08);
  background-color: rgba(255, 255, 255, 0.08);
  border-color: var(--accent-color);
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.6), 
              0 0 20px var(--accent-glow);
  z-index: 10;
}

.video-card.focused .thumbnail-img {
  transform: scale(1.05);
}

.video-card.focused .video-title {
  color: #ffffff;
}

/* Floating Live Stream Alert Notification card */
.live-alert {
  position: fixed;
  top: 40px;
  right: 80px;
  width: 440px;
  background: rgba(19, 21, 32, 0.85);
  backdrop-filter: blur(25px);
  -webkit-backdrop-filter: blur(25px);
  border: 2px solid rgba(239, 68, 68, 0.4);
  border-radius: var(--border-radius);
  padding: 24px;
  box-shadow: 0 15px 40px rgba(0, 0, 0, 0.7), 
              0 0 30px rgba(239, 68, 68, 0.2);
  z-index: 2000;
  animation: slideInRight 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  transition: opacity 0.3s, transform 0.3s;
}

.live-alert.hidden {
  display: none;
  opacity: 0;
  transform: translateX(100px);
}

@keyframes slideInRight {
  from { transform: translateX(150px); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

.live-alert-header {
  display: flex;
  align-items: center;
  gap: 15px;
  margin-bottom: 12px;
}

.live-badge-wrapper {
  display: inline-flex;
  align-items: center;
  background: rgba(239, 68, 68, 0.15);
  border: 1px solid rgba(239, 68, 68, 0.4);
  border-radius: 4px;
  padding: 2px 8px;
  gap: 6px;
}

.live-badge-pulsing {
  color: #ef4444;
  font-size: 14px;
  animation: textPulse 1s ease infinite;
}

@keyframes textPulse {
  0% { opacity: 0.3; }
  50% { opacity: 1; }
  100% { opacity: 0.3; }
}

.live-badge-text {
  color: #ef4444;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.5px;
}

.live-alert-source {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-color-secondary);
}

.live-alert-body h3 {
  font-size: 18px;
  font-weight: 500;
  line-height: 1.4;
  margin-bottom: 20px;
  color: #ffffff;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.live-alert-actions {
  display: flex;
  gap: 12px;
}

.live-alert-btn {
  flex: 1;
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  padding: 10px;
  border-radius: 8px;
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.25s;
}

.live-alert-btn.watch-btn {
  background: #ef4444;
  color: #fff;
  box-shadow: 0 4px 10px rgba(239, 68, 68, 0.25);
}

.live-alert-btn.dismiss-btn {
  background: rgba(255, 255, 255, 0.05);
  border-color: rgba(255, 255, 255, 0.1);
  color: #fff;
}

/* Focused elements inside Live Alert */
.live-alert-btn.focused {
  border-color: #fff;
  box-shadow: 0 0 15px rgba(255, 255, 255, 0.4);
  transform: scale(1.03);
}

/* Fullscreen Video Overlay */
.video-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: #000000;
  z-index: 9999;
  display: flex;
  justify-content: center;
  align-items: center;
  opacity: 1;
  transition: opacity 0.4s ease;
}

.video-overlay.hidden {
  display: none;
  opacity: 0;
}

#youtube-player {
  width: 100%;
  height: 100%;
  border: none;
}

/* HUD Overlay on Video Player */
.player-hud {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: linear-gradient(to top, rgba(0,0,0,0.9) 0%, rgba(0,0,0,0.5) 70%, rgba(0,0,0,0) 100%);
  padding: 40px 80px;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.5s ease;
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
}

.video-overlay:hover .player-hud, 
.video-overlay.show-hud .player-hud {
  opacity: 1;
}

.player-hud h2 {
  font-size: 28px;
  font-weight: 600;
  max-width: 60%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.hud-controls {
  font-size: 16px;
  font-weight: 500;
  color: var(--text-color-secondary);
  text-transform: uppercase;
  letter-spacing: 1px;
}

/* Footer Styling */
.app-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 15px var(--grid-padding-left);
  height: 110px;
  border-top: 1px solid rgba(255, 255, 255, 0.04);
  background: rgba(0, 0, 0, 0.2);
  margin-top: 20px;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.footer-column {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.footer-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 15px;
  font-weight: 500;
}

.address-col {
  max-width: 450px;
  flex-shrink: 1;
}

.address-wrapper {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.address-val {
  font-size: 13px !important;
  line-height: 1.4;
  white-space: normal;
}

.info-label {
  color: var(--text-color-secondary);
  font-weight: 500;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.info-value {
  color: var(--text-color-primary);
  font-weight: 600;
  font-size: 16px;
  letter-spacing: 0.2px;
}

/* Category Navigation Bar */
.category-bar {
  display: flex;
  gap: 20px;
  padding: 0 var(--grid-padding-left);
  height: 55px;
  align-items: center;
  margin-bottom: 5px;
  z-index: 10;
  position: relative;
}

.category-tab {
  font-size: 18px;
  font-weight: 500;
  color: var(--text-color-secondary);
  padding: 8px 24px;
  border-radius: 20px;
  cursor: pointer;
  transition: all 0.25s cubic-bezier(0.25, 0.8, 0.25, 1);
  border: 2px solid transparent;
  background: rgba(255, 255, 255, 0.02);
}

.category-tab.active {
  color: #fff;
  background: rgba(255, 255, 255, 0.08);
  font-weight: 600;
  border-color: rgba(255, 255, 255, 0.06);
}

.category-tab.focused {
  color: #fff;
  background: var(--accent-color);
  font-weight: 600;
  border-color: var(--accent-color);
  box-shadow: 0 4px 15px var(--accent-glow);
  transform: scale(1.06);
}

/* Scrolling Announcement Ticker */
.ticker-bar {
  height: 40px;
  background: rgba(0, 0, 0, 0.35);
  border-top: 1px solid rgba(255, 255, 255, 0.03);
  border-bottom: 1px solid rgba(255, 255, 255, 0.03);
  display: flex;
  align-items: center;
  overflow: hidden;
  width: 100%;
  margin-top: 10px;
  z-index: 5;
  position: relative;
}

.ticker-bar.hidden {
  display: none;
}

.ticker-wrapper {
  overflow: hidden;
  width: 100%;
  display: flex;
  align-items: center;
}

.ticker-text {
  white-space: nowrap;
  font-size: 15px;
  font-weight: 500;
  color: var(--text-color-primary);
  padding-left: 100%;
  display: inline-block;
  animation: tickerLoop 30s linear infinite;
  letter-spacing: 0.5px;
}

@keyframes tickerLoop {
  0% { transform: translate3d(0, 0, 0); }
  100% { transform: translate3d(-100%, 0, 0); }
}

.ticker-speed-fast {
  animation-duration: 15s;
}

.ticker-speed-slow {
  animation-duration: 50s;
}

/* Header TV Guide Button */
.schedule-btn {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 18px;
  color: var(--text-color-secondary);
  padding: 6px 18px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.25s cubic-bezier(0.25, 0.8, 0.25, 1);
  font-family: inherit;
  margin-left: 15px;
  border-color: rgba(255, 255, 255, 0.08);
}

.schedule-btn.focused {
  background: var(--accent-color);
  color: #fff;
  border-color: var(--accent-color);
  box-shadow: 0 4px 12px var(--accent-glow);
  transform: scale(1.05);
}

/* Watch History progress bar indicators */
.progress-bar-container {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 5px;
  background: rgba(255, 255, 255, 0.2);
}

.progress-bar-value {
  height: 100%;
  background: var(--accent-color);
  width: 0%;
  box-shadow: 0 0 5px var(--accent-color);
}

/* EPG Schedule TV Guide Overlay */
.epg-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(8, 9, 15, 0.96);
  z-index: 200;
  display: flex;
  justify-content: center;
  align-items: center;
  backdrop-filter: blur(25px);
  -webkit-backdrop-filter: blur(25px);
  transition: opacity 0.3s;
}

.epg-overlay.hidden {
  display: none;
}

.epg-content {
  width: 90%;
  height: 85%;
  display: flex;
  flex-direction: column;
  gap: 25px;
}

.epg-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  padding-bottom: 15px;
}

.epg-header-title h2 {
  font-size: 32px;
  font-weight: 700;
  color: var(--text-color-primary);
  letter-spacing: -0.5px;
}

.epg-header-title .desc {
  font-size: 14px;
  color: var(--text-color-secondary);
  margin-top: 4px;
}

.epg-subtitle {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-color-secondary);
  text-transform: uppercase;
  letter-spacing: 1px;
  opacity: 0.8;
}

.epg-days-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 15px;
  flex: 1;
  overflow: hidden;
}

.epg-day-col {
  background: rgba(255, 255, 255, 0.015);
  border: 1px solid rgba(255, 255, 255, 0.03);
  border-radius: var(--border-radius);
  padding: 15px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  height: 100%;
  overflow-y: auto;
  scrollbar-width: none;
}

.epg-day-col::-webkit-scrollbar {
  display: none;
}

.epg-day-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--accent-color);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  padding-bottom: 8px;
  margin-bottom: 4px;
  text-align: center;
}

.epg-slot {
  background: rgba(255, 255, 255, 0.02);
  border-left: 3px solid var(--accent-color);
  padding: 8px 10px;
  border-radius: 4px;
  display: flex;
  flex-direction: column;
  gap: 3px;
  transition: background-color 0.25s;
}

.epg-slot:hover {
  background: rgba(255, 255, 255, 0.05);
}

.epg-slot-time {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-color-secondary);
  letter-spacing: 0.2px;
}

.epg-slot-title {
  font-size: 13px;
  font-weight: 600;
  color: #fff;
  line-height: 1.3;
}

.epg-slot-speaker {
  font-size: 11px;
  color: var(--text-color-secondary);
  font-style: italic;
}

/* Fullscreen Video Gallery Grid Overlay (Search & Sort) */
.gallery-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(8, 9, 15, 0.97);
  z-index: 150;
  display: flex;
  justify-content: center;
  align-items: center;
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  transition: opacity 0.3s;
}

.gallery-overlay.hidden {
  display: none;
}

.gallery-content {
  width: 90%;
  height: 88%;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.gallery-header {
  display: flex;
  flex-direction: column;
  gap: 15px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  padding-bottom: 15px;
}

.gallery-title-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
}

.gallery-title-row h2 {
  font-size: 32px;
  font-weight: 700;
  color: var(--text-color-primary);
  letter-spacing: -0.5px;
}

.gallery-subtitle {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-color-secondary);
  text-transform: uppercase;
  letter-spacing: 1px;
}

.gallery-search-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 40px;
}

#gallery-search-input {
  flex: 1;
  max-width: 500px;
  background: rgba(255, 255, 255, 0.04);
  border: 1.5px solid rgba(255, 255, 255, 0.08);
  border-radius: 20px;
  padding: 10px 20px;
  color: #fff;
  font-size: 15px;
  font-family: inherit;
  transition: all 0.25s cubic-bezier(0.25, 0.8, 0.25, 1);
}

#gallery-search-input.focused {
  border-color: var(--accent-color);
  outline: none;
  background: rgba(255, 255, 255, 0.08);
  box-shadow: 0 0 15px rgba(255, 87, 34, 0.15);
}

.gallery-sort-group {
  display: flex;
  gap: 10px;
}

.gallery-sort-btn {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 16px;
  padding: 6px 16px;
  color: var(--text-color-secondary);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.25s cubic-bezier(0.25, 0.8, 0.25, 1);
  font-family: inherit;
}

.gallery-sort-btn.active {
  color: #fff;
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.12);
}

.gallery-sort-btn.focused {
  color: #fff;
  background: var(--accent-color);
  border-color: var(--accent-color);
  box-shadow: 0 4px 10px var(--accent-glow);
}

.gallery-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 28px;
  flex: 1;
  overflow-y: auto;
  padding: 10px 5px 40px 5px;
  scrollbar-width: none;
}

.gallery-grid::-webkit-scrollbar {
  display: none;
}

.view-all-card {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--border-radius);
  height: 100%;
  min-height: 180px;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
  gap: 12px;
  color: var(--text-color-secondary);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.2);
  
  /* Make card exactly same width as video cards */
  flex: 0 0 var(--card-width);
  width: var(--card-width);
}

.view-all-card.focused {
  border-color: var(--accent-color);
  background: var(--accent-color);
  color: #fff;
  transform: scale(1.06);
  box-shadow: 0 12px 30px var(--accent-glow);
}

.view-all-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
  color: inherit;
}

.view-all-card.focused .view-all-icon {
  transform: translateX(6px);
}

.view-all-text {
  font-size: 14px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
}

/* Gallery layout override: make cards stretch to grid column width, preserving aspect ratio */
.gallery-grid .video-card {
  width: 100% !important;
  max-width: 100% !important;
  flex: none !important;
}

