/* ==========================================================================
   JAV TH - Complete Web App Styling (Android M3 Dark Theme & High-End UX)
   ========================================================================== */

:root {
  --bg-dark: #07090E;
  --bg-surface: #0E131F;
  --bg-card: #141A29;
  --bg-card-hover: #1A2338;
  --border-color: rgba(255, 255, 255, 0.08);
  --border-focus: rgba(239, 68, 68, 0.5);
  
  --primary-red: #EF4444;
  --primary-red-hover: #DC2626;
  --primary-red-dark: #991B1B;
  --primary-red-glow: rgba(239, 68, 68, 0.35);

  --accent-gold: #EAB308;
  --accent-cyan: #38BDF8;
  --accent-green: #22C55E;

  --text-main: #FFFFFF;
  --text-secondary: #94A3B8;
  --text-muted: #64748B;
  
  --nav-height: 64px;
  --header-height: 58px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-top: env(safe-area-inset-top, 0px);
  
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 18px;
  --radius-full: 9999px;
  
  --font-sans: 'Kanit', system-ui, -apple-system, sans-serif;
  --font-mono: 'Roboto Mono', monospace;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

html, body {
  width: 100%;
  height: 100%;
  background-color: var(--bg-dark);
  color: var(--text-main);
  font-family: var(--font-sans);
  overflow-x: hidden;
  position: fixed;
}

button, input, select {
  font-family: inherit;
  outline: none;
  border: none;
}

button {
  cursor: pointer;
  background: transparent;
}

.hidden {
  display: none !important;
}

/* ==================== 1. LANDING SCREEN ==================== */
.landing-screen {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background-color: #07090E;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
}

.landing-bg-container {
  position: absolute;
  inset: 0;
  overflow: hidden;
}

.landing-hero-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center top;
}

.landing-gradient-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(7, 9, 14, 0.1) 0%, rgba(7, 9, 14, 0.6) 60%, #07090E 95%);
}

.landing-content {
  position: relative;
  z-index: 10;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0 24px calc(24px + var(--safe-bottom));
  width: 100%;
  max-width: 500px;
  margin: 0 auto;
}

.landing-progress-wrapper {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  margin-bottom: 20px;
}

.landing-progress-bar {
  width: 90%;
  height: 8px;
  background: #261214;
  border: 1px solid rgba(239, 68, 68, 0.35);
  border-radius: var(--radius-full);
  overflow: hidden;
  box-shadow: 0 0 10px rgba(239, 68, 68, 0.2);
}

