/* ═════════════════════════════════════════════════════════════════════
   Saral Content — Clean Professional Dark Theme
   ═════════════════════════════════════════════════════════════════════ */

:root {
    --bg: #09090b;
    --surface: #18181b;
    --surface2: #27272a;
    --border: #27272a;
    --border2: #3f3f46;
    --text: #fafafa;
    --text2: #a1a1aa;
    --text3: #71717a;
    --primary: #7c3aed;
    --primary-hover: #6d28d9;
    --primary-glow: rgba(124, 58, 237, 0.15);
    --success: #059669;
    --success-bg: #022c22;
    --danger: #dc2626;
    --danger-bg: #1c0707;
    --warning: #d97706;
    --warning-bg: #1c1102;
    --info: #2563eb;
    --info-bg: #020d24;
    --radius: 10px;
    --radius-sm: 6px;
    --radius-lg: 14px;
    --shadow: 0 1px 2px rgba(0,0,0,0.4), 0 4px 12px rgba(0,0,0,0.3);
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

/* ── Navbar ─────────────────────────────── */
.navbar {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 100;
    backdrop-filter: blur(12px);
}
.navbar-inner {
    max-width: 1100px;
    margin: 0 auto;
    padding: 0 24px;
    height: 56px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.nav-brand {
    font-size: 18px;
    font-weight: 700;
    color: var(--text);
    text-decoration: none;
    letter-spacing: -0.3px;
}
.nav-right {
    display: flex;
    align-items: center;
    gap: 12px;
}
.nav-user {
    font-size: 13px;
    color: var(--text2);
}

/* ── Container ──────────────────────────── */
.container {
    max-width: 1100px;
    margin: 0 auto;
    padding: 32px 24px;
}

/* ── Buttons ────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px 16px;
    border-radius: var(--radius-sm);
    border: 1px solid transparent;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    background: var(--surface2);
    color: var(--text);
    transition: all 0.15s ease;
    white-space: nowrap;
}
.btn:hover { background: var(--border2); }
.btn:active { transform: scale(0.98); }

.btn-primary {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
}
.btn-primary:hover { background: var(--primary-hover); }

.btn-outline {
    background: transparent;
    border-color: var(--border2);
    color: var(--text2);
}
.btn-outline:hover { background: var(--surface2); color: var(--text); }

.btn-danger-outline {
    background: transparent;
    border-color: rgba(220,38,38,0.3);
    color: #f87171;
}
.btn-danger-outline:hover { background: var(--danger-bg); }

.btn-selected { background: var(--primary) !important; color: #fff !important; }

.btn-xs { padding: 4px 10px; font-size: 12px; border-radius: 5px; }
.btn-sm { padding: 6px 14px; font-size: 13px; }
.btn-lg { padding: 12px 24px; font-size: 15px; }
.btn-full { width: 100%; }
.btn-icon { font-size: 16px; }

/* ── Alerts ─────────────────────────────── */
.alert {
    padding: 10px 16px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 500;
    margin-bottom: 16px;
    border: 1px solid transparent;
}
.alert-success { background: var(--success-bg); color: #34d399; border-color: rgba(5,150,105,0.3); }
.alert-danger  { background: var(--danger-bg);  color: #f87171;  border-color: rgba(220,38,38,0.3); }
.alert-warning { background: var(--warning-bg); color: #fbbf24; border-color: rgba(217,119,6,0.3); }
.alert-info    { background: var(--info-bg);    color: #60a5fa;  border-color: rgba(37,99,235,0.3); }

/* ── Auth Pages ─────────────────────────── */
.auth-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: radial-gradient(ellipse at top, #1a1a2e 0%, var(--bg) 70%);
}
.auth-wrapper {
    width: 100%;
    max-width: 400px;
    padding: 20px;
}
.auth-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 40px 36px;
    box-shadow: var(--shadow);
}
.auth-icon {
    font-size: 40px;
    text-align: center;
    margin-bottom: 12px;
}
.auth-title {
    font-size: 24px;
    font-weight: 700;
    text-align: center;
    margin-bottom: 4px;
}
.auth-sub {
    text-align: center;
    color: var(--text3);
    font-size: 14px;
    margin-bottom: 28px;
}
.auth-form { display: flex; flex-direction: column; gap: 16px; }

/* ── Page Header ────────────────────────── */
.page-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    margin-bottom: 24px;
    flex-wrap: wrap;
    gap: 12px;
}
.page-title {
    font-size: 26px;
    font-weight: 700;
    letter-spacing: -0.5px;
}
.back-link {
    display: inline-block;
    color: var(--text2);
    font-size: 13px;
    text-decoration: none;
    margin-bottom: 6px;
}
.back-link:hover { color: var(--text); }
.header-actions {
    display: flex;
    gap: 8px;
    align-items: center;
}
.inline-form {
    display: flex;
    gap: 8px;
    align-items: center;
}

/* ── Inputs ─────────────────────────────── */
.field {
    display: flex;
    flex-direction: column;
    gap: 5px;
}
.field-label {
    font-size: 13px;
    font-weight: 600;
    color: var(--text2);
}
.field-hint {
    font-weight: 400;
    color: var(--text3);
    font-size: 12px;
}
.field-input {
    background: var(--surface);
    border: 1px solid var(--border2);
    border-radius: var(--radius-sm);
    padding: 9px 12px;
    color: var(--text);
    font-size: 14px;
    font-family: inherit;
    transition: border-color 0.15s, box-shadow 0.15s;
}
.field-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-glow);
}
.field-textarea { resize: vertical; min-height: 80px; }
.field-row {
    display: flex;
    gap: 16px;
}
.input-sm { padding: 6px 10px; font-size: 13px; }

select.field-input { cursor: pointer; }

/* ── Cards ──────────────────────────────── */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    margin-bottom: 24px;
    overflow: hidden;
}
.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px 0;
    flex-wrap: wrap;
    gap: 8px;
}
.card-title {
    font-size: 18px;
    font-weight: 600;
}
.card-badge {
    font-size: 11px;
    font-weight: 600;
    background: var(--primary-glow);
    color: #a78bfa;
    padding: 3px 10px;
    border-radius: 999px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.card-body { padding: 20px 24px; }

.generate-form {
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 18px;
}

/* ── Section Dividers ───────────────────── */
.section-divider {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 4px 0;
}
.section-divider::before,
.section-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--border2);
}
.section-divider span {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text3);
}

