/* ═══════════════════════════════════════════════════════════════════════════
   BangtlFilm – Dark Neon Theme
   ═══════════════════════════════════════════════════════════════════════════ */

/* ── Design Tokens ───────────────────────────────────────────────────────── */
:root {
  /* Surfaces */
  --bg-primary: #0a0e1a;
  --bg-secondary: #111827;
  --bg-card: rgba(17, 24, 39, 0.75);
  --bg-glass: rgba(30, 41, 59, 0.55);
  --bg-glass-hover: rgba(30, 41, 59, 0.8);

  /* Accents */
  --accent: #6366f1;
  --accent-light: #818cf8;
  --accent-glow: rgba(99, 102, 241, 0.35);
  --accent-secondary: #06b6d4;
  --accent-gradient: linear-gradient(135deg, #6366f1 0%, #06b6d4 100%);

  /* Text */
  --text-primary: #f1f5f9;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;

  /* Borders */
  --border-subtle: rgba(255, 255, 255, 0.06);
  --border-hover: rgba(99, 102, 241, 0.4);

  /* Misc */
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;
  --transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  --shadow-glow: 0 0 30px -5px var(--accent-glow);
  --shadow-card: 0 4px 24px rgba(0, 0, 0, 0.4);

  /* Font */
  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

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

body {
  font-family: var(--font);
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  overflow-x: hidden;
  background-image:
    radial-gradient(ellipse 80% 50% at 50% -20%, rgba(99, 102, 241, 0.12) 0%, transparent 70%),
    radial-gradient(ellipse 60% 40% at 80% 100%, rgba(6, 182, 212, 0.08) 0%, transparent 60%);
}

a { color: inherit; text-decoration: none; }
img { display: block; max-width: 100%; }
button { cursor: pointer; font-family: inherit; }
input, select { font-family: inherit; }

/* ── Container ───────────────────────────────────────────────────────────── */
.container {
  max-width: 1320px;
  margin: 0 auto;
  padding: 0 16px;
}

@media (min-width: 640px) { .container { padding: 0 24px; } }
@media (min-width: 1024px) { .container { padding: 0 32px; } }

/* ── Header ──────────────────────────────────────────────────────────────── */
.header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(10, 14, 26, 0.85);
  backdrop-filter: blur(20px) saturate(1.4);
  border-bottom: 1px solid var(--border-subtle);
}

.header__inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 64px;
  gap: 16px;
}

.header__brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.header__logo {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  background: var(--accent-gradient);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 16px rgba(99, 102, 241, 0.3);
}

.header__logo svg { width: 22px; height: 22px; }

.header__title {
  font-size: 20px;
  font-weight: 800;
  background: linear-gradient(135deg, #fff 30%, var(--accent-light));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  letter-spacing: -0.02em;
}

/* ── Source Tabs ──────────────────────────────────────────────────────────── */
.source-tabs {
  display: flex;
  gap: 6px;
  background: rgba(255, 255, 255, 0.04);
  padding: 4px;
  border-radius: var(--radius-lg);
}

.source-btn {
  padding: 8px 18px;
  border: none;
  border-radius: var(--radius-md);
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  background: transparent;
  transition: var(--transition);
  position: relative;
}

.source-btn:hover {
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.08);
}

.source-btn.active {
  color: #fff;
  background: var(--accent-gradient);
  box-shadow: 0 4px 16px rgba(99, 102, 241, 0.35);
}

/* ── Controls Bar ────────────────────────────────────────────────────────── */
.controls {
  background: var(--bg-glass);
  backdrop-filter: blur(16px);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-xl);
  padding: 16px 20px;
  margin: 24px 0;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
}

.controls__group {
  display: flex;
  align-items: center;
  gap: 8px;
}

.controls__label {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  white-space: nowrap;
}

.input-field {
  background: rgba(15, 23, 42, 0.7);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  color: var(--text-primary);
  font-size: 13px;
  font-weight: 500;
  transition: var(--transition);
  outline: none;
  -moz-appearance: textfield;
}

.input-field::-webkit-inner-spin-button { -webkit-appearance: none; }

.input-field:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}

.input-number { width: 72px; text-align: center; }

select.input-field {
  cursor: pointer;
  -webkit-appearance: none;
  padding-right: 28px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
}

