/* ===== ShortsForge — Dark Theme ===== */

:root {
    --bg-0: #0b0d12;
    --bg-1: #11141b;
    --bg-2: #181c25;
    --bg-3: #1f2430;
    --border: #262c39;
    --border-soft: #1c2230;

    --text-0: #f3f5f9;
    --text-1: #c8cdd9;
    --text-2: #8a93a6;
    --text-muted: #6b7385;

    --accent: #ff3d6e;
    --accent-2: #6c5cff;
    --accent-grad: linear-gradient(135deg, #ff3d6e 0%, #ff7a3d 50%, #6c5cff 100%);

    --success: #2ecc71;
    --warn: #f0b429;
    --error: #ff5a5f;

    --radius-sm: 6px;
    --radius: 10px;
    --radius-lg: 16px;

    --shadow-1: 0 1px 2px rgba(0,0,0,0.4);
    --shadow-2: 0 8px 24px rgba(0,0,0,0.45);
    --shadow-glow: 0 0 0 1px rgba(108,92,255,0.25), 0 8px 32px rgba(255,61,110,0.15);

    --font: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    background: var(--bg-0);
    color: var(--text-0);
    font-family: var(--font);
    font-size: 15px;
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
    min-height: 100vh;
}

body {
    background:
        radial-gradient(1200px 600px at 80% -10%, rgba(108,92,255,0.18), transparent 60%),
        radial-gradient(900px 500px at -10% 30%, rgba(255,61,110,0.12), transparent 60%),
        var(--bg-0);
}

a { color: var(--accent); text-decoration: none; }
a:hover { color: #ff6b8e; }

h1, h2, h3, h4 { color: var(--text-0); margin: 0 0 .5em; line-height: 1.2; font-weight: 600; }
h1 { font-size: 2rem; }
h2 { font-size: 1.4rem; }
h3 { font-size: 1.15rem; }
h4 { font-size: 1rem; }

p { color: var(--text-1); margin: .25em 0 1em; }
.muted { color: var(--text-muted) !important; }
.small { font-size: 0.85rem; }
.grad { background: var(--accent-grad); -webkit-background-clip: text; background-clip: text; color: transparent; }

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 24px;
}

/* ---- Header ---- */
.app-header {
    position: sticky;
    top: 0;
    z-index: 50;
    background: rgba(11,13,18,0.85);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border-soft);
}
.header-inner {
    display: flex;
    align-items: center;
    height: 64px;
    gap: 32px;
}
.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--text-0);
    font-weight: 700;
    font-size: 1.05rem;
}
.brand:hover { color: var(--text-0); }
.brand-mark {
    width: 32px; height: 32px;
    border-radius: 8px;
    background: var(--accent-grad);
    display: grid; place-items: center;
    font-weight: 800; font-size: .8rem; color: #fff;
    box-shadow: var(--shadow-1);
}
.nav-primary { display: flex; gap: 18px; flex: 1; }
.nav-primary a {
    color: var(--text-1);
    font-weight: 500;
    padding: 8px 4px;
    border-bottom: 2px solid transparent;
    transition: color .15s, border-color .15s;
}
.nav-primary a:hover { color: var(--text-0); border-bottom-color: var(--accent); }

.user-area { display: flex; align-items: center; gap: 12px; }
.user-name { color: var(--text-2); font-size: .9rem; }
.logout-form { display: inline; margin: 0; }

/* ---- Buttons ---- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 9px 16px;
    border-radius: var(--radius);
    border: 1px solid transparent;
    font-family: var(--font);
    font-size: .9rem;
    font-weight: 500;
    cursor: pointer;
    transition: transform .08s, background .15s, border-color .15s, opacity .15s;
    text-decoration: none;
    background: var(--bg-2);
    color: var(--text-0);
}
.btn:hover { background: var(--bg-3); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.btn-primary {
    background: var(--accent-grad);
    color: #fff;
    border: none;
    box-shadow: var(--shadow-1);
}
.btn-primary:hover { filter: brightness(1.1); color: #fff; }

.btn-ghost {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-1);
}
.btn-ghost:hover { border-color: var(--accent); color: var(--text-0); }

.btn-lg { padding: 13px 24px; font-size: 1rem; }

/* ---- Main / Footer ---- */
.main { padding: 32px 0 64px; }
.app-footer {
    border-top: 1px solid var(--border-soft);
    padding: 24px 0;
    color: var(--text-muted);
    font-size: .85rem;
}
.footer-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
}

