/* ========================================================
   RIXTV - Pure Apple tvOS Clean Design System
   No Gradients • No Neon • Matte Solid Aesthetics
   4-Column Logo Grid • Force Fullscreen Live TV
   ======================================================== */

:root {
  --apple-black: #000000;
  --apple-card-bg: #151518;
  --apple-card-hover: #222226;
  --apple-border: rgba(255, 255, 255, 0.08);
  --apple-border-focus: #ffffff;
  --apple-text: #ffffff;
  --apple-text-muted: #86868b;
  --apple-pill: rgba(255, 255, 255, 0.12);
  --apple-pill-hover: rgba(255, 255, 255, 0.22);
  --font-apple: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

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

html, body {
  width: 100%;
  min-height: 100vh;
  background-color: var(--apple-black);
  color: var(--apple-text);
  font-family: var(--font-apple);
  overflow-x: hidden;
  user-select: none;
}

/* Scrollbar */
::-webkit-scrollbar {
  width: 8px;
}
::-webkit-scrollbar-track {
  background: var(--apple-black);
}
::-webkit-scrollbar-thumb {
  background: #28282d;
  border-radius: 4px;
}

/* ================= TV Focus States ================= */
.focusable {
  outline: none;
  transition: transform 0.22s cubic-bezier(0.2, 0.8, 0.2, 1), 
              border-color 0.2s ease, 
              background-color 0.2s ease, 
              box-shadow 0.22s ease;
}

.focusable:focus,
.focusable.focused {
  outline: none;
  transform: scale(1.06);
  border-color: var(--apple-border-focus) !important;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.9), 0 0 0 2px rgba(255, 255, 255, 0.8) !important;
  z-index: 10;
}

/* ================= Dashboard Layout ================= */
.dashboard-container {
  width: 100%;
  max-width: 1720px;
  margin: 0 auto;
  padding: 36px 48px 80px 48px;
  display: flex;
  flex-direction: column;
  gap: 32px;
}

/* Apple Header */
.apple-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--apple-border);
}

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

.apple-logo-badge {
  background: #ffffff;
  color: #000000;
  font-size: 0.85rem;
  font-weight: 900;
  letter-spacing: 0.5px;
  padding: 4px 10px;
  border-radius: 8px;
}

.apple-title {
  font-size: 1.8rem;
  font-weight: 700;
  letter-spacing: -0.5px;
  color: #ffffff;
}

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

.apple-pill-btn {
  background: var(--apple-pill);
  border: 1px solid var(--apple-border);
  color: #ffffff;
  padding: 10px 20px;
  border-radius: 30px;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: inherit;
}

.apple-pill-btn:hover {
  background: var(--apple-pill-hover);
}

/* ================= 4-Column Clean Apple Grid ================= */
.grid-container {
  width: 100%;
}

.channels-4col-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 28px;
}

.apple-channel-card {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 10;
  background-color: var(--apple-card-bg);
  border: 1px solid var(--apple-border);
  border-radius: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  cursor: pointer;
  overflow: hidden;
}

.apple-channel-card:hover {
  background-color: var(--apple-card-hover);
  border-color: rgba(255, 255, 255, 0.25);
}

.apple-logo-img {
  max-width: 84%;
  max-height: 80%;
  width: auto;
  height: auto;
  object-fit: contain;
  filter: drop-shadow(0 4px 12px rgba(0, 0, 0, 0.5));
  pointer-events: none;
}

/* ================= Fullscreen Video Player ================= */
.fullscreen-player {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  background-color: #000000;
  z-index: 99999;
  display: flex;
  align-items: center;
  justify-content: center;
}

.fullscreen-video {
  width: 100%;
  height: 100%;
  object-fit: contain;
  background-color: #000000;
  display: block;
}

/* Loader */
.video-loader {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}

.apple-spinner {
  width: 48px;
  height: 48px;
  border: 3.5px solid rgba(255, 255, 255, 0.2);
  border-top-color: #ffffff;
  border-radius: 50%;
  animation: appleSpin 0.7s linear infinite;
}

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

/* Player Overlay */
.player-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 36px 48px;
  pointer-events: auto;
  opacity: 1;
  transition: opacity 0.35s ease;
  z-index: 50;
  background: linear-gradient(180deg, rgba(0,0,0,0.6) 0%, transparent 25%, transparent 70%, rgba(0,0,0,0.7) 100%);
}

