/* ─── SimaStream Web Player Styles ─────────────────────────────── */
/* Dark theme — matches Android app aesthetic                    */

:root {
  --bg-primary: #0a0a0f;
  --bg-secondary: #141420;
  --bg-card: #1a1a2e;
  --bg-hover: #22223a;
  --accent: #e50914;
  --accent-hover: #ff1a25;
  --accent-glow: rgba(229, 9, 20, 0.3);
  --text-primary: #f5f5f5;
  --text-secondary: #a0a0b0;
  --text-muted: #606070;
  --border: #2a2a3a;
  --radius: 8px;
  --radius-lg: 12px;
  --shadow: 0 4px 24px rgba(0, 0, 0, 0.5);
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html, body {
  height: 100%;
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  overflow: hidden;
}

/* ─── App Layout ─────────────────────────────────────────── */

.app-container {
  display: flex;
  height: 100vh;
  width: 100vw;
}

/* ─── Sidebar ────────────────────────────────────────────── */

.sidebar {
  width: 260px;
  min-width: 260px;
  background: var(--bg-secondary);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.sidebar h3 {
  padding: 16px 20px;
  font-size: 14px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-secondary);
  border-bottom: 1px solid var(--border);
}

#categoryList {
  flex: 1;
  overflow-y: auto;
  padding: 8px 0;
}

#categoryList::-webkit-scrollbar {
  width: 4px;
}
#categoryList::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 2px;
}

.category-item {
  padding: 12px 20px;
  cursor: pointer;
  font-size: 14px;
  color: var(--text-secondary);
  transition: all 0.15s ease;
  border-left: 3px solid transparent;
}

.category-item:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.category-item.active {
  background: var(--bg-hover);
  color: var(--text-primary);
  border-left-color: var(--accent);
}

/* ─── Main Content ───────────────────────────────────────── */

.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ─── Player ─────────────────────────────────────────────── */

.player-wrapper {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  max-height: 60vh;
  background: #000;
  flex-shrink: 0;
}

.player-wrapper video {
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #000;
}

.player-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}

.player-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  color: var(--text-secondary);
}

.player-spinner {
  width: 48px;
  height: 48px;
  border: 4px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.player-error {
  background: rgba(0, 0, 0, 0.8);
  padding: 20px 30px;
  border-radius: var(--radius);
  text-align: center;
}

.player-error p {
  color: var(--accent);
  margin-bottom: 12px;
}

.player-error button {
  padding: 8px 20px;
  background: var(--accent);
  border: none;
  border-radius: var(--radius);
  color: white;
  cursor: pointer;
  font-size: 14px;
}

.player-error button:hover {
  background: var(--accent-hover);
}

/* ─── Now Playing ────────────────────────────────────────── */

.now-playing {
  padding: 8px 16px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
}

.now-playing .channel-icon {
  width: 36px;
  height: 36px;
  border-radius: 6px;
  background: var(--bg-card);
  object-fit: contain;
}

.now-playing .channel-name {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
}

.now-playing .live-badge {
  display: inline-block;
  padding: 2px 8px;
  background: var(--accent);
  color: white;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* ─── Channel Grid ───────────────────────────────────────── */

.channel-section {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.channel-section h3 {
  padding: 12px 16px 8px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 1px;
  flex-shrink: 0;
}

#channelGrid {
  flex: 1;
  overflow-y: auto;
  padding: 0 12px 12px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 8px;
  align-content: start;
}

#channelGrid::-webkit-scrollbar {
  width: 6px;
}
#channelGrid::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 3px;
}

.channel-card {
  background: var(--bg-card);
  border-radius: var(--radius);
  overflow: hidden;
  cursor: pointer;
  transition: all 0.15s ease;
  border: 1px solid transparent;
}

.channel-card:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
  box-shadow: 0 4px 16px var(--accent-glow);
}

.channel-card.active {
  border-color: var(--accent);
  box-shadow: 0 0 12px var(--accent-glow);
}

.channel-card img {
  width: 100%;
  aspect-ratio: 16 / 10;
  object-fit: contain;
  background: var(--bg-secondary);
  padding: 8px;
}

.channel-card p {
  padding: 8px 10px;
  font-size: 12px;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-align: center;
}

.channel-card .channel-num {
  position: absolute;
  top: 4px;
  left: 4px;
  background: rgba(0, 0, 0, 0.7);
  color: var(--text-muted);
  font-size: 10px;
  padding: 1px 6px;
  border-radius: 3px;
}

/* ─── Login Form ─────────────────────────────────────────── */

#loginForm {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 12px 16px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

#loginForm input {
  padding: 10px 14px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-primary);
  font-size: 14px;
  outline: none;
  width: 180px;
  transition: border-color 0.15s;
}

#loginForm input:focus {
  border-color: var(--accent);
}

#loginForm input::placeholder {
  color: var(--text-muted);
}

#loginForm button {
  padding: 10px 24px;
  background: var(--accent);
  border: none;
  border-radius: var(--radius);
  color: white;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
}

#loginForm button:hover {
  background: var(--accent-hover);
}

#loginForm button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

#statusText {
  font-size: 13px;
  color: var(--text-secondary);
  min-width: 120px;
}

/* ─── Loading / Empty States ─────────────────────────────── */

.loading-state, .empty-state {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px;
  color: var(--text-muted);
  font-size: 14px;
}

.empty-state {
  flex-direction: column;
  gap: 8px;
}

/* ─── Responsive ─────────────────────────────────────────── */

@media (max-width: 768px) {
  .app-container {
    flex-direction: column;
  }

  .sidebar {
    width: 100%;
    min-width: unset;
    max-height: 120px;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }

  #categoryList {
    display: flex;
    flex-wrap: nowrap;
    overflow-x: auto;
    overflow-y: hidden;
    padding: 4px 8px;
    gap: 4px;
  }

  .category-item {
    padding: 8px 14px;
    white-space: nowrap;
    font-size: 13px;
    border-left: none;
    border-bottom: 2px solid transparent;
  }

  .category-item.active {
    border-left-color: transparent;
    border-bottom-color: var(--accent);
  }

  #channelGrid {
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 6px;
    padding: 0 8px 8px;
  }

  #loginForm {
    flex-wrap: wrap;
    justify-content: center;
  }

  #loginForm input {
    width: 140px;
  }
}

@media (max-width: 480px) {
  #channelGrid {
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
  }
}
