/* ========================================
   Alp TV - تېلېۋىزور ئەپ دېتالى ئۇسلۇبى
   خەت شەكلى: AlpEkran
   ======================================== */

/* ====== خەت شەكلى ====== */
@font-face {
  font-family: 'AlpEkran';
  src: url('/assets/fonts/AlpEkran.ttf') format('truetype');
  font-weight: normal;
  font-style: normal;
  font-display: swap;
}

/* ====== ئاساسىي ئۇسلۇب ====== */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  /* كېچە ھالىتى (سۈكۈتتىكى) */
  --bg-primary: #0a0a14;
  --bg-secondary: #13131f;
  --bg-tertiary: #1c1c2e;
  --bg-card: #1a1a2e;
  --bg-hover: #252540;
  --text-primary: #f0f0f5;
  --text-secondary: #a0a0b8;
  --text-muted: #606078;
  --accent: #6c5ce7;
  --accent-light: #a29bfe;
  --accent-glow: rgba(108, 92, 231, 0.4);
  --danger: #e74c3c;
  --success: #2ecc71;
  --warning: #f39c12;
  --gold: #ffd700;
  --border: rgba(255, 255, 255, 0.08);
  --shadow: 0 8px 32px rgba(0, 0, 0, 0.6);
  --shadow-lg: 0 16px 48px rgba(0, 0, 0, 0.7);
  --radius: 12px;
  --radius-lg: 20px;
  --transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  --font-family: 'AlpEkran', 'Segoe UI', 'Arial', sans-serif;
}

body.theme-light {
  --bg-primary: #f5f5fa;
  --bg-secondary: #ffffff;
  --bg-tertiary: #eeeef5;
  --bg-card: #ffffff;
  --bg-hover: #e8e8f0;
  --text-primary: #1a1a2e;
  --text-secondary: #50506a;
  --text-muted: #9090a8;
  --accent: #6c5ce7;
  --accent-light: #a29bfe;
  --accent-glow: rgba(108, 92, 231, 0.25);
  --border: rgba(0, 0, 0, 0.08);
  --shadow: 0 8px 32px rgba(0, 0, 0, 0.12);
  --shadow-lg: 0 16px 48px rgba(0, 0, 0, 0.15);
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
}

body {
  font-family: var(--font-family);
  background: var(--bg-primary);
  color: var(--text-primary);
  transition: background var(--transition), color var(--transition);
  user-select: none;
  -webkit-user-select: none;
}

/* ====== يۈكلەش ئېكرانى ====== */
#loading-screen {
  position: fixed;
  inset: 0;
  background: var(--bg-primary);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  transition: opacity 0.6s;
}

.loading-logo {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}

.loading-icon {
  font-size: 80px;
  animation: pulse 1.5s ease-in-out infinite;
}

.loading-text {
  font-size: 36px;
  font-weight: bold;
  background: linear-gradient(135deg, var(--accent), var(--accent-light));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  letter-spacing: 2px;
}

.loading-bar {
  width: 240px;
  height: 4px;
  background: var(--bg-tertiary);
  border-radius: 2px;
  overflow: hidden;
  margin-top: 32px;
}

.loading-progress {
  width: 0%;
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--accent-light));
  border-radius: 2px;
  animation: loadProgress 1.5s ease-in-out forwards;
}

@keyframes loadProgress { to { width: 100%; } }
@keyframes pulse { 0%,100% { transform: scale(1); opacity: 1; } 50% { transform: scale(1.1); opacity: 0.8; } }

#loading-screen.hide {
  opacity: 0;
  pointer-events: none;
}

/* ====== ئۈستى قولتۇق ====== */
#top-bar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 70px;
  background: linear-gradient(180deg, var(--bg-primary) 0%, transparent 100%);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 32px;
  z-index: 100;
  transition: all var(--transition);
}

#top-bar.scrolled {
  background: var(--bg-secondary);
  box-shadow: 0 2px 20px rgba(0, 0, 0, 0.3);
}

.top-bar-left .logo {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
}

