/* === Reset & Base === */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #0f0f11;
  --bg-surface: #16171b;
  --bg-card: #1c1d22;
  --bg-elevated: #22232a;
  --border: rgba(255,255,255,0.08);
  --border-hover: rgba(255,255,255,0.15);
  --text: #f1f1f3;
  --text-secondary: #a0a1a8;
  --text-dim: #6b6c73;
  --primary: #2563eb;
  --primary-light: #3b82f6;
  --primary-soft: rgba(37,99,235,0.12);
  --primary-glow: rgba(37,99,235,0.25);
  --danger: #ef4444;
  --success: #22c55e;
  --radius: 12px;
  --radius-sm: 8px;
  --radius-xs: 6px;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.3);
  --shadow-md: 0 4px 16px rgba(0,0,0,0.4);
  --shadow-lg: 0 8px 32px rgba(0,0,0,0.5);
  --transition: 0.15s ease;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }

/* === Navbar === */
.navbar {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0 1.5rem;
  height: 56px;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(12px);
}

.navbar-brand {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-shrink: 0;
}

.brand-icon {
  width: 32px;
  height: 32px;
  background: var(--primary);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
}

.brand-icon svg {
  width: 16px;
  height: 16px;
}

.brand-text {
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text);
}

.brand-accent {
  color: var(--primary-light);
}

.navbar-search {
  flex: 1;
  max-width: 520px;
  margin: 0 auto;
  position: relative;
}

.search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  width: 16px;
  height: 16px;
  color: var(--text-dim);
  pointer-events: none;
}

.navbar-search input {
  width: 100%;
  padding: 0.55rem 1rem 0.55rem 2.4rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 20px;
  color: var(--text);
  font-size: 0.875rem;
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
}

.navbar-search input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft);
}

.navbar-search input::placeholder {
  color: var(--text-dim);
}

.navbar-end {
  flex-shrink: 0;
}

.navbar-tag {
  font-size: 0.75rem;
  color: var(--text-dim);
  background: var(--bg);
  padding: 0.3rem 0.75rem;
  border-radius: 20px;
  border: 1px solid var(--border);
}

/* === Filters bar === */
.filters-bar {
  display: flex;
  gap: 0.5rem;
  padding: 0.75rem 1.5rem;
  overflow-x: auto;
  border-bottom: 1px solid var(--border);
  background: var(--bg-surface);
  scrollbar-width: none;
}

.filters-bar::-webkit-scrollbar { display: none; }

.filter-chip {
  padding: 0.4rem 1rem;
  border-radius: 20px;
  border: none;
  background: var(--bg-elevated);
  color: var(--text-secondary);
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: background var(--transition), color var(--transition);
}

.filter-chip:hover {
  background: var(--border-hover);
  color: var(--text);
}

.filter-chip.active {
  background: var(--text);
  color: var(--bg);
}

/* === Main === */
main {
  flex: 1;
  padding: 1.5rem;
  max-width: 1400px;
  margin: 0 auto;
  width: 100%;
}

/* === Loading === */
.loading-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  padding: 5rem 1rem;
  color: var(--text-dim);
}

.spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  padding: 5rem 1rem;
  color: var(--text-dim);
}

.empty-icon {
  width: 48px;
  height: 48px;
  margin-bottom: 0.5rem;
  opacity: 0.4;
}

.empty-state p { font-size: 1rem; font-weight: 500; }
.empty-state span { font-size: 0.85rem; }

/* === Gallery Grid === */
.gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 1.25rem;
}

/* === Video Card === */
.card {
  background: var(--bg-card);
  border-radius: var(--radius);
  overflow: hidden;
  cursor: pointer;
  transition: transform var(--transition), box-shadow var(--transition);
}

.card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-md);
}

.card-thumb {
  position: relative;
  background: #000;
  aspect-ratio: 16/9;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.card-thumb video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  pointer-events: none;
}

.card-thumb-fallback {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  background: linear-gradient(135deg, #1a1b20, #252630);
  color: var(--text-dim);
  font-size: 0.85rem;
  font-weight: 600;
  letter-spacing: 0.05em;
}

.card-duration {
  position: absolute;
  bottom: 8px;
  right: 8px;
  background: rgba(0,0,0,0.8);
  color: #fff;
  font-size: 0.7rem;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: 4px;
}

.card-play-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0,0,0,0.3);
  opacity: 0;
  transition: opacity 0.2s;
}

.card:hover .card-play-overlay { opacity: 1; }

.card-play-btn {
  width: 52px;
  height: 52px;
  background: var(--primary);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 20px rgba(37,99,235,0.4);
  transition: transform 0.15s;
}

.card:hover .card-play-btn { transform: scale(1.05); }

.card-play-btn svg {
  width: 22px;
  height: 22px;
  fill: #fff;
  margin-left: 2px;
}

.card-body {
  padding: 0.85rem 1rem 1rem;
}