.landing-progress-fill {
  height: 100%;
  width: 15%;
  background: linear-gradient(90deg, #DC2626, #F97316, #FBBF24);
  border-radius: var(--radius-full);
  transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.landing-status-text {
  font-size: 13px;
  color: var(--text-secondary);
  font-weight: 400;
}

.btn-get-started {
  width: 85%;
  height: 52px;
  border-radius: var(--radius-full);
  background: linear-gradient(180deg, #F87171 0%, #DC2626 50%, #991B1B 100%);
  border: 1px solid rgba(255, 180, 180, 0.6);
  color: #FFFFFF;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.5px;
  box-shadow: 0 8px 24px var(--primary-red-glow);
  transition: transform 0.2s, box-shadow 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 24px;
}

.btn-get-started:active {
  transform: scale(0.96);
}

.pulse-anim {
  animation: pulseButton 2s infinite ease-in-out;
}

@keyframes pulseButton {
  0%, 100% { transform: scale(1); box-shadow: 0 8px 24px var(--primary-red-glow); }
  50% { transform: scale(1.03); box-shadow: 0 12px 30px rgba(239, 68, 68, 0.55); }
}

.landing-bottom-badges {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 12px;
}

.badge-android {
  color: var(--accent-gold);
  display: flex;
  align-items: center;
}

.icon-android {
  width: 32px;
  height: 32px;
}

.badge-4k {
  border: 1px solid var(--accent-gold);
  border-radius: 6px;
  background: #0F131D;
  padding: 2px 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  line-height: 1.1;
}

.badge-4k-sub {
  color: var(--accent-gold);
  font-size: 9px;
  font-weight: 500;
  letter-spacing: 0.5px;
}

.badge-4k-title {
  color: var(--accent-gold);
  font-size: 15px;
  font-weight: 800;
}

/* ==================== 2. MAIN APPLICATION ==================== */
.main-app {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  background-color: var(--bg-dark);
}

/* Top Header */
.app-header {
  height: var(--header-height);
  padding: var(--safe-top) 16px 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(14, 19, 31, 0.95);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-color);
  z-index: 100;
}

.app-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
}

.brand-logo-box {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: linear-gradient(135deg, #DC2626, #991B1B);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 12px rgba(220, 38, 38, 0.4);
}

.icon-play-badge {
  width: 20px;
  height: 20px;
}

.brand-name {
  font-size: 22px;
  font-weight: 900;
  letter-spacing: 1px;
}

.brand-jav {
  color: #FFFFFF;
}

.brand-th {
  color: var(--primary-red);
}

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

.btn-icon {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  transition: background 0.2s, color 0.2s;
}

.btn-icon:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #FFFFFF;
}

.btn-icon svg {
  width: 20px;
  height: 20px;
}

.icon-refresh.spinning {
  animation: spin 0.8s linear infinite;
}

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

/* Search Bar */
.search-bar-container {
  padding: 8px 16px 4px;
  background: var(--bg-dark);
}

.search-input-box {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  height: 42px;
  display: flex;
  align-items: center;
  padding: 0 12px;
  gap: 8px;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.search-input-box:focus-within {
  border-color: var(--primary-red);
  box-shadow: 0 0 12px rgba(239, 68, 68, 0.2);
}

.icon-search-input {
  width: 18px;
  height: 18px;
  color: var(--text-muted);
}

.search-input-box input {
  flex: 1;
  background: transparent;
  color: #FFFFFF;
  font-size: 14px;
}

.search-input-box input::placeholder {
  color: var(--text-muted);
}

.btn-icon-clear {
  color: var(--text-muted);
  font-size: 20px;
  line-height: 1;
  padding: 2px 6px;
}

/* Main Content Area */
.app-main-content {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding-bottom: calc(var(--nav-height) + var(--safe-bottom) + 16px);
  -webkit-overflow-scrolling: touch;
}

.tab-page {
  display: none;
  animation: fadeIn 0.25s ease-out;
}

.tab-page.active {
  display: block;
}

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

/* Category Chips */
.categories-scroll-wrapper {
  overflow-x: auto;
  white-space: nowrap;
  padding: 10px 16px;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

.categories-scroll-wrapper::-webkit-scrollbar {
  display: none;
}

.category-chips {
  display: inline-flex;
  gap: 8px;
}

.chip-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: var(--radius-full);
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 500;
  transition: all 0.2s;
}

.chip-item.active {
  background: var(--primary-red);
  border-color: var(--primary-red);
  color: #FFFFFF;
  box-shadow: 0 4px 12px var(--primary-red-glow);
}

.chip-count {
  font-size: 11px;
  background: rgba(255, 255, 255, 0.15);
  padding: 1px 6px;
  border-radius: 10px;
}

/* Sections */
.section-container {
  padding: 12px 16px 20px;
}

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.section-title-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
}

.section-indicator {
  width: 4px;
  height: 18px;
  border-radius: 2px;
}

.section-indicator.red { background: var(--primary-red); }
.section-indicator.gold { background: var(--accent-gold); }
.section-indicator.purple { background: #A855F7; }

.section-title {
  font-size: 16px;
  font-weight: 700;
  color: #FFFFFF;
}

.badge-count {
  font-size: 12px;
  color: var(--text-muted);
  background: var(--bg-card);
  padding: 3px 8px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
}

.btn-text {
  font-size: 12px;
  color: var(--text-muted);
  transition: color 0.2s;
}

.btn-text:hover {
  color: #FFFFFF;
}

.btn-text.text-danger {
  color: #EF4444;
}

/* Continue Watching Carousel */
.history-carousel {
  display: flex;
  gap: 12px;
  overflow-x: auto;
  padding-bottom: 8px;
  scrollbar-width: none;
}

.history-carousel::-webkit-scrollbar {
  display: none;
}

.history-card {
  flex: 0 0 200px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  overflow: hidden;
  position: relative;
  cursor: pointer;
  transition: transform 0.2s, border-color 0.2s;
}

.history-card:hover {
  transform: translateY(-2px);
  border-color: rgba(239, 68, 68, 0.4);
}

.history-poster-wrap {
  position: relative;
  width: 100%;
  height: 110px;
  background: #0B0E14;
}

.history-poster {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.history-play-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0.9;
}

.history-play-icon {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-full);
  background: var(--primary-red);
  color: #FFFFFF;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 8px rgba(0,0,0,0.5);
}

.history-progress-bar {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: rgba(255, 255, 255, 0.2);
}

.history-progress-fill {
  height: 100%;
  background: var(--primary-red);
}

.history-info {
  padding: 8px 10px;
}

.history-title {
  font-size: 13px;
  font-weight: 600;
  color: #FFFFFF;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.history-time-meta {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
}

.btn-history-dismiss {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 24px;
  height: 24px;
  border-radius: var(--radius-full);
  background: rgba(0, 0, 0, 0.7);
  color: #CBD5E1;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  z-index: 5;
}

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

@media (min-width: 600px) {
  .video-grid { grid-template-columns: repeat(3, 1fr); }
}

@media (min-width: 900px) {
  .video-grid { grid-template-columns: repeat(4, 1fr); gap: 16px; }
}

@media (min-width: 1200px) {
  .video-grid { grid-template-columns: repeat(5, 1fr); }
}

.video-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  cursor: pointer;
  position: relative;
  transition: transform 0.2s, box-shadow 0.2s, border-color 0.2s;
}

