/* ═══════════════════════════════════════════
   CKTec Video Creator — Flow-inspired Design
   ═══════════════════════════════════════════ */

:root {
    --bg-base: #1a1a1a;
    --bg-surface: #242424;
    --bg-raised: #2e2e2e;
    --bg-elevated: #383838;
    --bg-input: #1e1e1e;

    --accent: #e94560;
    --accent-dim: rgba(233, 69, 96, 0.12);
    --accent-hover: #d53a54;
    --blue: #5b9cf4;
    --blue-dim: rgba(91, 156, 244, 0.12);
    --green: #4caf50;
    --green-dim: rgba(76, 175, 80, 0.12);

    --text: #e8e8e8;
    --text-secondary: #999;
    --text-muted: #666;

    --border: rgba(255,255,255,0.08);
    --radius: 12px;
    --radius-sm: 8px;
    --radius-lg: 16px;

    --font: 'Outfit', -apple-system, sans-serif;
    --font-body: 'DM Sans', -apple-system, sans-serif;
    --nav-h: 56px;
    --safe-bottom: env(safe-area-inset-bottom, 0px);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; -webkit-tap-highlight-color: transparent; }

body {
    font-family: var(--font-body);
    background: var(--bg-base);
    color: var(--text);
    min-height: 100dvh;
    -webkit-font-smoothing: antialiased;
}

/* ── Nav ───────────────────────────────── */
.nav {
    position: fixed;
    top: 0; left: 0; right: 0;
    height: var(--nav-h);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    background: rgba(26,26,26,0.92);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-bottom: 1px solid var(--border);
    z-index: 100;
}

.nav__brand {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
}

.nav__logo-mark {
    width: 32px; height: 32px;
    background: var(--accent);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: var(--font);
    font-weight: 800;
    font-size: 12px;
    color: white;
}

.nav__title {
    font-family: var(--font);
    font-weight: 600;
    font-size: 15px;
}

.nav__settings {
    background: none;
    border: none;
    color: var(--text-secondary);
    padding: 8px;
    cursor: pointer;
    border-radius: var(--radius-sm);
    transition: all 0.15s;
}
.nav__settings:active { color: var(--text); background: var(--bg-raised); }

/* ── Views ─────────────────────────────── */
.view {
    position: relative;
    padding: calc(var(--nav-h) + 12px) 16px calc(20px + var(--safe-bottom));
    min-height: 100dvh;
    display: none;
    animation: fadeIn 0.25s ease;
}
.view--active { display: block; }

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ── Hero ──────────────────────────────── */
.hero { padding: 20px 0 16px; position: relative; }
.hero__stripe {
    position: absolute;
    top: 0; left: -16px;
    width: 3px; height: 100%;
    background: linear-gradient(180deg, var(--accent), transparent 85%);
}
.hero__title {
    font-family: var(--font);
    font-size: 28px;
    font-weight: 800;
    letter-spacing: -1px;
}
.hero__sub {
    font-size: 14px;
    color: var(--text-secondary);
    margin-top: 2px;
}

/* ── Buttons ───────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-family: var(--font);
    font-weight: 600;
    font-size: 14px;
    border: none;
    border-radius: var(--radius);
    padding: 12px 20px;
    cursor: pointer;
    transition: all 0.15s;
    text-decoration: none;
}

.btn--primary { background: var(--accent); color: white; }
.btn--primary:active { background: var(--accent-hover); transform: scale(0.97); }

.btn--secondary { background: var(--blue); color: white; }
.btn--secondary:active { transform: scale(0.97); }

.btn--outline {
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--border);
}

.btn--sm { padding: 8px 16px; font-size: 13px; border-radius: var(--radius-sm); }

.btn--new-project {
    width: 100%;
    padding: 14px;
    margin-bottom: 16px;
}

.btn--generate {
    width: 100%;
    padding: 16px;
    font-size: 15px;
    background: var(--accent);
    color: white;
    border-radius: var(--radius);
}
.btn--generate:active { transform: scale(0.98); }
.btn--generate:disabled { opacity: 0.35; pointer-events: none; }
.btn__text { flex: 1; }
.btn__icon { display: flex; }

.btn-back, .btn-delete-project {
    background: none;
    border: none;
    color: var(--text-secondary);
    padding: 8px;
    cursor: pointer;
    border-radius: var(--radius-sm);
}

.btn--loading { pointer-events: none; opacity: 0.7; }
.btn--loading::after {
    content: '';
    width: 16px; height: 16px;
    border: 2px solid transparent;
    border-top-color: currentColor;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
    margin-left: 8px;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Projects List ─────────────────────── */
.projects-list { display: flex; flex-direction: column; gap: 10px; }

