/* =============================================================================
   Church Streaming Player - Koinia theming via CSS custom properties
   :root { --brand-primary, --brand-accent, --brand-bg, --brand-text, --brand-font }
   ============================================================================= */
:root {
  --brand-primary: #1E3A8A;
  --brand-accent: #F59E0B;
  --brand-bg: #0F172A;
  --brand-text: #F8FAFC;
  --brand-font: Inter, system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--brand-bg);
  color: var(--brand-text);
  font-family: var(--brand-font);
  height: 100%;
}

a { color: var(--brand-accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.player-wrapper {
  max-width: 1100px;
  margin: 0 auto;
  padding: 16px;
}

.header {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 12px 0 16px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  margin-bottom: 16px;
}

.header img.logo {
  width: 56px;
  height: 56px;
  object-fit: contain;
  border-radius: 8px;
  background: rgba(255,255,255,0.06);
}

.header h1 {
  margin: 0;
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--brand-text);
}

.header p.sub {
  margin: 2px 0 0;
  opacity: 0.7;
  font-size: 0.9rem;
}

.live-badge {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  border-radius: 999px;
  font-weight: 700;
  font-size: 0.8rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  background: rgba(239,68,68,0.15);
  color: #FCA5A5;
  border: 1px solid rgba(239,68,68,0.3);
}
.live-badge.on {
  background: #DC2626;
  color: white;
  border-color: #B91C1C;
  animation: pulse 2s infinite;
}
.live-badge .dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: currentColor;
}
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(220,38,38,0.4); }
  70% { box-shadow: 0 0 0 10px rgba(220,38,38,0); }
  100% { box-shadow: 0 0 0 0 rgba(220,38,38,0); }
}

/* Video container */
.video-shell {
  position: relative;
  background: #000;
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 20px 60px rgba(0,0,0,0.5), 0 0 0 1px rgba(255,255,255,0.06);
  aspect-ratio: 16 / 9;
}

.video-shell video {
  width: 100%;
  height: 100%;
  display: block;
  background: #000;
}

/* Off-air slate */
.offair-slate {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 24px;
  background: radial-gradient(1200px 600px at 50% -10%, var(--brand-primary) 0%, transparent 60%),
              linear-gradient(180deg, rgba(0,0,0,0.2), rgba(0,0,0,0.7)),
              var(--brand-bg);
  color: var(--brand-text);
  z-index: 2;
}

.offair-slate.hidden { display: none; }

.offair-slate .icon {
  font-size: 48px;
  margin-bottom: 12px;
  opacity: 0.9;
}

.offair-slate h2 {
  margin: 0 0 8px;
  font-size: 1.6rem;
  font-weight: 800;
}

.offair-slate p {
  margin: 0;
  opacity: 0.8;
  max-width: 520px;
  line-height: 1.5;
}

.countdown {
  margin-top: 16px;
  display: inline-flex;
  gap: 12px;
  font-variant-numeric: tabular-nums;
}

.countdown span {
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.12);
  padding: 10px 14px;
  border-radius: 10px;
  min-width: 72px;
}
.countdown span b {
  display: block;
  font-size: 1.4rem;
  color: var(--brand-accent);
}
.countdown span i {
  font-style: normal;
  font-size: 0.7rem;
  opacity: 0.7;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.retry-note {
  margin-top: 14px;
  font-size: 0.8rem;
  opacity: 0.6;
}

/* Controls bar */
.meta-bar {
  margin-top: 14px;
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  align-items: center;
  font-size: 0.9rem;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  border-radius: 10px;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all .15s;
}
.btn-primary {
  background: var(--brand-primary);
  color: white;
  border-color: var(--brand-primary);
}
.btn-primary:hover { filter: brightness(1.15); }
.btn-ghost {
  background: rgba(255,255,255,0.06);
  color: var(--brand-text);
  border-color: rgba(255,255,255,0.12);
}
.btn-ghost:hover { background: rgba(255,255,255,0.10); }

.status {
  margin-left: auto;
  opacity: 0.6;
  font-size: 0.8rem;
}

/* P2P stats */
.p2p-stats {
  margin-top: 10px;
  font-size: 0.75rem;
  opacity: 0.5;
}

/* VOD list */
.vod-section {
  margin-top: 24px;
}
.vod-section h3 {
  margin: 0 0 12px;
  font-size: 1.1rem;
}
.vod-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 12px;
}
.vod-card {
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.06);
  border-radius: 12px;
  padding: 14px;
  transition: background .15s;
}
.vod-card:hover { background: rgba(255,255,255,0.07); }
.vod-card h4 { margin: 0 0 6px; font-size: 0.95rem; }
.vod-card p { margin: 0; opacity: 0.7; font-size: 0.85rem; line-height: 1.4; }