.logo-icon { font-size: 28px; }

.logo-text {
  font-size: 24px;
  font-weight: bold;
  background: linear-gradient(135deg, var(--accent), var(--accent-light));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

#main-nav {
  display: flex;
  gap: 8px;
}

.nav-btn {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-family: var(--font-family);
  font-size: 16px;
  padding: 10px 20px;
  border-radius: var(--radius);
  cursor: pointer;
  transition: all var(--transition);
  position: relative;
}

.nav-btn:hover, .nav-btn.active {
  color: var(--text-primary);
  background: var(--bg-hover);
}

.nav-btn.active::after {
  content: '';
  position: absolute;
  bottom: -2px;
  left: 50%;
  transform: translateX(-50%);
  width: 30px;
  height: 3px;
  background: var(--accent);
  border-radius: 2px;
}

.top-bar-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.clock {
  font-size: 16px;
  color: var(--text-secondary);
  font-variant-numeric: tabular-nums;
}

.icon-btn {
  background: var(--bg-tertiary);
  border: none;
  color: var(--text-primary);
  width: 40px;
  height: 40px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition);
}

.icon-btn:hover {
  background: var(--accent);
  transform: scale(1.1);
}

/* كۈن/كېچە سىنبەلگىسى */
.icon-sun { display: none; }
body.theme-light .icon-sun { display: inline; }
body.theme-light .icon-moon { display: none; }

/* ====== ئاساسىي مەزمۇن ====== */
#main-content {
  margin-top: 70px;
  height: calc(100vh - 70px);
  overflow-y: auto;
  overflow-x: hidden;
  scroll-behavior: smooth;
}

#main-content::-webkit-scrollbar { width: 6px; }
#main-content::-webkit-scrollbar-track { background: transparent; }
#main-content::-webkit-scrollbar-thumb { background: var(--bg-tertiary); border-radius: 3px; }

.page { display: none; padding: 0 32px 60px; }
.page.active { display: block; animation: fadeIn 0.4s ease; }

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

/* ====== Hero Banner ====== */
.hero-banner {
  position: relative;
  width: calc(100% + 64px);
  margin-left: -32px;
  height: 480px;
  border-radius: 0;
  overflow: hidden;
  margin-bottom: 32px;
}

.hero-slides {
  position: absolute;
  inset: 0;
}

.hero-slide {
  position: absolute;
  inset: 0;
  opacity: 0;
  transition: opacity 1s;
  background-size: cover;
  background-position: center;
}

.hero-slide.active { opacity: 1; }

.hero-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, var(--bg-primary) 0%, rgba(10,10,20,0.7) 50%, transparent 100%),
              linear-gradient(0deg, var(--bg-primary) 0%, transparent 50%);
}

body.theme-light .hero-overlay {
  background: linear-gradient(90deg, var(--bg-primary) 0%, rgba(245,245,250,0.7) 50%, transparent 100%),
              linear-gradient(0deg, var(--bg-primary) 0%, transparent 50%);
}

.hero-content {
  position: absolute;
  bottom: 60px;
  right: 32px;
  max-width: 600px;
  z-index: 2;
}

.hero-badge {
  display: inline-block;
  background: var(--accent);
  color: white;
  padding: 4px 14px;
  border-radius: 20px;
  font-size: 13px;
  margin-bottom: 12px;
}

.hero-title {
  font-size: 42px;
  font-weight: bold;
  line-height: 1.2;
  margin-bottom: 12px;
  text-shadow: 0 2px 20px rgba(0,0,0,0.5);
}

.hero-meta {
  display: flex;
  gap: 12px;
  margin-bottom: 12px;
  font-size: 15px;
  color: var(--text-secondary);
}

.hero-meta span { display: flex; align-items: center; gap: 4px; }
.hero-meta .star { color: var(--gold); }

