/* ═══════════════════════════════════════════════════════════════
   RayTV — Component Styles
   Cards, modals, channel rows, poster tiles, list items
═══════════════════════════════════════════════════════════════ */

/* ── Modal overlay ──────────────────────────────────────────── */
#modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 7777;
  animation: fade-in var(--t-base);
}

#modal-overlay[hidden] { display: none; }

@keyframes fade-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}

#modal-box {
  background: var(--bg-2);
  border: 1px solid var(--border-hi);
  border-radius: var(--r-xl);
  padding: var(--sp-6);
  width: 480px;
  max-height: 520px;
  overflow-y: auto;
  animation: modal-in var(--t-base) ease-out;
}

@keyframes modal-in {
  from { opacity: 0; transform: scale(0.95) translateY(8px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}

.modal-title {
  font-size: var(--text-xl);
  font-weight: var(--weight-bold);
  margin-bottom: var(--sp-5);
  color: var(--text);
}

.modal-actions {
  display: flex;
  gap: var(--sp-3);
  justify-content: flex-end;
  margin-top: var(--sp-6);
  padding-top: var(--sp-4);
  border-top: 1px solid var(--border);
}

/* ── Channel list row ───────────────────────────────────────── */
.channel-row {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-2) var(--sp-3);
  min-height: 56px;
  border-radius: var(--r-md);
  cursor: pointer;
  transition: background var(--t-fast);
  position: relative;
}

.channel-row:hover,
.channel-row.rt-focused {
  background: var(--bg-3);
}

.channel-row.rt-focused {
  outline: var(--focus-ring);
  outline-offset: -2px;
  box-shadow: var(--focus-shadow);
}

.channel-row.playing {
  background: rgba(229, 0, 0, 0.08);
}

.channel-row.playing::before {
  content: '';
  position: absolute;
  left: 0;
  top: 10%;
  bottom: 10%;
  width: 3px;
  background: var(--accent);
  border-radius: 0 var(--r-sm) var(--r-sm) 0;
}

.channel-logo {
  width: 40px;
  height: 40px;
  flex: 0 0 40px;
  object-fit: contain;
  border-radius: var(--r-sm);
  background: var(--bg-3);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.channel-logo img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.channel-logo-text {
  font-size: var(--text-xs);
  font-weight: var(--weight-bold);
  color: var(--text-2);
  text-align: center;
  padding: 2px;
  line-height: 1.1;
}

.channel-info {
  flex: 1;
  overflow: hidden;
}

.channel-name {
  font-size: var(--text-sm);
  font-weight: var(--weight-med);
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.channel-epg {
  font-size: var(--text-xs);
  color: var(--text-3);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  margin-top: 2px;
}

.channel-num {
  font-size: var(--text-xs);
  color: var(--text-dim);
  flex: 0 0 28px;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

/* ── Category tab strip ─────────────────────────────────────── */
.cat-tabs {
  display: flex;
  gap: var(--sp-1);
  overflow-x: auto;
  scrollbar-width: none;
  padding: var(--sp-2) var(--sp-4);
  border-bottom: 1px solid var(--border);
  flex: 0 0 auto;
}

.cat-tabs::-webkit-scrollbar { display: none; }

.cat-tab {
  flex: 0 0 auto;
  padding: var(--sp-1) var(--sp-3);
  min-height: 32px;
  border-radius: var(--r-pill);
  border: 1px solid var(--border);
  background: none;
  color: var(--text-2);
  font-size: var(--text-sm);
  font-family: var(--font);
  cursor: pointer;
  white-space: nowrap;
  transition: background var(--t-fast), color var(--t-fast), border-color var(--t-fast);
}

.cat-tab:hover,
.cat-tab.rt-focused {
  background: var(--bg-3);
  color: var(--text);
  border-color: var(--border-hi);
}

.cat-tab.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.cat-tab.rt-focused {
  outline: var(--focus-ring);
  outline-offset: 2px;
  box-shadow: var(--focus-shadow);
}

/* ── Poster card (VOD / Series) ─────────────────────────────── */
.poster-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--sp-3);
}

.poster-card {
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
  cursor: pointer;
  border-radius: var(--r-md);
  overflow: hidden;
  background: var(--bg-2);
  transition: transform var(--t-fast);
  position: relative;
}

.poster-card:hover,
.poster-card.rt-focused {
  transform: scale(1.03);
  z-index: 2;
}

.poster-card.rt-focused {
  outline: var(--focus-ring);
  outline-offset: 2px;
  box-shadow: var(--focus-shadow);
}

.poster-img-wrap {
  width: 100%;
  aspect-ratio: 2/3;
  background: var(--bg-3);
  overflow: hidden;
  position: relative;
}

.poster-img-wrap img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.poster-img-placeholder {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 32px;
  color: var(--text-dim);
}

.poster-progress {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--bg-4);
}

.poster-progress-fill {
  height: 100%;
  background: var(--accent);
}

.poster-info {
  padding: var(--sp-2);
}

.poster-title {
  font-size: var(--text-xs);
  font-weight: var(--weight-med);
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  line-height: 1.3;
}

.poster-meta {
  font-size: var(--text-xs);
  color: var(--text-3);
  margin-top: 2px;
}

/* ── Info panel (VOD detail / series detail) ────────────────── */
.detail-hero {
  display: flex;
  gap: var(--sp-4);
  padding: var(--sp-4);
  border-bottom: 1px solid var(--border);
  flex: 0 0 auto;
}

.detail-poster {
  width: 90px;
  flex: 0 0 90px;
  aspect-ratio: 2/3;
  background: var(--bg-3);
  border-radius: var(--r-md);
  overflow: hidden;
}

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

.detail-meta {
  flex: 1;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
}

.detail-title {
  font-size: var(--text-lg);
  font-weight: var(--weight-bold);
  color: var(--text);
  line-height: 1.2;
}

.detail-sub {
  font-size: var(--text-sm);
  color: var(--text-3);
}

.detail-desc {
  font-size: var(--text-sm);
  color: var(--text-2);
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.detail-actions {
  display: flex;
  gap: var(--sp-2);
  flex-wrap: wrap;
  margin-top: var(--sp-2);
}

/* ── Episode row ────────────────────────────────────────────── */
.episode-row {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-3);
  min-height: 60px;
  border-radius: var(--r-md);
  cursor: pointer;
  transition: background var(--t-fast);
}

.episode-row:hover,
.episode-row.rt-focused {
  background: var(--bg-3);
}

.episode-row.rt-focused {
  outline: var(--focus-ring);
  outline-offset: -2px;
  box-shadow: var(--focus-shadow);
}

.episode-row.watched .episode-title {
  color: var(--text-3);
}

.episode-thumb {
  width: 80px;
  height: 45px;
  flex: 0 0 80px;
  background: var(--bg-3);
  border-radius: var(--r-sm);
  overflow: hidden;
  position: relative;
}

.episode-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.episode-num-badge {
  position: absolute;
  bottom: 2px;
  right: 2px;
  background: rgba(0,0,0,0.75);
  color: var(--text-2);
  font-size: 10px;
  padding: 1px 4px;
  border-radius: var(--r-sm);
}

.episode-info { flex: 1; overflow: hidden; }

.episode-title {
  font-size: var(--text-sm);
  font-weight: var(--weight-med);
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.episode-sub {
  font-size: var(--text-xs);
  color: var(--text-3);
  margin-top: 2px;
}

/* ── Account card ───────────────────────────────────────────── */
.account-card {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-4);
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  margin-bottom: var(--sp-3);
  cursor: pointer;
  transition: border-color var(--t-fast), background var(--t-fast);
}

.account-card:hover,
.account-card.rt-focused {
  background: var(--bg-3);
  border-color: var(--border-hi);
}

.account-card.rt-focused {
  outline: var(--focus-ring);
  outline-offset: 2px;
  box-shadow: var(--focus-shadow);
}

.account-card.active {
  border-color: var(--accent);
}

.account-avatar {
  width: 40px;
  height: 40px;
  flex: 0 0 40px;
  background: var(--accent-dim);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  color: var(--accent-2);
  font-weight: var(--weight-bold);
}

.account-info { flex: 1; overflow: hidden; }

.account-name {
  font-size: var(--text-base);
  font-weight: var(--weight-med);
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.account-url {
  font-size: var(--text-xs);
  color: var(--text-3);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.account-status {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 2px;
  flex: 0 0 auto;
}

.account-badge-active {
  font-size: var(--text-xs);
  color: var(--live);
  font-weight: var(--weight-bold);
}

.account-badge-expired {
  font-size: var(--text-xs);
  color: var(--error);
  font-weight: var(--weight-bold);
}

/* ── Favorite group card ────────────────────────────────────── */
.fav-group {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  margin-bottom: var(--sp-3);
  overflow: hidden;
}

.fav-group-header {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-4);
  min-height: 48px;
  cursor: pointer;
  transition: background var(--t-fast);
}

.fav-group-header:hover,
.fav-group-header.rt-focused {
  background: var(--bg-3);
}

.fav-group-header.rt-focused {
  outline: var(--focus-ring);
  outline-offset: -2px;
  box-shadow: var(--focus-shadow);
}

.fav-group-name {
  font-size: var(--text-base);
  font-weight: var(--weight-med);
  color: var(--text);
  flex: 1;
}

.fav-group-count {
  font-size: var(--text-sm);
  color: var(--text-3);
}

/* ── Search input row ───────────────────────────────────────── */
.search-bar {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-4);
  border-bottom: 1px solid var(--border);
  flex: 0 0 auto;
}

.search-input {
  flex: 1;
  min-height: var(--min-touch);
  padding: 0 var(--sp-3);
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  color: var(--text);
  font-size: var(--text-base);
  font-family: var(--font);
  outline: none;
}

.search-input:focus,
.search-input.rt-focused {
  border-color: var(--focus);
  box-shadow: var(--focus-shadow);
}

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

.search-icon {
  font-size: 20px;
  color: var(--text-3);
  flex: 0 0 auto;
}

/* ── Settings row ───────────────────────────────────────────── */
.setting-row {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-3) 0;
  border-bottom: 1px solid var(--border);
  min-height: var(--min-touch);
}