.footer {
  margin-top: 32px;
  padding-top: 16px;
  border-top: 1px solid rgba(255,255,255,0.06);
  font-size: 0.8rem;
  opacity: 0.5;
  text-align: center;
}

/* Video.js theming overrides */
.video-js .vjs-big-play-button {
  background: var(--brand-primary) !important;
  border-color: var(--brand-primary) !important;
}
.video-js .vjs-control-bar { background: rgba(0,0,0,0.7) !important; }
.video-js .vjs-play-progress { background: var(--brand-accent) !important; }

/* =============================================================================
   Toast notifications
   ============================================================================= */
#toast-root {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
  max-width: 380px;
}
@media (max-width: 480px) {
  #toast-root { top: auto; bottom: 16px; left: 16px; right: 16px; max-width: none; }
}
.toast {
  pointer-events: auto;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 14px;
  border-radius: 12px;
  background: rgba(15, 23, 42, 0.96);
  border: 1px solid rgba(255,255,255,0.1);
  box-shadow: 0 10px 40px rgba(0,0,0,0.5), 0 0 0 1px rgba(255,255,255,0.05);
  transform: translateX(110%);
  opacity: 0;
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.2s;
  backdrop-filter: blur(8px);
}
@media (max-width: 480px) {
  .toast { transform: translateY(110%); }
}
.toast.show { transform: translateX(0); opacity: 1; }
@media (max-width: 480px) {
  .toast.show { transform: translateY(0); }
}
.toast-icon { flex-shrink: 0; width: 20px; height: 20px; margin-top: 2px; }
.toast-success .toast-icon { color: #22C55E; }
.toast-error .toast-icon { color: #EF4444; }
.toast-info .toast-icon { color: var(--brand-accent); }
.toast-warning .toast-icon { color: #F59E0B; }
.toast-message { flex: 1; font-size: 0.9rem; line-height: 1.4; color: var(--brand-text); }
.toast-action {
  flex-shrink: 0;
  padding: 4px 10px;
  font-size: 0.75rem;
  font-weight: 700;
  border-radius: 6px;
  background: var(--brand-primary);
  color: white;
  border: none;
  cursor: pointer;
  transition: filter 0.15s;
}
.toast-action:hover { filter: brightness(1.2); }
.toast-close {
  flex-shrink: 0;
  width: 24px; height: 24px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.2rem; line-height: 1;
  color: rgba(248,250,252,0.5);
  background: none; border: none; border-radius: 6px;
  cursor: pointer; transition: color 0.15s, background 0.15s;
}
.toast-close:hover { color: var(--brand-text); background: rgba(255,255,255,0.08); }

/* =============================================================================
   Skeleton loaders
   ============================================================================= */
.skeleton {
  background: linear-gradient(90deg,
    rgba(255,255,255,0.04) 25%,
    rgba(255,255,255,0.08) 50%,
    rgba(255,255,255,0.04) 75%
  );
  background-size: 200% 100%;
  animation: skeleton-shimmer 1.5s infinite;
  border-radius: 8px;
}
@keyframes skeleton-shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}
.skeleton-text { height: 1rem; margin: 0.5rem 0; }
.skeleton-title { height: 1.5rem; width: 60%; margin: 0.75rem 0; }
.skeleton-avatar { width: 56px; height: 56px; border-radius: 8px; }
.skeleton-card { padding: 16px; border-radius: 12px; }
.skeleton-row { display: flex; gap: 12px; align-items: center; margin: 8px 0; }

/* =============================================================================
   Modal system (shared)
   ============================================================================= */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 1000;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s, visibility 0.2s;
}
.modal-overlay.show { opacity: 1; visibility: visible; }
.modal {
  background: var(--brand-bg);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 16px;
  max-width: 900px;
  width: 100%;
  max-height: 90vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transform: scale(0.95);
  transition: transform 0.2s;
}
.modal-overlay.show .modal { transform: scale(1); }
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}
.modal-header h3 { margin: 0; font-size: 1.1rem; }
.modal-close {
  width: 36px; height: 36px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.5rem; line-height: 1;
  color: rgba(248,250,252,0.6);
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 10px;
  cursor: pointer;
}
.modal-close:hover { color: var(--brand-text); background: rgba(255,255,255,0.1); }
.modal-body { padding: 20px; overflow-y: auto; }
.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 16px 20px;
  border-top: 1px solid rgba(255,255,255,0.08);
}

