/* Video Streaming App Styles */

.video-streaming-app {
  display: flex;
  flex-direction: column;
  height: 100%;
  background: #1a1a1a;
  color: #ffffff;
  position: relative;
}

/* ============ Channel Selector Button (Top-Left) ============ */

.channel-selector-btn {
  position: absolute;
  top: calc(12px * var(--ui-scale));
  left: calc(12px * var(--ui-scale));
  z-index: 10;
  display: flex;
  align-items: center;
  gap: calc(8px * var(--ui-scale));
  padding: calc(10px * var(--ui-scale)) calc(16px * var(--ui-scale));
  background: rgba(0, 0, 0, 0.8);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: calc(8px * var(--ui-scale));
  color: #ffffff;
  font-size: calc(14px * var(--ui-scale));
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.channel-selector-btn.hover {
  background: rgba(0, 102, 204, 0.9);
  border-color: #0066cc;
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 102, 204, 0.4);
}

.channel-selector-icon {
  font-size: calc(20px * var(--ui-scale));
}

.channel-selector-label {
  font-size: calc(14px * var(--ui-scale));
}

/* ============ Quality Selector (Top-Left, next to Channels) ============ */

.quality-selector-container {
  position: absolute;
  top: calc(12px * var(--ui-scale));
  left: calc(140px * var(--ui-scale));
  z-index: 10;
}

.quality-selector-btn {
  display: flex;
  align-items: center;
  gap: calc(8px * var(--ui-scale));
  padding: calc(10px * var(--ui-scale)) calc(16px * var(--ui-scale));
  background: rgba(0, 0, 0, 0.8);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: calc(8px * var(--ui-scale));
  color: #ffffff;
  font-size: calc(14px * var(--ui-scale));
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.quality-selector-btn.hover {
  background: rgba(0, 102, 204, 0.9);
  border-color: #0066cc;
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 102, 204, 0.4);
}

.quality-selector-icon {
  font-size: calc(18px * var(--ui-scale));
}

.quality-selector-label {
  font-size: calc(14px * var(--ui-scale));
}

/* Quality Dropdown */

.quality-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  min-width: calc(120px * var(--ui-scale));
  background: rgba(0, 0, 0, 0.95);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: calc(8px * var(--ui-scale));
  overflow: hidden;
  opacity: 0;
  pointer-events: none;
  transform: translateY(-10px);
  transition: all 0.2s ease;
  z-index: 5;
}

.quality-dropdown.visible {
  opacity: 1;
  pointer-events: all;
  transform: translateY(0);
}

/* Freeze Toast */

.freeze-toast {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  display: flex;
  align-items: center;
  gap: calc(8px * var(--ui-scale));
  padding: calc(10px * var(--ui-scale)) calc(16px * var(--ui-scale));
  background: rgba(255, 107, 107, 0.95);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 107, 107, 0.4);
  border-radius: calc(8px * var(--ui-scale));
  color: #ffffff;
  font-size: calc(14px * var(--ui-scale));
  font-weight: 600;
  cursor: pointer;
  opacity: 0;
  pointer-events: none;
  transform: translateY(-10px);
  transition: all 0.3s ease;
  z-index: 6;
  white-space: nowrap;
}

.freeze-toast.visible {
  opacity: 1;
  pointer-events: all;
  transform: translateY(0);
}

.freeze-toast.fading {
  opacity: 0;
  transition: opacity 2s ease;
}

.freeze-toast.hover {
  background: rgba(255, 107, 107, 1);
  border-color: #ff6b6b;
  transform: translateY(0) scale(1.05);
}

.freeze-toast-icon {
  font-size: calc(18px * var(--ui-scale));
}

.freeze-toast-text {
  font-size: calc(14px * var(--ui-scale));
}