.controls__spacer { flex: 1; }

.controls__info {
  font-size: 13px;
  color: var(--text-muted);
  font-weight: 500;
}

/* ── Buttons ─────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 16px;
  border: none;
  border-radius: var(--radius-md);
  font-size: 13px;
  font-weight: 600;
  transition: var(--transition);
  white-space: nowrap;
}

.btn svg { width: 16px; height: 16px; flex-shrink: 0; }

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

.btn-primary:hover {
  box-shadow: var(--shadow-glow);
  transform: translateY(-1px);
}

.btn-primary:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.btn-ghost {
  color: var(--text-secondary);
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--border-subtle);
}

.btn-ghost:hover {
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.1);
}

/* ── Video Grid ──────────────────────────────────────────────────────────── */
.video-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
}

@media (min-width: 640px) { .video-grid { grid-template-columns: repeat(2, 1fr); gap: 20px; } }
@media (min-width: 768px) { .video-grid { grid-template-columns: repeat(3, 1fr); } }
@media (min-width: 1024px) { .video-grid { grid-template-columns: repeat(4, 1fr); } }
@media (min-width: 1280px) { .video-grid { grid-template-columns: repeat(5, 1fr); } }

/* ── Image grid (masonry, portrait) ─────────────────────────────────────── */
.video-grid.image-grid {
  display: block;
  column-count: 2;
  column-gap: 10px;
}

@media (min-width: 640px) {
  .video-grid.image-grid { column-count: 3; column-gap: 12px; }
}

@media (min-width: 1024px) {
  .video-grid.image-grid { column-count: 4; column-gap: 14px; }
}

@media (min-width: 1280px) {
  .video-grid.image-grid { column-count: 5; column-gap: 14px; }
}

.image-card {
  break-inside: avoid;
  margin-bottom: 10px;
  border-radius: var(--radius-md);
  overflow: hidden;
  cursor: pointer;
  background: var(--bg-secondary);
  border: 1px solid var(--border-subtle);
  transition: var(--transition);
  animation: cardIn 0.4s ease-out both;
}

.image-card--offset {
  margin-top: 18px;
}

@media (min-width: 640px) {
  .image-card--offset { margin-top: 28px; }
}

.image-card:hover {
  border-color: var(--border-hover);
  box-shadow: var(--shadow-glow), var(--shadow-card);
  transform: translateY(-2px);
}

.image-card__img {
  width: 100%;
  height: auto;
  display: block;
  vertical-align: middle;
  transition: transform 0.4s ease;
}

.image-card:hover .image-card__img {
  transform: scale(1.02);
}

/* ── Video Card ──────────────────────────────────────────────────────────── */
.video-card {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  overflow: hidden;
  border: 1px solid var(--border-subtle);
  cursor: pointer;
  transition: var(--transition);
  animation: cardIn 0.4s ease-out both;
}

.video-card:hover {
  transform: translateY(-4px);
  border-color: var(--border-hover);
  box-shadow: var(--shadow-glow), var(--shadow-card);
}

@keyframes cardIn {
  from { opacity: 0; transform: translateY(16px); }
  to { opacity: 1; transform: translateY(0); }
}

.thumb-wrapper {
  position: relative;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  background: var(--bg-secondary);
}

.video-thumbnail {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.45s ease;
}

.video-card:hover .video-thumbnail { transform: scale(1.06); }

.thumb-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(to top, rgba(0,0,0,0.65) 0%, transparent 55%);
  opacity: 0;
  transition: opacity var(--transition);
  display: flex;
  align-items: center;
  justify-content: center;
}

.video-card:hover .thumb-overlay { opacity: 1; }

.play-icon {
  width: 48px;
  height: 48px;
  background: rgba(255,255,255,0.92);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transform: scale(0.7);
  opacity: 0;
  transition: all 0.3s ease;
  box-shadow: 0 6px 20px rgba(0,0,0,0.3);
}

.video-card:hover .play-icon { transform: scale(1); opacity: 1; }
.play-icon svg { fill: var(--bg-primary); width: 20px; height: 20px; margin-left: 2px; }