.video-card:hover {
  transform: translateY(-3px);
  border-color: rgba(239, 68, 68, 0.4);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.4);
}

.video-card-poster-box {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 10;
  background: #0B0E14;
  overflow: hidden;
}

.video-card-poster {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.3s;
}

.video-card:hover .video-card-poster {
  transform: scale(1.05);
}

.video-badge-thai-sub {
  position: absolute;
  top: 6px;
  left: 6px;
  background: linear-gradient(135deg, #EF4444, #B91C1C);
  color: #FFFFFF;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 4px;
  box-shadow: 0 2px 6px rgba(0,0,0,0.5);
  letter-spacing: 0.3px;
}

.video-badge-streams {
  position: absolute;
  bottom: 6px;
  left: 6px;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(4px);
  color: #CBD5E1;
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 4px;
}

.btn-card-fav {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 32px;
  height: 32px;
  border-radius: var(--radius-full);
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(6px);
  color: #FFFFFF;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s, transform 0.2s, color 0.2s;
  z-index: 4;
}

.btn-card-fav:hover {
  background: rgba(0, 0, 0, 0.9);
  transform: scale(1.1);
}

.btn-card-fav.active {
  color: #EF4444;
}

.btn-card-fav svg {
  width: 16px;
  height: 16px;
}

.video-card-body {
  padding: 10px;
  display: flex;
  flex-direction: column;
  flex: 1;
}

.video-card-actor {
  font-size: 11px;
  color: var(--accent-gold);
  font-weight: 600;
  margin-bottom: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.video-card-title {
  font-size: 13px;
  font-weight: 500;
  color: #FFFFFF;
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* Loading & Empty States */
.loading-spinner-wrap {
  padding: 60px 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  color: var(--text-secondary);
  font-size: 14px;
}

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

.spinner.lg {
  width: 48px;
  height: 48px;
  border-width: 4px;
}

.empty-state {
  padding: 60px 20px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  color: var(--text-muted);
}

.empty-state svg {
  width: 56px;
  height: 56px;
  margin-bottom: 16px;
  stroke: var(--text-muted);
}

.empty-state h3 {
  color: #FFFFFF;
  font-size: 17px;
  margin-bottom: 6px;
}

.empty-state p {
  font-size: 13px;
  max-width: 280px;
  margin-bottom: 16px;
}

.btn-primary-sm {
  background: var(--primary-red);
  color: #FFFFFF;
  padding: 8px 18px;
  border-radius: var(--radius-full);
  font-size: 13px;
  font-weight: 600;
  box-shadow: 0 4px 12px var(--primary-red-glow);
}

/* Catalogue Grid */
.catalogue-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}

@media (min-width: 600px) {
  .catalogue-grid { grid-template-columns: repeat(3, 1fr); }
}

@media (min-width: 900px) {
  .catalogue-grid { grid-template-columns: repeat(4, 1fr); }
}

.catalogue-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 14px;
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  transition: transform 0.2s, border-color 0.2s, background 0.2s;
}

.catalogue-card:hover {
  transform: translateY(-2px);
  border-color: var(--primary-red);
  background: var(--bg-card-hover);
}

.catalogue-avatar {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-md);
  background: #1F293D;
  overflow: hidden;
  flex-shrink: 0;
}

