:root {
  --bg-main: #0a0b10;
  --bg-card: #12141f;
  --bg-card-hover: #1b1e2f;
  --bg-card-active: #152238;
  --border-color: rgba(255, 255, 255, 0.08);
  --border-focus: #00e5ff;
  --text-main: #f0f2f8;
  --text-muted: #8b92a5;
  --accent-cyan: #00e5ff;
  --accent-green: #00ff66;
  --accent-red: #ff3366;
  --header-height: 64px;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: var(--font-sans);
  background-color: var(--bg-main);
  color: var(--text-main);
  overflow: hidden;
  height: 100vh;
  width: 100vw;
}

/* App Layout */
.app-layout {
  display: flex;
  flex-direction: column;
  height: 100vh;
  width: 100vw;
}

/* Header */
.app-header {
  height: var(--header-height);
  background: rgba(10, 11, 16, 0.85);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  z-index: 100;
  flex-shrink: 0;
}

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

.brand-logo {
  font-size: 24px;
}

.brand-title {
  font-size: 20px;
  font-weight: 800;
  letter-spacing: -0.5px;
}

.brand-title .highlight {
  color: var(--accent-cyan);
}

.brand-badge {
  background: rgba(0, 229, 255, 0.12);
  color: var(--accent-cyan);
  padding: 3px 8px;
  border-radius: var(--radius-sm);
  font-size: 11px;
  font-weight: 600;
}

.header-controls {
  display: flex;
  align-items: center;
  gap: 16px;
}

.mode-switch {
  display: flex;
  background: var(--bg-card);
  padding: 3px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
}

