/* Dashboard Layout */
.dashboard {
  display: flex;
  min-height: 100vh;
  background: var(--bg);
}

/* Sidebar */
.sidebar {
  width: 260px;
  background: var(--bg-secondary);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 100;
  transition: transform 0.3s;
}

.sidebar-header {
  padding: 1.5rem;
  border-bottom: 1px solid var(--border);
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-weight: 700;
  font-size: 1.125rem;
  color: var(--text);
}

.sidebar-logo svg {
  width: 1.75rem;
  height: 1.75rem;
  color: var(--primary);
}

.sidebar-nav {
  flex: 1;
  padding: 1rem 0;
  overflow-y: auto;
}

.nav-section {
  padding: 0 0.75rem;
  margin-bottom: 1.5rem;
}

.nav-section-title {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  padding: 0 0.75rem;
  margin-bottom: 0.5rem;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem;
  border-radius: 0.5rem;
  color: var(--text-muted);
  font-weight: 500;
  transition: all 0.2s;
  cursor: pointer;
}

.nav-item:hover {
  background: var(--bg-tertiary);
  color: var(--text);
}

.nav-item.active {
  background: var(--primary-glow);
  color: var(--primary);
}

.nav-item svg {
  width: 1.25rem;
  height: 1.25rem;
  flex-shrink: 0;
}

.nav-item .badge {
  margin-left: auto;
  background: var(--primary);
  color: white;
  font-size: 0.75rem;
  padding: 0.125rem 0.5rem;
  border-radius: 1rem;
}

/* Sidebar Footer */
.sidebar-footer {
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--border);
}

.user-info {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.user-avatar {
  width: 2.5rem;
  height: 2.5rem;
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
  border-radius: 0.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-weight: 600;
}

.user-details {
  flex: 1;
  min-width: 0;
}

.user-name {
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-plan {
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* Main Content */
.main-content {
  flex: 1;
  margin-left: 260px;
  display: flex;
  flex-direction: column;
}

/* Top Bar */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 2rem;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 50;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.menu-toggle {
  display: none;
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 0.5rem;
  color: var(--text);
}

.menu-toggle svg {
  width: 1.5rem;
  height: 1.5rem;
}

.page-title {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--text);
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.topbar-btn {
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 0.5rem;
  border-radius: 0.5rem;
  color: var(--text-muted);
  transition: all 0.2s;
}

.topbar-btn:hover {
  background: var(--bg-tertiary);
  color: var(--text);
}

.topbar-btn svg {
  width: 1.25rem;
  height: 1.25rem;
}

/* Content Area */
.content {
  flex: 1;
  padding: 2rem;
}

/* Stats Cards */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1.5rem;
  margin-bottom: 2rem;
}

.stat-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 1rem;
  padding: 1.5rem;
  transition: all 0.2s;
}

.stat-card:hover {
  border-color: var(--primary);
}

.stat-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
}

.stat-card-icon {
  width: 2.5rem;
  height: 2.5rem;
  background: var(--primary-glow);
  border-radius: 0.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--primary);
}

.stat-card-icon svg {
  width: 1.25rem;
  height: 1.25rem;
}

.stat-card-value {
  font-size: 2rem;
  font-weight: 700;
  color: var(--text);
}

.stat-card-label {
  font-size: 0.875rem;
  color: var(--text-muted);
}

/* Cards */
.card {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 1rem;
  overflow: hidden;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border);
}

.card-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
}

.card-body {
  padding: 1.5rem;
}

