/* ============================================================
   Pluto TV — بهینه‌سازی‌شده برای مرورگر تلویزیون سامسونگ (Tizen)
   نکته: از flex gap استفاده نشده (پشتیبانی قدیمی‌ترها)، فقط margin.
   ============================================================ */

@font-face {
  font-family: 'Vazirmatn';
  src: url('../assets/fonts/vazirmatn_regular.ttf') format('truetype');
  font-weight: 400;
  font-display: swap;
}
@font-face {
  font-family: 'Vazirmatn';
  src: url('../assets/fonts/vazirmatn_medium.ttf') format('truetype');
  font-weight: 500;
  font-display: swap;
}
@font-face {
  font-family: 'Vazirmatn';
  src: url('../assets/fonts/vazirmatn_bold.ttf') format('truetype');
  font-weight: 700;
  font-display: swap;
}
@font-face {
  font-family: 'Vazirmatn';
  src: url('../assets/fonts/vazirmatn_black.ttf') format('truetype');
  font-weight: 900;
  font-display: swap;
}

:root {
  --bg: #0b0b12;
  --bg2: #14141f;
  --bg3: #1e1e2e;
  --text: #f2f2f7;
  --muted: #9a9ab0;
  --accent: #a855f7;
  --accent2: #7c3aed;
  --focus: #ffffff;
  --focus-bg: #3b2a6d;
  --radius: 12px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html, body {
  width: 100%;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: 'Vazirmatn', Tahoma, sans-serif;
  overflow: hidden;
  -webkit-user-select: none;
  user-select: none;
}

.hidden { display: none !important; }

/* ---------- صفحه بارگذاری ---------- */
#splash {
  position: fixed; inset: 0;
  display: flex; align-items: center; justify-content: center;
  background: radial-gradient(ellipse at 50% 40%, #1a1033 0%, #0b0b12 70%);
  z-index: 1000;
}
.splash-logo { text-align: center; }
.splash-logo h1 {
  font-size: 52px; font-weight: 900; letter-spacing: 1px; margin-top: 12px;
  background: linear-gradient(90deg, #e879f9, #a855f7, #7c3aed);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  background-clip: text;
}
.splash-logo h1 span { display: inline-block; }
.splash-logo p { color: var(--muted); margin-top: 10px; font-size: 18px; }

/* ---------- چیدمان اصلی ---------- */
#app { display: flex; width: 100%; height: 100%; }

#sidebar {
  width: 230px; flex: 0 0 230px;
  background: var(--bg2);
  display: flex; flex-direction: column;
  padding: 28px 16px 20px;
  border-left: 1px solid rgba(255,255,255,0.06);
}
.brand { display: flex; align-items: center; padding: 0 8px 26px; }
.brand svg { flex: 0 0 auto; }
.brand-name {
  font-size: 24px; font-weight: 900; margin-right: 10px;
  background: linear-gradient(90deg, #e879f9, #a855f7);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  background-clip: text;
}

#nav-items { flex: 1; display: flex; flex-direction: column; }

.nav-item {
  display: flex; align-items: center;
  padding: 16px 18px; margin-bottom: 10px;
  border-radius: var(--radius);
  font-size: 20px; font-weight: 500;
  color: var(--muted);
  cursor: pointer;
  outline: none;
  background: transparent;
  border: 2px solid transparent;
}
.nav-item .nav-icon { margin-left: 14px; font-size: 24px; width: 30px; text-align: center; }
.nav-item.active {
  background: var(--focus-bg);
  color: var(--text);
  border-color: var(--accent);
}
.nav-item.focused {
  background: var(--bg3);
  color: var(--text);
  box-shadow: 0 0 0 3px var(--focus), 0 0 0 6px rgba(168,85,247,0.4);
  transform: scale(1.04);
}
.nav-item.focused.active {
  background: var(--accent2);
  border-color: #fff;
}

.sidebar-footer { padding: 14px 8px 0; border-top: 1px solid rgba(255,255,255,0.07); }
.hint { font-size: 13px; color: var(--muted); line-height: 1.9; opacity: 0.75; }

/* ---------- محتوا ---------- */
#main {
  flex: 1; overflow-y: auto; overflow-x: hidden;
  padding: 26px 34px 60px;
  background:
    radial-gradient(ellipse at 85% 0%, rgba(124,58,237,0.12) 0%, transparent 55%),
    var(--bg);
}

.screen-title {
  font-size: 32px; font-weight: 900;
  margin-bottom: 22px;
  display: flex; align-items: center;
}
.screen-title .sub { font-size: 18px; color: var(--muted); font-weight: 400; margin-right: 14px; }

/* ردیف ژانر / دسته */
.row { margin-bottom: 30px; }
.row-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 14px;
}
.row-title { font-size: 24px; font-weight: 700; }
.row-all { font-size: 16px; color: var(--accent); cursor: pointer; outline: none; padding: 6px 10px; border-radius: 8px; border: 2px solid transparent; }
.row-all.focused { border-color: var(--focus); background: var(--focus-bg); }

