/* ============================
   IELTS CD TEST BUILDER — CSS
   ============================ */

/* ---------- RESET & BASE ---------- */
*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --bg: #0a0a0f;
    --bg-card: rgba(17, 17, 27, 0.85);
    --bg-card-border: rgba(99, 102, 241, 0.15);
    --bg-input: rgba(30, 30, 50, 0.8);
    --text: #e2e8f0;
    --text-dim: #94a3b8;
    --text-bright: #f8fafc;
    --primary: #6366f1;
    --primary-light: #818cf8;
    --primary-dark: #4f46e5;
    --accent: #a855f7;
    --success: #10b981;
    --error: #ef4444;
    --radius: 16px;
    --radius-sm: 10px;
    --radius-xs: 6px;
    --font: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    --shadow-glow: 0 0 60px -12px rgba(99, 102, 241, 0.25);
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    overflow-x: hidden;
    line-height: 1.6;
}

/* ---------- BACKGROUND EFFECTS ---------- */
.bg-grid {
    position: fixed;
    inset: 0;
    background-image:
        linear-gradient(rgba(99, 102, 241, 0.03) 1px, transparent 1px),
        linear-gradient(90deg, rgba(99, 102, 241, 0.03) 1px, transparent 1px);
    background-size: 60px 60px;
    pointer-events: none;
    z-index: 0;
}

.bg-glow {
    position: fixed;
    border-radius: 50%;
    filter: blur(120px);
    pointer-events: none;
    z-index: 0;
}

.glow-1 {
    width: 600px;
    height: 600px;
    background: rgba(99, 102, 241, 0.08);
    top: -200px;
    left: -200px;
    animation: float 20s ease-in-out infinite;
}

.glow-2 {
    width: 500px;
    height: 500px;
    background: rgba(168, 85, 247, 0.06);
    top: 40%;
    right: -200px;
    animation: float 25s ease-in-out infinite reverse;
}

.glow-3 {
    width: 400px;
    height: 400px;
    background: rgba(99, 102, 241, 0.05);
    bottom: -100px;
    left: 30%;
    animation: float 18s ease-in-out infinite 5s;
}

@keyframes float {

    0%,
    100% {
        transform: translate(0, 0);
    }

    33% {
        transform: translate(30px, -30px);
    }

    66% {
        transform: translate(-20px, 20px);
    }
}

/* ---------- NAV ---------- */
.nav {
    position: relative;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 40px;
    max-width: 1200px;
    margin: 0 auto;
}

.nav-brand {
    display: flex;
    align-items: center;
    gap: 12px;
}

.nav-logo {
    width: 36px;
    height: 36px;
    flex-shrink: 0;
}

.nav-logo svg {
    width: 36px;
    height: 36px;
    display: block;
}

.nav-title {
    font-size: 18px;
    font-weight: 700;
    color: var(--text-bright);
    letter-spacing: -0.3px;
}

.nav-links {
    display: flex;
    gap: 8px;
}

.nav-link {
    color: var(--text-dim);
    text-decoration: none;
    font-size: 13px;
    font-weight: 500;
    padding: 8px 16px;
    border-radius: var(--radius-xs);
    border: 1px solid transparent;
    transition: all 0.2s;
}

.nav-link:hover {
    color: var(--text);
    border-color: var(--bg-card-border);
    background: var(--bg-card);
}

/* ---------- HERO ---------- */
.hero {
    position: relative;
    z-index: 1;
    text-align: center;
    padding: 60px 40px 40px;
    max-width: 800px;
    margin: 0 auto;
}

.hero-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: rgba(99, 102, 241, 0.1);
    border: 1px solid rgba(99, 102, 241, 0.2);
    color: var(--primary-light);
    font-size: 13px;
    font-weight: 600;
    padding: 6px 16px;
    border-radius: 100px;
    margin-bottom: 24px;
}

.hero-badge svg {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
    color: #fbbf24;
}