.card-title {
  font-size: 0.9rem;
  font-weight: 600;
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.card-meta {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.4rem;
  font-size: 0.75rem;
  color: var(--text-dim);
}

.card-meta .dot::before { content: "\00B7"; }

.card-badge {
  display: inline-block;
  padding: 0.1rem 0.4rem;
  border-radius: 4px;
  background: var(--primary-soft);
  color: var(--primary-light);
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

/* === Watch page === */
.watch-page {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: var(--bg);
  overflow-y: auto;
}

.watch-inner {
  max-width: 1400px;
  margin: 0 auto;
  padding: 1rem 1.5rem 3rem;
}

.watch-back {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  padding: 0.5rem 0;
  margin-bottom: 1rem;
  transition: color var(--transition);
}

.watch-back:hover { color: var(--text); }

.watch-back svg { width: 18px; height: 18px; }

.watch-layout {
  display: grid;
  grid-template-columns: 1fr 360px;
  gap: 1.5rem;
}

.player-container {
  background: #000;
  border-radius: var(--radius);
  overflow: hidden;
  aspect-ratio: 16/9;
}

.player-container video {
  width: 100%;
  height: 100%;
  display: block;
}

.watch-info {
  margin-top: 1rem;
}

.watch-title {
  font-size: 1.3rem;
  font-weight: 700;
  line-height: 1.3;
  letter-spacing: -0.01em;
}

.watch-meta-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-top: 0.5rem;
  font-size: 0.8rem;
  color: var(--text-dim);
}

.watch-badge {
  background: var(--primary-soft);
  color: var(--primary-light);
  padding: 0.15rem 0.5rem;
  border-radius: 4px;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
}

.watch-desc {
  margin-top: 1rem;
  padding: 1rem;
  background: var(--bg-card);
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  line-height: 1.6;
  color: var(--text-secondary);
  white-space: pre-wrap;
}

.watch-actions {
  display: flex;
  gap: 0.75rem;
  margin-top: 1rem;
}

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

.sidebar-title {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 1rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.sidebar-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.sidebar-item {
  display: flex;
  gap: 0.75rem;
  cursor: pointer;
  padding: 0.35rem;
  border-radius: var(--radius-sm);
  transition: background var(--transition);
}

.sidebar-item:hover { background: var(--bg-card); }

.sidebar-thumb {
  width: 160px;
  height: 90px;
  flex-shrink: 0;
  border-radius: var(--radius-xs);
  overflow: hidden;
  background: #000;
}

.sidebar-thumb video, .sidebar-thumb div {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.sidebar-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.sidebar-info-title {
  font-size: 0.8rem;
  font-weight: 600;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  line-height: 1.3;
}

.sidebar-info-meta {
  font-size: 0.7rem;
  color: var(--text-dim);
  margin-top: 0.25rem;
}

/* === Cinema Mode === */
.watch-page.cinema-mode {
  background: #000;
}

.watch-page.cinema-mode .watch-inner {
  max-width: 100%;
  padding: 0;
}

.watch-page.cinema-mode .watch-back {
  display: none;
}

.watch-page.cinema-mode .watch-layout {
  grid-template-columns: 1fr;
  gap: 0;
}

.watch-page.cinema-mode .watch-sidebar {
  display: none;
}

.watch-page.cinema-mode .watch-info {
  display: none;
}

.watch-page.cinema-mode .player-container {
  border-radius: 0;
  aspect-ratio: unset;
  height: calc(100vh - 60px);
}

.watch-page.cinema-mode .watch-actions {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  display: flex;
  justify-content: center;
  padding: 0.75rem;
  background: rgba(0,0,0,0.85);
  z-index: 210;
}

/* === Buttons === */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.55rem 1.1rem;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  font-weight: 600;
  text-decoration: none;
  border: none;
  cursor: pointer;
  transition: background var(--transition), transform var(--transition);
}

.btn:active { transform: scale(0.97); }

.btn-primary {
  background: var(--primary);
  color: #fff;
}

.btn-primary:hover {
  background: var(--primary-light);
}

.btn-secondary {
  background: var(--bg-elevated);
  color: var(--text);
  border: 1px solid var(--border);
}

.btn-secondary:hover {
  background: var(--border-hover);
}

.btn-danger {
  background: rgba(239,68,68,0.1);
  color: var(--danger);
}

.btn-danger:hover {
  background: rgba(239,68,68,0.2);
}

.btn-sm {
  padding: 0.4rem 0.8rem;
  font-size: 0.8rem;
}

/* === Footer === */
footer {
  border-top: 1px solid var(--border);
  padding: 1.25rem 1.5rem;
  background: var(--bg-surface);
}

.footer-inner {
  max-width: 1400px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.78rem;
  color: var(--text-dim);
}

.footer-inner a {
  color: var(--primary-light);
  transition: color var(--transition);
}

.footer-inner a:hover { color: var(--text); }

/* === Upload page === */
.upload-container {
  max-width: 800px;
  margin: 0 auto;
  padding: 2rem 1.5rem;
}

.auth-form {
  max-width: 380px;
  margin: 5rem auto;
  text-align: center;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2.5rem 2rem;
}

.auth-form .auth-icon {
  width: 48px;
  height: 48px;
  margin: 0 auto 1.25rem;
  background: var(--primary-soft);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--primary-light);
}

.auth-form .auth-icon svg { width: 22px; height: 22px; }

.auth-form h2 {
  font-size: 1.15rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
}

.auth-form .auth-sub {
  color: var(--text-dim);
  font-size: 0.85rem;
  margin-bottom: 1.5rem;
}

.auth-form input {
  width: 100%;
  padding: 0.7rem 1rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 0.9rem;
  outline: none;
  margin-bottom: 1rem;
  transition: border-color var(--transition), box-shadow var(--transition);
}

.auth-form input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft);
}