/* Stream List */
.stream-list {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.stream-item {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 0.75rem;
  transition: all 0.2s;
  cursor: pointer;
}

.stream-item:hover {
  border-color: var(--primary);
}

.stream-thumbnail {
  width: 120px;
  height: 68px;
  background: var(--bg-tertiary);
  border-radius: 0.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  flex-shrink: 0;
}

.stream-thumbnail svg {
  width: 2rem;
  height: 2rem;
}

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

.stream-name {
  font-weight: 600;
  color: var(--text);
  margin-bottom: 0.25rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.stream-meta {
  display: flex;
  align-items: center;
  gap: 1rem;
  font-size: 0.875rem;
  color: var(--text-muted);
}

.stream-status {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.status-dot.running {
  background: var(--success);
  animation: pulse 2s infinite;
}

.status-dot.stopped {
  background: var(--text-muted);
}

.status-dot.error {
  background: var(--error);
}

.status-dot.starting {
  background: var(--warning);
  animation: pulse 1s infinite;
}

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

.stream-actions {
  display: flex;
  gap: 0.5rem;
}

.stream-actions .btn {
  padding: 0.5rem 1rem;
  font-size: 0.875rem;
}

/* Video Grid */
.video-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 1rem;
}

.video-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 0.75rem;
  overflow: hidden;
  transition: all 0.2s;
  cursor: pointer;
}

.video-card:hover {
  border-color: var(--primary);
  transform: translateY(-2px);
}

.video-thumbnail {
  aspect-ratio: 16/9;
  background: var(--bg-tertiary);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
}

.video-thumbnail svg {
  width: 3rem;
  height: 3rem;
}

.video-info {
  padding: 1rem;
}

.video-name {
  font-weight: 500;
  color: var(--text);
  margin-bottom: 0.25rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.video-meta {
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* Empty State */
.empty-state {
  text-align: center;
  padding: 4rem 2rem;
  color: var(--text-muted);
}

.empty-state svg {
  width: 4rem;
  height: 4rem;
  margin-bottom: 1rem;
  opacity: 0.5;
}

.empty-state h3 {
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 0.5rem;
}

.empty-state p {
  margin-bottom: 1.5rem;
}

/* Modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  visibility: hidden;
  transition: all 0.2s;
}

.modal-overlay.active {
  opacity: 1;
  visibility: visible;
}

.modal {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 1rem;
  width: 100%;
  max-width: 500px;
  max-height: 90vh;
  overflow-y: auto;
  transform: scale(0.95);
  transition: transform 0.2s;
}

.modal-overlay.active .modal {
  transform: scale(1);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border);
}

.modal-title {
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--text);
}

.modal-close {
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 0.25rem;
  color: var(--text-muted);
  transition: color 0.2s;
}

.modal-close:hover {
  color: var(--text);
}

.modal-close svg {
  width: 1.5rem;
  height: 1.5rem;
}

.modal-body {
  padding: 1.5rem;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 1rem;
  padding: 1.25rem 1.5rem;
  border-top: 1px solid var(--border);
}

/* Upload Zone */
.upload-zone {
  border: 2px dashed var(--border);
  border-radius: 0.75rem;
  padding: 3rem 2rem;
  text-align: center;
  transition: all 0.2s;
  cursor: pointer;
}

.upload-zone:hover,
.upload-zone.dragover {
  border-color: var(--primary);
  background: var(--primary-glow);
}

.upload-zone svg {
  width: 3rem;
  height: 3rem;
  color: var(--text-muted);
  margin-bottom: 1rem;
}

.upload-zone h4 {
  font-weight: 600;
  color: var(--text);
  margin-bottom: 0.5rem;
}

.upload-zone p {
  font-size: 0.875rem;
  color: var(--text-muted);
}

/* Progress Bar */
.progress-bar {
  height: 8px;
  background: var(--bg-tertiary);
  border-radius: 4px;
  overflow: hidden;
  margin-top: 1rem;
}

.progress-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--primary) 0%, var(--primary-dark) 100%);
  border-radius: 4px;
  transition: width 0.3s;
}

/* Responsive */
@media (max-width: 1024px) {
  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .main-content {
    margin-left: 0;
  }

  .menu-toggle {
    display: block;
  }

  .stats-grid {
    grid-template-columns: 1fr;
  }

  .content {
    padding: 1rem;
  }

  .stream-item {
    flex-direction: column;
    align-items: flex-start;
  }

  .stream-thumbnail {
    width: 100%;
    height: auto;
    aspect-ratio: 16/9;
  }
}


/* SPA Modal Styles */
.modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  transition: all 0.2s;
}

.modal.open {
  opacity: 1;
  visibility: visible;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
}

.modal-content {
  position: relative;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 1rem;
  width: 100%;
  max-width: 500px;
  max-height: 90vh;
  overflow-y: auto;
  transform: scale(0.95);
  transition: transform 0.2s;
}

.modal.open .modal-content {
  transform: scale(1);
}

/* Stream Item Styles */
.stream-item-info {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex: 1;
}