.hero-title {
    font-size: clamp(36px, 5vw, 56px);
    font-weight: 900;
    line-height: 1.1;
    letter-spacing: -1.5px;
    color: var(--text-bright);
    margin-bottom: 20px;
}

.gradient-text {
    background: linear-gradient(135deg, var(--primary-light), var(--accent));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.hero-desc {
    font-size: 16px;
    color: var(--text-dim);
    max-width: 600px;
    margin: 0 auto;
    line-height: 1.7;
}

/* ---------- BUILDER CONTAINER ---------- */
.builder-container {
    position: relative;
    z-index: 1;
    max-width: 680px;
    margin: 0 auto;
    padding: 0 24px 80px;
}

/* ---------- BUILDER CARD ---------- */
.builder-card {
    background: var(--bg-card);
    border: 1px solid var(--bg-card-border);
    border-radius: var(--radius);
    padding: 32px;
    backdrop-filter: blur(20px);
    box-shadow: var(--shadow-glow);
    transition: opacity 0.3s, transform 0.3s;
}

.builder-card.hidden {
    opacity: 0;
    transform: translateY(20px);
    pointer-events: none;
    position: absolute;
}

.step-divider {
    width: 100%;
    height: 1px;
    background: linear-gradient(90deg, transparent, var(--bg-card-border), transparent);
    margin: 28px 0;
}

/* ---------- STEP HEADER ---------- */
.step-header {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 20px;
}

.step-number {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 15px;
    font-weight: 700;
    flex-shrink: 0;
}

.step-header h3 {
    font-size: 16px;
    font-weight: 700;
    color: var(--text-bright);
    margin-bottom: 2px;
}

.step-header p {
    font-size: 13px;
    color: var(--text-dim);
}

/* ---------- FORM ---------- */
.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-dim);
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.input-wrap {
    position: relative;
}

.input-wrap input {
    width: 100%;
    padding: 12px 48px 12px 16px;
    background: var(--bg-input);
    border: 1px solid rgba(99, 102, 241, 0.1);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-size: 14px;
    font-family: var(--font);
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.input-wrap input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}

.input-wrap input::placeholder {
    color: rgba(148, 163, 184, 0.5);
}

.toggle-key {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    cursor: pointer;
    padding: 6px;
    color: var(--text-dim);
    transition: color 0.2s;
}

.toggle-key:hover {
    color: var(--text);
}

.toggle-key svg {
    width: 18px;
    height: 18px;
}

/* ---------- TYPE TABS ---------- */
.type-tabs {
    display: flex;
    gap: 12px;
}

.type-tab {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 14px;
    border-radius: var(--radius-sm);
    border: 1px solid rgba(99, 102, 241, 0.1);
    background: var(--bg-input);
    color: var(--text-dim);
    font-size: 14px;
    font-weight: 600;
    font-family: var(--font);
    cursor: pointer;
    transition: all 0.25s;
}

.type-tab svg {
    width: 20px;
    height: 20px;
}

.type-tab:hover {
    border-color: var(--primary);
    color: var(--text);
}

.type-tab.active {
    border-color: var(--primary);
    background: rgba(99, 102, 241, 0.1);
    color: var(--primary-light);
    box-shadow: 0 0 20px -8px rgba(99, 102, 241, 0.3);
}

/* ---------- DROPZONE ---------- */
.dropzone {
    border: 2px dashed rgba(99, 102, 241, 0.2);
    border-radius: var(--radius-sm);
    padding: 40px 24px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s;
    position: relative;
}

.dropzone:hover,
.dropzone.dragover {
    border-color: var(--primary);
    background: rgba(99, 102, 241, 0.05);
}

.dropzone.dragover {
    transform: scale(1.01);
}

.dropzone-icon {
    margin-bottom: 16px;
    display: flex;
    justify-content: center;
}

.dropzone-icon svg {
    width: 44px;
    height: 44px;
    color: var(--primary-light);
    opacity: 0.6;
    display: block;
}

