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

/* Light theme (default) */
:root {
  --primary-color: #1a73e8;
  --primary-dark: #1557b0;
  --bg-color: #f5f5f5;
  --surface-color: #ffffff;
  --text-primary: #1a1a1a;
  --text-secondary: #666666;
  --accent-color: #00c853;
  --error-color: #d32f2f;
  --surface-hover: rgba(0, 0, 0, 0.03);
  --surface-active: rgba(0, 0, 0, 0.05);
  --border-subtle: rgba(0, 0, 0, 0.1);
  --shadow: 0 2px 12px rgba(0, 0, 0, 0.1);
}

/* Dark theme (system preference) */
@media (prefers-color-scheme: dark) {
  :root {
    --bg-color: #121212;
    --surface-color: #1e1e1e;
    --text-primary: #ffffff;
    --text-secondary: #b3b3b3;
    --error-color: #cf6679;
    --surface-hover: rgba(255, 255, 255, 0.03);
    --surface-active: rgba(255, 255, 255, 0.05);
    --border-subtle: rgba(255, 255, 255, 0.1);
    --shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
  }
}

/* Explicit light override */
[data-theme="light"] {
  --bg-color: #f5f5f5;
  --surface-color: #ffffff;
  --text-primary: #1a1a1a;
  --text-secondary: #666666;
  --error-color: #d32f2f;
  --surface-hover: rgba(0, 0, 0, 0.03);
  --surface-active: rgba(0, 0, 0, 0.05);
  --border-subtle: rgba(0, 0, 0, 0.1);
  --shadow: 0 2px 12px rgba(0, 0, 0, 0.1);
}

/* Explicit dark override */
[data-theme="dark"] {
  --bg-color: #121212;
  --surface-color: #1e1e1e;
  --text-primary: #ffffff;
  --text-secondary: #b3b3b3;
  --error-color: #cf6679;
  --surface-hover: rgba(255, 255, 255, 0.03);
  --surface-active: rgba(255, 255, 255, 0.05);
  --border-subtle: rgba(255, 255, 255, 0.1);
  --shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}

body {
  font-family: 'Vazirmatn', 'Tahoma', 'Arial', sans-serif;
  background-color: var(--bg-color);
  color: var(--text-primary);
  min-height: 100vh;
  direction: rtl;
}

.player-container {
  width: 100%;
  max-width: 400px;
  background-color: var(--surface-color);
  border-radius: 16px;
  padding: 24px;
  margin: 16px auto;
  box-shadow: var(--shadow);
}

.player-header {
  text-align: center;
  margin-bottom: 24px;
  position: relative;
}

.player-header h1 {
  margin-bottom: 8px;
  line-height: 0;
}

.logo {
  height: 40px;
  width: auto;
  color: var(--text-primary);
}

.status {
  font-size: 0.875rem;
  color: var(--text-secondary);
}

.test-badge {
  display: inline-block;
  background: rgba(255, 152, 0, 0.2);
  color: #ffab40;
  font-size: 0.625rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 4px;
  letter-spacing: 0.5px;
  margin-bottom: 4px;
}

.player-main {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* Schedule */
.schedule-container {
  width: 100%;
}

.schedule-header {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-secondary);
  margin-bottom: 12px;
}

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

.schedule-loading {
  text-align: center;
  color: var(--text-secondary);
  padding: 20px;
}

.schedule-box {
  background: var(--surface-hover);
  border-radius: 8px;
  overflow: hidden;
}

.box-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  background: var(--surface-active);
  font-weight: 500;
  font-size: 0.875rem;
  cursor: pointer;
  user-select: none;
}

.box-title {
  flex: 1;
  min-width: 0;
}

.box-time {
  font-size: 0.75rem;
  color: var(--text-secondary);
  white-space: nowrap;
}

.program-list {
  display: none;
  flex-direction: column;
}

.schedule-box.expanded .program-list {
  display: flex;
}

.program-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 12px;
  font-size: 0.8125rem;
  color: var(--text-secondary);
  border-right: 3px solid transparent;
  transition: all 0.2s ease;
}

.program-item.active {
  background: rgba(26, 115, 232, 0.15);
  border-right-color: var(--primary-color);
  color: var(--text-primary);
}

.program-item.adhan {
  color: var(--accent-color);
  font-weight: 600;
}

.program-item.adhan.active {
  background: rgba(0, 200, 83, 0.15);
  border-right-color: var(--accent-color);
}

.program-item.past {
  opacity: 0.5;
}

.program-name {
  display: flex;
  align-items: center;
  gap: 6px;
}

.program-time {
  font-size: 0.75rem;
  white-space: nowrap;
}

.box-status {
  font-size: 0.625rem;
  padding: 2px 6px;
  border-radius: 4px;
  text-transform: uppercase;
  font-weight: 600;
}

.box-status.upcoming {
  background: var(--border-subtle);
  color: var(--text-secondary);
}

.box-status.live {
  background: rgba(0, 200, 83, 0.2);
  color: var(--accent-color);
}

.box-status.ended {
  background: var(--surface-active);
  color: var(--text-secondary);
  opacity: 0.5;
}

/* Player controls */
.player-controls {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  padding-top: 8px;
  border-top: 1px solid var(--border-subtle);
}

.live-indicator {
  display: flex;
  align-items: center;
  gap: 6px;
  background-color: rgba(0, 200, 83, 0.15);
  color: var(--accent-color);
  padding: 6px 12px;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.live-indicator.offline {
  background-color: rgba(207, 102, 121, 0.15);
  color: var(--error-color);
}

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

.live-indicator.offline .live-dot {
  background-color: var(--error-color);
  animation: none;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

.controls {
  display: flex;
  justify-content: center;
  align-items: center;
}

.play-button {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  border: none;
  background-color: var(--primary-color);
  color: white;
  cursor: pointer;
  display: flex;
  justify-content: center;
  align-items: center;
  transition: background-color 0.2s, transform 0.1s;
}

.play-button:hover:not(:disabled) {
  background-color: var(--primary-dark);
}

.play-button:active:not(:disabled) {
  transform: scale(0.95);
}

.play-button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.icon {
  width: 32px;
  height: 32px;
  fill: currentColor;
}

/* Theme toggle */
.theme-toggle {
  position: absolute;
  left: 0;
  top: 0;
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 4px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.2s;
}

.theme-toggle:hover {
  color: var(--text-primary);
}

.theme-icon {
  width: 18px;
  height: 18px;
  fill: currentColor;
}

.hidden {
  display: none !important;
}

.location-info {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  font-size: 0.75rem;
  color: var(--text-secondary);
}

.location-icon {
  opacity: 0.7;
}

.player-footer {
  margin-top: 16px;
}

.error-message {
  background-color: rgba(207, 102, 121, 0.15);
  color: var(--error-color);
  padding: 12px;
  border-radius: 8px;
  font-size: 0.875rem;
  text-align: center;
}

/* Responsive adjustments */
@media (max-width: 480px) {
  .player-container {
    margin: 8px;
    padding: 20px;
    border-radius: 12px;
  }

  .logo {
    height: 32px;
  }

  .play-button {
    width: 56px;
    height: 56px;
  }

  .icon {
    width: 28px;
    height: 28px;
  }
}

/* Landscape mode on mobile */
@media (max-height: 500px) and (orientation: landscape) {
  .player-container {
    max-width: 600px;
    padding: 16px 24px;
  }

  .player-main {
    flex-direction: row;
    flex-wrap: wrap;
    justify-content: center;
  }

  .controls {
    order: -1;
  }
}
