/* ClipEngine — App UI */

:root {
  --bg: #0d0d0d;
  --bg-2: #111111;
  --bg-3: #161616;
  --fg: #f5f0e8;
  --fg-dim: rgba(245, 240, 232, 0.45);
  --accent: #00ff6a;
  --accent-dim: rgba(0, 255, 106, 0.12);
  --accent-glow: rgba(0, 255, 106, 0.2);
  --border: rgba(245, 240, 232, 0.08);
  --grid-line: rgba(0, 255, 106, 0.04);
  --danger: #ff4444;
}

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

body {
  background: var(--bg);
  color: var(--fg);
  font-family: 'DM Sans', system-ui, sans-serif;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

h1, h2, h3 {
  font-family: 'Bebas Neue', 'Arial Black', sans-serif;
  letter-spacing: 0.02em;
  line-height: 1.05;
}

/* ===== LAYOUT ===== */
.app-shell {
  max-width: 680px;
  margin: 0 auto;
  padding: 40px 24px 80px;
}

.app-header {
  margin-bottom: 48px;
}

.app-header h1 {
  font-size: 3rem;
  color: var(--accent);
  margin-bottom: 4px;
}

.app-header p {
  color: var(--fg-dim);
  font-size: 0.95rem;
}

/* ===== CARD ===== */
.card {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 28px;
  margin-bottom: 20px;
}

/* ===== FORM ===== */
.topic-form { width: 100%; }

.form-row {
  display: flex;
  gap: 12px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.form-group { flex: 1; min-width: 200px; }

label {
  display: block;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--fg-dim);
  margin-bottom: 8px;
}

input[type="text"], select {
  width: 100%;
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 16px;
  color: var(--fg);
  font-size: 1rem;
  font-family: inherit;
  outline: none;
  transition: border-color 0.2s;
}

input[type="text"]:focus, select:focus {
  border-color: var(--accent);
}

select { cursor: pointer; }

/* ===== BUTTON ===== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: var(--accent);
  color: #000;
  border: none;
  border-radius: 8px;
  padding: 14px 28px;
  font-size: 0.95rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.2s;
  letter-spacing: 0.01em;
}

.btn:hover { filter: brightness(1.1); transform: translateY(-1px); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

.btn-large { width: 100%; padding: 16px; font-size: 1.05rem; }

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

/* ===== STATUS ===== */
.status-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 20px;
  padding: 12px 16px;
  background: var(--bg-3);
  border-radius: 8px;
  font-size: 0.85rem;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--fg-dim);
  flex-shrink: 0;
}

.status-dot.active {
  background: var(--accent);
  box-shadow: 0 0 8px var(--accent-glow);
  animation: pulse 1.5s ease-in-out infinite;
}

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

/* ===== SCRIPT PREVIEW ===== */
.script-preview {
  background: var(--bg-3);
  border-radius: 8px;
  padding: 20px;
  margin-bottom: 24px;
  font-size: 0.9rem;
  line-height: 1.8;
  white-space: pre-wrap;
  max-height: 400px;
  overflow-y: auto;
}

.script-preview::-webkit-scrollbar { width: 4px; }
.script-preview::-webkit-scrollbar-track { background: var(--bg-3); }
.script-preview::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

/* ===== VIDEO PREVIEW ===== */
.video-preview {
  display: none;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  margin-bottom: 24px;
}

.video-preview.visible { display: flex; }

.preview-wrapper {
  position: relative;
  width: 270px; /* 9:16 at scale */
  height: 480px;
  border-radius: 12px;
  overflow: hidden;
  border: 2px solid var(--border);
}

#previewCanvas {
  display: block;
  width: 100%;
  height: 100%;
}

.preview-badge {
  position: absolute;
  top: 12px;
  left: 12px;
  background: var(--accent);
  color: #000;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  padding: 4px 8px;
  border-radius: 4px;
}

/* ===== DOWNLOAD ===== */
.download-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.download-actions .btn {
  flex: 1;
  min-width: 140px;
}

/* ===== ERROR ===== */
.error-msg {
  background: rgba(255, 68, 68, 0.1);
  border: 1px solid var(--danger);
  border-radius: 8px;
  padding: 12px 16px;
  color: var(--danger);
  font-size: 0.9rem;
  margin-bottom: 16px;
  display: none;
}

.error-msg.visible { display: block; }

/* ===== RESPONSIVE ===== */
@media (max-width: 480px) {
  .app-shell { padding: 24px 16px 60px; }
  .app-header h1 { font-size: 2.2rem; }
  .form-row { flex-direction: column; }
  .form-group { min-width: unset; }
  .download-actions { flex-direction: column; }
  .download-actions .btn { min-width: unset; }
}