.hot-badge {
  position: absolute;
  top: 8px;
  left: 8px;
  background: linear-gradient(135deg, #ef4444, #f97316);
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 700;
  color: #fff;
  z-index: 2;
  box-shadow: 0 3px 10px rgba(239, 68, 68, 0.4);
  animation: pulseBadge 2s infinite;
}

@keyframes pulseBadge {
  0%, 100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.35); }
  50% { box-shadow: 0 0 0 6px rgba(239, 68, 68, 0); }
}

.video-info { padding: 12px 14px 14px; }

.video-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.45;
  margin-bottom: 8px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  min-height: 38px;
}

.video-stats {
  display: flex;
  align-items: center;
  gap: 14px;
  font-size: 12px;
  color: var(--text-muted);
}

.stat-item { display: flex; align-items: center; gap: 4px; }

/* ── Bottom Pagination ───────────────────────────────────────────────────── */
.bottom-pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  margin: 40px 0 32px;
  padding: 16px 24px;
  background: var(--bg-glass);
  backdrop-filter: blur(16px);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-xl);
}

.bottom-pagination .page-info {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-secondary);
  min-width: 120px;
  text-align: center;
}

.bottom-pagination .page-info span {
  color: var(--accent-light);
}

/* ── Loading ─────────────────────────────────────────────────────────────── */
.loading-state {
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 80px 0;
}

.spinner {
  width: 44px;
  height: 44px;
  border: 3px solid rgba(99, 102, 241, 0.15);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin-bottom: 16px;
}

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

.loading-text {
  font-size: 14px;
  color: var(--text-muted);
  font-weight: 500;
}

/* ── Error State ─────────────────────────────────────────────────────────── */
.error-state {
  display: none;
  max-width: 420px;
  margin: 0 auto;
  text-align: center;
  padding: 48px 24px;
  background: var(--bg-glass);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-xl);
}

.error-state__icon {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: rgba(239, 68, 68, 0.15);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 16px;
}

.error-state__icon svg { width: 28px; height: 28px; color: #f87171; }

.error-state h3 {
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 8px;
}

.error-state p {
  font-size: 14px;
  color: var(--text-muted);
  margin-bottom: 24px;
}

.error-state .error-msg {
  font-size: 13px;
  color: var(--text-muted);
}

/* ── Modal ───────────────────────────────────────────────────────────────── */
.modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: none;
}

.modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.88);
  backdrop-filter: blur(8px);
}

.modal__wrapper {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 16px;
}

.modal__content {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 900px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  background: var(--bg-secondary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-xl);
  overflow: hidden;
  animation: modalIn 0.3s ease-out;
}

@keyframes modalIn {
  from { opacity: 0; transform: scale(0.95) translateY(10px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

.modal__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border-subtle);
}

.modal__title {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-primary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  padding-right: 16px;
  flex: 1;
}

.modal__close {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  border: none;
  background: rgba(255,255,255,0.06);
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
  flex-shrink: 0;
}

.modal__close:hover { background: rgba(255,255,255,0.12); color: #fff; }
.modal__close svg { width: 18px; height: 18px; }

.modal__player {
  background: #000;
  flex: 1;
  overflow: hidden;
}

.modal__player video,
.modal__player .modal__image {
  width: 100%;
  max-height: 60vh;
  object-fit: contain;
  display: block;
  margin: 0 auto;
}

.modal__info {
  padding: 14px 18px;
  border-top: 1px solid var(--border-subtle);
  display: flex;
  flex-wrap: wrap;
  gap: 20px;
  font-size: 13px;
  color: var(--text-secondary);
}

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

.modal__stat svg { width: 18px; height: 18px; }
.modal__stat .value { font-weight: 600; color: var(--text-primary); }

/* ── Utilities ───────────────────────────────────────────────────────────── */
.hidden { display: none !important; }

.sr-only {
  position: absolute; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}

/* ── Responsive tweaks ───────────────────────────────────────────────────── */
@media (max-width: 639px) {
  .header__inner { height: 56px; }
  .header__title { font-size: 16px; }
  .source-btn { padding: 6px 12px; font-size: 12px; }
  .controls { padding: 12px; gap: 10px; }
  .video-grid { gap: 12px; }
  .video-info { padding: 10px 10px 12px; }
  .video-title { font-size: 12px; min-height: 34px; }
  .bottom-pagination { margin: 24px 0; padding: 12px 16px; }
  .hide-mobile { display: none; }
}