.hero-description {
  font-size: 15px;
  color: var(--text-secondary);
  line-height: 1.6;
  margin-bottom: 20px;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.hero-actions { display: flex; gap: 12px; }

.btn-play, .btn-info, .btn-favorite {
  font-family: var(--font-family);
  font-size: 16px;
  padding: 12px 28px;
  border-radius: var(--radius);
  cursor: pointer;
  border: none;
  transition: all var(--transition);
  display: flex;
  align-items: center;
  gap: 8px;
}

.btn-play {
  background: var(--accent);
  color: white;
  font-weight: bold;
}

.btn-play:hover { background: var(--accent-light); transform: scale(1.05); }

.btn-info, .btn-favorite {
  background: rgba(255,255,255,0.15);
  color: var(--text-primary);
  backdrop-filter: blur(10px);
}

.btn-info:hover, .btn-favorite:hover { background: rgba(255,255,255,0.25); }

.btn-favorite.active { background: var(--danger); color: white; }
.btn-favorite.active::before { content: '♥ '; }

.hero-dots {
  position: absolute;
  bottom: 24px;
  right: 32px;
  display: flex;
  gap: 8px;
  z-index: 3;
}

.hero-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: rgba(255,255,255,0.3);
  cursor: pointer;
  transition: all var(--transition);
}

.hero-dot.active { background: var(--accent); width: 24px; border-radius: 4px; }

/* ====== كىنو بۆلىكى ====== */
.movie-section { margin-bottom: 40px; }

.section-title {
  font-size: 22px;
  font-weight: bold;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.section-title::before {
  content: '';
  width: 4px;
  height: 22px;
  background: var(--accent);
  border-radius: 2px;
}

/* ====== كىنو كاتەكچىسى ====== */
.movie-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 20px;
}

.movie-row {
  display: flex;
  gap: 16px;
  overflow-x: auto;
  overflow-y: hidden;
  padding-bottom: 12px;
  scroll-behavior: smooth;
}

.movie-row::-webkit-scrollbar { height: 4px; }
.movie-row::-webkit-scrollbar-thumb { background: var(--bg-tertiary); border-radius: 2px; }

.movie-row .movie-card { flex-shrink: 0; width: 220px; }

.movie-card {
  background: var(--bg-card);
  border-radius: var(--radius);
  overflow: hidden;
  cursor: pointer;
  transition: all var(--transition);
  border: 2px solid transparent;
  position: relative;
}

.movie-card:hover, .movie-card.focused {
  transform: translateY(-6px) scale(1.03);
  box-shadow: var(--shadow-lg);
  border-color: var(--accent);
}

.movie-card.focused {
  box-shadow: 0 0 0 4px var(--accent-glow), var(--shadow-lg);
}

.movie-card-poster {
  width: 100%;
  aspect-ratio: 2/3;
  object-fit: cover;
  background: var(--bg-tertiary);
}

.movie-card-poster-placeholder {
  width: 100%;
  aspect-ratio: 2/3;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--bg-tertiary), var(--bg-secondary));
  font-size: 48px;
  color: var(--text-muted);
}

.movie-card-badge {
  position: absolute;
  top: 8px;
  right: 8px;
  background: var(--accent);
  color: white;
  padding: 2px 8px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: bold;
}

.movie-card-rating {
  position: absolute;
  top: 8px;
  left: 8px;
  background: rgba(0,0,0,0.7);
  color: var(--gold);
  padding: 2px 8px;
  border-radius: 6px;
  font-size: 12px;
  display: flex;
  align-items: center;
  gap: 2px;
}

.movie-card-info {
  padding: 10px 12px;
}

.movie-card-title {
  font-size: 14px;
  font-weight: bold;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 4px;
}

.movie-card-meta {
  font-size: 12px;
  color: var(--text-muted);
  display: flex;
  gap: 8px;
}

/* ====== سەھىپە تابلىرى ====== */
.category-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 24px;
  overflow-x: auto;
  padding-bottom: 4px;
}

.category-tab {
  background: var(--bg-tertiary);
  border: none;
  color: var(--text-secondary);
  padding: 8px 20px;
  border-radius: 20px;
  cursor: pointer;
  font-family: var(--font-family);
  font-size: 14px;
  white-space: nowrap;
  transition: all var(--transition);
}