.quality-option {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: calc(12px * var(--ui-scale)) calc(16px * var(--ui-scale));
  font-size: calc(14px * var(--ui-scale));
  font-weight: 500;
  color: #ffffff;
  cursor: pointer;
  transition: all 0.2s ease;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.quality-option:last-child {
  border-bottom: none;
}

.quality-option.hover {
  background: rgba(0, 102, 204, 0.3);
}

.quality-option.active {
  background: rgba(0, 102, 204, 0.5);
  font-weight: 600;
}

.quality-check {
  margin-left: calc(8px * var(--ui-scale));
  color: #00ff88;
  font-size: calc(16px * var(--ui-scale));
}

/* ============ Current Channel Name (Top-Right) ============ */

.current-channel-name {
  position: absolute;
  top: calc(12px * var(--ui-scale));
  right: calc(12px * var(--ui-scale));
  z-index: 10;
  padding: calc(10px * var(--ui-scale)) calc(16px * var(--ui-scale));
  background: rgba(0, 0, 0, 0.8);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: calc(8px * var(--ui-scale));
  font-size: calc(14px * var(--ui-scale));
  font-weight: 600;
  color: #ffffff;
}

/* ============ Stream Container ============ */

.streaming-container {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #000000;
  position: relative;
  overflow: hidden;
}

.streaming-video {
  width: 100%;
  height: 100%;
  background: #000000;
  object-fit: contain;
}

/* ============ Loading State ============ */

.streaming-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  background: #000000;
  color: #ffffff;
  font-size: calc(18px * var(--ui-scale));
  font-weight: 500;
}

.streaming-loading::after {
  content: '...';
  animation: dots 1.5s infinite;
}

@keyframes dots {
  0%, 20% { content: '.'; }
  40% { content: '..'; }
  60%, 100% { content: '...'; }
}

/* ============ Error State ============ */

.streaming-error {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: calc(16px * var(--ui-scale));
  width: 100%;
  height: 100%;
  background: #000000;
  text-align: center;
  padding: calc(40px * var(--ui-scale));
}

.error-icon {
  font-size: calc(48px * var(--ui-scale));
}

.error-message {
  font-size: calc(16px * var(--ui-scale));
  color: #ff6b6b;
  max-width: calc(500px * var(--ui-scale));
  line-height: 1.5;
}

.error-retry-btn,
.error-channels-btn {
  padding: calc(10px * var(--ui-scale)) calc(20px * var(--ui-scale));
  background: #0066cc;
  border: none;
  border-radius: calc(6px * var(--ui-scale));
  color: #ffffff;
  font-size: calc(14px * var(--ui-scale));
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.error-retry-btn.hover,
.error-channels-btn.hover {
  background: #0052a3;
  transform: translateY(-2px);
}

.error-channels-btn {
  background: #444444;
}

.error-channels-btn.hover {
  background: #555555;
}

/* ============ Channel Grid Modal ============ */

.channel-grid-modal {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.95);
  backdrop-filter: blur(10px);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.channel-grid-modal.visible {
  opacity: 1;
  pointer-events: all;
}

.channel-grid-content {
  width: calc(90% * var(--ui-scale));
  max-width: calc(1000px * var(--ui-scale));
  max-height: calc(80% * var(--ui-scale));
  background: #1a1a1a;
  border: 1px solid #3a3a3a;
  border-radius: calc(12px * var(--ui-scale));
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

/* ============ Modal Header ============ */

.channel-grid-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: calc(20px * var(--ui-scale));
  background: #252525;
  border-bottom: 1px solid #3a3a3a;
  flex-shrink: 0;
}

.channel-grid-header h2 {
  margin: 0;
  font-size: calc(20px * var(--ui-scale));
  font-weight: 600;
  color: #ffffff;
}

.channel-grid-close {
  width: calc(36px * var(--ui-scale));
  height: calc(36px * var(--ui-scale));
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: calc(6px * var(--ui-scale));
  color: #ffffff;
  font-size: calc(20px * var(--ui-scale));
  cursor: pointer;
  transition: all 0.2s ease;
}

.channel-grid-close.hover {
  background: #ff4444;
  border-color: #ff4444;
}

/* ============ Channel Grid ============ */

.channel-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(calc(280px * var(--ui-scale)), 1fr));
  gap: calc(16px * var(--ui-scale));
  padding: calc(20px * var(--ui-scale));
  overflow-y: auto;
  flex: 1;
}

/* ============ Channel Cards ============ */

.channel-card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: calc(12px * var(--ui-scale));
  padding: calc(16px * var(--ui-scale));
  background: #252525;
  border: 2px solid transparent;
  border-radius: calc(10px * var(--ui-scale));
  cursor: pointer;
  transition: all 0.2s ease;
}