.catalogue-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.catalogue-meta {
  flex: 1;
  overflow: hidden;
}

.catalogue-name {
  font-size: 14px;
  font-weight: 600;
  color: #FFFFFF;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.catalogue-count {
  font-size: 12px;
  color: var(--accent-gold);
}

/* ==================== 3. SETTINGS TAB ==================== */
.settings-container {
  padding: 12px 16px 30px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  max-width: 700px;
  margin: 0 auto;
}

.settings-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.settings-card-header {
  display: flex;
  align-items: center;
  gap: 10px;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 10px;
}

.settings-icon {
  width: 20px;
  height: 20px;
  color: var(--primary-red);
}

.settings-card-header h3 {
  font-size: 15px;
  font-weight: 700;
  color: #FFFFFF;
}

.setting-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.setting-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.setting-label {
  font-size: 14px;
  font-weight: 600;
  color: #FFFFFF;
}

.setting-sub {
  font-size: 12px;
  color: var(--text-muted);
}

.setting-select {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: #FFFFFF;
  padding: 8px 12px;
  font-size: 13px;
  cursor: pointer;
  max-width: 170px;
}

.setting-select option {
  background: var(--bg-card);
  color: #FFFFFF;
}

/* Toggle Switch */
.switch {
  position: relative;
  display: inline-block;
  width: 46px;
  height: 26px;
  flex-shrink: 0;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider.round {
  position: absolute;
  cursor: pointer;
  top: 0; left: 0; right: 0; bottom: 0;
  background-color: #334155;
  transition: .3s;
  border-radius: 34px;
}

.slider.round:before {
  position: absolute;
  content: "";
  height: 20px;
  width: 20px;
  left: 3px;
  bottom: 3px;
  background-color: white;
  transition: .3s;
  border-radius: 50%;
}

input:checked + .slider.round {
  background-color: var(--primary-red);
}

input:checked + .slider.round:before {
  transform: translateX(20px);
}

.setting-btn-row {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.btn-setting-action {
  width: 100%;
  padding: 12px 16px;
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  color: #CBD5E1;
  font-size: 13px;
  font-weight: 500;
  text-align: left;
  transition: background 0.2s, color 0.2s;
}

.btn-setting-action:hover {
  background: rgba(255, 255, 255, 0.05);
  color: #FFFFFF;
}

.btn-setting-action.text-danger {
  color: #EF4444;
}

/* App Info Box */
.app-info-row {
  display: flex;
  align-items: center;
  gap: 14px;
}

.app-info-avatar {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  background: linear-gradient(135deg, #DC2626, #991B1B);
  display: flex;
  align-items: center;
  justify-content: center;
}

.app-info-avatar svg {
  width: 26px;
  height: 26px;
}

.app-info-name {
  font-size: 16px;
  font-weight: 800;
  color: #FFFFFF;
}

.app-info-desc {
  font-size: 12px;
  color: var(--text-muted);
}

.app-info-tag {
  display: inline-block;
  margin-top: 4px;
  font-size: 10px;
  font-weight: 600;
  background: rgba(239, 68, 68, 0.2);
  color: #F87171;
  padding: 2px 8px;
  border-radius: 4px;
}

.app-spec-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin-top: 6px;
}

.spec-item {
  background: var(--bg-surface);
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  display: flex;
  flex-direction: column;
}

.spec-label {
  font-size: 11px;
  color: var(--text-muted);
}

.spec-value {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
}

/* ==================== 4. BOTTOM NAVIGATION ==================== */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: calc(var(--nav-height) + var(--safe-bottom));
  padding-bottom: var(--safe-bottom);
  background: #11141B;
  border-top: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-around;
  z-index: 100;
}

.nav-item {
  flex: 1;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  color: #94A3B8;
  font-size: 11px;
  font-weight: 500;
  transition: color 0.2s;
  position: relative;
}

.nav-icon {
  width: 22px;
  height: 22px;
  transition: transform 0.2s;
}

.nav-item.active {
  color: var(--primary-red);
  font-weight: 700;
}

.nav-item.active .nav-icon {
  transform: translateY(-2px);
  stroke: var(--primary-red);
}

/* ==================== 5. HIGH-PERFORMANCE VIDEO PLAYER ==================== */
.player-overlay {
  position: fixed;
  inset: 0;
  z-index: 10000;
  background: #000000;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.video-container {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #000000;
  cursor: pointer;
}

.video-container video {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.video-container.fit-cover video { object-fit: cover; }
.video-container.fit-16-9 video { aspect-ratio: 16 / 9; object-fit: fill; }
.video-container.fit-4-3 video { aspect-ratio: 4 / 3; object-fit: fill; }

/* Subtitles Layer */
.subtitle-overlay {
  position: absolute;
  bottom: 90px;
  left: 5%;
  right: 5%;
  text-align: center;
  pointer-events: none;
  z-index: 10;
  font-family: var(--font-sans);
  font-weight: 600;
  font-size: 20px;
  color: #FFFFFF;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.9), 0 -1px 2px rgba(0, 0, 0, 0.8), 1px 1px 2px rgba(0,0,0,0.9), -1px -1px 2px rgba(0,0,0,0.9);
  line-height: 1.4;
  white-space: pre-wrap;
  transition: bottom 0.2s;
}

.player-controls-overlay.visible ~ * .subtitle-overlay,
.player-controls-overlay:not(.hidden) ~ * .subtitle-overlay {
  bottom: 130px;
}

.subtitle-text-box {
  display: inline-block;
  background: rgba(0, 0, 0, 0.65);
  padding: 4px 12px;
  border-radius: 6px;
}

/* Buffering Spinner */
.player-buffering {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.35);
  z-index: 15;
}

/* Double-tap Seek Flash Indicator */
.seek-flash {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 35%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.12);
  color: #FFFFFF;
  font-size: 18px;
  font-weight: 700;
  z-index: 16;
  border-radius: var(--radius-full);
  pointer-events: none;
  animation: flashFade 0.6s ease-out;
}