.player-overlay.idle {
  opacity: 0;
  pointer-events: none;
}

/* Top Bar */
.fullscreen-top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.apple-round-btn {
  width: 50px;
  height: 50px;
  border-radius: 50%;
  background: rgba(30, 30, 35, 0.85);
  backdrop-filter: blur(25px);
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.apple-round-btn:hover {
  background: rgba(45, 45, 52, 0.95);
}

.top-channel-display {
  display: flex;
  align-items: center;
  gap: 14px;
  background: rgba(25, 25, 30, 0.8);
  backdrop-filter: blur(25px);
  border: 1px solid rgba(255, 255, 255, 0.12);
  padding: 8px 18px;
  border-radius: 30px;
}

.fs-logo {
  height: 32px;
  width: auto;
  max-width: 60px;
  object-fit: contain;
}

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

.fs-name {
  font-weight: 700;
  font-size: 1.05rem;
}

.fs-live-badge {
  background: #ff3b30;
  color: #ffffff;
  font-size: 0.68rem;
  font-weight: 800;
  padding: 2px 7px;
  border-radius: 6px;
}

/* Bottom Bar */
.fullscreen-bottom-bar {
  display: flex;
  justify-content: center;
}

.apple-control-pill {
  display: flex;
  align-items: center;
  gap: 12px;
  background: rgba(25, 25, 30, 0.85);
  backdrop-filter: blur(25px);
  border: 1px solid rgba(255, 255, 255, 0.14);
  padding: 8px 16px;
  border-radius: 40px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.7);
}

.apple-ctrl-btn {
  background: transparent;
  border: none;
  color: #ffffff;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.apple-ctrl-btn:hover {
  background: rgba(255, 255, 255, 0.15);
}

.apple-ctrl-btn.play-pause-btn {
  background: #ffffff;
  color: #000000;
  width: 48px;
  height: 48px;
}

.apple-ctrl-btn.play-pause-btn:hover {
  background: #e5e5ea;
}

.apple-divider {
  width: 1px;
  height: 24px;
  background: rgba(255, 255, 255, 0.15);
  margin: 0 4px;
}

/* ================= Modal ================= */
.apple-modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.8);
  backdrop-filter: blur(20px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10000;
  padding: 20px;
}

.apple-modal-box {
  background: #1c1c1e;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 24px;
  width: 100%;
  max-width: 540px;
  padding: 30px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.modal-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-top h3 {
  font-size: 1.3rem;
  font-weight: 700;
}

.modal-close-btn {
  background: rgba(255, 255, 255, 0.1);
  border: none;
  color: #ffffff;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  cursor: pointer;
}

.modal-subtitle {
  color: var(--apple-text-muted);
  font-size: 0.95rem;
  margin-bottom: 16px;
}

.instruction-steps {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.step-row {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  font-size: 0.95rem;
  line-height: 1.4;
}

.step-badge {
  width: 26px;
  height: 26px;
  background: #ffffff;
  color: #000000;
  font-weight: 800;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  flex-shrink: 0;
}

.step-row code {
  background: #2c2c2e;
  color: #ffffff;
  padding: 3px 8px;
  border-radius: 6px;
  font-size: 0.9rem;
  display: inline-block;
  margin-top: 4px;
}

.apple-btn-primary {
  background: #ffffff;
  color: #000000;
  border: none;
  padding: 12px 24px;
  border-radius: 12px;
  font-weight: 700;
  font-size: 0.95rem;
  cursor: pointer;
  width: 100%;
}

.apple-toast {
  position: fixed;
  bottom: 30px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(30, 30, 35, 0.92);
  backdrop-filter: blur(20px);
  border: 1px solid rgba(255, 255, 255, 0.15);
  padding: 12px 24px;
  border-radius: 20px;
  font-size: 0.95rem;
  font-weight: 600;
  z-index: 10001;
}

.hidden {
  display: none !important;
}

/* ================= Responsive Layout ================= */
@media (max-width: 1200px) {
  .channels-4col-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

@media (max-width: 800px) {
  .dashboard-container {
    padding: 24px 20px;
  }
  .channels-4col-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
  }
  .apple-channel-card {
    border-radius: 18px;
  }
  .player-overlay {
    padding: 20px;
  }
}