.auth-form .error {
  color: var(--danger);
  font-size: 0.85rem;
  margin-bottom: 0.75rem;
  padding: 0.5rem;
  background: rgba(239,68,68,0.08);
  border-radius: var(--radius-xs);
}

.dropzone {
  border: 2px dashed var(--border-hover);
  border-radius: var(--radius);
  padding: 3.5rem 2rem;
  text-align: center;
  color: var(--text-dim);
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
  margin-bottom: 2rem;
  background: var(--bg-card);
}

.dropzone:hover,
.dropzone.dragover {
  border-color: var(--primary);
  background: var(--primary-soft);
}

.dropzone-icon {
  width: 48px;
  height: 48px;
  margin: 0 auto 1rem;
  background: var(--primary-soft);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--primary-light);
}

.dropzone-icon svg { width: 24px; height: 24px; }

.dropzone p {
  font-size: 0.95rem;
  color: var(--text-secondary);
  font-weight: 500;
  margin-bottom: 0.4rem;
}

.dropzone span {
  font-size: 0.78rem;
  color: var(--text-dim);
}

.progress-bar {
  height: 6px;
  background: var(--bg-elevated);
  border-radius: 3px;
  overflow: hidden;
  margin-bottom: 0.5rem;
  display: none;
}

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

.progress-text {
  text-align: center;
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-bottom: 1.5rem;
  display: none;
}

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

.section-header h3 {
  font-size: 1rem;
  font-weight: 600;
}

.section-header span {
  font-size: 0.78rem;
  color: var(--text-dim);
}

/* === Video list (upload page) === */
.video-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.video-item {
  display: flex;
  align-items: center;
  gap: 1rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.85rem 1rem;
  transition: border-color var(--transition);
}

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

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

.video-item-title {
  font-weight: 600;
  font-size: 0.9rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.video-item-meta {
  font-size: 0.75rem;
  color: var(--text-dim);
  margin-top: 0.2rem;
}

.video-item-thumb {
  width: 120px;
  height: 68px;
  flex-shrink: 0;
  border-radius: var(--radius-xs);
  overflow: hidden;
  background: #000;
}

.video-item-thumb video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  pointer-events: none;
}

.video-item-thumb-fallback {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #1a1b20, #252630);
  color: var(--text-dim);
  font-size: 0.7rem;
  font-weight: 600;
}

.video-item-desc {
  font-size: 0.78rem;
  color: var(--text-secondary);
  margin-top: 0.3rem;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  line-height: 1.4;
}

.video-item-actions {
  display: flex;
  gap: 0.5rem;
  flex-shrink: 0;
}

/* === Edit form inline === */
.edit-form {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-top: 0.75rem;
}

.edit-form input,
.edit-form textarea {
  width: 100%;
  padding: 0.5rem 0.75rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  color: var(--text);
  font-size: 0.85rem;
  outline: none;
  font-family: inherit;
  transition: border-color var(--transition);
}

.edit-form textarea {
  resize: vertical;
  min-height: 60px;
}

.edit-form input:focus,
.edit-form textarea:focus {
  border-color: var(--primary);
}

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

/* === Responsive === */
@media (max-width: 960px) {
  .watch-layout {
    grid-template-columns: 1fr;
  }
  .watch-sidebar {
    border-left: none;
    border-top: 1px solid var(--border);
    padding-left: 0;
    padding-top: 1.5rem;
  }
  .sidebar-item { flex-direction: row; }
  .sidebar-thumb { width: 140px; height: 79px; }
}

@media (max-width: 640px) {
  .navbar { padding: 0 1rem; gap: 0.75rem; }
  .navbar-end { display: none; }
  main { padding: 1rem; }
  .filters-bar { padding: 0.75rem 1rem; }
  .gallery { grid-template-columns: 1fr; }
  .watch-inner { padding: 0.75rem 1rem 2rem; }
  .watch-title { font-size: 1.1rem; }
  .video-item { flex-direction: column; align-items: stretch; }
  .video-item-actions { justify-content: flex-end; }
}