.seek-flash.left { left: 0; border-top-left-radius: 0; border-bottom-left-radius: 0; }
.seek-flash.right { right: 0; border-top-right-radius: 0; border-bottom-right-radius: 0; }

@keyframes flashFade {
  0% { opacity: 0; }
  50% { opacity: 1; }
  100% { opacity: 0; }
}

/* Stats for Nerds */
.stats-overlay {
  position: absolute;
  top: 60px;
  left: 16px;
  background: rgba(14, 19, 31, 0.85);
  backdrop-filter: blur(8px);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 10px 14px;
  font-family: var(--font-mono);
  font-size: 11px;
  color: #E2E8F0;
  z-index: 30;
  min-width: 220px;
}

.stats-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  padding-bottom: 4px;
  margin-bottom: 6px;
  font-weight: 700;
  color: var(--accent-gold);
}

.stats-content div {
  margin: 2px 0;
}

.stats-content span {
  color: #FFFFFF;
}

/* Floating Unlock Button (when locked) */
.floating-unlock-btn {
  position: absolute;
  top: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(239, 68, 68, 0.9);
  color: #FFFFFF;
  border-radius: var(--radius-full);
  padding: 8px 18px;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 600;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.6);
  z-index: 50;
  animation: pulseButton 2s infinite ease-in-out;
}

.floating-unlock-btn svg {
  width: 18px;
  height: 18px;
}

/* Player Controls Overlay */
.player-controls-overlay {
  position: absolute;
  inset: 0;
  z-index: 20;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  background: linear-gradient(180deg, rgba(0,0,0,0.85) 0%, rgba(0,0,0,0.1) 40%, rgba(0,0,0,0.1) 60%, rgba(0,0,0,0.92) 100%);
  transition: opacity 0.3s ease;
  user-select: none;
  -webkit-user-select: none;
  cursor: pointer;
}

.player-controls-overlay button,
.player-controls-overlay input,
.player-controls-overlay select,
.player-controls-overlay .slider-wrapper,
.player-controls-overlay .player-tool-pill {
  cursor: pointer;
}

.player-controls-overlay.hidden {
  opacity: 0;
  pointer-events: none;
}