.channel-card.hover {
  background: #2a2a2a;
  border-color: #0066cc;
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 102, 204, 0.3);
}

.channel-card.active {
  border-color: #00cc66;
  background: #1a2a1a;
}

.channel-card.active.hover {
  border-color: #00ff88;
}

.channel-card-icon {
  width: calc(60px * var(--ui-scale));
  height: calc(60px * var(--ui-scale));
  display: flex;
  align-items: center;
  justify-content: center;
  background: #d91f5a;
  border-radius: calc(8px * var(--ui-scale));
  font-size: calc(32px * var(--ui-scale));
}

.channel-card-info {
  flex: 1;
}

.channel-card-name {
  margin: 0 0 calc(4px * var(--ui-scale)) 0;
  font-size: calc(16px * var(--ui-scale));
  font-weight: 600;
  color: #ffffff;
}

.channel-card-lang {
  display: inline-block;
  padding: calc(2px * var(--ui-scale)) calc(6px * var(--ui-scale));
  background: rgba(255, 255, 255, 0.1);
  border-radius: calc(4px * var(--ui-scale));
  font-size: calc(11px * var(--ui-scale));
  font-weight: 600;
  color: #cccccc;
  margin-left: calc(8px * var(--ui-scale));
}

.channel-card-desc {
  margin: calc(4px * var(--ui-scale)) 0 0 0;
  font-size: calc(13px * var(--ui-scale));
  color: #999999;
  line-height: 1.4;
}

.channel-card-active-indicator {
  margin-top: calc(8px * var(--ui-scale));
  padding: calc(6px * var(--ui-scale)) calc(10px * var(--ui-scale));
  background: rgba(0, 204, 102, 0.2);
  border: 1px solid rgba(0, 204, 102, 0.4);
  border-radius: calc(6px * var(--ui-scale));
  font-size: calc(12px * var(--ui-scale));
  font-weight: 600;
  color: #00ff88;
  text-align: center;
}

/* ============ Mode Toggle ============ */

.mode-toggle-container {
  position: absolute;
  top: calc(12px * var(--ui-scale));
  left: 50%;
  transform: translateX(-50%);
  z-index: 10;
  display: flex;
  gap: calc(8px * var(--ui-scale));
  background: rgba(0, 0, 0, 0.8);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: calc(8px * var(--ui-scale));
  padding: calc(4px * var(--ui-scale));
}

.mode-toggle-btn {
  display: flex;
  align-items: center;
  gap: calc(6px * var(--ui-scale));
  padding: calc(8px * var(--ui-scale)) calc(16px * var(--ui-scale));
  background: transparent;
  border: none;
  border-radius: calc(6px * var(--ui-scale));
  color: rgba(255, 255, 255, 0.6);
  font-size: calc(14px * var(--ui-scale));
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.mode-toggle-btn .material-symbols-outlined {
  font-size: calc(18px * var(--ui-scale));
}

.mode-toggle-btn.hover {
  color: rgba(255, 255, 255, 0.9);
  background: rgba(255, 255, 255, 0.1);
}

.mode-toggle-btn.active {
  color: #ffffff;
  background: #0066cc;
}

/* ============ Download Mode ============ */

.download-mode-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: calc(80px * var(--ui-scale)) calc(20px * var(--ui-scale)) calc(20px * var(--ui-scale));
  gap: calc(20px * var(--ui-scale));
  overflow-y: auto;
}

.download-input-section {
  display: flex;
  gap: calc(12px * var(--ui-scale));
  max-width: calc(800px * var(--ui-scale));
  margin: 0 auto;
  width: 100%;
}

.download-url-input {
  flex: 1;
  padding: calc(12px * var(--ui-scale)) calc(16px * var(--ui-scale));
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: calc(8px * var(--ui-scale));
  color: #ffffff;
  font-size: calc(14px * var(--ui-scale));
  outline: none;
  transition: all 0.2s ease;
}

.download-url-input::placeholder {
  color: rgba(255, 255, 255, 0.4);
}

.download-url-input:focus {
  background: rgba(255, 255, 255, 0.15);
  border-color: #0066cc;
  box-shadow: 0 0 0 3px rgba(0, 102, 204, 0.2);
}