.setting-row:last-child { border-bottom: none; }

.setting-label {
  flex: 1;
  font-size: var(--text-base);
  color: var(--text);
}

.setting-sub {
  font-size: var(--text-xs);
  color: var(--text-3);
  margin-top: 2px;
}

.setting-value {
  font-size: var(--text-sm);
  color: var(--text-2);
  flex: 0 0 auto;
}

/* ── Toggle switch ──────────────────────────────────────────── */
.toggle {
  position: relative;
  width: 44px;
  height: 26px;
  flex: 0 0 44px;
}

.toggle input {
  opacity: 0;
  width: 0;
  height: 0;
  position: absolute;
}

.toggle-track {
  position: absolute;
  inset: 0;
  background: var(--bg-4);
  border-radius: var(--r-pill);
  transition: background var(--t-base);
  cursor: pointer;
}

.toggle-track::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 20px;
  height: 20px;
  background: var(--text-3);
  border-radius: 50%;
  transition: transform var(--t-base), background var(--t-base);
}

.toggle input:checked + .toggle-track {
  background: var(--accent);
}

.toggle input:checked + .toggle-track::after {
  transform: translateX(18px);
  background: #fff;
}

.toggle input:focus + .toggle-track,
.toggle.rt-focused .toggle-track {
  outline: var(--focus-ring);
  outline-offset: 2px;
  box-shadow: var(--focus-shadow);
}

