/* Import distinctive fonts */
@import url('https://fonts.googleapis.com/css2?family=DM+Sans:wght@400;500;700;900&family=JetBrains+Mono:wght@400;600&display=swap');

:root {
    /* OpenEconomics Brand Colors */
    --bluette: #4400B3;           /* Primary brand color - Bluette */
    --bluette-dark: #3300A0;      /* Darker shade for hover states */
    --lime: #B9FF69;              /* Secondary accent - Lime */
    --lime-dark: #A0E850;         /* Darker lime for hover */

    /* Foundation colors */
    --black: #000000;             /* Pure black */
    --white: #FFFFFF;             /* Pure white */
    --gray-bg: #F5F5F5;           /* Light gray background */
    --gray-light: #E0E0E0;        /* Light gray borders */
    --gray-medium: #757575;       /* Medium gray text */
    --gray-dark: #212121;         /* Dark gray text */

    /* Semantic colors */
    --success-green: #10b981;
    --error-red: #ef4444;

    /* Shadows */
    --shadow-sm: 0 2px 8px rgba(68, 0, 179, 0.08);
    --shadow-md: 0 4px 16px rgba(68, 0, 179, 0.12);
    --shadow-bluette: 0 4px 16px rgba(68, 0, 179, 0.25);
}

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

body {
    font-family: 'DM Sans', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--white);
    color: var(--black);
    line-height: 1.6;
    padding: 24px;
    -webkit-font-smoothing: antialiased;
}

.container {
    max-width: 960px;
    margin: 0 auto;
}

/* ============================================
   NAVIGATION - SEGMENTED CONTROL STYLE
   ============================================ */
nav {
    background: var(--white);
    padding: 8px;
    border-radius: 12px;
    box-shadow: var(--shadow-sm);
    margin-bottom: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    border: 2px solid var(--gray-light);
}

nav a {
    flex: 1;
    max-width: 240px;
    text-align: center;
    padding: 14px 24px;
    font-weight: 700;
    font-size: 15px;
    text-decoration: none;
    color: var(--gray-dark);
    background: transparent;
    border-radius: 8px;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    letter-spacing: -0.01em;
}

nav a:hover {
    color: var(--black);
    background: var(--gray-bg);
}

nav a.active {
    background: var(--bluette);
    color: var(--white);
    box-shadow: var(--shadow-bluette);
}

nav .separator {
    display: none; /* Hide separator in segmented control */
}

/* ============================================
   HEADER
   ============================================ */
header {
    text-align: center;
    padding: 48px 0 32px 0;
    border-bottom: 2px solid var(--gray-light);
    margin-bottom: 40px;
}

header h1 {
    font-size: 2.5rem;
    font-weight: 900;
    margin-bottom: 12px;
    letter-spacing: -0.02em;
    color: var(--black);
}

header p {
    color: var(--gray-medium);
    font-size: 1.125rem;
    font-weight: 500;
}

/* ============================================
   CARDS AND SECTIONS
   ============================================ */
.upload-section,
.info-section {
    background: var(--white);
    padding: 32px;
    border-radius: 16px;
    box-shadow: var(--shadow-md);
    margin-bottom: 24px;
    border: 2px solid var(--gray-light);
}

/* ============================================
   FORMS
   ============================================ */
.form-group {
    margin-bottom: 24px;
}

.form-group label {
    display: block;
    font-weight: 700;
    font-size: 14px;
    margin-bottom: 8px;
    color: var(--black);
    letter-spacing: -0.01em;
}

.form-group input[type="file"],
.form-group input[type="text"],
.workspace-select {
    width: 100%;
    padding: 14px 16px;
    border: 2px solid var(--gray-light);
    border-radius: 10px;
    font-size: 15px;
    font-family: inherit;
    font-weight: 500;
    background: var(--white);
    color: var(--black);
    transition: all 0.2s;
}

.form-group input[type="file"] {
    padding: 12px;
    cursor: pointer;
}

.form-group input[type="text"]:focus,
.workspace-select:focus {
    outline: none;
    border-color: var(--bluette);
    box-shadow: 0 0 0 4px rgba(68, 0, 179, 0.1);
}

.form-group small {
    display: block;
    margin-top: 8px;
    color: var(--gray-medium);
    font-size: 13px;
    font-weight: 500;
}

/* ============================================
   BUTTONS - BOLD AND UNMISSABLE
   ============================================ */
button,
.btn-primary,
.btn-secondary,
button[type="submit"] {
    font-family: 'DM Sans', sans-serif;
    font-weight: 700;
    font-size: 15px;
    padding: 16px 32px;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    border: none;
    letter-spacing: -0.01em;
    position: relative;
    overflow: hidden;
}

.btn-primary,
button[type="submit"] {
    background: var(--bluette);
    color: var(--white);
    box-shadow: var(--shadow-bluette);
    width: 100%;
}

