/* SA Video Library — Scientific Animations Brand Theme */
@import url('https://fonts.googleapis.com/css2?family=Khula:wght@300;400;600;700;800&family=JetBrains+Mono:wght@400;500&display=swap');

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

:root {
  --bg-primary: #1a0a3e;
  --bg-secondary: #2F135D;
  --bg-tertiary: #3A10AE;
  --border: rgba(90, 50, 160, 0.4);
  --border-light: rgba(120, 80, 200, 0.5);
  --text-primary: #ffffff;
  --text-secondary: #f0f0f0;
  --text-muted: #d0c0e8;
  --text-dim: #b0a0c8;
  --accent: #32C8E9;
  --accent-hover: #28b0cc;
  --highlight: #FF8100;
  --narration: #fde68a;
  --visual: #cbd5e1;
  --actions: #6ee7b7;
  --timestamp: #60a5fa;
  --tag-bg: rgba(50, 200, 233, 0.15);
  --tag-text: #32C8E9;
  --success: #10b981;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 4px 6px -1px rgba(0,0,0,0.3), 0 2px 4px -2px rgba(0,0,0,0.2);
  --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.4), 0 4px 6px -4px rgba(0,0,0,0.3);
  --transition: all 0.2s ease;
}

body {
  font-family: 'Khula', Arial, Helvetica, sans-serif;
  background: linear-gradient(135deg, var(--bg-primary) 0%, #1a0a3e 100%);
  color: var(--text-secondary);
  line-height: 1.6;
  min-height: 100vh;
}

.container { max-width: 1200px; margin: 0 auto; padding: 0 24px; }

/* ===== HEADER ===== */
.header {
  background: linear-gradient(135deg, rgba(47, 19, 93, 0.95) 0%, rgba(26, 10, 62, 0.95) 100%);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 100;
  padding: 16px 0;
}
.header-content { display: flex; align-items: center; justify-content: space-between; }
.logo h1 { font-size: 24px; font-weight: 800; color: var(--text-primary); letter-spacing: -0.5px; }
.logo .tagline { font-size: 12px; color: var(--text-dim); margin-top: 2px; }
.nav { display: flex; gap: 4px; }
.nav-link {
  padding: 8px 16px; border-radius: var(--radius-sm); font-size: 14px; font-weight: 500;
  color: var(--text-muted); text-decoration: none; transition: var(--transition);
}
.nav-link:hover { color: var(--text-secondary); background: rgba(50, 200, 233, 0.1); }
.nav-link.active { color: var(--accent); background: rgba(50, 200, 233, 0.15); box-shadow: 0 0 15px rgba(50, 200, 233, 0.2); }

/* ===== MAIN ===== */
.main { padding: 32px 0; min-height: calc(100vh - 80px); }
.view { display: none; animation: fadeIn 0.3s ease; }
.view.active { display: block; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
@keyframes pulse { 0% { opacity: 1; } 50% { opacity: 0.8; } 100% { opacity: 1; } }

/* ===== SEARCH HERO ===== */
.search-hero { margin-bottom: 32px; }
.hero-gradient {
  text-align: center;
  padding: 40px 0 24px;
  background: linear-gradient(135deg, rgba(47, 19, 93, 0.8) 0%, rgba(26, 10, 62, 0.9) 100%);
  border-radius: var(--radius);
  margin-bottom: 24px;
  border: 1px solid var(--border);
}
.hero-title {
  font-size: 50px;
  font-weight: 800;
  color: var(--text-primary);
  margin-bottom: 8px;
  letter-spacing: -1px;
}
.hero-subtitle {
  font-size: 18px;
  color: var(--accent);
  font-weight: 400;
  animation: pulse 3s ease-in-out infinite;
}
.search-container {
  position: relative; max-width: 700px; margin: 0 auto 16px;
}
.search-input {
  width: 100%; padding: 16px 48px 16px 20px;
  background: rgba(47, 19, 93, 0.6); border: 2px solid var(--border);
  border-radius: var(--radius); color: var(--text-primary);
  font-size: 16px; font-family: inherit; outline: none; transition: var(--transition);
}
.search-input:focus { border-color: var(--accent); box-shadow: 0 0 0 4px rgba(50, 200, 233, 0.15); }
.search-input::placeholder { color: var(--text-dim); }
.search-clear {
  position: absolute; right: 12px; top: 50%; transform: translateY(-50%);
  background: none; border: none; color: var(--text-muted); font-size: 24px;
  cursor: pointer; padding: 4px 8px; border-radius: 4px;
}
.search-clear:hover { color: var(--text-primary); background: var(--bg-tertiary); }

.search-filters {
  display: flex; gap: 8px; justify-content: center; flex-wrap: wrap;
}
.filter-select {
  padding: 8px 12px; background: rgba(47, 19, 93, 0.6); border: 1px solid var(--border);
  border-radius: var(--radius-sm); color: var(--text-secondary); font-size: 13px;
  font-family: inherit; outline: none; cursor: pointer;
}
.filter-select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(50, 200, 233, 0.1); }

/* ===== SEARCH RESULTS ===== */
.search-results-header {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 16px; padding: 0 4px;
}
.result-count { font-size: 14px; color: var(--text-muted); }
.result-count strong { color: var(--text-secondary); }

.result-card {
  background: rgba(47, 19, 93, 0.6); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 20px; margin-bottom: 12px;
  transition: var(--transition); cursor: pointer;
  backdrop-filter: blur(10px);
}
.result-card:hover { 
  border-color: var(--accent); 
  box-shadow: 0 8px 25px rgba(50, 200, 233, 0.15); 
  transform: translateY(-2px); 
  background: rgba(58, 16, 174, 0.4);
}

.result-card-header {
  display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 12px;
}
.result-video-title {
  font-size: 16px; font-weight: 700; color: var(--accent); margin-bottom: 2px;
}
.result-timestamp {
  font-family: 'JetBrains Mono', monospace; font-size: 13px; font-weight: 500;
  color: var(--timestamp); background: rgba(96,165,250,0.1);
  padding: 4px 10px; border-radius: 6px; white-space: nowrap;
}
.result-field-badge {
  display: inline-block; font-size: 10px; text-transform: uppercase; letter-spacing: 0.5px;
  padding: 2px 8px; border-radius: 4px; font-weight: 600; margin-left: 8px;
}
.badge-narration { background: rgba(253,230,138,0.15); color: var(--narration); }
.badge-visual { background: rgba(203,213,225,0.15); color: var(--visual); }
.badge-actions { background: rgba(110,231,183,0.15); color: var(--actions); }
.badge-tags { background: var(--tag-bg); color: var(--tag-text); }
.badge-text { background: rgba(167,139,250,0.15); color: #a78bfa; }

.result-snippet { font-size: 14px; line-height: 1.7; margin-bottom: 12px; color: var(--text-muted); }
.result-snippet mark { background: var(--highlight); color: var(--bg-primary); padding: 1px 4px; border-radius: 3px; }
.result-snippet .field-label { font-size: 11px; text-transform: uppercase; letter-spacing: 0.5px; color: var(--text-dim); margin-right: 6px; }

.result-tags { display: flex; flex-wrap: wrap; gap: 6px; }
.tag {
  display: inline-block; padding: 4px 12px; border-radius: 20px; font-size: 11px;
  font-weight: 600; background: var(--tag-bg); color: var(--tag-text);
  cursor: pointer; transition: var(--transition);
  border: 1px solid rgba(50, 200, 233, 0.3);
}
.tag:hover { background: rgba(50, 200, 233, 0.25); transform: translateY(-1px); }

/* ===== EMPTY STATE ===== */
.empty-state { text-align: center; padding: 60px 20px; }
.empty-state h3 { font-size: 16px; color: var(--text-muted); margin-bottom: 16px; font-weight: 500; }
.search-suggestions { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }
.suggestion-btn {
  padding: 8px 16px; background: rgba(47, 19, 93, 0.6); border: 1px solid var(--border);
  border-radius: 20px; color: var(--accent); font-size: 13px; cursor: pointer;
  font-family: inherit; transition: var(--transition);
}
.suggestion-btn:hover { background: rgba(50, 200, 233, 0.15); border-color: var(--accent); }

.keyboard-hint { margin-top: 24px; font-size: 12px; color: var(--text-dim); }
.keyboard-hint kbd {
  background: var(--bg-tertiary); padding: 2px 8px; border-radius: 4px;
  font-family: 'JetBrains Mono', monospace; font-size: 11px; border: 1px solid var(--border-light);
}

/* ===== VIDEO DETAIL ===== */
.video-header { margin-bottom: 24px; }
.back-btn {
  background: none; border: none; color: var(--accent); font-size: 14px;
  cursor: pointer; font-family: inherit; padding: 4px 0; margin-bottom: 12px;
}
.back-btn:hover { color: var(--accent-hover); }
.video-meta h2 { font-size: 28px; color: var(--text-primary); margin-bottom: 8px; font-weight: 700; }
.video-stats { display: flex; gap: 16px; color: var(--text-muted); font-size: 13px; }
.video-stats span { display: flex; align-items: center; gap: 4px; }
/* Video Detail Layout — side by side */
.video-detail-layout {
  display: flex; gap: 20px; align-items: flex-start;
  height: calc(100vh - 180px);
}

/* Left: sticky video + search */
.video-sidebar {
  position: sticky; top: 100px;
  flex: 0 0 420px; min-width: 320px;
}
.video-player-container {
  border-radius: var(--radius);
  overflow: hidden; background: #000; border: 1px solid var(--border);
}
.video-player-container video {
  width: 100%; display: block;
}
.video-search-container { margin-top: 12px; }

/* Right: scrollable scenes table */
.video-detail-layout .video-scenes {
  flex: 1; overflow-y: auto; overflow-x: auto;
  max-height: calc(100vh - 180px);
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}
.video-detail-layout .video-scenes::-webkit-scrollbar { width: 6px; }
.video-detail-layout .video-scenes::-webkit-scrollbar-track { background: transparent; }
.video-detail-layout .video-scenes::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

@media (max-width: 900px) {
  .video-detail-layout { flex-direction: column; height: auto; }
  .video-sidebar { position: static; flex: none; width: 100%; }
  .video-detail-layout .video-scenes { max-height: none; }
}
.video-search-input {
  width: 100%; max-width: 400px; padding: 10px 16px;
  background: rgba(47, 19, 93, 0.6); border: 1px solid var(--border);
  border-radius: var(--radius-sm); color: var(--text-primary);
  font-size: 14px; font-family: inherit; outline: none;
}
.video-search-input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(50, 200, 233, 0.1); }

.scene-card {
  background: rgba(47, 19, 93, 0.6); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 20px; margin-bottom: 8px;
  display: grid; grid-template-columns: 100px 1fr; gap: 16px;
  transition: var(--transition);
  backdrop-filter: blur(10px);
}
.scene-card:hover { border-color: var(--accent); box-shadow: 0 4px 15px rgba(50, 200, 233, 0.1); }
.scene-card.hidden { display: none; }
.scene-timestamp {
  font-family: 'JetBrains Mono', monospace; font-size: 13px; font-weight: 600;
  color: var(--timestamp); padding-top: 2px;
}
.scene-content { display: flex; flex-direction: column; gap: 8px; }
.scene-visual { font-size: 13px; color: var(--visual); line-height: 1.6; }
.scene-text-screen { font-family: 'JetBrains Mono', monospace; font-size: 12px; color: #a78bfa; }
.scene-narration { font-size: 13px; color: var(--narration); font-style: italic; line-height: 1.6; }
.scene-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.action-chip {
  padding: 3px 10px; border-radius: 20px; font-size: 11px;
  background: rgba(110,231,183,0.1); color: var(--actions); border: 1px solid rgba(110,231,183,0.2);
}
.scene-tags { display: flex; flex-wrap: wrap; gap: 4px; }

/* ===== LIBRARY ===== */
.library-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 24px; }
.library-header h2 { font-size: 24px; color: var(--text-primary); font-weight: 700; }
.library-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 16px; }
.video-card {
  background: rgba(47, 19, 93, 0.6); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 20px; cursor: pointer; transition: var(--transition);
  backdrop-filter: blur(10px);
}
.video-card:hover { border-color: var(--accent); box-shadow: 0 8px 25px rgba(50, 200, 233, 0.15); transform: translateY(-2px); }
.video-card-thumb {
  width: 100%; height: 160px; background: linear-gradient(135deg, var(--bg-tertiary) 0%, #2F135D 100%);
  border-radius: var(--radius-sm); margin-bottom: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 48px; color: var(--accent);
  border: 1px solid var(--border);
  position: relative;
  overflow: hidden;
}
.video-card-thumb::before {
  content: '';
  position: absolute;
  top: -50%; left: -50%;
  width: 200%; height: 200%;
  background: linear-gradient(45deg, transparent, rgba(50, 200, 233, 0.1), transparent);
  transform: rotate(45deg);
  transition: all 0.5s ease;
}
.video-card:hover .video-card-thumb::before {
  animation: shine 0.5s ease-in-out;
}
@keyframes shine {
  0% { transform: translateX(-100%) translateY(-100%) rotate(45deg); }
  100% { transform: translateX(100%) translateY(100%) rotate(45deg); }
}
.video-card h3 { font-size: 16px; color: var(--text-primary); margin-bottom: 8px; font-weight: 600; }
.video-card-meta { display: flex; gap: 12px; font-size: 12px; color: var(--text-muted); }

/* ===== STATS ===== */
#stats-view h2 { font-size: 24px; color: var(--text-primary); margin-bottom: 24px; font-weight: 700; }
.stats-container { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; margin-bottom: 32px; }
.stat-card {
  background: rgba(47, 19, 93, 0.6); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 24px; text-align: center;
  backdrop-filter: blur(10px);
}
.stat-card .stat-value { font-size: 36px; font-weight: 700; color: var(--text-primary); margin-bottom: 4px; }
.stat-card .stat-label { font-size: 13px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; }
.stat-card.accent { border-color: var(--accent); background: rgba(50, 200, 233, 0.1); }
.stat-card.accent .stat-value { color: var(--accent); }

.tags-section { margin-top: 24px; }
.tags-section h3 { font-size: 16px; color: var(--text-primary); margin-bottom: 16px; }
.tags-cloud { display: flex; flex-wrap: wrap; gap: 8px; }
.tag-cloud-item {
  padding: 6px 14px; border-radius: 20px; font-size: 13px;
  background: rgba(47, 19, 93, 0.6); border: 1px solid var(--border);
  color: var(--text-secondary); cursor: pointer; transition: var(--transition);
}
.tag-cloud-item:hover { border-color: var(--accent); color: var(--accent); background: rgba(50, 200, 233, 0.1); }
.tag-cloud-item .tag-count { color: var(--text-dim); font-size: 11px; margin-left: 4px; }

/* ===== SCENES TABLE ===== */
.scenes-table {
  width: 100%; border-collapse: separate; border-spacing: 0;
  background: var(--bg-secondary); border: 1px solid var(--border);
  border-radius: var(--radius); overflow: hidden;
}
.scenes-table thead th {
  padding: 12px 16px; text-align: left; font-size: 11px;
  text-transform: uppercase; letter-spacing: 0.5px; font-weight: 600;
  color: var(--text-dim); background: var(--bg-tertiary);
  border-bottom: 2px solid var(--border);
  position: sticky; top: -1px; z-index: 2;
}
.scenes-table tbody tr {
  transition: var(--transition);
}
.scenes-table tbody tr:hover { background: rgba(255,255,255,0.03); }
.scenes-table tbody tr.hidden { display: none; }
.scenes-table tbody td {
  padding: 12px 16px; vertical-align: top;
  border-bottom: 1px solid var(--border); font-size: 13px; line-height: 1.6;
}
.scenes-table tbody tr:last-child td { border-bottom: none; }

.scenes-table .col-num {
  width: 40px; text-align: center; font-weight: 600;
  color: var(--text-dim); font-family: 'JetBrains Mono', monospace; font-size: 12px;
}
.scenes-table .col-time { width: 120px; white-space: nowrap; }
.scenes-table .col-visual { color: var(--visual); min-width: 200px; }
.scenes-table .col-narration { color: var(--narration); font-style: italic; min-width: 180px; }
.scenes-table .col-actions { min-width: 140px; }
.scenes-table .col-tags { min-width: 120px; }
.scenes-table .text-dim { color: var(--text-dim); }

.scenes-table .scene-timestamp {
  font-family: 'JetBrains Mono', monospace; font-size: 12px; font-weight: 500;
  color: var(--timestamp); background: rgba(96,165,250,0.1);
  padding: 3px 8px; border-radius: 4px; white-space: nowrap;
}
.scenes-table .scene-timestamp.clickable {
  cursor: pointer; transition: var(--transition);
}
.scenes-table .scene-timestamp.clickable:hover {
  background: rgba(96,165,250,0.3); text-decoration: underline;
}
.scenes-table .scene-text-screen {
  margin-top: 6px; font-family: 'JetBrains Mono', monospace; font-size: 11px; color: #a78bfa;
}
.scenes-table .action-chip {
  display: inline-block; padding: 2px 8px; border-radius: 12px; font-size: 11px; margin: 2px 0;
  background: rgba(110,231,183,0.1); color: var(--actions); border: 1px solid rgba(110,231,183,0.2);
}
.scenes-table .tag {
  display: inline-block; padding: 2px 8px; border-radius: 12px; font-size: 10px; margin: 2px 0;
  background: var(--tag-bg); color: var(--tag-text); cursor: pointer;
}
.scenes-table .tag:hover { background: rgba(59,130,246,0.25); }

/* Table responsive: horizontal scroll on small screens */
.video-scenes { overflow-x: auto; }

@media (max-width: 768px) {
  .scenes-table { font-size: 12px; }
  .scenes-table thead { display: none; }
  .scenes-table tbody tr {
    display: block; margin-bottom: 8px; border: 1px solid var(--border);
    border-radius: var(--radius-sm); padding: 8px;
  }
  .scenes-table tbody td {
    display: block; border-bottom: none; padding: 4px 8px;
  }
  .scenes-table tbody td::before {
    content: attr(data-label); display: block; font-size: 10px;
    text-transform: uppercase; color: var(--text-dim); margin-bottom: 2px;
  }
}

/* ===== LOADING ===== */
.loading { text-align: center; padding: 40px; color: var(--accent); font-size: 14px; }
.loading::before { content: '⏳ '; animation: spin 1s linear infinite; }
@keyframes spin { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
  .header-content { flex-direction: column; gap: 12px; }
  .search-input { font-size: 14px; padding: 14px 16px; }
  .search-filters { flex-direction: column; align-items: stretch; }
  .scene-card { grid-template-columns: 1fr; }
  .scene-timestamp { padding-bottom: 4px; border-bottom: 1px solid var(--border); }
  .library-grid { grid-template-columns: 1fr; }
  .stats-container { grid-template-columns: repeat(2, 1fr); }
}
