/**
 * Viewer App Styles
 *
 * Dark-themed, clean viewer interface for watching live sermon translations.
 * Shares design tokens with the admin interface but has a simpler layout.
 */

/* --- Reset & Base --- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg-primary: #0f1117;
  --bg-secondary: #1a1d27;
  --bg-card: #1e2130;
  --bg-hover: #252840;
  --text-primary: #e8eaed;
  --text-secondary: #9aa0a6;
  --text-muted: #5f6368;
  --accent: #8ab4f8;
  --accent-hover: #aecbfa;
  --live-red: #ea4335;
  --live-red-glow: rgba(234, 67, 53, 0.3);
  --paused-yellow: #fbbc04;
  --ended-gray: #5f6368;
  --border: #2d3142;
  --caption-font-size: 1.25rem;
  --font-mono: 'SF Mono', 'Fira Code', monospace;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  line-height: 1.5;
}

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

/* --- Landing Page --- */
.landing-container {
  max-width: 800px;
  margin: 0 auto;
  padding: 2rem 1.5rem;
}

.landing-header {
  text-align: center;
  margin-bottom: 3rem;
  padding-bottom: 2rem;
  border-bottom: 1px solid var(--border);
}

.landing-header h1 {
  font-size: 1.75rem;
  font-weight: 600;
  margin-bottom: 0.5rem;
}

.landing-header p {
  color: var(--text-secondary);
  font-size: 1rem;
}

.section-title {
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  margin-bottom: 1rem;
}

/* --- Session Cards --- */
.session-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-bottom: 2.5rem;
}

.session-card {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1rem 1.25rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.session-card:hover {
  background: var(--bg-hover);
  border-color: var(--accent);
  transform: translateY(-1px);
}

.session-card.live {
  border-color: var(--live-red);
  box-shadow: 0 0 20px var(--live-red-glow);
}

.session-card.live:hover {
  border-color: var(--live-red);
}

.btn-delete {
  background: none;
  border: none;
  font-size: 1.1rem;
  cursor: pointer;
  padding: 0.35rem;
  border-radius: 6px;
  line-height: 1;
  transition: all 0.15s ease;
  z-index: 10;
  opacity: 0.4;
}

.btn-delete:hover {
  background: rgba(234, 67, 53, 0.15);
  opacity: 1;
  transform: scale(1.1);
}

/* Status badge */
.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.2rem 0.6rem;
  border-radius: 20px;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  white-space: nowrap;
  flex-shrink: 0;
}

.status-badge.live {
  background: rgba(234, 67, 53, 0.15);
  color: var(--live-red);
}

.status-badge.live .pulse {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--live-red);
  animation: pulse 1.5s ease-in-out infinite;
}

.status-badge.paused {
  background: rgba(251, 188, 4, 0.15);
  color: var(--paused-yellow);
}

.status-badge.ended {
  background: rgba(95, 99, 104, 0.15);
  color: var(--ended-gray);
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

.session-info {
  flex: 1;
  min-width: 0;
}

.session-date {
  font-size: 0.95rem;
  font-weight: 500;
}

.session-time {
  font-size: 0.8rem;
  color: var(--text-secondary);
  margin-top: 0.15rem;
}

.session-arrow {
  color: var(--text-muted);
  font-size: 1.2rem;
  flex-shrink: 0;
}

.empty-state {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--text-muted);
}

.empty-state .icon {
  font-size: 2.5rem;
  margin-bottom: 1rem;
}

/* --- Watch Page --- */
.watch-container {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

.video-panel {
  flex: 1;
  min-width: 0;
  background: #000;
  display: flex;
  flex-direction: column;
}

.video-wrapper {
  flex: 1;
  position: relative;
}

.video-wrapper iframe,
.video-wrapper #yt-player {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  border: none;
}

