/* videos.ast.bar — AST Dark tokens */

:root {
  --bg: #0F1014;
  --surface: #16181F;
  --surface-elevated: #1F222C;
  --border: #2A2E3A;
  --text: #E5E7EB;
  --text-muted: #9CA3AF;
  --brand: #D97706;
  --brand-hover: #B45309;
  --accent: #10B981;
  --danger: #EF4444;
  --radius: 8px;
  --radius-lg: 12px;
  --shadow-modal: 0 20px 60px rgba(0,0,0,0.6);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

button {
  font-family: inherit;
  font-size: inherit;
  cursor: pointer;
}

/* Header */
#app-header {
  position: sticky;
  top: 0;
  z-index: 10;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
#app-header h1 {
  margin: 0;
  font-size: 1.125rem;
  text-align: center;
  font-weight: 600;
}
#btn-inicio {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 6px 12px;
  font-size: 0.875rem;
}
#btn-inicio:hover { color: var(--text); border-color: var(--text-muted); }

#btn-admin-upload {
  background: var(--brand);
  color: white;
  border: none;
  border-radius: var(--radius);
  padding: 8px 14px;
  font-size: 0.875rem;
  font-weight: 600;
}
#btn-admin-upload:hover { background: var(--brand-hover); }

/* Filter bar */
#filter-bar {
  display: flex;
  gap: 8px;
  padding: 12px 16px;
  overflow-x: auto;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
}
#filter-bar::-webkit-scrollbar { height: 4px; }
#filter-bar::-webkit-scrollbar-thumb { background: var(--border); }

.filter-group { display: flex; gap: 8px; align-items: center; }
.filter-group + .filter-group { margin-left: 12px; padding-left: 12px; border-left: 1px solid var(--border); }
.filter-group-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  white-space: nowrap;
}

.filter-pill {
  background: var(--surface-elevated);
  color: var(--text-muted);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 6px 14px;
  font-size: 0.875rem;
  white-space: nowrap;
  transition: all 0.15s;
}
.filter-pill:hover { color: var(--text); }
.filter-pill.active {
  background: var(--brand);
  color: white;
  border-color: var(--brand);
}

/* Video grid */
#video-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
  padding: 16px;
}

.video-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  cursor: pointer;
  transition: all 0.15s;
  display: flex;
  flex-direction: column;
}
.video-card:hover {
  border-color: var(--brand);
  transform: translateY(-2px);
}

.video-thumb {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  background: var(--bg);
  background-size: cover;
  background-position: center;
}
.video-thumb-fallback {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: var(--text-muted);
  font-size: 0.875rem;
}
.video-thumb-play {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0,0,0,0.2);
  opacity: 0;
  transition: opacity 0.15s;
}
.video-card:hover .video-thumb-play { opacity: 1; }
.video-thumb-play::before {
  content: "▶";
  width: 56px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--brand);
  color: white;
  border-radius: 50%;
  font-size: 1.25rem;
  padding-left: 4px;
}

.video-meta { padding: 12px; }
.video-title {
  font-size: 1rem;
  font-weight: 600;
  margin: 0 0 6px;
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.video-tags { display: flex; gap: 6px; flex-wrap: wrap; }
.video-badge {
  font-size: 0.7rem;
  padding: 2px 8px;
  border-radius: 4px;
  background: var(--surface-elevated);
  color: var(--text-muted);
}
.video-badge.audiencia-graduado { background: rgba(16,185,129,0.15); color: var(--accent); }
.video-badge.audiencia-no_graduado { background: rgba(217,119,6,0.15); color: var(--brand); }

.empty-state {
  text-align: center;
  color: var(--text-muted);
  padding: 48px 16px;
  font-size: 0.95rem;
}

/* Modal shared */
.modal[hidden] { display: none; }
.modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.85);
  backdrop-filter: blur(4px);
}
.modal-body {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  max-width: 900px;
  width: 100%;
  max-height: 92vh;
  overflow-y: auto;
  box-shadow: var(--shadow-modal);
}
.btn-modal-close {
  position: absolute;
  top: 8px;
  right: 8px;
  z-index: 2;
  background: rgba(0,0,0,0.5);
  color: white;
  border: none;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  font-size: 1.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}
.btn-modal-close:hover { background: rgba(0,0,0,0.8); }

/* Modal player */
.iframe-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  background: black;
}
.iframe-wrap iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
}
#modal-meta {
  padding: 16px 20px 20px;
}
#modal-meta h2 {
  margin: 0 0 8px;
  font-size: 1.25rem;
}
#modal-meta p {
  margin: 0;
  color: var(--text-muted);
  white-space: pre-wrap;
}

/* Modal upload form */
.modal-body-form {
  max-width: 540px;
  padding: 24px;
}
.modal-body-form h2 { margin: 0 0 20px; font-size: 1.25rem; }

#form-upload {
  display: flex;
  flex-direction: column;
  gap: 14px;
}
#form-upload label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.875rem;
  color: var(--text-muted);
}
#form-upload label small { color: var(--text-muted); opacity: 0.7; }

#form-upload input,
#form-upload textarea,
#form-upload select {
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 12px;
  font-family: inherit;
  font-size: 0.95rem;
}
#form-upload input:focus,
#form-upload textarea:focus,
#form-upload select:focus {
  outline: none;
  border-color: var(--brand);
}

#form-upload textarea { resize: vertical; min-height: 70px; }

#btn-form-submit {
  background: var(--brand);
  color: white;
  border: none;
  border-radius: var(--radius);
  padding: 12px;
  font-size: 1rem;
  font-weight: 600;
  margin-top: 4px;
}
#btn-form-submit:hover { background: var(--brand-hover); }
#btn-form-submit:disabled { opacity: 0.5; cursor: not-allowed; }

.form-error {
  background: rgba(239,68,68,0.12);
  border: 1px solid rgba(239,68,68,0.3);
  color: var(--danger);
  padding: 10px 12px;
  border-radius: var(--radius);
  font-size: 0.875rem;
}

/* Mobile tweaks */
@media (max-width: 600px) {
  #app-header { padding: 10px 12px; }
  #app-header h1 { font-size: 1rem; }
  #video-grid { padding: 12px; gap: 12px; grid-template-columns: 1fr; }
  .filter-group + .filter-group { margin-left: 8px; padding-left: 8px; }
  .modal { padding: 0; }
  .modal-body { max-height: 100vh; border-radius: 0; }
}
