/* Dashboard — CompoundCast
   Uses the design tokens from theme.css (:root vars defined there).
   This file owns dashboard-specific layout and components only.
*/

/* ── HEADER ── */
.dash-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  padding: 0 2rem;
}

.dash-header-inner {
  max-width: 1200px;
  margin: 0 auto;
  height: 60px;
  display: flex;
  align-items: center;
  gap: 2rem;
}

.dash-brand {
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  text-decoration: none;
  color: var(--fg);
}

.dash-brand .thin {
  font-weight: 400;
  color: var(--fg-muted);
}

.dash-nav {
  display: flex;
  gap: 1.5rem;
  flex: 1;
}

.dash-nav-item {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  letter-spacing: 0.1em;
  color: var(--fg-dim);
  cursor: pointer;
  padding: 0.25rem 0;
  border-bottom: 1px solid transparent;
  transition: color 0.2s, border-color 0.2s;
}

.dash-nav-item.active,
.dash-nav-item:hover {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

.dash-header-right {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--fg-dim);
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--fg-dim);
  transition: background 0.3s;
}

.status-dot.loading { background: var(--gold); animation: pulse 1s infinite; }
.status-dot.success { background: var(--accent); }
.status-dot.error   { background: #e05252; }

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

/* ── MAIN LAYOUT ── */
.dash-main {
  max-width: 1200px;
  margin: 0 auto;
  padding: 3rem 2rem 6rem;
  display: flex;
  flex-direction: column;
  gap: 5rem;
}

/* ── SECTIONS ── */
.dash-section {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.section-label {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  letter-spacing: 0.2em;
  color: var(--fg-dim);
}

.section-label .accent {
  color: var(--accent);
}

.section-title {
  font-size: 1.75rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  margin-top: -0.5rem;
}

/* ── GENERATE CARD ── */
.generate-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 2rem;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.gen-field-row {
  display: grid;
  grid-template-columns: 1fr 160px;
  gap: 1rem;
}

.gen-field {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.field-label {
  font-family: var(--font-mono);
  font-size: 0.65rem;
  letter-spacing: 0.15em;
  color: var(--fg-dim);
  font-weight: 600;
}

.field-input {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.75rem 1rem;
  color: var(--fg);
  font-family: var(--font-display);
  font-size: 0.95rem;
  outline: none;
  transition: border-color 0.2s;
}

.field-input:focus {
  border-color: rgba(0, 220, 130, 0.4);
}

.field-input::placeholder {
  color: var(--fg-dim);
}

.field-select {
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%235a5a65' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 2.5rem;
}

.gen-actions {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
}

/* ── BUTTONS ── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.7rem 1.5rem;
  border-radius: 8px;
  border: 1px solid transparent;
  font-family: var(--font-display);
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-accent {
  background: var(--accent);
  color: #0a0a0f;
  border-color: var(--accent);
}

.btn-accent:hover:not(:disabled) {
  background: #00f090;
  border-color: #00f090;
}

.btn-ghost {
  background: transparent;
  color: var(--fg-muted);
  border-color: var(--border);
}

.btn-ghost:hover:not(:disabled) {
  border-color: rgba(255,255,255,0.15);
  color: var(--fg);
}

.btn-danger {
  background: transparent;
  color: #e05252;
  border-color: rgba(224,82,82,0.3);
}

.btn-danger:hover:not(:disabled) {
  background: rgba(224,82,82,0.1);
}

.btn-icon {
  font-size: 0.85rem;
}

/* ── SCRIPT OUTPUT ── */
.script-output {
  background: var(--bg-card);
  border: 1px solid rgba(0, 220, 130, 0.2);
  border-radius: 12px;
  overflow: hidden;
}

.script-header {
  padding: 1.75rem 2rem 1.25rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

.script-label {
  font-family: var(--font-mono);
  font-size: 0.65rem;
  letter-spacing: 0.15em;
  color: var(--accent);
  margin-bottom: 0.5rem;
}

.script-title {
  font-size: 1.25rem;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.script-meta-row {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.5rem;
}

.tag-chip {
  font-family: var(--font-mono);
  font-size: 0.65rem;
  letter-spacing: 0.1em;
  color: var(--gold);
  background: var(--gold-dim);
  padding: 0.3rem 0.75rem;
  border-radius: 4px;
  white-space: nowrap;
}

.script-tags {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.script-tag {
  font-family: var(--font-mono);
  font-size: 0.6rem;
  letter-spacing: 0.1em;
  color: var(--fg-dim);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  padding: 0.2rem 0.6rem;
  border-radius: 4px;
}

.script-body {
  padding: 1.5rem 2rem;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.script-part {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.part-label {
  font-family: var(--font-mono);
  font-size: 0.65rem;
  letter-spacing: 0.15em;
  color: var(--fg-dim);
  font-weight: 600;
}

.part-content {
  font-size: 0.95rem;
  color: var(--fg-muted);
  line-height: 1.75;
}

.script-sections {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.script-section-item {
  padding: 1.25rem 1.5rem;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 8px;
}

.script-section-heading {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--fg);
  margin-bottom: 0.5rem;
}

.script-section-content {
  font-size: 0.9rem;
  color: var(--fg-muted);
  line-height: 1.7;
}

.script-actions {
  padding: 1.25rem 2rem;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
}

/* ── ERROR BANNER ── */
.error-banner {
  background: rgba(224,82,82,0.1);
  border: 1px solid rgba(224,82,82,0.3);
  border-radius: 8px;
  padding: 1rem 1.25rem;
  color: #e05252;
  font-size: 0.9rem;
}

/* ── QUEUE ── */
.queue-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

.queue-filters {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
}

.filter-btn {
  font-family: var(--font-mono);
  font-size: 0.65rem;
  letter-spacing: 0.1em;
  color: var(--fg-dim);
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0.35rem 0.75rem;
  cursor: pointer;
  transition: all 0.2s;
}

.filter-btn:hover,
.filter-btn.active {
  color: var(--accent);
  border-color: rgba(0,220,130,0.3);
  background: var(--accent-dim);
}

/* ── QUEUE TABLE ── */
.queue-table-wrap {
  overflow-x: auto;
  border-radius: 12px;
  border: 1px solid var(--border);
}

.queue-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.queue-table th {
  font-family: var(--font-mono);
  font-size: 0.62rem;
  letter-spacing: 0.12em;
  color: var(--fg-dim);
  background: var(--bg-elevated);
  padding: 0.9rem 1.25rem;
  text-align: left;
  font-weight: 600;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.queue-table td {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

.queue-table tbody tr:last-child td {
  border-bottom: none;
}

.queue-table tbody tr {
  cursor: pointer;
  transition: background 0.15s;
}

.queue-table tbody tr:hover {
  background: var(--bg-elevated);
}

.topic-cell {
  font-weight: 500;
  color: var(--fg);
  max-width: 320px;
}

.topic-text {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: block;
  max-width: 320px;
}

.lang-chip {
  font-family: var(--font-mono);
  font-size: 0.6rem;
  letter-spacing: 0.1em;
  color: var(--fg-dim);
  background: var(--bg-card);
  border: 1px solid var(--border);
  padding: 0.2rem 0.5rem;
  border-radius: 3px;
  text-transform: uppercase;
}

.status-badge {
  font-family: var(--font-mono);
  font-size: 0.65rem;
  letter-spacing: 0.1em;
  padding: 0.3rem 0.7rem;
  border-radius: 4px;
  font-weight: 600;
  white-space: nowrap;
}

.status-pending   { color: var(--fg-muted); background: rgba(255,255,255,0.05); border: 1px solid var(--border); }
.status-scripted  { color: var(--gold);     background: var(--gold-dim);          border: 1px solid rgba(230,197,71,0.2); }
.status-voiceover { color: #7eb8f7;         background: rgba(126,184,247,0.1);    border: 1px solid rgba(126,184,247,0.2); }
.status-editing   { color: #c47ef7;         background: rgba(196,126,247,0.1);    border: 1px solid rgba(196,126,247,0.2); }
.status-published { color: var(--accent);   background: var(--accent-dim);        border: 1px solid rgba(0,220,130,0.2); }

.link-icon {
  color: var(--accent);
  font-size: 0.85rem;
}

.no-link {
  color: var(--fg-dim);
  font-size: 0.8rem;
}

.date-cell {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--fg-dim);
  white-space: nowrap;
}

/* ── EMPTY / LOADING STATES ── */
.loading-state,
.empty-state {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 1rem;
  padding: 4rem 2rem;
  color: var(--fg-dim);
  font-size: 0.9rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
}

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

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

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

/* ── MODAL ── */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  backdrop-filter: blur(4px);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.modal-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 16px;
  width: 100%;
  max-width: 620px;
  max-height: 90vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

.modal-header {
  padding: 1.5rem 1.75rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  position: sticky;
  top: 0;
  background: var(--bg-card);
}

.modal-title {
  font-size: 1.05rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  line-height: 1.4;
}

.modal-close {
  background: none;
  border: none;
  color: var(--fg-dim);
  cursor: pointer;
  font-size: 1rem;
  padding: 0.25rem;
  border-radius: 4px;
  transition: color 0.2s;
  flex-shrink: 0;
}

.modal-close:hover { color: var(--fg); }

.modal-body {
  padding: 1.5rem 1.75rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  flex: 1;
}

.modal-field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

.modal-field {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.modal-script-view {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1.25rem;
  font-size: 0.85rem;
  color: var(--fg-muted);
  line-height: 1.7;
  max-height: 280px;
  overflow-y: auto;
  white-space: pre-wrap;
  font-family: var(--font-mono);
}

.modal-footer {
  padding: 1.25rem 1.75rem;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 0.75rem;
  justify-content: flex-end;
}

/* ── UTILITIES ── */
.hidden { display: none !important; }

/* ── RESPONSIVE ── */
@media (max-width: 768px) {
  .dash-main { padding: 2rem 1rem 4rem; }
  .gen-field-row { grid-template-columns: 1fr; }
  .modal-field-row { grid-template-columns: 1fr; }
  .queue-header { flex-direction: column; align-items: flex-start; }
}
