:root {
    --bg-color: #0b0f19;
    --panel-bg: rgba(22, 27, 34, 0.4);
    --panel-border: rgba(255, 255, 255, 0.1);
    --text-primary: #f0f6fc;
    --text-secondary: #8b949e;

    /* Vibrant, Consumer SaaS Accents - Purple Edition */
    --accent-color: #8b5cf6;
    --accent-hover: #7c3aed;
    --accent-glow: rgba(139, 92, 246, 0.4);

    --success-color: #10b981;
    --error-color: #ef4444;

    --input-bg: rgba(0, 0, 0, 0.3);
    --input-border: rgba(255, 255, 255, 0.15);

    --glass-blur: blur(20px);
    --font-family: 'Outfit', sans-serif;
}

[data-theme="light"] {
    --bg-color: #f8fafc;
    --panel-bg: rgba(255, 255, 255, 0.7);
    --panel-border: rgba(0, 0, 0, 0.1);
    --text-primary: #0f172a;
    --text-secondary: #64748b;

    --accent-color: #8b5cf6;
    --accent-hover: #7c3aed;

    --input-bg: rgba(255, 255, 255, 0.9);
    --input-border: rgba(0, 0, 0, 0.15);
}

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

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

/* Background Gradients & Shapes for consumer feel */
.bg-shape {
    position: fixed;
    border-radius: 50%;
    filter: blur(100px);
    z-index: -1;
    opacity: 0.5;
}