.btn-primary:hover:not(:disabled),
button[type="submit"]:hover:not(:disabled) {
    background: var(--bluette-dark);
    box-shadow: 0 6px 24px rgba(68, 0, 179, 0.35);
    transform: translateY(-1px);
}

.btn-primary:active:not(:disabled),
button[type="submit"]:active:not(:disabled) {
    transform: translateY(0);
}

.btn-primary:disabled,
button[type="submit"]:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.btn-secondary {
    background: var(--white);
    color: var(--black);
    border: 2px solid var(--gray-light);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

.btn-secondary:hover {
    border-color: var(--bluette);
    color: var(--bluette);
    background: rgba(68, 0, 179, 0.05);
    box-shadow: 0 4px 12px rgba(68, 0, 179, 0.15);
    transform: translateY(-1px);
}

/* Button groups */
.button-group {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    margin-top: 24px;
}

.button-group .btn-primary,
.button-group .btn-secondary {
    flex: 1;
    min-width: 180px;
}

/* ============================================
   STEP WORKFLOW - CRITICAL FOR UX
   ============================================ */
.step {
    display: none !important; /* Force hide with !important */
}

.step.active {
    display: block !important; /* Force show with !important */
    animation: fadeInUp 0.4s ease-out;
}

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

.step-container {
    background: var(--white);
    padding: 40px;
    border-radius: 16px;
    box-shadow: var(--shadow-md);
    border: 2px solid var(--gray-light);
    margin-bottom: 24px;
}

.step-container h2 {
    font-size: 1.75rem;
    font-weight: 900;
    margin-bottom: 24px;
    color: var(--black);
    letter-spacing: -0.02em;
}

/* ============================================
   INFO BOXES
   ============================================ */
.info-box {
    background: rgba(68, 0, 179, 0.05);
    border: 2px solid rgba(68, 0, 179, 0.2);
    border-left: 6px solid var(--bluette);
    color: var(--bluette-dark);
    padding: 16px 20px;
    border-radius: 10px;
    margin: 20px 0;
    font-weight: 600;
}

.info-box p {
    margin: 0;
}

.success-box {
    background: rgba(16, 185, 129, 0.1);
    border: 2px solid rgba(16, 185, 129, 0.3);
    border-left: 6px solid var(--success-green);
    color: #065f46;
    padding: 16px 20px;
    border-radius: 10px;
    margin: 20px 0;
    font-weight: 600;
    font-size: 15px;
}

.error-box {
    background: rgba(239, 68, 68, 0.1);
    border: 2px solid rgba(239, 68, 68, 0.3);
    border-left: 6px solid var(--error-red);
    color: #991b1b;
    padding: 16px 20px;
    border-radius: 10px;
    margin: 20px 0;
    font-weight: 600;
}

/* ============================================
   QUESTION LIST
   ============================================ */
.question-list {
    max-height: 400px;
    overflow-y: auto;
    border: 2px solid var(--gray-light);
    border-radius: 12px;
    padding: 16px;
    margin: 20px 0;
    background: var(--white);
}

.question-item {
    padding: 12px 16px;
    border-bottom: 1px solid var(--gray-light);
    transition: background 0.2s;
    border-radius: 6px;
    margin-bottom: 4px;
}

.question-item:last-child {
    border-bottom: none;
    margin-bottom: 0;
}

.question-item:hover {
    background: var(--gray-bg);
}

.question-item strong {
    color: var(--bluette);
    font-weight: 900;
    margin-right: 8px;
}

/* ============================================
   PROGRESS LOG - TERMINAL STYLE
   ============================================ */
.progress-container {
    margin: 20px 0;
}

.progress-log {
    max-height: 320px;
    overflow-y: auto;
    font-family: 'JetBrains Mono', 'Monaco', monospace;
    font-size: 13px;
    background: var(--black);
    color: var(--lime);
    padding: 20px;
    border-radius: 12px;
    line-height: 1.6;
    box-shadow: inset 0 2px 8px rgba(0, 0, 0, 0.5);
    border: 2px solid var(--gray-dark);
    position: relative;
    min-height: 120px;
}

/* Pulsing border animation when active */
.progress-log.active {
    animation: progressPulse 2s ease-in-out infinite;
}

@keyframes progressPulse {
    0%, 100% {
        border-color: var(--gray-dark);
        box-shadow: inset 0 2px 8px rgba(0, 0, 0, 0.5);
    }
    50% {
        border-color: var(--lime);
        box-shadow: inset 0 2px 8px rgba(0, 0, 0, 0.5), 0 0 20px rgba(185, 255, 105, 0.3);
    }
}

/* Blinking cursor for loading state */
.progress-log:empty::before {
    content: '▸ Initializing...';
    color: var(--lime);
    animation: blink 1.5s ease-in-out infinite;
}

@keyframes blink {
    0%, 49% {
        opacity: 1;
    }
    50%, 100% {
        opacity: 0.3;
    }
}

/* Animated working indicator */
.working-indicator {
    display: inline-block;
    color: var(--lime);
    font-weight: bold;
}

.working-indicator::after {
    content: '⠋';
    animation: spinner 1s steps(10) infinite;
}

@keyframes spinner {
    0% { content: '⠋'; }
    10% { content: '⠙'; }
    20% { content: '⠹'; }
    30% { content: '⠸'; }
    40% { content: '⠼'; }
    50% { content: '⠴'; }
    60% { content: '⠦'; }
    70% { content: '⠧'; }
    80% { content: '⠇'; }
    90% { content: '⠏'; }
    100% { content: '⠋'; }
}

/* Elapsed time indicator */
.elapsed-time {
    color: var(--lime);
    font-weight: 600;
    opacity: 0.8;
}

.progress-log::-webkit-scrollbar {
    width: 10px;
}

.progress-log::-webkit-scrollbar-track {
    background: var(--gray-dark);
    border-radius: 5px;
}

.progress-log::-webkit-scrollbar-thumb {
    background: var(--gray-medium);
    border-radius: 5px;
}

.progress-log::-webkit-scrollbar-thumb:hover {
    background: var(--gray-light);
}

/* ============================================
   REPORT PREVIEW
   ============================================ */
.report-preview {
    border: 2px solid var(--gray-light);
    border-radius: 12px;
    padding: 24px;
    margin: 20px 0;
    max-height: 600px;
    overflow-y: auto;
    background: var(--white);
    box-shadow: var(--shadow-sm);
}

.report-preview::-webkit-scrollbar {
    width: 12px;
}

.report-preview::-webkit-scrollbar-track {
    background: var(--gray-bg);
    border-radius: 6px;
}

.report-preview::-webkit-scrollbar-thumb {
    background: var(--gray-light);
    border-radius: 6px;
}

.report-preview::-webkit-scrollbar-thumb:hover {
    background: var(--gray-medium);
}

/* ============================================
   RESULT MESSAGES
   ============================================ */
.result {
    margin-top: 24px;
    padding: 20px;
    border-radius: 12px;
    border-left: 6px solid;
    animation: slideIn 0.3s ease-out;
}

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

.result.success {
    background: rgba(16, 185, 129, 0.1);
    border-color: var(--success-green);
    color: #065f46;
}

.result.error {
    background: rgba(239, 68, 68, 0.1);
    border-color: var(--error-red);
    color: #991b1b;
}

.result h3 {
    margin-bottom: 12px;
    font-weight: 900;
    font-size: 1.25rem;
}

.result p {
    margin-bottom: 8px;
    font-weight: 500;
}

/* ============================================
   WORKSPACE LINK
   ============================================ */
.workspace-link {
    display: inline-block;
    margin-top: 16px;
    padding: 14px 28px;
    background: var(--bluette);
    color: var(--white);
    text-decoration: none;
    border-radius: 10px;
    font-weight: 700;
    font-size: 15px;
    box-shadow: var(--shadow-bluette);
    transition: all 0.2s;
}

.workspace-link:hover {
    background: var(--bluette-dark);
    box-shadow: 0 6px 24px rgba(68, 0, 179, 0.35);
    transform: translateY(-2px);
}

/* ============================================
   INFO SECTION
   ============================================ */
.info-section h2 {
    margin-bottom: 20px;
    font-size: 1.5rem;
    font-weight: 900;
    color: var(--black);
}

.info-section h3 {
    margin-top: 28px;
    margin-bottom: 12px;
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--black);
}