.project-card {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 14px 16px;
    cursor: pointer;
    transition: background 0.15s;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.project-card:active { background: var(--bg-raised); }

.project-card__title {
    font-family: var(--font);
    font-weight: 600;
    font-size: 15px;
}

.project-card__meta {
    display: flex;
    gap: 12px;
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 3px;
}

.project-card__status {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    padding: 4px 10px;
    border-radius: 6px;
    white-space: nowrap;
    flex-shrink: 0;
}
.project-card__status[data-s="draft"] { background: var(--bg-elevated); color: var(--text-muted); }
.project-card__status[data-s="generating"] { background: var(--blue-dim); color: var(--blue); }
.project-card__status[data-s="completed"] { background: var(--green-dim); color: var(--green); }
.project-card__status[data-s="error"] { background: var(--accent-dim); color: var(--accent); }

/* ── Empty State ───────────────────────── */
.empty-state { text-align: center; padding: 48px 20px; color: var(--text-muted); }
.empty-state--small { padding: 32px 20px; }
.empty-state__icon { margin-bottom: 12px; opacity: 0.3; }
.empty-state__hint { font-size: 13px; margin-top: 4px; }

/* ── Editor Header ─────────────────────── */
.editor-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 0 12px;
}
.editor-header__title {
    flex: 1;
    background: none;
    border: none;
    color: var(--text);
    font-family: var(--font);
    font-weight: 700;
    font-size: 18px;
    letter-spacing: -0.3px;
    outline: none;
    padding: 4px 0;
    border-bottom: 2px solid transparent;
}
.editor-header__title:focus { border-color: var(--accent); }
.editor-header__title::placeholder { color: var(--text-muted); }
.editor-header__label {
    font-family: var(--font);
    font-weight: 700;
    font-size: 18px;
    flex: 1;
}

/* ── Add Actions (Upload + AI) ─────────── */
.add-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-bottom: 16px;
}

.add-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 20px 12px;
    background: var(--bg-surface);
    border: 1.5px dashed rgba(255,255,255,0.1);
    border-radius: var(--radius);
    color: var(--text-secondary);
    font-family: var(--font);
    font-weight: 500;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.15s;
}
.add-btn:active {
    background: var(--bg-raised);
    border-color: var(--accent);
    color: var(--text);
}

/* ── AI Prompt Box ─────────────────────── */
.ai-prompt-box {
    background: var(--bg-surface);
    border: 1px solid rgba(91, 156, 244, 0.3);
    border-radius: var(--radius);
    padding: 14px;
    margin-bottom: 16px;
    animation: fadeIn 0.2s ease;
}

.ai-prompt-input {
    width: 100%;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-family: var(--font-body);
    font-size: 14px;
    padding: 10px 12px;
    resize: none;
    outline: none;
    line-height: 1.4;
    transition: border-color 0.15s;
}
.ai-prompt-input:focus { border-color: var(--blue); }
.ai-prompt-input::placeholder { color: var(--text-muted); }

.ai-prompt-actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
    margin-top: 10px;
}

/* ── Photo Grid ────────────────────────── */
.photo-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
    margin-bottom: 8px;
}

.photo-card {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    position: relative;
    animation: cardIn 0.25s ease both;
}
@keyframes cardIn {
    from { opacity: 0; transform: scale(0.94); }
    to { opacity: 1; transform: scale(1); }
}

.photo-card__img {
    width: 100%;
    aspect-ratio: 1;
    object-fit: cover;
    display: block;
    background: var(--bg-raised);
}

.photo-card__caption {
    padding: 6px 10px 8px;
}
.photo-card__caption input {
    width: 100%;
    background: none;
    border: none;
    color: var(--text);
    font-family: var(--font-body);
    font-size: 12px;
    outline: none;
    padding: 2px 0;
    border-bottom: 1px solid transparent;
}
.photo-card__caption input:focus { border-color: var(--accent); }
.photo-card__caption input::placeholder { color: var(--text-muted); }

.photo-card__delete {
    position: absolute;
    top: 6px; right: 6px;
    width: 26px; height: 26px;
    background: rgba(0,0,0,0.6);
    backdrop-filter: blur(6px);
    border: none;
    color: white;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.15s;
}
.photo-card:hover .photo-card__delete { opacity: 1; }
@media (hover: none) { .photo-card__delete { opacity: 0.8; } }

.photo-card__badge {
    position: absolute;
    top: 6px; left: 6px;
    background: rgba(91, 156, 244, 0.85);
    backdrop-filter: blur(6px);
    color: white;
    font-family: var(--font);
    font-size: 9px;
    font-weight: 700;
    padding: 2px 7px;
    border-radius: 5px;
    letter-spacing: 0.5px;
    text-transform: uppercase;
}

/* Loading card while AI generates */
.photo-card--loading {
    min-height: 120px;
    display: flex;
    align-items: center;
    justify-content: center;
}
.photo-card--loading::after {
    content: '';
    width: 24px; height: 24px;
    border: 2.5px solid var(--bg-elevated);
    border-top-color: var(--blue);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}

/* ── Editor Settings ───────────────────── */
.editor-settings {
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid var(--border);
}
.editor-settings__title {
    font-family: var(--font);
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 1.2px;
    text-transform: uppercase;
    color: var(--text-muted);
    margin-bottom: 14px;
}
.setting-group { margin-bottom: 14px; }
.setting-label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 6px;
}
.setting-chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
    font-family: var(--font);
    font-weight: 500;
    font-size: 13px;
    color: var(--text-secondary);
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 7px 14px;
    cursor: pointer;
    transition: all 0.15s;
}
.chip--active {
    background: var(--accent-dim);
    border-color: rgba(233, 69, 96, 0.35);
    color: var(--accent);
}