/* نوار کارت‌های افقی */
.hscroll {
  display: flex; flex-direction: row;
  overflow-x: auto; overflow-y: hidden;
  padding: 10px 4px 18px;
  scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch;
}
.hscroll::-webkit-scrollbar { height: 6px; }
.hscroll::-webkit-scrollbar-thumb { background: var(--accent); border-radius: 3px; }

/* کارت فیلم/سریال */
.card {
  flex: 0 0 auto;
  width: 185px;
  margin-left: 18px;
  cursor: pointer;
  outline: none;
  border-radius: 10px;
  border: 2px solid transparent;
  background: var(--bg2);
  overflow: hidden;
  position: relative;
}
.card .poster {
  width: 100%; height: 260px;
  background: var(--bg3);
  display: flex; align-items: center; justify-content: center;
  color: var(--muted); font-size: 40px;
  overflow: hidden;
}
.card .poster img { width: 100%; height: 100%; object-fit: cover; }
.card .card-title {
  padding: 10px 10px 6px;
  font-size: 15px; font-weight: 500;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.card .card-meta {
  padding: 0 10px 12px;
  font-size: 12.5px; color: var(--muted);
  display: flex; align-items: center;
}
.card .card-meta .imdb { color: #f5c518; font-weight: 700; margin-left: 8px; }
.card.focused {
  border-color: var(--focus);
  box-shadow: 0 0 0 3px var(--accent), 0 0 30px rgba(168,85,247,0.35);
  transform: scale(1.06);
  z-index: 5;
}
.card.focused .card-title { color: #fff; }

/* گرید (صفحات فهرست) */
.grid {
  display: flex; flex-direction: row; flex-wrap: wrap;
  margin-right: -18px;
}
.grid .card { margin-bottom: 26px; margin-right: 18px; margin-left: 0; }

/* چیپ‌های فیلتر */
.chips {
  display: flex; flex-direction: row; flex-wrap: wrap;
  margin-bottom: 24px;
}
.chip {
  padding: 12px 22px; margin-left: 12px; margin-bottom: 10px;
  border-radius: 999px;
  background: var(--bg2);
  color: var(--muted);
  font-size: 17px; font-weight: 500;
  cursor: pointer; outline: none;
  border: 2px solid rgba(255,255,255,0.1);
}
.chip.active { background: var(--accent2); color: #fff; border-color: var(--accent); }
.chip.focused { border-color: var(--focus); color: var(--text); box-shadow: 0 0 0 2px var(--accent); }

/* صفحه جزئیات */
.detail {
  display: flex; flex-direction: row;
  position: relative;
}
.detail-backdrop {
  position: absolute; inset: 0;
  background-size: cover; background-position: center 20%;
  opacity: 0.22;
  filter: blur(6px);
  border-radius: 18px;
  pointer-events: none;
}
.detail-cover {
  flex: 0 0 auto;
  width: 270px; height: 400px;
  border-radius: 14px; overflow: hidden;
  background: var(--bg3);
  border: 1px solid rgba(255,255,255,0.1);
  position: relative; z-index: 1;
  display: flex; align-items: center; justify-content: center;
  font-size: 60px; color: var(--muted);
}
.detail-cover img { width: 100%; height: 100%; object-fit: cover; }
.detail-info {
  flex: 1; position: relative; z-index: 1;
  padding-right: 30px;
}
.detail-info h2 { font-size: 40px; font-weight: 900; line-height: 1.4; }
.detail-meta {
  display: flex; align-items: center; flex-wrap: wrap;
  margin: 14px 0;
  font-size: 17px; color: var(--muted);
}
.detail-meta .imdb { color: #f5c518; font-weight: 900; font-size: 20px; margin-left: 14px; }
.detail-meta .badge {
  background: var(--bg3); padding: 5px 14px; border-radius: 999px;
  margin-left: 10px; margin-bottom: 6px;
}
.detail-desc {
  font-size: 17.5px; line-height: 2;
  color: #c9c9dd;
  max-height: 190px; overflow: hidden;
  margin-bottom: 22px;
}
.detail-genres { display: flex; flex-wrap: wrap; margin-bottom: 24px; }
.detail-genres .badge { background: rgba(168,85,247,0.18); color: #d8b4fe; }

.actions { display: flex; flex-direction: row; flex-wrap: wrap; }
.btn {
  padding: 16px 34px;
  margin-left: 16px; margin-bottom: 12px;
  border-radius: 12px;
  border: 2px solid transparent;
  font-family: inherit;
  font-size: 19px; font-weight: 700;
  cursor: pointer; outline: none;
  background: var(--accent2); color: #fff;
}
.btn.secondary { background: var(--bg3); color: var(--text); }
.btn.focused { border-color: var(--focus); box-shadow: 0 0 0 2px var(--accent); transform: scale(1.05); }

/* فصل‌ها و قسمت‌ها */
.section-title { font-size: 26px; font-weight: 800; margin: 30px 0 16px; }
.seasons { display: flex; flex-direction: row; flex-wrap: wrap; margin-bottom: 10px; }
.episode-list { display: flex; flex-direction: column; }
.episode {
  display: flex; flex-direction: row; align-items: center;
  padding: 16px 20px; margin-bottom: 10px;
  background: var(--bg2);
  border-radius: 12px;
  border: 2px solid transparent;
  cursor: pointer; outline: none;
}
.episode .ep-num {
  flex: 0 0 auto;
  width: 46px; height: 46px;
  border-radius: 50%;
  background: var(--bg3);
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 18px;
  margin-left: 16px;
}
.episode .ep-title { font-size: 18px; font-weight: 600; flex: 1; }
.episode .ep-dur { color: var(--muted); font-size: 15px; }
.episode.focused { border-color: var(--focus); background: var(--focus-bg); }
.episode.focused .ep-num { background: var(--accent); color: #fff; }

/* جستجو */
.search-box {
  background: var(--bg2);
  border-radius: 14px;
  border: 2px solid var(--accent);
  padding: 20px 26px;
  font-size: 30px;
  font-weight: 700;
  margin-bottom: 26px;
  min-height: 80px;
  display: flex; align-items: center;
  color: var(--text);
}
.search-box .caret { display: inline-block; width: 3px; height: 36px; background: var(--accent); margin-right: 8px; animation: blink 1s steps(1) infinite; }
@keyframes blink { 50% { opacity: 0; } }

.kbd {
  display: flex; flex-direction: row; flex-wrap: wrap;
  max-width: 1050px;
}
.kbd-key {
  width: 74px; height: 74px;
  margin-left: 10px; margin-bottom: 10px;
  border-radius: 12px;
  background: var(--bg2);
  border: 2px solid rgba(255,255,255,0.1);
  color: var(--text);
  font-size: 24px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; outline: none;
  font-family: inherit;
}
.kbd-key.wide { width: 150px; font-size: 18px; }
.kbd-key.focused { border-color: var(--focus); background: var(--focus-bg); box-shadow: 0 0 0 2px var(--accent); transform: scale(1.1); }

/* علاقه‌مندی‌ها / پیام خالی */
.empty {
  text-align: center; padding: 90px 30px;
  color: var(--muted); font-size: 22px;
}

/* تنظیمات */
.settings-card {
  background: var(--bg2);
  border-radius: 14px;
  padding: 24px 28px;
  margin-bottom: 18px;
  border: 2px solid transparent;
  outline: none;
  max-width: 900px;
}
.settings-card.focused { border-color: var(--focus); background: var(--bg3); }
.settings-card h3 { font-size: 22px; font-weight: 800; margin-bottom: 14px; }
.settings-row {
  display: flex; align-items: center;
  margin-bottom: 12px; font-size: 18px;
  cursor: pointer; outline: none;
  padding: 10px 14px; border-radius: 10px;
  border: 2px solid transparent;
}
.settings-row .lbl { flex: 1; }
.settings-row .val { color: var(--accent); font-weight: 700; }
.settings-row.focused { border-color: var(--accent); background: var(--bg3); }

/* ---------- پخش‌کننده ---------- */
#player-overlay {
  position: fixed; inset: 0; z-index: 500;
  background: #000;
}
#video { width: 100%; height: 100%; object-fit: contain; }
#player-ui {
  position: fixed; inset: 0;
  display: flex; flex-direction: column; justify-content: space-between;
  background: linear-gradient(180deg, rgba(0,0,0,0.7) 0%, transparent 30%, transparent 65%, rgba(0,0,0,0.85) 100%);
  pointer-events: none;
  opacity: 1;
  transition: opacity 0.4s;
}
#player-ui.faded { opacity: 0; }
#player-top {
  display: flex; align-items: center; justify-content: space-between;
  padding: 26px 30px 0;
}
#player-title { font-size: 24px; font-weight: 800; max-width: 70%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#player-center { display: flex; flex-direction: column; align-items: center; }
#player-msg { color: #fff; background: rgba(0,0,0,0.7); padding: 12px 24px; border-radius: 10px; margin-top: 18px; font-size: 18px; }
#player-bottom { padding: 0 34px 28px; }
#player-timebar {
  position: relative; height: 10px;
  background: rgba(255,255,255,0.2);
  border-radius: 5px;
  cursor: pointer; outline: none;
  margin-bottom: 10px;
  border: 2px solid transparent;
}
#player-timebar.focused { border-color: var(--focus); box-shadow: 0 0 0 2px var(--accent); }
#player-buffer { position: absolute; top: 0; right: 0; height: 100%; background: rgba(255,255,255,0.35); border-radius: 5px; }
#player-progress { position: absolute; top: 0; right: 0; height: 100%; background: var(--accent); border-radius: 5px; }
#player-handle { position: absolute; top: -7px; width: 24px; height: 24px; border-radius: 50%; background: #fff; box-shadow: 0 0 10px rgba(0,0,0,0.6); }
#player-time { text-align: center; font-size: 16px; color: #ddd; margin-bottom: 12px; direction: ltr; }
#player-controls { display: flex; flex-direction: row; justify-content: center; flex-wrap: wrap; }

.player-btn {
  padding: 14px 24px;
  margin: 0 8px 8px;
  border-radius: 12px;
  border: 2px solid rgba(255,255,255,0.25);
  background: rgba(0,0,0,0.55);
  color: #fff;
  font-family: inherit;
  font-size: 17px; font-weight: 700;
  cursor: pointer; outline: none;
  pointer-events: auto;
  min-width: 90px;
}
.player-btn.big { padding: 22px 40px; font-size: 30px; border-radius: 999px; }
.player-btn.sm { font-size: 15px; padding: 12px 18px; }
.player-btn.focused { border-color: var(--focus); background: var(--accent2); box-shadow: 0 0 0 2px var(--accent); transform: scale(1.08); }

#quality-menu {
  position: fixed; bottom: 130px; left: 50%;
  transform: translateX(-50%);
  background: rgba(10,10,18,0.95);
  border-radius: 14px;
  border: 1px solid var(--accent);
  padding: 14px;
  z-index: 600;
  display: flex; flex-direction: column;
  min-width: 340px;
}
.q-item {
  padding: 14px 24px; margin-bottom: 6px;
  border-radius: 10px;
  font-size: 18px; font-weight: 600;
  color: var(--text);
  cursor: pointer; outline: none;
  border: 2px solid transparent;
  text-align: right;
}
.q-item.active { background: var(--accent2); }
.q-item.focused { border-color: var(--focus); }
.q-item:last-child { margin-bottom: 0; }

/* توست */
#toast {
  position: fixed; bottom: 60px; left: 50%; transform: translateX(-50%);
  background: rgba(0,0,0,0.88);
  color: #fff;
  padding: 14px 30px;
  border-radius: 12px;
  font-size: 18px;
  z-index: 900;
  border: 1px solid var(--accent);
  max-width: 80%;
  text-align: center;
}

/* اسکرول‌بار */
#main::-webkit-scrollbar { width: 8px; }
#main::-webkit-scrollbar-thumb { background: var(--accent); border-radius: 4px; }

/* حالت فوکوس پیش‌فرض برای همه عناصر قابل فوکوس */
.focusable:focus { outline: none; }

@media (max-width: 1200px) {
  .card { width: 160px; }
  .card .poster { height: 225px; }
}