/* Top Bar in Player */
.player-top-bar {
  padding: var(--safe-top) 16px 0;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.player-icon-btn {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #FFFFFF;
  background: rgba(0, 0, 0, 0.3);
  transition: background 0.2s;
}

.player-icon-btn:hover {
  background: rgba(255, 255, 255, 0.15);
}

.player-icon-btn svg {
  width: 20px;
  height: 20px;
}

.player-title-box {
  flex: 1;
  overflow: hidden;
  text-align: left;
}

.player-title-sub {
  font-size: 10px;
  letter-spacing: 1px;
  color: var(--accent-gold);
  font-weight: 600;
  display: block;
}

.player-title-text {
  font-size: 14px;
  font-weight: 600;
  color: #FFFFFF;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.player-top-right {
  display: flex;
  align-items: center;
  gap: 6px;
}

.player-live-clock {
  font-family: var(--font-mono);
  font-size: 13px;
  color: #E2E8F0;
  margin-right: 4px;
}

/* Center Playback Controls */
.player-center-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 24px;
}

.center-btn-main {
  width: 64px;
  height: 64px;
  border-radius: var(--radius-full);
  background: rgba(239, 68, 68, 0.9);
  color: #FFFFFF;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 24px rgba(239, 68, 68, 0.5);
  transition: transform 0.2s, background 0.2s;
}

.center-btn-main:active {
  transform: scale(0.92);
}

.center-btn-main svg {
  width: 32px;
  height: 32px;
}

.center-btn-secondary {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-full);
  background: rgba(0, 0, 0, 0.5);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: #FFFFFF;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  position: relative;
  transition: background 0.2s, transform 0.2s;
}

.center-btn-secondary:active {
  transform: scale(0.92);
}

.center-btn-secondary svg {
  width: 22px;
  height: 22px;
}

.center-btn-label {
  font-size: 9px;
  font-weight: 700;
  position: absolute;
  bottom: 8px;
}

/* Bottom Controls Section */
.player-bottom-section {
  padding: 0 16px calc(14px + var(--safe-bottom));
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* Progress Bar */
.player-progress-bar-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.player-time-text {
  font-family: var(--font-mono);
  font-size: 12px;
  color: #CBD5E1;
  min-width: 45px;
}

.slider-wrapper {
  position: relative;
  flex: 1;
  height: 24px;
  display: flex;
  align-items: center;
}

.buffer-track {
  position: absolute;
  left: 0;
  height: 4px;
  width: 0%;
  background: rgba(255, 255, 255, 0.35);
  border-radius: 2px;
  pointer-events: none;
}

.player-seek-slider {
  width: 100%;
  height: 4px;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 2px;
  -webkit-appearance: none;
  cursor: pointer;
  position: relative;
  z-index: 2;
}

.player-seek-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--primary-red);
  box-shadow: 0 0 8px rgba(239, 68, 68, 0.8);
  cursor: pointer;
  transition: transform 0.15s;
}

.player-seek-slider::-webkit-slider-thumb:hover {
  transform: scale(1.3);
}

/* Scrollable Bottom Tools Bar (Matches Android layout!) */
.player-tools-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  overflow-x: auto;
  scrollbar-width: none;
  padding: 2px 0;
}

.player-tools-toolbar::-webkit-scrollbar {
  display: none;
}

.player-tool-pill {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 7px 12px;
  border-radius: var(--radius-full);
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: #CBD5E1;
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
  transition: all 0.2s;
  flex-shrink: 0;
}

.player-tool-pill:hover,
.player-tool-pill.active {
  background: rgba(239, 68, 68, 0.25);
  border-color: var(--primary-red);
  color: #FFFFFF;
}

.player-tool-pill svg {
  width: 16px;
  height: 16px;
}

.player-tool-pill.icon-only {
  padding: 7px;
  border-radius: var(--radius-full);
}

/* ==================== 6. BOTTOM SHEETS & MODALS ==================== */
.sheet-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  z-index: 10001;
  transition: opacity 0.25s;
}

.bottom-sheet {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  max-width: 650px;
  margin: 0 auto;
  background: #11141B;
  border-top-left-radius: 20px;
  border-top-right-radius: 20px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-bottom: none;
  z-index: 10002;
  padding: 12px 18px calc(24px + var(--safe-bottom));
  max-height: 85vh;
  overflow-y: auto;
  box-shadow: 0 -8px 30px rgba(0, 0, 0, 0.7);
  animation: slideUp 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes slideUp {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}

.sheet-handle {
  width: 40px;
  height: 4px;
  border-radius: 2px;
  background: rgba(255, 255, 255, 0.3);
  margin: 0 auto 12px;
}

.sheet-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 10px;
  margin-bottom: 14px;
}