/* ── Toggle Switches ────────────────────── */
.toggle-row { padding-left: 0; }
.toggle {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    user-select: none;
}
.toggle input { display: none; }
.toggle-track {
    width: 36px;
    height: 20px;
    background: var(--border2);
    border-radius: 99px;
    position: relative;
    transition: background 0.2s;
    flex-shrink: 0;
}
.toggle-track::after {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    width: 16px;
    height: 16px;
    background: #fff;
    border-radius: 50%;
    transition: transform 0.2s;
}
.toggle input:checked + .toggle-track {
    background: var(--primary);
}
.toggle input:checked + .toggle-track::after {
    transform: translateX(16px);
}
.toggle-label-text {
    font-size: 13px;
    color: var(--text2);
}

/* ── Upload Zones ───────────────────────── */
.upload-zone {
    padding: 16px;
    border: 2px dashed var(--border2);
    border-radius: var(--radius);
    transition: border-color 0.2s;
}
.upload-zone:hover { border-color: var(--primary); }
.file-input {
    color: var(--text2);
    font-size: 13px;
}
.upload-preview {
    margin-top: 10px;
    position: relative;
    display: inline-block;
}
.upload-preview img {
    max-width: 180px;
    max-height: 180px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border2);
    object-fit: cover;
}
.preview-remove {
    position: absolute;
    top: -8px;
    right: -8px;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    border: 1px solid var(--border2);
    background: var(--surface);
    color: var(--text2);
    font-size: 14px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}
.preview-remove:hover { background: var(--danger-bg); color: #f87171; }

/* ── Actor Attributes ───────────────────── */
.attr-section {
    padding: 16px;
    background: var(--bg);
    border-radius: var(--radius);
    border: 1px solid var(--border);
}
.attr-heading {
    font-size: 13px;
    color: var(--text2);
    margin-bottom: 12px;
}
.attr-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
    gap: 12px;
}

/* ── Sections ───────────────────────────── */
.section-title {
    font-size: 20px;
    font-weight: 700;
    margin-bottom: 20px;
}