.info-section ol,
.info-section ul {
    margin-left: 24px;
}

.info-section li {
    margin-bottom: 8px;
    font-weight: 500;
    color: var(--gray-dark);
}

.info-section li strong {
    color: var(--black);
}

/* ============================================
   SPINNER/LOADER
   ============================================ */
.spinner,
.loader {
    display: inline-block;
    width: 18px;
    height: 18px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-top-color: var(--white);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

/* Info text */
.info-text {
    color: var(--gray-medium);
    font-style: italic;
    margin: 16px 0;
    font-weight: 500;
}

/* ============================================
   RESPONSIVE DESIGN
   ============================================ */
@media (max-width: 768px) {
    body {
        padding: 16px;
    }

    header h1 {
        font-size: 1.75rem;
    }

    header p {
        font-size: 1rem;
    }

    .upload-section,
    .info-section,
    .step-container {
        padding: 24px;
    }

    nav {
        flex-direction: column;
        gap: 8px;
    }

    nav a {
        max-width: none;
        width: 100%;
    }

    .button-group {
        flex-direction: column;
    }

    .button-group .btn-primary,
    .button-group .btn-secondary {
        width: 100%;
        min-width: 0;
    }

    button,
    .btn-primary,
    .btn-secondary {
        padding: 14px 24px;
    }
}