.sheet-header h3 {
  font-size: 16px;
  font-weight: 700;
  color: #FFFFFF;
}

.sheet-close-btn {
  font-size: 24px;
  color: var(--text-muted);
  line-height: 1;
  padding: 2px 6px;
}

.sheet-close-btn:hover {
  color: #FFFFFF;
}

/* Audio Tracks Specific UI (Matches User Screenshot!) */
.audio-tool-buttons-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 16px;
}

.btn-audio-tool {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 8px;
  border-radius: var(--radius-sm);
  background: transparent;
  border: 1px solid #00F0FF;
  color: #00F0FF;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-audio-tool:hover {
  background: rgba(0, 240, 255, 0.15);
}

.btn-audio-tool svg {
  width: 16px;
  height: 16px;
}

/* Audio Amplifier Card */
.audio-amplifier-card {
  background: #181C26;
  border-radius: var(--radius-md);
  padding: 14px 16px;
  margin-bottom: 16px;
}

.amp-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-family: var(--font-mono);
  font-size: 12px;
  color: #94A3B8;
  margin-bottom: 10px;
}

.amp-value {
  color: #00F0FF;
  font-weight: 700;
}

.amp-slider-container {
  position: relative;
  height: 28px;
  display: flex;
  align-items: center;
}

/* Cyan dots track from user image */
.amp-dots-track {
  position: absolute;
  left: 8px;
  right: 8px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  pointer-events: none;
}

.amp-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: #00F0FF;
  opacity: 0.8;
}

.amp-dot.red {
  background: #EF4444;
}

.amp-range-slider {
  width: 100%;
  height: 6px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 3px;
  -webkit-appearance: none;
  cursor: pointer;
  position: relative;
  z-index: 2;
}

.amp-range-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 8px;
  height: 22px;
  border-radius: 2px;
  background: #EF4444;
  box-shadow: 0 0 8px rgba(239, 68, 68, 0.8);
  cursor: pointer;
}

/* Audio Track Item */
.audio-track-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  background: #141720;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  margin-bottom: 10px;
}

.track-radio-ring {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 2px solid #EF4444;
  display: flex;
  align-items: center;
  justify-content: center;
}

.track-radio-inner {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #EF4444;
}

.track-details {
  display: flex;
  align-items: center;
  gap: 10px;
}

.track-lang {
  font-size: 14px;
  font-weight: 600;
  color: #FFFFFF;
}

.track-chips {
  display: flex;
  gap: 6px;
}

.chip-tech {
  font-family: var(--font-mono);
  font-size: 11px;
  background: #0B0E14;
  border: 1px solid #00F0FF;
  color: #00F0FF;
  padding: 2px 8px;
  border-radius: 6px;
}

/* A/V Sync Section */
.av-sync-box {
  background: var(--bg-surface);
  padding: 12px;
  border-radius: var(--radius-sm);
  margin-top: 10px;
}

.sync-header {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.sync-slider-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.btn-tiny {
  padding: 4px 8px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 4px;
  color: #CBD5E1;
  font-size: 11px;
}

.mini-slider {
  flex: 1;
}

/* Subtitle Options List */
.subtitle-options-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 16px;
}

.sub-option-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all 0.2s;
}

.sub-option-row:hover,
.sub-option-row.active {
  border-color: var(--primary-red);
  background: var(--bg-card-hover);
}

.sub-radio {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2px solid var(--text-muted);
  flex-shrink: 0;
  position: relative;
}

.sub-option-row.active .sub-radio {
  border-color: var(--primary-red);
}

.sub-option-row.active .sub-radio:after {
  content: "";
  position: absolute;
  top: 3px; left: 3px;
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--primary-red);
}

.sub-label-wrap {
  flex: 1;
  display: flex;
  flex-direction: column;
}

.sub-name {
  font-size: 14px;
  font-weight: 600;
  color: #FFFFFF;
}

.sub-desc {
  font-size: 11px;
  color: var(--text-muted);
}

.badge-thai {
  background: rgba(239, 68, 68, 0.2);
  color: #EF4444;
  font-size: 11px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 4px;
}