/* ---- Cards ---- */
.card {
    background: var(--bg-1);
    border: 1px solid var(--border-soft);
    border-radius: var(--radius-lg);
    padding: 24px;
    margin-bottom: 24px;
    box-shadow: var(--shadow-1);
}

.empty-state { text-align: center; padding: 48px 24px; }

/* ---- Alerts ---- */
.alert {
    padding: 12px 16px;
    border-radius: var(--radius);
    margin-bottom: 16px;
    border: 1px solid var(--border);
}
.alert-error { background: rgba(255,90,95,.1); border-color: var(--error); color: var(--error); }

/* ---- Hero ---- */
.hero {
    position: relative;
    padding: 80px 0 60px;
    overflow: hidden;
}
.hero-content { position: relative; max-width: 800px; z-index: 2; }
.hero-title { font-size: clamp(2rem, 4.5vw, 3.4rem); font-weight: 700; line-height: 1.1; margin-bottom: 16px; }
.hero-sub { font-size: 1.15rem; color: var(--text-1); max-width: 680px; }
.hero-cta { margin-top: 28px; display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.hero-note { color: var(--text-muted); font-size: .85rem; }

.hero-art { position: absolute; inset: 0; pointer-events: none; z-index: 1; }
.orb { position: absolute; border-radius: 50%; filter: blur(60px); opacity: .55; }
.orb-1 { width: 320px; height: 320px; background: #ff3d6e; top: -40px; right: -60px; }
.orb-2 { width: 260px; height: 260px; background: #6c5cff; top: 80px; right: 220px; }
.orb-3 { width: 200px; height: 200px; background: #ff7a3d; top: 220px; right: -40px; }

.features {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 20px;
    margin-top: 32px;
}
.feature {
    background: var(--bg-1);
    border: 1px solid var(--border-soft);
    border-radius: var(--radius-lg);
    padding: 24px;
}
.feature-icon { font-size: 1.6rem; margin-bottom: 12px; }

/* ---- Content pages ---- */
.content-shell {
    max-width: 860px;
}
.content-shell h1 {
    margin-bottom: 12px;
}
.content-shell h2 {
    margin-top: 28px;
}
.content-shell ul {
    margin: 0 0 18px;
    padding-left: 20px;
    color: var(--text-1);
}
.content-shell li {
    margin-bottom: 10px;
}

/* ---- Dashboard ---- */
.dashboard-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 24px;
    margin-bottom: 24px;
    flex-wrap: wrap;
}
.stat-pill {
    background: var(--bg-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 12px 20px;
    text-align: center;
}
.stat-num { display: block; font-size: 1.6rem; font-weight: 700; }
.stat-label { font-size: .8rem; color: var(--text-muted); }

/* Toolbar / sort tabs */
.toolbar {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    margin-bottom: 16px;
}
.sort-tabs {
    display: inline-flex;
    background: var(--bg-2);
    border: 1px solid var(--border);
    border-radius: 999px;
    padding: 4px;
    gap: 2px;
}
.sort-tab {
    padding: 8px 16px;
    border-radius: 999px;
    font-size: .9rem;
    color: var(--text-muted);
    text-decoration: none;
    transition: background .15s, color .15s;
}
.sort-tab:hover { color: var(--text-0); }
.sort-tab.active {
    background: var(--accent, #6e8bff);
    color: #fff;
    font-weight: 600;
}

.video-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 20px;
}

.video-card {
    background: var(--bg-1);
    border: 1px solid var(--border-soft);
    border-radius: var(--radius-lg);
    overflow: hidden;
    transition: transform .15s, border-color .15s, box-shadow .15s;
    color: var(--text-0);
    display: flex;
    flex-direction: column;
}
.video-card:hover {
    transform: translateY(-3px);
    border-color: var(--accent);
    box-shadow: var(--shadow-2);
    color: var(--text-0);
}

.thumb {
    position: relative;
    width: 100%;
    aspect-ratio: 16 / 9;
    background: var(--bg-3);
    overflow: hidden;
}
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb-duration {
    position: absolute;
    right: 8px; bottom: 8px;
    background: rgba(0,0,0,.75);
    color: #fff;
    font-size: .75rem;
    padding: 2px 6px;
    border-radius: 4px;
}

.video-meta { padding: 12px 14px 16px; }
.video-title {
    font-size: .95rem;
    margin: 0 0 6px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.video-stats { color: var(--text-muted); font-size: .8rem; display: flex; gap: 12px; flex-wrap: wrap; }

/* ---- Video Details ---- */
.back-link {
    display: inline-block;
    color: var(--text-2);
    margin-bottom: 16px;
    font-size: .9rem;
}
.back-link:hover { color: var(--text-0); }

.video-details {
    display: grid;
    grid-template-columns: 1.6fr 1fr;
    gap: 24px;
    margin-bottom: 24px;
}
.player-wrap {
    aspect-ratio: 16/9;
    background: #000;
    border-radius: var(--radius-lg);
    overflow: hidden;
    border: 1px solid var(--border-soft);
}
.player-wrap iframe { width: 100%; height: 100%; border: 0; }

.video-info { background: var(--bg-1); border: 1px solid var(--border-soft); border-radius: var(--radius-lg); padding: 20px; }
.video-info .video-stats { gap: 16px; margin: 8px 0 16px; }
.desc summary { cursor: pointer; color: var(--text-2); }
.desc pre { white-space: pre-wrap; word-wrap: break-word; color: var(--text-1); font-family: inherit; font-size: .9rem; margin-top: 8px; }

/* ---- Form ---- */
.generator-panel { }
.form-row { margin-bottom: 16px; }
.form-row label { display: block; font-size: .85rem; color: var(--text-2); margin-bottom: 6px; }
.form-row.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; align-items: end; }

input[type=text], input[type=number], textarea {
    width: 100%;
    background: var(--bg-2);
    border: 1px solid var(--border);
    color: var(--text-0);
    padding: 10px 12px;
    border-radius: var(--radius);
    font-family: var(--font);
    font-size: .95rem;
    transition: border-color .15s;
}
textarea { resize: vertical; }
input:focus, textarea:focus {
    outline: none;
    border-color: var(--accent-2);
    box-shadow: 0 0 0 3px rgba(108,92,255,.18);
}

.checkbox-row { display: flex; align-items: center; gap: 12px; padding-top: 24px; color: var(--text-1); }

/* iOS-style switch */
.switch { position: relative; display: inline-block; width: 44px; height: 24px; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch .slider {
    position: absolute; cursor: pointer;
    inset: 0;
    background-color: var(--bg-3);
    transition: .2s;
    border-radius: 24px;
}
.switch .slider::before {
    position: absolute; content: "";
    height: 18px; width: 18px;
    left: 3px; bottom: 3px;
    background-color: #fff;
    transition: .2s;
    border-radius: 50%;
}
.switch input:checked + .slider { background: var(--accent-grad); }
.switch input:checked + .slider::before { transform: translateX(20px); }

/* Spinner */
.spinner {
    display: inline-block;
    width: 16px; height: 16px;
    border: 2px solid rgba(255,255,255,.4);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin .9s linear infinite;
}
.spinner[hidden] { display: none; }
@@keyframes spin { to { transform: rotate(360deg); } }

/* ---- Generation Status ---- */
.generation-status {
    margin-top: 16px;
    padding: 12px 16px;
    border-radius: var(--radius);
    background: var(--bg-2);
    border: 1px solid var(--border);
    color: var(--text-1);
}
.generation-status.error { border-color: var(--error); color: var(--error); background: rgba(255,90,95,.06); }
.generation-status.success { border-color: var(--success); color: var(--success); background: rgba(46,204,113,.06); }

.generation-status .progress-message {
    font-size: 14px;
    margin-bottom: 8px;
}
.generation-status .progress-track {
    height: 8px;
    border-radius: 999px;
    background: rgba(255,255,255,.08);
    overflow: hidden;
}
.generation-status .progress-track .bar {
    height: 100%;
    background: var(--accent, #6e8bff);
    border-radius: 999px;
    transition: width .35s ease;
}
.generation-status .progress-track .bar.bar-success { background: var(--success); }
.generation-status .progress-track .bar.bar-error   { background: var(--error); }
.generation-status .progress-percent {
    margin-top: 6px;
    font-size: 12px;
    color: var(--text-2, #aaa);
    text-align: right;
}

.generation-results { margin-top: 16px; }
.generation-results .result-item {
    padding: 10px 14px;
    margin-bottom: 8px;
    background: var(--bg-2);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    gap: 12px;
}

/* ---- Shorts list (existing) ---- */
.shorts-list { list-style: none; padding: 0; margin: 0; }
.short-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px;
    background: var(--bg-2);
    border-radius: var(--radius);
    margin-bottom: 8px;
    gap: 12px;
}
.short-meta { display: flex; flex-direction: column; gap: 4px; }
.short-actions { display: flex; gap: 8px; }

/* ---- Shorts grid (Video Details page) ---- */
.shorts-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 16px;
}
.short-card {
    background: var(--bg-2);
    border: 1px solid var(--border-soft);
    border-radius: var(--radius-lg);
    padding: 0;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    gap: 0;
    animation: fadeInShort .25s ease-out;
}
@keyframes fadeInShort {
    from { opacity: 0; transform: translateY(6px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* Thumbnail with play overlay + score badge */
.short-thumb {
    position: relative;
    aspect-ratio: 9/16;
    background: #000;
    overflow: hidden;
    max-height: 320px;
}
.short-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}
.thumb-placeholder {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-3);
}
.thumb-spinner {
    width: 28px;
    height: 28px;
    border: 3px solid var(--border);
    border-top-color: var(--accent, #6e8bff);
    border-radius: 50%;
    animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.play-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,.18);
    border: 0;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background .15s;
}
.play-overlay:hover { background: rgba(0,0,0,.36); }
.play-icon {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: rgba(255,255,255,.92);
    color: #000;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4rem;
    padding-left: 4px;
    box-shadow: 0 4px 16px rgba(0,0,0,.4);
    transition: transform .15s;
}
.play-overlay:hover .play-icon { transform: scale(1.08); }

.short-card-body {
    padding: 12px 14px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    flex: 1;
}
.short-card-body h4 {
    margin: 0;
    font-size: 1rem;
    line-height: 1.3;
}
.short-desc {
    margin: 6px 0 0 0;
    font-size: .85rem;
    color: var(--text-1);
    white-space: pre-wrap;
    max-height: 4.5em;
    overflow: hidden;
}
.short-card-actions {
    display: flex;
    gap: 8px;
    padding: 0 14px 14px 14px;
}
.short-card-actions .btn { flex: 1; text-align: center; }
.btn-sm { padding: 6px 12px; font-size: .85rem; }

/* Score badge — gradient pill on top-right of thumbnail. */
.score-badge {
    position: absolute;
    top: 8px;
    right: 8px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 44px;
    height: 28px;
    padding: 0 10px;
    border-radius: 999px;
    font-weight: 700;
    font-size: .9rem;
    color: #fff;
    z-index: 2;
    pointer-events: none;
}
.score-badge.score-high {
    background: linear-gradient(135deg, #ff5f6d 0%, #ffc371 100%);
    box-shadow: 0 2px 12px rgba(255, 95, 109, .45);
}
.score-badge.score-mid {
    background: linear-gradient(135deg, #6e8bff 0%, #8e7bff 100%);
}
.score-badge.score-low {
    background: rgba(0,0,0,.6);
    color: #ddd;
}

/* ---- Modals ---- */
.modal {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    animation: modalFade .15s ease-out;
}
.modal[hidden] { display: none; }
@keyframes modalFade { from { opacity: 0; } to { opacity: 1; } }
.modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,.7);
    backdrop-filter: blur(4px);
    cursor: pointer;
}
.modal-panel {
    position: relative;
    background: var(--bg-1);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 24px;
    max-width: 560px;
    width: 100%;
    max-height: 90vh;
    overflow: auto;
    box-shadow: 0 20px 60px rgba(0,0,0,.6);
    animation: modalSlide .2s ease-out;
}
.modal-panel.preview-panel {
    max-width: 420px;
    padding: 16px;
}
@keyframes modalSlide {
    from { opacity: 0; transform: translateY(10px) scale(.97); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}
.modal-close {
    position: absolute;
    top: 10px;
    right: 12px;
    width: 36px;
    height: 36px;
    border: 0;
    background: transparent;
    color: var(--text-muted);
    font-size: 1.6rem;
    line-height: 1;
    cursor: pointer;
    border-radius: 50%;
    transition: background .15s, color .15s;
}
.modal-close:hover { background: var(--bg-2); color: var(--text-0); }
.modal-title {
    margin: 0 0 12px 0;
    font-size: 1.2rem;
}
.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 20px;
}

.preview-video-wrap {
    background: #000;
    border-radius: var(--radius);
    overflow: hidden;
    aspect-ratio: 9/16;
    max-height: 70vh;
}
.preview-video-wrap video {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
}
.publish-icon {
    font-size: 2.6rem;
    text-align: center;
    margin-bottom: 8px;
}

/* ---- Badges ---- */
.badge {
    display: inline-block;
    font-size: .7rem;
    padding: 2px 8px;
    border-radius: 999px;
    text-transform: uppercase;
    letter-spacing: .04em;
    background: var(--bg-3);
    color: var(--text-1);
    width: fit-content;
}
.badge-completed { background: rgba(46,204,113,.15); color: var(--success); }
.badge-uploaded { background: rgba(108,92,255,.18); color: #a99bff; }
.badge-failed { background: rgba(255,90,95,.15); color: var(--error); }
.badge-uploading, .badge-cutting, .badge-pending, .badge-transcribing, .badge-analyzingmoments, .badge-downloading {
    background: rgba(240,180,41,.15); color: var(--warn);
}

/* ---- Shorts grid (My Shorts page) ---- */
.shorts-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 20px;
}
.short-card {
    background: var(--bg-1);
    border: 1px solid var(--border-soft);
    border-radius: var(--radius-lg);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}
.short-card-video {
    aspect-ratio: 9/16;
    background: #000;
    max-height: 480px;
    display: grid; place-items: center;
}
.short-card-video video { width: 100%; height: 100%; object-fit: contain; }
.short-placeholder { color: var(--text-2); font-size: .9rem; text-transform: uppercase; letter-spacing: .04em; }
.short-card-body { padding: 14px; flex: 1; }
.short-card-body h4 { margin-bottom: 6px; }
.short-card-actions { padding: 12px 14px; border-top: 1px solid var(--border-soft); display: flex; gap: 8px; flex-wrap: wrap; }
.yt-link { display: inline-block; margin-top: 6px; font-size: .85rem; }

/* ---- Responsive ---- */
@@media (max-width: 800px) {
    .video-details { grid-template-columns: 1fr; }
    .form-row.two-col { grid-template-columns: 1fr; }
    .header-inner { gap: 16px; }
    .nav-primary { gap: 12px; }
    .user-name { display: none; }
}