/* =============================================================================
   Tabs (for frame picker, wizard)
   ============================================================================= */
.tabs { display: flex; gap: 4px; margin-bottom: 16px; border-bottom: 1px solid rgba(255,255,255,0.1); }
.tab-btn {
  padding: 10px 16px;
  font-size: 0.85rem;
  font-weight: 600;
  color: rgba(248,250,252,0.6);
  background: none; border: none; border-bottom: 2px solid transparent;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
}
.tab-btn:hover { color: var(--brand-text); }
.tab-btn.active { color: var(--brand-accent); border-bottom-color: var(--brand-accent); }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* =============================================================================
   Wizard steps
   ============================================================================= */
.wizard-steps {
  display: flex;
  gap: 8px;
  margin-bottom: 24px;
  padding-bottom: 16px;
  border-bottom: 1px solid rgba(255,255,255,0.1);
  overflow-x: auto;
}
.wizard-step {
  flex: 1;
  min-width: 120px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 8px;
  position: relative;
}
.wizard-step::before {
  content: '';
  position: absolute;
  bottom: -17px;
  left: 50%;
  transform: translateX(-50%);
  width: 28px; height: 28px;
  border-radius: 50%;
  background: rgba(255,255,255,0.08);
  border: 2px solid rgba(255,255,255,0.15);
  z-index: 1;
}
.wizard-step.active::before { background: var(--brand-primary); border-color: var(--brand-primary); }
.wizard-step.completed::before { background: #22C55E; border-color: #22C55E; }
.wizard-step-number {
  width: 28px; height: 28px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 0.85rem;
  color: rgba(248,250,252,0.5);
  background: rgba(255,255,255,0.06);
  border: 2px solid rgba(255,255,255,0.1);
  position: relative; z-index: 2;
}
.wizard-step.active .wizard-step-number { color: white; background: var(--brand-primary); border-color: var(--brand-primary); }
.wizard-step.completed .wizard-step-number { color: white; background: #22C55E; border-color: #22C55E; }
.wizard-step-label { font-size: 0.7rem; text-align: center; opacity: 0.7; }

/* =============================================================================
   Drag handle
   ============================================================================= */
.drag-handle {
  cursor: grab;
  padding: 4px;
  color: rgba(248,250,252,0.4);
  transition: color 0.15s;
}
.drag-handle:hover { color: var(--brand-accent); }
.drag-handle:active { cursor: grabbing; }

/* =============================================================================
   Checkbox column
   ============================================================================= */
.select-col { width: 40px; text-align: center; }
.select-all { opacity: 0.6; transition: opacity 0.15s; }
.select-all:hover { opacity: 1; }

/* =============================================================================
   Bulk action bar
   ============================================================================= */
.bulk-bar {
  position: fixed;
  bottom: 16px;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  display: flex;
  gap: 8px;
  padding: 12px 16px;
  background: rgba(15, 23, 42, 0.96);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 12px;
  box-shadow: 0 10px 40px rgba(0,0,0,0.5);
  opacity: 0;
  visibility: hidden;
  transition: transform 0.3s, opacity 0.2s, visibility 0.2s;
  backdrop-filter: blur(8px);
  z-index: 100;
}
.bulk-bar.show { transform: translateX(-50%) translateY(0); opacity: 1; visibility: visible; }
@media (max-width: 480px) {
  .bulk-bar { left: 16px; right: 16px; bottom: 16px; transform: translateY(100px); }
  .bulk-bar.show { transform: translateY(0); }
}

/* =============================================================================
   Mobile improvements
   ============================================================================= */
@media (max-width: 600px) {
  .player-wrapper { padding: 12px; }
  .header { flex-wrap: wrap; gap: 12px; }
  .header h1 { font-size: 1.25rem; }
  .live-badge { margin-left: 0; order: 3; width: 100%; justify-content: center; }
  .grid2 { grid-template-columns: 1fr !important; }
  .card { padding: 14px; }
  input, textarea, select { padding: 14px 16px; font-size: 1rem; }
  .btn { padding: 14px 20px; font-size: 1rem; }
  .table { font-size: 0.8rem; }
  .table th, .table td { padding: 10px 8px; }
  .modal { max-height: 100vh; border-radius: 0; }
  .modal-header { position: sticky; top: 0; background: var(--brand-bg); z-index: 1; }
  .wizard-steps { gap: 4px; }
  .wizard-step { min-width: 100px; }
}

/* =============================================================================
   Viewer: theater mode, last-video card, recent grid, player extras
   ============================================================================= */
body.theater .player-wrapper { max-width: 1400px; }
body.theater .header, body.theater .footer, body.theater .vod-section { opacity: 0.25; transition: opacity 0.2s; }
body.theater .header:hover, body.theater .footer:hover, body.theater .vod-section:hover { opacity: 1; }

.last-video-card {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 16px;
  padding: 8px 16px 8px 8px;
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 12px;
  cursor: pointer;
  color: var(--brand-text);
  font-family: var(--brand-font);
  transition: background 0.15s, transform 0.15s;
  max-width: 420px;
}
.last-video-card:hover { background: rgba(255,255,255,0.1); transform: translateY(-1px); }
.last-video-card img { width: 120px; height: 68px; object-fit: cover; border-radius: 8px; }
.last-video-fallback { width: 120px; height: 68px; display: flex; align-items: center; justify-content: center; font-size: 1.5rem; background: rgba(0,0,0,0.4); border-radius: 8px; }
.last-video-text { display: flex; flex-direction: column; gap: 2px; text-align: left; }
.last-video-text b { font-size: 0.95rem; color: var(--brand-accent); }
.last-video-text i { font-style: normal; font-size: 0.8rem; opacity: 0.75; }

button.vod-card {
  display: block;
  width: 100%;
  text-align: left;
  font-family: var(--brand-font);
  color: var(--brand-text);
  cursor: pointer;
}
button.vod-card .vod-thumb { width: 100%; aspect-ratio: 16/9; object-fit: cover; border-radius: 8px; margin-bottom: 8px; background: rgba(255,255,255,0.06); }
.vod-thumb-fallback { display: flex; align-items: center; justify-content: center; font-size: 2rem; }
.vod-card h3 { margin: 0 0 4px; font-size: 0.95rem; }
.vod-card .vod-meta { margin: 0; opacity: 0.7; font-size: 0.82rem; }
.vod-empty { opacity: 0.6; }

.video-js .vjs-KoiniaPiP-button .vjs-icon-placeholder::before,
.video-js .vjs-KoiniaTheater-button .vjs-icon-placeholder::before,
.video-js .vjs-KoiniaShare-button .vjs-icon-placeholder::before {
  font-family: inherit;
  font-size: 1.1em;
  line-height: 1.6;
}
.footer .hint kbd {
  font-family: ui-monospace, monospace;
  font-size: 0.72rem;
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 4px;
  padding: 1px 5px;
}