.category-tab:hover, .category-tab.active {
  background: var(--accent);
  color: white;
}

.category-tab.focused { box-shadow: 0 0 0 3px var(--accent-glow); }

/* ====== بەت بېشى ====== */
.page-header { margin: 20px 0; }

.page-title {
  font-size: 32px;
  font-weight: bold;
}

/* ====== ئىزدەش ====== */
.search-container {
  display: flex;
  gap: 12px;
  margin: 20px 0;
}

.search-input {
  flex: 1;
  background: var(--bg-tertiary);
  border: 2px solid transparent;
  color: var(--text-primary);
  padding: 14px 20px;
  border-radius: var(--radius);
  font-family: var(--font-family);
  font-size: 16px;
  outline: none;
  transition: all var(--transition);
}

.search-input:focus { border-color: var(--accent); }

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

.search-btn {
  background: var(--accent);
  border: none;
  color: white;
  padding: 14px 28px;
  border-radius: var(--radius);
  cursor: pointer;
  font-family: var(--font-family);
  font-size: 16px;
  transition: all var(--transition);
}

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

/* ====== بوش ھالەت ====== */
.empty-state {
  text-align: center;
  padding: 80px 20px;
  color: var(--text-muted);
}

.empty-icon { font-size: 64px; margin-bottom: 16px; opacity: 0.5; }
.empty-state p { font-size: 18px; }

/* ====== مودېل ====== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.85);
  backdrop-filter: blur(8px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: fadeIn 0.3s ease;
}

.modal-content {
  background: var(--bg-secondary);
  border-radius: var(--radius-lg);
  max-width: 900px;
  width: 90%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
}

.modal-content::-webkit-scrollbar { width: 6px; }
.modal-content::-webkit-scrollbar-thumb { background: var(--bg-tertiary); border-radius: 3px; }

.movie-detail-modal { max-width: 900px; }

.modal-backdrop {
  position: relative;
  height: 360px;
  overflow: hidden;
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}

.modal-backdrop img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.backdrop-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(0deg, var(--bg-secondary) 0%, transparent 60%);
}

.modal-close {
  position: absolute;
  top: 16px;
  left: 16px;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: rgba(0,0,0,0.6);
  color: white;
  border: none;
  font-size: 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition);
  z-index: 5;
}

.modal-close:hover { background: var(--danger); transform: rotate(90deg); }

.modal-body { padding: 24px 32px 32px; }

.detail-header { margin-bottom: 20px; }

.detail-header h2 { font-size: 28px; margin-bottom: 12px; }

.detail-meta { display: flex; gap: 8px; flex-wrap: wrap; }

.detail-badge {
  background: var(--bg-tertiary);
  padding: 4px 12px;
  border-radius: 8px;
  font-size: 13px;
}

.rating-badge { color: var(--gold); }
.quality-badge { background: var(--accent); color: white; }

.detail-info { display: flex; gap: 24px; }

.detail-poster { flex-shrink: 0; }

.detail-poster img {
  width: 180px;
  border-radius: var(--radius);
  object-fit: cover;
}

.detail-poster-placeholder {
  width: 180px;
  aspect-ratio: 2/3;
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-tertiary);
  font-size: 48px;
  color: var(--text-muted);
}

.detail-text { flex: 1; }

.detail-text p {
  color: var(--text-secondary);
  line-height: 1.7;
  margin-bottom: 16px;
  font-size: 15px;
}

.detail-rows { margin-bottom: 20px; }

.detail-row {
  font-size: 14px;
  margin-bottom: 8px;
  color: var(--text-secondary);
}

.detail-row .label {
  color: var(--text-muted);
  font-weight: bold;
  display: inline-block;
  min-width: 70px;
}

.detail-actions { display: flex; gap: 12px; }

/* ====== ۋىدېئو قويغۇچ ====== */
.player-overlay { background: #000; }

.player-container {
  width: 100%;
  height: 100vh;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}

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

.player-close {
  position: absolute;
  top: 20px;
  left: 20px;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: rgba(0,0,0,0.6);
  color: white;
  border: none;
  font-size: 20px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
  transition: all var(--transition);
}

.player-close:hover { background: var(--danger); }

.player-title {
  position: absolute;
  top: 28px;
  right: 80px;
  color: white;
  font-size: 18px;
  font-weight: bold;
  z-index: 10;
  text-shadow: 0 2px 8px rgba(0,0,0,0.8);
}

/* ====== تەڭشەكلەر ====== */
.settings-modal { max-width: 500px; }

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

.modal-header h2 { font-size: 22px; }

.settings-body { padding: 16px 0; }

.setting-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 32px;
  cursor: pointer;
  transition: background var(--transition);
}