.download-url-input:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.download-btn {
  display: flex;
  align-items: center;
  gap: calc(8px * var(--ui-scale));
  padding: calc(12px * var(--ui-scale)) calc(24px * var(--ui-scale));
  background: #0066cc;
  border: none;
  border-radius: calc(8px * var(--ui-scale));
  color: #ffffff;
  font-size: calc(14px * var(--ui-scale));
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
}

.download-btn .material-symbols-outlined {
  font-size: calc(20px * var(--ui-scale));
}

.download-btn.hover:not(:disabled) {
  background: #0052a3;
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 102, 204, 0.4);
}

.download-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Downloads List */

.downloads-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(calc(300px * var(--ui-scale)), 1fr));
  gap: calc(16px * var(--ui-scale));
  max-width: calc(1200px * var(--ui-scale));
  margin: 0 auto;
  width: 100%;
}

.download-card {
  display: flex;
  align-items: center;
  gap: calc(16px * var(--ui-scale));
  padding: calc(16px * var(--ui-scale));
  background: #252525;
  border: 2px solid transparent;
  border-radius: calc(10px * var(--ui-scale));
  cursor: pointer;
  transition: all 0.2s ease;
}

.download-card.hover {
  background: #2a2a2a;
  border-color: #0066cc;
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 102, 204, 0.3);
}

.download-card-icon {
  width: calc(60px * var(--ui-scale));
  height: calc(60px * var(--ui-scale));
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 102, 204, 0.2);
  border-radius: calc(8px * var(--ui-scale));
  color: #0066cc;
  font-size: calc(32px * var(--ui-scale));
}

.download-card-icon .material-symbols-outlined {
  font-size: calc(40px * var(--ui-scale));
}

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

.download-card-name {
  margin: 0 0 calc(4px * var(--ui-scale)) 0;
  font-size: calc(14px * var(--ui-scale));
  font-weight: 600;
  color: #ffffff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.download-card-size {
  margin: 0;
  font-size: calc(12px * var(--ui-scale));
  color: #999999;
}

.download-empty {
  grid-column: 1 / -1;
  text-align: center;
  padding: calc(60px * var(--ui-scale)) calc(20px * var(--ui-scale));
  color: rgba(255, 255, 255, 0.4);
  font-size: calc(16px * var(--ui-scale));
}

/* Download Player */

.download-player-container {
  grid-column: 1 / -1;
  display: flex;
  flex-direction: column;
  gap: calc(16px * var(--ui-scale));
}

.download-back-btn {
  display: flex;
  align-items: center;
  gap: calc(8px * var(--ui-scale));
  padding: calc(10px * var(--ui-scale)) calc(16px * var(--ui-scale));
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: calc(8px * var(--ui-scale));
  color: #ffffff;
  font-size: calc(14px * var(--ui-scale));
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  align-self: flex-start;
}

.download-back-btn .material-symbols-outlined {
  font-size: calc(20px * var(--ui-scale));
}

.download-back-btn.hover {
  background: rgba(255, 255, 255, 0.2);
  border-color: rgba(255, 255, 255, 0.3);
  transform: translateX(-4px);
}

.download-video {
  width: 100%;
  max-height: calc(70vh * var(--ui-scale));
  background: #000000;
  border-radius: calc(8px * var(--ui-scale));
  object-fit: contain;
}

/* ============ Responsive Design ============ */

@media (max-width: 800px) {
  .channel-grid {
    grid-template-columns: repeat(auto-fill, minmax(calc(240px * var(--ui-scale)), 1fr));
    gap: calc(12px * var(--ui-scale));
  }

  .channel-selector-btn {
    padding: calc(8px * var(--ui-scale)) calc(12px * var(--ui-scale));
  }

  .quality-selector-container {
    left: calc(110px * var(--ui-scale));
  }

  .quality-selector-btn {
    padding: calc(8px * var(--ui-scale)) calc(12px * var(--ui-scale));
  }

  .current-channel-name {
    font-size: calc(12px * var(--ui-scale));
    padding: calc(8px * var(--ui-scale)) calc(12px * var(--ui-scale));
  }

  .downloads-list {
    grid-template-columns: 1fr;
  }

  .download-input-section {
    flex-direction: column;
  }

  .mode-toggle-btn span:not(.material-symbols-outlined) {
    display: none;
  }
}