/* Watch header bar */
.watch-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.5rem 1rem;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.watch-header .back-link {
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.watch-header .session-status {
  margin-left: auto;
}

/* Panel divider */
.panel-divider {
  width: 4px;
  background: var(--border);
  position: relative;
  flex-shrink: 0;
  cursor: col-resize;
  transition: background 0.15s ease;
  z-index: 10;
}

.panel-divider:hover, .panel-divider.dragging {
  background: var(--accent);
  box-shadow: 0 0 8px rgba(138, 180, 248, 0.4);
}

.panel-divider::after {
  content: '';
  position: absolute;
  top: 0;
  bottom: 0;
  left: -4px;
  right: -4px;
  background: transparent;
  cursor: col-resize;
}

/* Caption panel (viewer) */
.caption-panel {
  width: 420px;
  min-width: 300px;
  display: flex;
  flex-direction: column;
  background: var(--bg-secondary);
  border-left: 1px solid var(--border);
}

.caption-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.caption-header h2 {
  font-size: 0.9rem;
  font-weight: 600;
}

.caption-toolbar {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.caption-toolbar select {
  background: var(--bg-card);
  color: var(--text-primary);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.25rem 0.5rem;
  font-size: 0.75rem;
  cursor: pointer;
}

.toolbar-btn {
  background: none;
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 0.85rem;
  padding: 0.2rem 0.45rem;
  transition: all 0.15s ease;
  line-height: 1;
}

.toolbar-btn:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
  border-color: var(--accent);
}

.toolbar-btn.active {
  color: var(--accent);
  border-color: var(--accent);
  background: rgba(138, 180, 248, 0.08);
}

.caption-content {
  flex: 1;
  overflow-y: auto;
  padding: 1rem;
  scroll-behavior: smooth;
}

/* --- Caption Blocks (shared with admin) --- */
.caption-block {
  margin-bottom: 0.75rem;
  padding: 0.5rem 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}

.caption-block[data-timestamp] {
  cursor: pointer;
  border-left: 3px solid transparent;
  padding-left: 0.5rem;
  transition: all 0.2s ease;
  border-radius: 4px;
}

.caption-block[data-timestamp]:hover {
  background: rgba(255, 255, 255, 0.04);
}

.caption-block.synced-active {
  border-left-color: var(--accent);
  background: rgba(138, 180, 248, 0.08);
  padding-left: 0.5rem;
  border-radius: 4px;
}

.caption-text {
  font-size: var(--caption-font-size);
  line-height: 1.6;
  color: var(--text-primary);
}

.caption-text.active {
  border-right: 2px solid var(--accent);
  padding-right: 0.25rem;
  animation: blink 1s step-end infinite;
}

@keyframes blink {
  50% { border-color: transparent; }
}

.caption-english {
  font-size: calc(var(--caption-font-size) * 0.75);
  color: var(--text-secondary);
  margin-bottom: 0.25rem;
  line-height: 1.4;
}

.caption-timestamp {
  font-size: 0.65rem;
  color: var(--text-muted);
  margin-top: 0.25rem;
  font-family: var(--font-mono);
}

.caption-system {
  text-align: center;
  padding: 0.5rem 0.75rem;
  margin: 0.75rem 0;
  font-size: 0.8rem;
  color: var(--text-muted);
  background: rgba(255, 255, 255, 0.03);
  border-radius: 8px;
  font-style: italic;
}

.caption-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 3rem 1rem;
  text-align: center;
  color: var(--text-muted);
  gap: 0.5rem;
}

.caption-empty .icon {
  font-size: 2rem;
}

/* --- Loading spinner --- */
.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100vh;
  color: var(--text-secondary);
  font-size: 1.1rem;
}

.spinner {
  width: 24px;
  height: 24px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin-right: 0.75rem;
}

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

/* --- Responsive --- */
@media (max-width: 768px) {
  .watch-container {
    flex-direction: column;
    height: 100vh;
    height: 100dvh;
  }

  .video-panel {
    height: 35vh;
    flex: none;
  }

  .panel-divider {
    display: none !important;
  }

  .caption-panel {
    width: 100% !important;
    min-width: unset;
    flex: 1;
    min-height: 0;
    border-left: none;
    border-top: 1px solid var(--border);
  }

  .caption-content {
    min-height: 0;
    touch-action: pan-y;
    -webkit-overflow-scrolling: touch;
  }

  .landing-container {
    padding: 1rem;
  }
}