/* ── Spinner (inline) ───────────────────────────────────────── */
.spinner {
  width: 24px;
  height: 24px;
  border: 2px solid var(--bg-4);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  display: inline-block;
  flex: 0 0 24px;
}

/* ── Home screen sections ───────────────────────────────────── */
.home-section {
  margin-bottom: var(--sp-6);
}

.home-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--sp-3);
}

.home-section-title {
  font-size: var(--text-base);
  font-weight: var(--weight-bold);
  color: var(--text);
}

.home-section-link {
  font-size: var(--text-sm);
  color: var(--accent);
  background: none;
  border: none;
  cursor: pointer;
  font-family: var(--font);
  padding: 0;
}

.home-section-link:hover,
.home-section-link.rt-focused {
  text-decoration: underline;
  outline: none;
}

/* ── Continue watching progress card ────────────────────────── */
.continue-card {
  flex: 0 0 130px;
  border-radius: var(--r-md);
  overflow: hidden;
  background: var(--bg-2);
  cursor: pointer;
  position: relative;
}

.continue-card.rt-focused {
  outline: var(--focus-ring);
  outline-offset: 2px;
  box-shadow: var(--focus-shadow);
}

.continue-thumb {
  width: 130px;
  height: 73px;
  background: var(--bg-3);
  overflow: hidden;
}