.shape-1 {
    width: 600px;
    height: 600px;
    background: radial-gradient(circle, #4f46e5 0%, transparent 70%);
    top: -200px;
    right: -100px;
}

.shape-2 {
    width: 500px;
    height: 500px;
    background: radial-gradient(circle, #0ea5e9 0%, transparent 70%);
    bottom: -150px;
    left: -100px;
}

.shape-3 {
    width: 400px;
    height: 400px;
    background: radial-gradient(circle, #8b5cf6 0%, transparent 70%);
    top: 40%;
    left: 40%;
    opacity: 0.2;
}

.app-container {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    max-width: 1000px;
    margin: 0 auto;
    padding: 1.5rem;
}

/* Glassmorphism Classes */
.glass-panel {
    background: var(--panel-bg);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    border: 1px solid var(--panel-border);
    border-radius: 20px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.4);
}

/* Header */
.app-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 0 2rem 0;
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.logo-icon {
    background: linear-gradient(135deg, var(--accent-color), #8b5cf6);
    width: 40px;
    height: 40px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    color: white;
    box-shadow: 0 4px 15px var(--accent-glow);
}

.logo h1 {
    font-size: 1.8rem;
    font-weight: 700;
    letter-spacing: -0.5px;
}

/* Buttons */
.btn {
    font-family: var(--font-family);
    cursor: pointer;
    border: none;
    border-radius: 10px;
    padding: 0.6rem 1.2rem;
    font-size: 0.95rem;
    font-weight: 600;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.primary-btn {
    background: linear-gradient(135deg, var(--accent-color), #8b5cf6);
    color: white;
    box-shadow: 0 4px 10px var(--accent-glow);
}

.primary-btn:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px var(--accent-glow);
    filter: brightness(1.1);
}

.primary-btn:disabled {
    background: #374151;
    color: #9ca3af;
    box-shadow: none;
    cursor: not-allowed;
}

.secondary-btn {
    background: var(--accent-color);
    color: white;
    border: none;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
}

.secondary-btn:hover {
    background: var(--accent-hover);
    transform: translateY(-2px);
    box-shadow: 0 6px 15px rgba(0, 0, 0, 0.3);
}

.ghost-btn {
    background: transparent;
    color: var(--text-secondary);
}

.ghost-btn:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.05);
}

.large-action-btn {
    font-size: 1.1rem;
    padding: 1rem 2rem;
    width: 100%;
    margin-top: 1rem;
}

.small-btn {
    padding: 0.4rem 0.8rem;
    font-size: 0.85rem;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 6px;
}

/* Wizard Layout */
.wizard-container {
    display: flex;
    flex-direction: column;
    flex: 1;
    overflow: hidden;
    position: relative;
}

/* Progress Bar */
.wizard-progress {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    border-bottom: 1px solid var(--panel-border);
    background: rgba(0, 0, 0, 0.2);
}

.step {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    opacity: 0.5;
    transition: opacity 0.3s;
}

.step.active {
    opacity: 1;
}

.step-num {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--input-bg);
    border: 2px solid var(--text-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    transition: all 0.3s;
}

.step.active .step-num {
    background: var(--accent-color);
    border-color: var(--accent-color);
    color: white;
    box-shadow: 0 0 15px var(--accent-glow);
}

.step-label {
    font-size: 0.85rem;
    font-weight: 500;
}

.step-line {
    height: 2px;
    width: 80px;
    background: var(--panel-border);
    margin: 0 1rem;
    transform: translateY(-12px);
}

/* Steps Content */
.wizard-body {
    position: relative;
    flex: 1;
    padding: 2.5rem;
    display: flex;
    flex-direction: column;
}

.wizard-step {
    display: none;
    flex-direction: column;
    flex: 1;
    animation: slideIn 0.4s ease-out;
}

.wizard-step.active-step {
    display: flex;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateX(20px);
    }

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

.step-header {
    margin-bottom: 2rem;
    text-align: center;
}

.step-header h2 {
    font-size: 1.8rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.step-header p {
    color: var(--text-secondary);
}

/* Intro Hero */
.intro-hero {
    text-align: center;
    padding: 3rem 1rem 4rem;
    background: linear-gradient(180deg, rgba(139, 92, 246, 0.05) 0%, transparent 100%);
    border-radius: 24px;
    margin-bottom: 2rem;
    border: 1px solid rgba(139, 92, 246, 0.1);
}

.intro-hero h1 {
    font-size: 2.8rem;
    font-weight: 800;
    margin-bottom: 1rem;
    letter-spacing: -1px;
    line-height: 1.1;
}

.intro-hero h1 span {
    color: var(--accent-color);
    background: linear-gradient(135deg, var(--accent-color), #a78bfa);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.intro-hero p {
    font-size: 1.15rem;
    color: var(--text-secondary);
    max-width: 600px;
    margin: 0 auto 2.5rem;
}

.intro-features {
    display: flex;
    justify-content: center;
    gap: 3rem;
    flex-wrap: wrap;
}

.feature-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.75rem;
    width: 140px;
}

.feature-item i {
    font-size: 1.5rem;
    color: var(--accent-color);
    background: rgba(139, 92, 246, 0.1);
    width: 50px;
    height: 50px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.3s;
}

.feature-item:hover i {
    transform: translateY(-5px);
    background: var(--accent-color);
    color: white;
}

.feature-item span {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-primary);
}

/* Form UI */
.upload-area {
    border: 2px dashed var(--input-border);
    border-radius: 16px;
    padding: 4rem 2rem;
    text-align: center;
    background: rgba(255, 255, 255, 0.02);
    transition: all 0.3s;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
}

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

.upload-icon {
    font-size: 3rem;
    color: var(--accent-color);
    opacity: 0.8;
}

.file-status {
    margin-top: 1rem;
    padding: 1rem;
    border-radius: 10px;
    background: rgba(16, 185, 129, 0.1);
    border: 1px solid rgba(16, 185, 129, 0.2);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.file-status.hidden {
    display: none;
}

.file-info {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-weight: 500;
}

.parse-status {
    font-size: 0.85rem;
    color: var(--success-color);
}

/* URL Input */
.url-input-group {
    display: flex;
    gap: 1rem;
}

.input-with-icon {
    position: relative;
    flex: 1;
}

.input-with-icon i {
    position: absolute;
    left: 1rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-secondary);
}

.input-with-icon input {
    width: 100%;
    padding-left: 2.5rem;
}

input,
select,
textarea {
    font-family: var(--font-family);
    background-color: var(--input-bg);
    border: 1px solid var(--input-border);
    color: var(--text-primary);
    border-radius: 10px;
    padding: 0.8rem 1rem;
    font-size: 1rem;
    transition: all 0.2s;
}

input:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: var(--accent-color);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

.divider {
    display: flex;
    align-items: center;
    text-align: center;
    margin: 2rem 0;
    color: var(--text-secondary);
    font-size: 0.8rem;
    letter-spacing: 1px;
}

.divider::before,
.divider::after {
    content: '';
    flex: 1;
    border-bottom: 1px solid var(--panel-border);
}

.divider span {
    padding: 0 1rem;
}

.manual-jd {
    height: 150px;
    resize: vertical;
}

/* Step Actions */
.step-actions {
    display: flex;
    margin-top: auto;
    padding-top: 2rem;
}

.step-actions.right {
    justify-content: flex-end;
}

.step-actions.between {
    justify-content: space-between;
}

.step-actions.start {
    justify-content: flex-start;
}

/* Output Generation */
.generation-intro {
    text-align: center;
    max-width: 500px;
    margin: 0 auto;
    padding: 2rem 0;
}

.results-view {
    display: flex;
    flex-direction: column;
    flex: 1;
}

.results-view.hidden {
    display: none;
}

.results-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.tabs {
    display: flex;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 8px;
    padding: 0.25rem;
}

.tab-btn {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    padding: 0.5rem 1rem;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 500;
    transition: all 0.2s;
}

.tab-btn.active {
    background: var(--panel-border);
    color: var(--text-primary);
}

.output-content {
    position: relative;
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 400px;
}

.tab-pane {
    display: none;
    flex: 1;
    position: relative;
}

.tab-pane.active {
    display: flex;
}

.rich-output-area {
    flex: 1;
    font-family: var(--font-family);
    font-size: 0.95rem;
    border-radius: 12px;
    background: var(--panel-bg);
    border: 1px solid var(--panel-border);
    padding: 2rem;
    overflow-y: auto;
    color: var(--text-primary);
    line-height: 1.6;
}

.rich-output-area:focus {
    outline: none;
    border-color: var(--accent-color);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

.rich-output-area[data-placeholder]:empty:before {
    content: attr(data-placeholder);
    color: var(--text-secondary);
    font-style: italic;
    opacity: 0.7;
}

/* Rich Text Formatting */
.rich-output-area h1 {
    font-size: 1.8rem;
    margin-top: 0;
    margin-bottom: 0.5rem;
    text-align: center;
    color: var(--accent-color);
}

.rich-output-area h2 {
    font-size: 1.3rem;
    margin-top: 1.2rem;
    margin-bottom: 0.3rem;
    border-bottom: 2px solid var(--panel-border);
    padding-bottom: 0.3rem;
    color: var(--text-primary);
}

.rich-output-area h3 {
    font-size: 1.1rem;
    margin-top: 0.6rem;
    margin-bottom: 0.2rem;
}

/* Remove gaps when elements follow a header */
.rich-output-area h2+*,
.rich-output-area h3+* {
    margin-top: 0 !important;
}

.rich-output-area p {
    margin-bottom: 0.8rem;
}

.rich-output-area ul {
    margin-bottom: 1rem;
    padding-left: 1.5rem;
}

.rich-output-area li {
    margin-bottom: 0.4rem;
}

.rich-output-area h1,
.rich-output-area h2,
.rich-output-area h3,
.rich-output-area p,
.rich-output-area li {
    break-inside: avoid;
}

.rich-output-area *:first-child {
    margin-top: 0;
}

.rich-output-area b,
.rich-output-area strong {
    color: var(--text-primary);
    font-weight: 600;
}

/* PDF Export mode: Adjust margins/borders for printing */
.rich-output-area.pdf-rendering {
    border: none !important;
    border-radius: 0 !important;
    box-shadow: none !important;
    padding: 0 1mm !important;
    /* Side safety buffer only */
    height: auto !important;
    max-height: none !important;
    overflow: visible !important;
    width: 182.5mm !important;
    /* Maximized width for 0.5in margins */
    box-sizing: border-box !important;
    overflow-wrap: break-word !important;
    word-break: break-word !important;
}

.rich-output-area.pdf-rendering * {
    overflow-wrap: break-word !important;
    word-break: break-word !important;
    max-width: 100% !important;
}

.output-actions {
    position: absolute;
    top: 15px;
    right: 25px;
    z-index: 10;
}

/* Loaders and Status */
.loading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(11, 15, 25, 0.8);
    backdrop-filter: blur(8px);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 20;
    border-radius: 12px;
    text-align: center;
}

.loading-overlay.hidden {
    display: none;
}

.spinner {
    width: 50px;
    height: 50px;
    border: 4px solid rgba(255, 255, 255, 0.1);
    border-top-color: var(--accent-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 1.5rem;
}

.status-message {
    font-size: 0.9rem;
    margin-top: 1rem;
    text-align: center;
    min-height: 24px;
}

.message-area {
    margin-top: 1rem;
    font-size: 0.9rem;
}

.error-text {
    color: var(--error-color);
}

.success-text {
    color: var(--success-color);
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(5px);
    z-index: 1000;
    align-items: center;
    justify-content: center;
}

.modal.visible {
    display: flex;
    animation: fadeIn 0.2s;
}

.modal-content {
    width: 90%;
    max-width: 450px;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem;
    border-bottom: 1px solid var(--panel-border);
}

.icon-btn {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 1.2rem;
    cursor: pointer;
}

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

.modal-body {
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1.2rem;
}

.modal-desc {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.form-group label {
    font-weight: 500;
    font-size: 0.9rem;
    color: var(--text-primary);
}

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

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

/* ------ MODALS ------ */
.modal {
    display: none;
    position: fixed;
    z-index: 2000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
}

.modal-content {
    background: var(--panel-bg);
    margin: 10% auto;
    padding: 0;
    border: 1px solid var(--panel-border);
    width: 90%;
    max-width: 500px;
    border-radius: 16px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.4);
    overflow: hidden;
    animation: modalFade 0.3s ease-out;
}

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

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

.modal-header {
    padding: 1.5rem;
    background: rgba(255, 255, 255, 0.05);
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--panel-border);
}

.modal-header h3 {
    margin: 0;
    font-size: 1.2rem;
    color: var(--accent-color);
}

.modal-body {
    padding: 1.5rem;
}

.modal-body p.field-label {
    font-weight: 500;
    margin-bottom: 0.5rem;
    font-size: 0.9rem;
}

.modal-body textarea {
    width: 100%;
    height: 120px;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--panel-border);
    border-radius: 8px;
    padding: 0.8rem;
    color: var(--text-primary);
    font-family: inherit;
    resize: vertical;
    margin-bottom: 0.5rem;
}

.modal-body .helper-text {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.close {
    color: var(--text-secondary);
    font-size: 24px;
    font-weight: bold;
    cursor: pointer;
    transition: 0.2s;
}

.close:hover {
    color: var(--text-primary);
}

/* Mobile Responsiveness */
@media screen and (max-width: 768px) {
    .app-container {
        padding: 1rem;
    }

    .app-header {
        flex-direction: column;
        gap: 1rem;
        text-align: center;
        padding-bottom: 1.5rem;
    }

    .logo h1 {
        font-size: 1.5rem;
    }

    .wizard-progress {
        padding: 1.5rem 1rem;
    }

    .step-label {
        display: none;
        /* Hide labels on mobile to save space */
    }

    .step-line {
        width: 40px;
        margin: 0 0.5rem;
    }

    .wizard-body {
        padding: 1.5rem 1rem;
    }

    .intro-hero h1 {
        font-size: 2rem;
    }

    .intro-hero p {
        font-size: 1rem;
    }

    .intro-features {
        gap: 1.5rem;
    }

    .feature-item {
        width: 100px;
    }

    .feature-item i {
        width: 40px;
        height: 40px;
        font-size: 1.2rem;
    }

    .step-header h2 {
        font-size: 1.5rem;
    }

    .upload-area {
        padding: 2.5rem 1rem;
    }

    .rich-output-area {
        padding: 1rem;
    }

    .output-actions {
        position: static;
        display: flex;
        justify-content: flex-end;
        gap: 0.5rem;
        margin-bottom: 1rem;
    }

    .results-header {
        flex-direction: column;
        gap: 1rem;
        align-items: flex-start;
    }

    .tabs {
        width: 100%;
    }

    .tab-btn {
        flex: 1;
        text-align: center;
    }

    .modal-content {
        width: 95%;
        margin: 1rem;
    }
}

@media screen and (max-width: 480px) {
    .intro-hero h1 {
        font-size: 1.8rem;
    }

    .step-actions {
        flex-direction: column;
        gap: 1rem;
    }

    .step-actions button {
        width: 100%;
    }

    .step-actions.right {
        justify-content: center;
    }
}