.sub-custom-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.sub-custom-card h4 {
  font-size: 13px;
  color: var(--text-secondary);
}

.sub-setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-size: 13px;
}

.sub-pill-group {
  display: flex;
  gap: 6px;
}

.pill-btn {
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  color: #CBD5E1;
  font-size: 12px;
}

.pill-btn.active {
  background: var(--primary-red);
  color: #FFFFFF;
  border-color: var(--primary-red);
}

.pill-color-btn {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 2px solid transparent;
  cursor: pointer;
}

.pill-color-btn.active {
  border-color: #FFFFFF;
  box-shadow: 0 0 6px rgba(255, 255, 255, 0.8);
}

/* Modals */
.modal-dialog {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 90%;
  max-width: 480px;
  background: #11141B;
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: var(--radius-lg);
  padding: 16px 20px;
  z-index: 10003;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.8);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 10px;
  margin-bottom: 14px;
}

.modal-header h3 {
  font-size: 16px;
  font-weight: 700;
  color: #FFFFFF;
}

/* Equalizer Sliders */
.eq-presets-row {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  margin-bottom: 20px;
  padding-bottom: 4px;
}

.eq-preset-chip {
  padding: 6px 12px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-full);
  color: #CBD5E1;
  font-size: 12px;
  white-space: nowrap;
}

.eq-preset-chip.active {
  background: var(--primary-red);
  color: #FFFFFF;
  border-color: var(--primary-red);
}

.eq-sliders-grid {
  display: flex;
  justify-content: space-around;
  height: 160px;
  padding: 10px 0;
}

.eq-col {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-muted);
}

.eq-v-slider {
  writing-mode: bt-lr; /* IE */
  -webkit-appearance: slider-vertical; /* WebKit */
  width: 8px;
  height: 120px;
  cursor: pointer;
}

/* Options Vertical List (for Sources, Quality, Speed) */
.options-vertical-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.opt-row, .speed-opt-row {
  padding: 12px 14px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  font-size: 13px;
  font-weight: 500;
  color: #CBD5E1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  transition: all 0.2s;
}

.opt-row:hover, .opt-row.active,
.speed-opt-row:hover, .speed-opt-row.active {
  background: var(--bg-card-hover);
  border-color: var(--primary-red);
  color: #FFFFFF;
}

/* Playlist / Episodes List */
.playlist-search-box {
  margin-bottom: 12px;
}

.playlist-search-box input {
  width: 100%;
  padding: 10px 14px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  color: #FFFFFF;
  font-size: 13px;
}

.playlist-items-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 50vh;
  overflow-y: auto;
}

.playlist-item-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 12px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  cursor: pointer;
}

.playlist-item-card.active {
  border-color: var(--primary-red);
  background: rgba(239, 68, 68, 0.15);
}

.playlist-item-thumb {
  width: 60px;
  height: 38px;
  border-radius: 4px;
  object-fit: cover;
  background: #0B0E14;
}

.playlist-item-title {
  font-size: 13px;
  font-weight: 500;
  color: #FFFFFF;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
}

/* VideoX Tools Grid */
.videox-tools-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 16px;
}

.videox-tool-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 14px 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  color: #CBD5E1;
  font-size: 11px;
  font-weight: 600;
  text-align: center;
  transition: all 0.2s;
}

.videox-tool-card:hover {
  border-color: var(--primary-red);
  color: #FFFFFF;
}

.videox-tool-card svg {
  width: 22px;
  height: 22px;
  color: var(--primary-red);
}

/* Toast */
.toast-container {
  position: fixed;
  bottom: calc(var(--nav-height) + var(--safe-bottom) + 20px);
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 20000;
  pointer-events: none;
}

.toast {
  background: rgba(15, 23, 42, 0.95);
  backdrop-filter: blur(8px);
  border: 1px solid var(--border-color);
  color: #FFFFFF;
  padding: 10px 18px;
  border-radius: var(--radius-full);
  font-size: 13px;
  font-weight: 500;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.5);
  animation: toastFade 2.5s forwards ease-in-out;
}

@keyframes toastFade {
  0% { opacity: 0; transform: translateY(10px); }
  10%, 80% { opacity: 1; transform: translateY(0); }
  100% { opacity: 0; transform: translateY(-10px); }
}