.setting-item:hover { background: var(--bg-hover); }
.setting-item.focused { background: var(--bg-hover); box-shadow: inset 4px 0 0 var(--accent); }

.setting-label { font-size: 16px; }
.setting-value { font-size: 14px; color: var(--text-muted); }
.setting-arrow { font-size: 24px; color: var(--text-muted); }

.setting-toggle { display: flex; align-items: center; gap: 10px; }

.toggle-track {
  width: 48px;
  height: 26px;
  background: var(--bg-tertiary);
  border-radius: 13px;
  position: relative;
  transition: background var(--transition);
}

body.theme-light .toggle-track { background: var(--accent); }

.toggle-thumb {
  position: absolute;
  top: 3px;
  right: 3px;
  width: 20px;
  height: 20px;
  background: white;
  border-radius: 50%;
  transition: all var(--transition);
}

body.theme-light .toggle-thumb { right: 25px; }

.toggle-text { font-size: 14px; color: var(--text-secondary); }

/* ====== ئۇقتۇرۇش ====== */
.toast {
  position: fixed;
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: var(--bg-tertiary);
  color: var(--text-primary);
  padding: 14px 28px;
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  z-index: 2000;
  opacity: 0;
  transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  font-size: 15px;
  border: 1px solid var(--border);
}

.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.success { border-right: 4px solid var(--success); }
.toast.error { border-right: 4px solid var(--danger); }

/* ====== ياردەمچى قولتۇق ====== */
.help-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  display: flex;
  justify-content: center;
  gap: 24px;
  padding: 8px 0;
  background: linear-gradient(0deg, var(--bg-primary) 60%, transparent);
  z-index: 50;
  opacity: 0;
  transition: opacity 0.3s;
  pointer-events: none;
}

.help-bar.show { opacity: 0.6; }

.help-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-muted);
}

.key {
  background: var(--bg-tertiary);
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11px;
  border: 1px solid var(--border);
}

/* ====== فوكۇس ھالىتى (تىزگىنەك) ====== */
[data-focusable] { outline: none; }

[data-focusable].focused,
.movie-card.focused,
.nav-btn.focused,
.category-tab.focused,
.icon-btn.focused,
.setting-item.focused {
  outline: none;
  box-shadow: 0 0 0 3px var(--accent), 0 0 20px var(--accent-glow);
  transform: scale(1.05);
  z-index: 10;
}

.nav-btn.focused { border-radius: var(--radius); }
.icon-btn.focused { border-radius: 50%; }
.movie-card.focused { transform: translateY(-6px) scale(1.05); }

/* ====== ماسلاشقان ====== */
@media (max-width: 768px) {
  #top-bar { padding: 0 16px; height: 60px; }
  #main-nav { gap: 4px; }
  .nav-btn { padding: 8px 12px; font-size: 14px; }
  .clock { display: none; }
  .page { padding: 0 16px 60px; }
  .hero-banner { height: 320px; }
  .hero-title { font-size: 28px; }
  .hero-content { bottom: 30px; right: 16px; max-width: 90%; }
  .movie-grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 12px; }
  .detail-info { flex-direction: column; }
  .detail-poster img, .detail-poster-placeholder { width: 120px; }
  .modal-backdrop { height: 240px; }
  .modal-body { padding: 16px; }
  .help-bar { display: none; }
}