.continue-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.continue-info {
  padding: var(--sp-2);
}

.continue-title {
  font-size: var(--text-xs);
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: var(--weight-med);
}

.continue-sub {
  font-size: 10px;
  color: var(--text-3);
  margin-top: 2px;
}

/* ═══════════════════════════════════════════════════════════════
   Virtual Keyboard
═══════════════════════════════════════════════════════════════ */

#rt-keyboard {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 9000;
  background: var(--bg-2);
  border-top: 1px solid var(--border);
  padding: 8px 4px 10px;
  transform: translateY(105%);
  transition: transform 0.18s ease;
  /* display toggled via JS inline style — no display:none here */
}

#rt-keyboard.kb-visible {
  transform: translateY(0);
}

.kb-preview {
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 6px 10px;
  margin-bottom: 8px;
  min-height: 32px;
  display: flex;
  align-items: center;
  gap: 2px;
  overflow: hidden;
}

.kb-preview-text {
  font-size: 14px;
  color: var(--text);
  font-family: monospace;
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.kb-cursor {
  font-size: 14px;
  color: var(--accent);
  animation: kb-blink 1s step-end infinite;
  flex: 0 0 auto;
}

@keyframes kb-blink {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0; }
}

.kb-grid {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.kb-row {
  display: flex;
  gap: 3px;
  justify-content: center;
}

.kb-key {
  flex: 1 1 0;
  min-width: 0;
  height: 38px;
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-size: 15px;
  font-family: var(--font);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 2px;
  transition: background 0.08s, border-color 0.08s;
  white-space: nowrap;
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
}

.kb-key.kb-wide {
  flex: 1.6 1 0;
  font-size: 12px;
}

.kb-key.kb-focused,
.kb-key:focus {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  outline: none;
  box-shadow: 0 0 0 2px rgba(229,0,0,0.4);
}

.kb-key:active {
  transform: scale(0.93);
}

/* Dwell progress bar — fills across the bottom of the key */
.kb-key {
  position: relative;
  overflow: hidden;
}

.kb-key.kb-dwelling::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  height: 3px;
  width: 100%;
  background: #fff;
  transform: scaleX(0);
  transform-origin: left center;
  animation: kb-dwell-fill 1.5s linear forwards;
}

@keyframes kb-dwell-fill {
  from { transform: scaleX(0); }
  to   { transform: scaleX(1); }
}

/* ═══════════════════════════════════════════════════════════════
   Voice Input Overlay
═══════════════════════════════════════════════════════════════ */

#rt-voice {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 9000;
  background: var(--bg-2);
  border-top: 2px solid var(--accent);
  padding: 16px 12px 20px;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  transform: translateY(100%);
  transition: transform 0.2s ease;
}

#rt-voice.voice-visible {
  transform: translateY(0);
}

.voice-icon {
  font-size: 36px;
  animation: voice-pulse 1.2s ease-in-out infinite;
}

@keyframes voice-pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%       { opacity: 0.6; transform: scale(1.15); }
}

.voice-label {
  font-size: 13px;
  color: var(--accent);
  font-weight: var(--weight-med);
  text-align: center;
}

.voice-interim {
  font-size: 15px;
  color: var(--text-3);
  font-style: italic;
  min-height: 20px;
  text-align: center;
}

.voice-value {
  font-size: 15px;
  color: var(--text);
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 6px 10px;
  width: 100%;
  min-height: 32px;
  word-break: break-all;
  font-family: monospace;
}

.voice-hint {
  font-size: 11px;
  color: var(--text-dim);
  text-align: center;
}