.dropzone-text {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.dropzone-text strong {
    font-size: 15px;
    color: var(--text);
}

.dropzone-text span {
    font-size: 13px;
    color: var(--text-dim);
}

.dropzone-formats {
    margin-top: 12px;
    font-size: 11px;
    color: var(--text-dim);
    opacity: 0.7;
    letter-spacing: 1px;
    text-transform: uppercase;
}

/* ---------- FILE INFO ---------- */
.file-info {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    background: rgba(99, 102, 241, 0.06);
    border: 1px solid rgba(99, 102, 241, 0.12);
    border-radius: var(--radius-sm);
    margin-top: 12px;
}

.file-icon {
    font-size: 28px;
}

.file-details {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.file-name {
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
}

.file-size {
    font-size: 12px;
    color: var(--text-dim);
}

.file-remove {
    background: none;
    border: none;
    color: var(--text-dim);
    cursor: pointer;
    font-size: 18px;
    padding: 4px 8px;
    border-radius: 6px;
    transition: all 0.2s;
}

.file-remove:hover {
    background: rgba(239, 68, 68, 0.15);
    color: var(--error);
}

/* ---------- GENERATE BUTTON ---------- */
.btn-generate {
    width: 100%;
    padding: 16px;
    border-radius: var(--radius-sm);
    border: none;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    color: white;
    font-size: 16px;
    font-weight: 700;
    font-family: var(--font);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    transition: all 0.3s;
    position: relative;
    overflow: hidden;
}

.btn-generate::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, transparent, rgba(255, 255, 255, 0.1));
    opacity: 0;
    transition: opacity 0.3s;
}

.btn-generate:hover::before {
    opacity: 1;
}

.btn-generate:hover {
    transform: translateY(-1px);
    box-shadow: 0 8px 30px -8px rgba(99, 102, 241, 0.5);
}

.btn-generate:active {
    transform: translateY(0);
}

.btn-generate:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.btn-generate svg {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}

/* Constrain all SVGs inside builder */
.builder-card svg,
.result-card svg,
.error-toast svg,
.progress-card svg:not(.progress-spinner svg) {
    max-width: 100%;
    max-height: 100%;
}

/* ---------- PROGRESS OVERLAY ---------- */
.progress-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(10, 10, 15, 0.85);
    backdrop-filter: blur(8px);
    z-index: 100;
    align-items: center;
    justify-content: center;
}

.progress-overlay.show {
    display: flex;
}

.progress-card {
    background: var(--bg-card);
    border: 1px solid var(--bg-card-border);
    border-radius: var(--radius);
    padding: 48px;
    text-align: center;
    max-width: 420px;
    width: 90%;
    box-shadow: var(--shadow-glow);
}

.progress-spinner {
    width: 64px;
    height: 64px;
    margin: 0 auto 24px;
    animation: spin 1.2s linear infinite;
}

.progress-spinner svg {
    width: 100%;
    height: 100%;
}

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

.progress-title {
    font-size: 20px;
    font-weight: 700;
    color: var(--text-bright);
    margin-bottom: 8px;
}

.progress-detail {
    font-size: 14px;
    color: var(--text-dim);
    margin-bottom: 32px;
}

.progress-steps {
    display: flex;
    justify-content: center;
    gap: 32px;
}

.p-step {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    opacity: 0.3;
    transition: opacity 0.4s;
}

.p-step.active {
    opacity: 1;
}

.p-step.done {
    opacity: 0.7;
}

.p-step-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--text-dim);
    transition: all 0.4s;
}

.p-step.active .p-step-dot {
    background: var(--primary-light);
    box-shadow: 0 0 12px var(--primary);
    animation: pulse 1.5s ease-in-out infinite;
}

.p-step.done .p-step-dot {
    background: var(--success);
}

@keyframes pulse {

    0%,
    100% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.3);
    }
}

.p-step span {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-dim);
}

.p-step.active span {
    color: var(--text);
}