/* ── Editor Actions ────────────────────── */
.editor-actions {
    position: sticky;
    bottom: 0;
    padding: 12px 0 calc(8px + var(--safe-bottom));
    background: linear-gradient(to top, var(--bg-base) 70%, transparent);
    margin-top: 16px;
}

/* ── Status ────────────────────────────── */
.status-panel {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 16px 0;
}
.status-ring {
    position: relative;
    width: 120px; height: 120px;
    margin-bottom: 24px;
}
.status-ring svg { width: 100%; height: 100%; }
.status-ring__label {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: var(--font);
    font-weight: 700;
    font-size: 24px;
}
#status-ring-progress { transition: stroke-dashoffset 0.4s ease; }

.status-steps { width: 100%; max-width: 340px; display: flex; flex-direction: column; gap: 8px; }
.status-step {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 13px;
    color: var(--text-secondary);
}
.status-step__dot {
    width: 8px; height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}
.status-step__dot--pending { background: var(--text-muted); opacity: 0.4; }
.status-step__dot--generating { background: var(--blue); animation: pulse-dot 1s ease infinite; }
.status-step__dot--completed { background: var(--green); }
.status-step__dot--error { background: var(--accent); }
@keyframes pulse-dot {
    0%, 100% { box-shadow: 0 0 0 0 rgba(91,156,244,0.4); }
    50% { box-shadow: 0 0 0 5px rgba(91,156,244,0); }
}

.status-complete { animation: fadeIn 0.3s ease; }
.status-complete__player {
    border-radius: var(--radius);
    overflow: hidden;
    background: #000;
    border: 1px solid var(--border);
    margin-bottom: 16px;
}
.status-complete__player video { width: 100%; display: block; max-height: 55vh; }
.status-complete__actions { display: flex; gap: 10px; }
.status-complete__actions .btn { flex: 1; padding: 14px; }

.status-error { text-align: center; padding: 40px; color: var(--accent); }
.status-error p { font-family: var(--font); font-weight: 600; margin-bottom: 14px; }

/* ── Branding ──────────────────────────── */
.branding-section { display: flex; flex-direction: column; gap: 16px; }
.branding-logo-upload { display: flex; justify-content: center; margin-bottom: 4px; }
.branding-logo-box {
    width: 120px; height: 120px;
    border: 1.5px dashed var(--border);
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    overflow: hidden;
    transition: border-color 0.15s;
}
.branding-logo-box:active { border-color: var(--accent); }
.branding-logo-box img { width: 100%; height: 100%; object-fit: contain; padding: 10px; }
.branding-logo-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    color: var(--text-muted);
    font-size: 11px;
}
.branding-field { display: flex; flex-direction: column; gap: 4px; }
.color-input-row { display: flex; gap: 8px; align-items: center; }
.color-swatch {
    width: 40px; height: 40px;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    padding: 0;
    -webkit-appearance: none;
}
.color-swatch::-webkit-color-swatch-wrapper { padding: 2px; }
.color-swatch::-webkit-color-swatch { border: 1px solid var(--border); border-radius: 6px; }

.input {
    width: 100%;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-family: var(--font-body);
    font-size: 14px;
    padding: 10px 12px;
    outline: none;
    transition: border-color 0.15s;
}
.input:focus { border-color: var(--accent); }
.input::placeholder { color: var(--text-muted); }
.input--small { width: 100px; }

.toggle { display: inline-flex; cursor: pointer; }
.toggle input { display: none; }
.toggle__track {
    width: 42px; height: 24px;
    background: var(--bg-elevated);
    border-radius: 12px;
    position: relative;
    transition: background 0.15s;
}
.toggle__track::after {
    content: '';
    position: absolute;
    width: 18px; height: 18px;
    background: var(--text-muted);
    border-radius: 50%;
    top: 3px; left: 3px;
    transition: all 0.15s;
}
.toggle input:checked + .toggle__track { background: var(--accent-dim); }
.toggle input:checked + .toggle__track::after { background: var(--accent); transform: translateX(18px); }

/* ── Toast ─────────────────────────────── */
.toast {
    position: fixed;
    bottom: calc(20px + var(--safe-bottom));
    left: 50%;
    transform: translateX(-50%) translateY(60px);
    background: var(--bg-elevated);
    color: var(--text);
    font-family: var(--font);
    font-weight: 500;
    font-size: 14px;
    padding: 10px 20px;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    box-shadow: 0 8px 30px rgba(0,0,0,0.4);
    z-index: 200;
    opacity: 0;
    transition: all 0.25s ease;
    pointer-events: none;
    white-space: nowrap;
}
.toast--visible { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast--error { border-color: var(--accent); color: var(--accent); }

/* ── Responsive ────────────────────────── */
@media (min-width: 480px) {
    .photo-grid { grid-template-columns: repeat(3, 1fr); }
}
@media (min-width: 768px) {
    .view { max-width: 560px; margin: 0 auto; }
}