.stream-item-status {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.stream-item-status.status-running { background: var(--success); animation: pulse 2s infinite; }
.stream-item-status.status-starting { background: var(--warning); animation: pulse 1s infinite; }
.stream-item-status.status-pending { background: var(--text-muted); }
.stream-item-status.status-error { background: var(--error); }
.stream-item-status.status-stopped { background: var(--text-muted); }

.stream-item-details { flex: 1; min-width: 0; }
.stream-item-name { font-weight: 600; color: var(--text); margin-bottom: 0.25rem; }
.stream-item-meta { display: flex; align-items: center; gap: 0.5rem; font-size: 0.875rem; color: var(--text-muted); flex-wrap: wrap; }
.stream-item-actions { display: flex; gap: 0.5rem; }

/* Status Badge */
.status-badge {
  display: inline-flex;
  align-items: center;
  padding: 0.25rem 0.5rem;
  border-radius: 0.25rem;
  font-size: 0.75rem;
  font-weight: 500;
}
.status-badge.status-running { background: rgba(34, 197, 94, 0.2); color: var(--success); }
.status-badge.status-starting { background: rgba(234, 179, 8, 0.2); color: var(--warning); }
.status-badge.status-error { background: rgba(239, 68, 68, 0.2); color: var(--error); }
.status-badge.status-stopped, .status-badge.status-pending { background: var(--bg-tertiary); color: var(--text-muted); }
.status-badge.status-active { background: rgba(34, 197, 94, 0.2); color: var(--success); }

/* Video Card Actions */
.video-actions {
  display: flex;
  gap: 0.5rem;
  padding: 0 1rem 1rem;
}

/* Key List */
.key-list { display: flex; flex-direction: column; gap: 1rem; }
.key-item {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 0.75rem;
}
.key-item-info { display: flex; align-items: center; gap: 1rem; flex: 1; }
.key-item-icon { width: 2.5rem; height: 2.5rem; background: var(--primary-glow); border-radius: 0.5rem; display: flex; align-items: center; justify-content: center; color: var(--primary); }
.key-item-icon svg { width: 1.25rem; height: 1.25rem; }
.key-item-details { flex: 1; }
.key-item-name { font-weight: 600; color: var(--text); margin-bottom: 0.25rem; }
.key-item-meta { font-size: 0.75rem; color: var(--text-muted); display: flex; gap: 0.5rem; flex-wrap: wrap; }
.key-item-actions { display: flex; gap: 0.5rem; }

/* Storage Info */
.storage-info { margin-bottom: 1.5rem; padding: 1rem; background: var(--bg-secondary); border: 1px solid var(--border); border-radius: 0.75rem; }
.storage-bar { height: 8px; background: var(--bg-tertiary); border-radius: 4px; overflow: hidden; margin-bottom: 0.5rem; }
.storage-used { height: 100%; background: linear-gradient(90deg, var(--primary) 0%, var(--primary-dark) 100%); border-radius: 4px; transition: width 0.3s; }
.storage-text { font-size: 0.875rem; color: var(--text-muted); }

/* Upload Progress */
.upload-progress { text-align: center; }
.upload-file-name { font-weight: 500; color: var(--text); margin-bottom: 1rem; }
.progress-fill { height: 100%; background: linear-gradient(90deg, var(--primary) 0%, var(--primary-dark) 100%); border-radius: 4px; transition: width 0.3s; }
.progress-text { margin-top: 0.5rem; font-size: 0.875rem; color: var(--text-muted); }

/* Alert */
.alert { padding: 1rem; border-radius: 0.5rem; }
.alert-info { background: rgba(59, 130, 246, 0.1); border: 1px solid rgba(59, 130, 246, 0.3); color: var(--text); }
.alert a { color: var(--primary); text-decoration: underline; }

/* Checkbox */
.checkbox-label { display: flex; align-items: center; gap: 0.5rem; cursor: pointer; }
.checkbox-label input { width: 1rem; height: 1rem; }

/* Current Plan */
.current-plan { display: flex; flex-direction: column; gap: 1rem; }
.current-plan-name { font-size: 2rem; font-weight: 700; color: var(--primary); }
.current-plan-info { display: flex; flex-wrap: wrap; gap: 2rem; }
.plan-info-item { display: flex; flex-direction: column; gap: 0.25rem; }
.plan-info-item .label { font-size: 0.75rem; color: var(--text-muted); text-transform: uppercase; }
.plan-info-item .value { font-weight: 600; color: var(--text); }

/* Pricing Grid Compact */
.pricing-grid.compact { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 1rem; }
.pricing-grid.compact .pricing-card { padding: 1.5rem; }
.pricing-card.current { border-color: var(--primary); }
.current-badge { background: var(--primary) !important; }

/* Loading */
.loading { text-align: center; padding: 2rem; color: var(--text-muted); }

/* Button sizes */
.btn-sm { padding: 0.5rem 0.75rem; font-size: 0.875rem; }
.btn svg { width: 1rem; height: 1rem; }