/* ── Thread Tiles ───────────────────────── */
.thread-grid {
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.thread-tile {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    text-decoration: none;
    color: var(--text);
    transition: border-color 0.15s, background 0.15s;
}
.thread-tile:hover {
    border-color: var(--primary);
    background: var(--surface2);
}
.tile-content { display: flex; flex-direction: column; gap: 2px; }
.tile-title { font-size: 15px; font-weight: 600; }
.tile-meta { font-size: 12px; color: var(--text3); }
.tile-arrow { color: var(--text3); font-size: 18px; }

/* ── Reference Images Strip ─────────────── */
.ref-strip {
    display: flex;
    gap: 10px;
    margin-bottom: 12px;
    flex-wrap: wrap;
}
.ref-thumb {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}
.ref-thumb img {
    width: 80px;
    height: 80px;
    object-fit: cover;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border2);
}
.ref-thumb span {
    font-size: 10px;
    color: var(--text3);
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

/* ── Actor Attributes Summary ───────────── */
.attrs-summary {
    font-size: 13px;
    color: var(--text2);
    margin-bottom: 8px;
    padding: 6px 10px;
    background: var(--bg);
    border-radius: var(--radius-sm);
    display: inline-block;
}
.attrs-label {
    color: #a78bfa;
    font-weight: 600;
}

/* ── Prompt Display ─────────────────────── */
.prompt-display {
    margin-top: 8px;
    margin-bottom: 8px;
}
.prompt-label {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.7px;
    color: var(--text3);
}
.prompt-text {
    font-size: 13px;
    color: var(--text2);
    margin-top: 4px;
    white-space: pre-wrap;
    line-height: 1.5;
    max-height: 150px;
    overflow-y: auto;
}

/* ── Timestamp ──────────────────────────── */
.timestamp {
    display: block;
    font-size: 11px;
    color: var(--text3);
    margin-top: 8px;
}

/* ── Image Gallery ──────────────────────── */
.gallery {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 16px;
    margin-top: 16px;
}
.gallery-card {
    background: var(--bg);
    border: 1px solid var(--border2);
    border-radius: var(--radius);
    overflow: hidden;
    transition: border-color 0.15s, box-shadow 0.15s;
}
.gallery-card:hover { border-color: var(--primary); }
.gallery-selected {
    border-color: var(--primary);
    box-shadow: 0 0 0 1px var(--primary), 0 0 20px var(--primary-glow);
}
.gallery-img-wrap {
    background: #000;
    min-height: 200px;
    display: flex;
    align-items: center;
    justify-content: center;
}
.gallery-img-wrap img {
    width: 100%;
    height: auto;
    display: block;
    max-height: 350px;
    object-fit: contain;
}
.gallery-actions {
    display: flex;
    gap: 6px;
    padding: 10px 12px;
}
.vary-form {
    display: flex;
    gap: 6px;
    padding: 0 12px 10px;
}
.vary-form .field-input { flex: 1; }

/* ── Variation Strip ────────────────────── */
.variation-strip {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    gap: 6px;
    padding: 0 12px 12px;
}
.var-item {
    background: var(--surface2);
    border-radius: var(--radius-sm);
    overflow: hidden;
}
.var-item img {
    width: 100%;
    height: auto;
    display: block;
}
.var-item span {
    display: block;
    padding: 3px 6px;
    font-size: 10px;
    color: var(--text3);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ── Empty States ───────────────────────── */
.empty-card {
    text-align: center;
    padding: 48px 20px;
    color: var(--text3);
    background: var(--surface);
    border: 1px dashed var(--border2);
    border-radius: var(--radius-lg);
}
.empty-icon { font-size: 48px; margin-bottom: 12px; }
.empty-card p { font-size: 14px; }

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

/* ── History Section ─────────────────────── */
.prompt-block {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    margin-bottom: 16px;
}
.prompt-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}
.prompt-id {
    font-size: 12px;
    color: var(--text3);
    font-weight: 600;
}
.history-section {
    margin-top: 32px;
}

/* ── Auth Footer ────────────────────────── */
.auth-footer {
    text-align: center;
    margin-top: 20px;
    font-size: 13px;
    color: var(--text2);
}
.auth-footer a {
    color: var(--primary);
    text-decoration: none;
    font-weight: 600;
}
.auth-footer a:hover { text-decoration: underline; }

/* ── Wide Auth Card (Signup) ────────────── */
.auth-card-wide {
    max-width: 480px !important;
}

/* ── Warning Button ─────────────────────── */
.btn-warning {
    background: var(--warning);
    color: #000;
    border-color: var(--warning);
}
.btn-warning:hover { background: #b45309; color: #fff; }

/* ── Success Button ─────────────────────── */
.btn-success {
    background: var(--success);
    color: #fff;
    border-color: var(--success);
}
.btn-success:hover { background: #047857; }