.btn-toggle {
  background: transparent;
  border: none;
  color: var(--text-muted);
  padding: 6px 14px;
  font-size: 13px;
  font-weight: 600;
  border-radius: 7px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-toggle.active {
  background: var(--accent-cyan);
  color: #000;
  box-shadow: 0 0 12px rgba(0, 229, 255, 0.4);
}

.search-box {
  position: relative;
  display: flex;
  align-items: center;
}

.search-box input {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  padding: 8px 14px;
  border-radius: var(--radius-md);
  font-size: 13px;
  width: 240px;
  transition: all 0.2s ease;
}

.search-box input:focus {
  outline: none;
  border-color: var(--accent-cyan);
  box-shadow: 0 0 8px rgba(0, 229, 255, 0.3);
  width: 280px;
}

.btn-icon {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  width: 38px;
  height: 38px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s;
  font-size: 16px;
}

.btn-icon:hover, .btn-icon:focus-visible {
  border-color: var(--accent-cyan);
  box-shadow: 0 0 8px rgba(0, 229, 255, 0.3);
  outline: none;
}

/* Main Content: Split layout */
.main-content {
  display: flex;
  flex: 1;
  overflow: hidden;
  height: calc(100vh - var(--header-height));
}

/* Left: Player Section */
.player-section {
  flex: 62;
  display: flex;
  flex-direction: column;
  background: #000;
  border-right: 1px solid var(--border-color);
  overflow: hidden;
  position: relative;
}

.player-wrapper {
  position: relative;
  width: 100%;
  flex: 1;
  background: #000;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

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

/* Radio Backdrop & Visualizer */
.radio-backdrop {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: radial-gradient(circle at center, #111425 0%, #06070a 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 5;
}

#visualizer-canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 1;
}

.radio-card {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  gap: 20px;
  background: rgba(18, 20, 31, 0.85);
  backdrop-filter: blur(16px);
  border: 1px solid rgba(0, 229, 255, 0.2);
  border-radius: var(--radius-lg);
  padding: 24px 32px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.6);
  max-width: 600px;
}

.radio-card-logo {
  width: 80px;
  height: 80px;
  object-fit: contain;
  background: #000;
  border-radius: var(--radius-md);
  padding: 6px;
  border: 1px solid var(--border-color);
}

.radio-card-info {
  display: flex;
  flex-direction: column;
}

.radio-live-tag {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-weight: 700;
  color: var(--accent-cyan);
  letter-spacing: 0.5px;
}

.pulse-dot {
  width: 8px;
  height: 8px;
  background: var(--accent-cyan);
  border-radius: 50%;
  box-shadow: 0 0 8px var(--accent-cyan);
  animation: pulse 1.5s infinite;
}

@keyframes pulse {
  0% { transform: scale(0.9); opacity: 0.7; }
  50% { transform: scale(1.2); opacity: 1; }
  100% { transform: scale(0.9); opacity: 0.7; }
}

.radio-name {
  font-size: 24px;
  font-weight: 700;
  margin-top: 4px;
}

.radio-genre {
  color: var(--text-muted);
  font-size: 13px;
  margin-top: 2px;
}

.visualizer-theme-tag {
  font-size: 11px;
  color: #7928ca;
  background: rgba(121, 40, 202, 0.15);
  padding: 2px 8px;
  border-radius: var(--radius-sm);
  margin-top: 8px;
  width: fit-content;
}

/* OSD Banner */
.osd-banner {
  position: absolute;
  top: 24px;
  left: 24px;
  display: flex;
  align-items: center;
  gap: 16px;
  background: rgba(10, 12, 20, 0.85);
  backdrop-filter: blur(14px);
  border: 1px solid var(--border-color);
  padding: 12px 20px;
  border-radius: var(--radius-md);
  z-index: 15;
  transition: opacity 0.4s ease;
  pointer-events: none;
}

.osd-logo {
  width: 64px;
  height: 38px;
  object-fit: contain;
  background: #000;
  border-radius: 4px;
  padding: 2px;
}

.osd-row-top {
  display: flex;
  align-items: center;
  gap: 8px;
}

.osd-num {
  font-size: 18px;
  font-weight: 800;
  color: var(--accent-cyan);
}

.osd-name {
  font-size: 18px;
  font-weight: 700;
}

.badge-res {
  background: var(--accent-green);
  color: #000;
  font-size: 10px;
  font-weight: 800;
  padding: 2px 6px;
  border-radius: 4px;
}

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

.osd-epg-now {
  font-size: 12px;
  color: var(--accent-green);
  margin-top: 4px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.osd-progress-bar {
  width: 240px;
  height: 3px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 2px;
  margin-top: 4px;
  overflow: hidden;
}

.osd-progress-fill {
  height: 100%;
  background: var(--accent-green);
  width: 0%;
}

/* Buffering Spinner */
.player-spinner {
  position: absolute;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  z-index: 20;
}

.spinner-ring {
  width: 50px;
  height: 50px;
  border: 4px solid rgba(0, 229, 255, 0.2);
  border-top-color: var(--accent-cyan);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

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

/* Controls Bar */
.player-controls-bar {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  background: linear-gradient(to top, rgba(0, 0, 0, 0.85) 0%, rgba(0, 0, 0, 0) 100%);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 20px;
  z-index: 25;
  opacity: 0;
  transition: opacity 0.3s;
}

.player-wrapper:hover .player-controls-bar,
.player-controls-bar:focus-within {
  opacity: 1;
}

.ctrl-btn {
  background: rgba(255, 255, 255, 0.1);
  border: none;
  color: #fff;
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  cursor: pointer;
  transition: background 0.2s;
}

.ctrl-btn:hover, .ctrl-btn:focus-visible {
  background: var(--accent-cyan);
  color: #000;
  outline: none;
}

.volume-container {
  display: flex;
  align-items: center;
  gap: 8px;
}

#volume-slider {
  width: 80px;
  accent-color: var(--accent-cyan);
  cursor: pointer;
}

.channel-info-pill {
  flex: 1;
  font-size: 13px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  padding: 0 10px;
}

/* Details & EPG Panel */
.current-details-panel {
  padding: 20px 24px;
  background: var(--bg-card);
  border-top: 1px solid var(--border-color);
  max-height: 180px;
  overflow-y: auto;
}

.details-header {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 12px;
}

.detail-logo {
  width: 60px;
  height: 36px;
  object-fit: contain;
  background: #000;
  border-radius: var(--radius-sm);
  padding: 3px;
}

.detail-titles {
  flex: 1;
}

.detail-titles h1 {
  font-size: 20px;
  font-weight: 700;
}

.detail-titles p {
  font-size: 12px;
  color: var(--text-muted);
}

.detail-badges {
  display: flex;
  gap: 8px;
}

.tech-badge {
  background: rgba(255, 255, 255, 0.08);
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  font-size: 11px;
  font-weight: 700;
  color: var(--accent-cyan);
}

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

.epg-item {
  display: flex;
  gap: 16px;
  font-size: 13px;
}

.epg-time {
  font-weight: 700;
  color: var(--accent-green);
  min-width: 50px;
}

.epg-desc {
  flex: 1;
}

.epg-meter {
  height: 3px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 2px;
  margin-top: 6px;
  overflow: hidden;
}

.epg-meter div {
  height: 100%;
  background: var(--accent-green);
  transition: width 0.3s;
}

/* Right: Channels Section */
.channels-section {
  flex: 38;
  display: flex;
  flex-direction: column;
  background: var(--bg-main);
  overflow: hidden;
}

.categories-bar {
  display: flex;
  gap: 8px;
  padding: 14px 18px;
  overflow-x: auto;
  scrollbar-width: none;
  background: rgba(18, 20, 31, 0.4);
  border-bottom: 1px solid var(--border-color);
  flex-shrink: 0;
}

.categories-bar::-webkit-scrollbar {
  display: none;
}

.category-chip {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  color: var(--text-muted);
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.2s;
}

.category-chip:hover, .category-chip:focus-visible {
  border-color: var(--accent-cyan);
  color: var(--text-main);
  outline: none;
}

.category-chip.active {
  background: var(--accent-cyan);
  color: #000;
  border-color: var(--accent-cyan);
  box-shadow: 0 0 10px rgba(0, 229, 255, 0.3);
}

.channels-container {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.channel-card {
  display: flex;
  align-items: center;
  gap: 14px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 10px 14px;
  cursor: pointer;
  transition: all 0.15s ease;
  position: relative;
}

.channel-card:hover, .channel-card:focus-visible, .channel-card.focused {
  background: var(--bg-card-hover);
  border-color: var(--border-focus);
  transform: translateX(4px);
  outline: none;
  box-shadow: 0 0 12px rgba(0, 229, 255, 0.25);
}

.channel-card.active {
  background: var(--bg-card-active);
  border-color: var(--accent-green);
  box-shadow: 0 0 10px rgba(0, 255, 102, 0.2);
}

.channel-card-num {
  font-size: 13px;
  font-weight: 800;
  color: var(--text-muted);
  min-width: 28px;
}

.channel-card.active .channel-card-num {
  color: var(--accent-green);
}

.channel-card-logo {
  width: 52px;
  height: 32px;
  object-fit: contain;
  background: #000;
  border-radius: 4px;
  padding: 2px;
}

.channel-card-info {
  flex: 1;
  min-width: 0;
}

.channel-card-name {
  font-size: 14px;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.channel-card.active .channel-card-name {
  color: var(--accent-green);
}

.channel-card-epg {
  font-size: 11px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 2px;
}

.channel-card-badge {
  font-size: 10px;
  font-weight: 800;
  padding: 2px 6px;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--accent-cyan);
}

.channel-card-badge.badge-4k {
  background: #ffaa00;
  color: #000;
}

/* Modal */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
}

.modal-content {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  width: 480px;
  max-width: 90vw;
  padding: 24px;
  box-shadow: 0 15px 40px rgba(0, 0, 0, 0.7);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}

.modal-body {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.modal-body label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-main);
  margin-bottom: 6px;
}

.modal-body select, .modal-body input {
  background: var(--bg-main);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  padding: 10px 14px;
  border-radius: var(--radius-md);
  font-size: 13px;
  width: 100%;
}

.modal-body small {
  color: var(--text-muted);
  font-size: 11px;
  margin-top: 4px;
}

.info-box {
  background: rgba(0, 229, 255, 0.05);
  border: 1px solid rgba(0, 229, 255, 0.15);
  padding: 12px;
  border-radius: var(--radius-md);
}

.info-box h4 {
  font-size: 12px;
  color: var(--accent-cyan);
  margin-bottom: 6px;
}

.info-box ul {
  padding-left: 18px;
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.6;
}

.modal-footer {
  margin-top: 24px;
  display: flex;
  justify-content: flex-end;
}

.btn-primary {
  background: var(--accent-cyan);
  color: #000;
  border: none;
  font-weight: 700;
  padding: 10px 20px;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all 0.2s;
}

.btn-primary:hover {
  box-shadow: 0 0 15px rgba(0, 229, 255, 0.5);
}

.hidden {
  display: none !important;
}

/* Mobile & Tablet Responsive Adaptations */
@media (max-width: 1024px) {
  body {
    overflow-y: auto;
  }

  .main-content {
    flex-direction: column;
    overflow-y: auto;
  }

  .player-section {
    flex: none;
    width: 100%;
    height: 48vh;
    border-right: none;
    border-bottom: 1px solid var(--border-color);
  }

  .current-details-panel {
    display: none;
  }

  .channels-section {
    flex: 1;
    width: 100%;
    overflow: visible;
  }

  .search-box input {
    width: 160px;
  }

  .search-box input:focus {
    width: 200px;
  }
}