/* ---------- RESULT CARD ---------- */
.result-card {
    background: var(--bg-card);
    border: 1px solid var(--bg-card-border);
    border-radius: var(--radius);
    padding: 48px 32px;
    text-align: center;
    backdrop-filter: blur(20px);
    box-shadow: var(--shadow-glow);
    animation: slideUp 0.5s ease-out;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.result-icon {
    width: 72px;
    height: 72px;
    border-radius: 50%;
    background: rgba(16, 185, 129, 0.1);
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 24px;
}

.result-icon svg {
    width: 36px;
    height: 36px;
    color: var(--success);
}

.result-title {
    font-size: 28px;
    font-weight: 800;
    color: var(--text-bright);
    margin-bottom: 8px;
}

.result-desc {
    font-size: 15px;
    color: var(--text-dim);
    margin-bottom: 32px;
}

/* ---------- PREVIEW ---------- */
.result-preview {
    text-align: left;
    margin-bottom: 32px;
    padding: 20px;
    background: rgba(30, 30, 50, 0.5);
    border-radius: var(--radius-sm);
    border: 1px solid rgba(99, 102, 241, 0.08);
}

.result-preview h4 {
    font-size: 13px;
    font-weight: 700;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 16px;
}

.preview-parts {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.preview-part {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background: rgba(99, 102, 241, 0.04);
    border-radius: var(--radius-xs);
    border: 1px solid rgba(99, 102, 241, 0.06);
}

.preview-part-num {
    font-size: 12px;
    font-weight: 700;
    color: var(--primary-light);
    background: rgba(99, 102, 241, 0.12);
    padding: 4px 10px;
    border-radius: 6px;
}

.preview-part-info {
    flex: 1;
    font-size: 13px;
    color: var(--text);
}

.preview-part-badge {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-dim);
    background: rgba(30, 30, 50, 0.8);
    padding: 3px 8px;
    border-radius: 4px;
}

/* ---------- RESULT ACTIONS ---------- */
.result-actions {
    display: flex;
    gap: 12px;
}

.btn-download {
    flex: 1;
    padding: 14px;
    border-radius: var(--radius-sm);
    border: none;
    background: linear-gradient(135deg, var(--success), #059669);
    color: white;
    font-size: 15px;
    font-weight: 700;
    font-family: var(--font);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all 0.3s;
}

.btn-download:hover {
    transform: translateY(-1px);
    box-shadow: 0 8px 30px -8px rgba(16, 185, 129, 0.5);
}

.btn-download svg {
    width: 18px;
    height: 18px;
}

.btn-new {
    padding: 14px 24px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--bg-card-border);
    background: transparent;
    color: var(--text-dim);
    font-size: 14px;
    font-weight: 600;
    font-family: var(--font);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.2s;
}

.btn-new:hover {
    border-color: var(--primary);
    color: var(--text);
}

.btn-new svg {
    width: 16px;
    height: 16px;
}

/* ---------- ERROR TOAST ---------- */
.error-toast {
    position: fixed;
    bottom: -80px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--error);
    color: white;
    padding: 14px 24px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 14px;
    font-weight: 600;
    z-index: 200;
    transition: bottom 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
    max-width: 500px;
    box-shadow: 0 10px 40px -10px rgba(239, 68, 68, 0.4);
}

.error-toast.show {
    bottom: 32px;
}

.error-toast svg {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
}

/* ---------- FOOTER ---------- */
.footer {
    position: relative;
    z-index: 1;
    text-align: center;
    padding: 32px;
    font-size: 13px;
    color: rgba(148, 163, 184, 0.4);
}

/* ---------- RESPONSIVE ---------- */
@media (max-width: 640px) {
    .nav {
        padding: 16px 20px;
    }

    .nav-links {
        display: none;
    }

    .hero {
        padding: 40px 20px 30px;
    }

    .builder-card {
        padding: 24px 20px;
    }

    .type-tabs {
        flex-direction: column;
    }

    .result-actions {
        flex-direction: column;
    }

    .progress-steps {
        gap: 20px;
    }
}