@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background: #f0f2f5;
    color: #1e293b;
    line-height: 1.6;
    min-height: 100vh;
}

/* ─── Header / Brand Bar ─── */
.app-header {
    background: linear-gradient(135deg, #1a237e 0%, #283593 50%, #3949ab 100%);
    color: #fff;
    padding: 20px 24px;
    text-align: center;
    box-shadow: 0 2px 12px rgba(26, 35, 126, 0.3);
    position: relative;
    overflow: hidden;
}

.app-header::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle at 30% 50%, rgba(255,255,255,0.06) 0%, transparent 60%);
    pointer-events: none;
}

.app-header h1 {
    font-size: 22px;
    font-weight: 700;
    letter-spacing: -0.3px;
    margin: 0;
    position: relative;
}

.app-header .subtitle {
    font-size: 13px;
    opacity: 0.75;
    margin-top: 4px;
    font-weight: 400;
    position: relative;
}

/* ─── Container ─── */
.container {
    max-width: 920px;
    margin: 0 auto;
    padding: 24px 20px 40px;
}

/* ─── Wizard Navigation ─── */
.wizard-nav {
    display: flex;
    align-items: flex-start;
    justify-content: center;
    gap: 0;
    margin-bottom: 32px;
    padding: 24px 16px;
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.06), 0 4px 12px rgba(0,0,0,0.04);
    position: relative;
}

.wizard-step {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 0;
    border: none;
    background: transparent;
    cursor: pointer;
    font-size: 12px;
    font-weight: 500;
    color: #94a3b8;
    transition: color 0.3s;
    position: relative;
    font-family: inherit;
}

.wizard-step:hover { color: #64748b; }

.step-circle {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 15px;
    font-weight: 600;
    border: 2.5px solid #cbd5e1;
    background: #fff;
    color: #94a3b8;
    transition: all 0.3s ease;
    position: relative;
    z-index: 2;
    flex-shrink: 0;
}

.step-label {
    text-align: center;
    line-height: 1.3;
    max-width: 100px;
}

/* Connecting line between steps */
.wizard-step:not(:last-child)::after {
    content: '';
    position: absolute;
    top: 20px;
    left: calc(50% + 24px);
    width: calc(100% - 48px);
    height: 2.5px;
    background: #e2e8f0;
    z-index: 1;
    transition: background 0.3s;
}

/* Active step */
.wizard-step.active .step-circle {
    border-color: #1a237e;
    background: #1a237e;
    color: #fff;
    box-shadow: 0 0 0 4px rgba(26, 35, 126, 0.15);
}

.wizard-step.active { color: #1a237e; }
.wizard-step.active .step-label { font-weight: 600; }

/* Completed step */
.wizard-step.completed .step-circle {
    border-color: #16a34a;
    background: #16a34a;
    color: #fff;
}

.wizard-step.completed { color: #16a34a; }

.wizard-step.completed:not(:last-child)::after {
    background: #16a34a;
}

/* Checkmark SVG inside completed step */
.step-circle .check-icon {
    display: none;
}
.wizard-step.completed .step-circle .step-number { display: none; }
.wizard-step.completed .step-circle .check-icon { display: block; }

/* ─── Step Panels ─── */
.step-panel {
    display: none;
    background: #fff;
    border-radius: 16px;
    padding: 32px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.06), 0 4px 12px rgba(0,0,0,0.04);
    animation: fadeIn 0.3s ease;
}

.step-panel.active { display: block; }

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

.step-panel > h2 {
    font-size: 20px;
    font-weight: 700;
    color: #1a237e;
    margin-bottom: 6px;
    letter-spacing: -0.3px;
}

.step-panel > p {
    font-size: 14px;
    color: #64748b;
    margin-bottom: 20px;
    line-height: 1.5;
}

/* ─── Document Upload Cards ─── */
.doc-uploads {
    display: flex;
    flex-direction: column;
    gap: 16px;
    margin: 20px 0;
}

.doc-upload-card {
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    padding: 20px;
    transition: all 0.3s ease;
    border-left: 4px solid #e2e8f0;
    background: #fff;
}

.doc-upload-card:hover {
    box-shadow: 0 4px 16px rgba(0,0,0,0.06);
    transform: translateY(-1px);
}

.doc-upload-card .card-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.doc-upload-card .card-top h3 {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 15px;
    font-weight: 600;
    color: #334155;
}

.card-icon {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #eff1fe;
    flex-shrink: 0;
}

.card-icon svg {
    width: 18px;
    height: 18px;
    color: #1a237e;
}

.card-badge {
    font-size: 12px;
    font-weight: 600;
    padding: 4px 12px;
    border-radius: 20px;
    white-space: nowrap;
    letter-spacing: 0.02em;
}

/* Card status states */
.doc-upload-card.status-idle { border-left-color: #e2e8f0; }
.doc-upload-card.status-idle .card-badge { display: none; }

.doc-upload-card.status-processing {
    border-left-color: #1a237e;
    background: #fafbff;
}
.doc-upload-card.status-processing .card-badge {
    background: #eff1fe;
    color: #1a237e;
}
.doc-upload-card.status-processing .card-icon {
    background: #eff1fe;
    animation: pulse-icon 1.5s infinite;
}

@keyframes pulse-icon {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.doc-upload-card.status-done {
    border-left-color: #16a34a;
    background: #f0fdf4;
}
.doc-upload-card.status-done .card-badge {
    background: #dcfce7;
    color: #16a34a;
}
.doc-upload-card.status-done .card-icon {
    background: #dcfce7;
}
.doc-upload-card.status-done .card-icon svg { color: #16a34a; }

.doc-upload-card.status-error {
    border-left-color: #dc2626;
    background: #fef2f2;
}
.doc-upload-card.status-error .card-badge {
    background: #fecaca;
    color: #dc2626;
}
.doc-upload-card.status-error .card-icon {
    background: #fecaca;
}
.doc-upload-card.status-error .card-icon svg { color: #dc2626; }

/* ─── File Drop Zone ─── */
.file-drop {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 24px 16px;
    border: 2px dashed #cbd5e1;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
    background: #fafbfc;
    text-align: center;
    min-height: 100px;
}

.file-drop:hover {
    border-color: #1a237e;
    background: #f5f6ff;
}

.file-drop.drag-over {
    border-color: #1a237e;
    background: #eff1fe;
    border-style: solid;
    transform: scale(1.01);
}

.file-drop.has-file {
    border-color: #16a34a;
    border-style: solid;
    background: #f0fdf4;
}

.file-drop input[type="file"] {
    display: none;
}

.file-drop-icon {
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: #eff1fe;
    color: #1a237e;
    flex-shrink: 0;
}

.file-drop-icon svg {
    width: 22px;
    height: 22px;
}

.file-drop-text {
    font-size: 13px;
    color: #64748b;
    font-weight: 500;
}

.file-drop-hint {
    font-size: 11px;
    color: #94a3b8;
}

.file-drop-filename {
    font-size: 12px;
    color: #16a34a;
    font-weight: 600;
    display: none;
    align-items: center;
    gap: 4px;
    margin-top: 2px;
}

.file-drop.has-file .file-drop-filename { display: flex; }
.file-drop.has-file .file-drop-text { display: none; }
.file-drop.has-file .file-drop-hint { display: none; }

/* Image thumbnail preview */
.upload-preview {
    display: none;
    margin-top: 12px;
}

.upload-preview.visible {
    display: block;
}

.upload-preview img {
    max-width: 180px;
    max-height: 120px;
    border-radius: 8px;
    border: 1px solid #e2e8f0;
    object-fit: cover;
}

/* ─── Buttons ─── */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 24px;
    border: 1px solid #e2e8f0;
    border-radius: 50px;
    background: #fff;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    font-family: inherit;
    transition: all 0.2s ease;
    color: #475569;
    box-shadow: 0 1px 2px rgba(0,0,0,0.04);
}

.btn:hover {
    background: #f8fafc;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    transform: translateY(-1px);
}

.btn:active {
    transform: translateY(0);
    box-shadow: 0 1px 2px rgba(0,0,0,0.04);
}

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

.btn-primary {
    background: linear-gradient(135deg, #1a237e 0%, #283593 100%);
    color: #fff;
    border-color: transparent;
    box-shadow: 0 2px 8px rgba(26, 35, 126, 0.25);
}

.btn-primary:hover {
    background: linear-gradient(135deg, #283593 0%, #3949ab 100%);
    box-shadow: 0 4px 16px rgba(26, 35, 126, 0.3);
}

.btn-primary:active {
    box-shadow: 0 2px 4px rgba(26, 35, 126, 0.2);
}

.btn-record {
    background: linear-gradient(135deg, #dc2626 0%, #b91c1c 100%);
    color: #fff;
    border-color: transparent;
    box-shadow: 0 2px 8px rgba(220, 38, 38, 0.25);
    padding: 12px 28px;
    font-size: 15px;
}

.btn-record:hover {
    background: linear-gradient(135deg, #b91c1c 0%, #991b1b 100%);
    box-shadow: 0 4px 16px rgba(220, 38, 38, 0.3);
}

.btn-record.recording {
    animation: pulse-record 1.5s infinite;
    box-shadow: 0 0 0 4px rgba(220, 38, 38, 0.2);
}

@keyframes pulse-record {
    0%, 100% { box-shadow: 0 0 0 4px rgba(220, 38, 38, 0.2); }
    50% { box-shadow: 0 0 0 8px rgba(220, 38, 38, 0.1); }
}

.step-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 28px;
    padding-top: 20px;
    border-top: 1px solid #f1f5f9;
}

/* ─── Extraction Results ─── */
.extraction-result {
    margin-top: 12px;
    padding: 14px 16px;
    background: #f8fafc;
    border-radius: 10px;
    font-size: 13px;
    white-space: pre-wrap;
    display: none;
    font-family: 'SF Mono', 'Fira Code', monospace;
    border: 1px solid #e2e8f0;
    max-height: 200px;
    overflow-y: auto;
    line-height: 1.5;
}

.extraction-result.visible { display: block; }

.extraction-result.error {
    background: #fef2f2;
    color: #dc2626;
    border-color: #fecaca;
}

/* ─── Success Message ─── */
.success-msg {
    margin-top: 16px;
    padding: 12px 16px;
    background: #f0fdf4;
    border: 1px solid #bbf7d0;
    border-left: 4px solid #16a34a;
    border-radius: 10px;
    color: #15803d;
    font-size: 14px;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 8px;
}

/* ─── Voice Section ─── */
.voice-section {
    display: flex;
    gap: 20px;
    margin: 20px 0;
    flex-wrap: wrap;
}

.voice-recorder, .voice-upload {
    flex: 1;
    min-width: 260px;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    padding: 24px;
    background: #fff;
    transition: box-shadow 0.3s;
}

.voice-recorder:hover, .voice-upload:hover {
    box-shadow: 0 4px 16px rgba(0,0,0,0.06);
}

.voice-recorder h3, .voice-upload h3 {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 15px;
    font-weight: 600;
    color: #334155;
    margin-bottom: 16px;
}

.voice-recorder h3 .section-icon,
.voice-upload h3 .section-icon {
    width: 28px;
    height: 28px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.voice-recorder h3 .section-icon {
    background: #fef2f2;
    color: #dc2626;
}

.voice-upload h3 .section-icon {
    background: #eff1fe;
    color: #1a237e;
}

.voice-recorder h3 .section-icon svg,
.voice-upload h3 .section-icon svg {
    width: 16px;
    height: 16px;
}

#record-status {
    display: inline-block;
    margin-left: 10px;
    font-size: 13px;
    color: #64748b;
    font-weight: 500;
}

#audio-preview {
    margin-top: 16px;
    width: 100%;
    border-radius: 8px;
}

/* ─── Form Styles ─── */
fieldset {
    border: none;
    border-left: 4px solid #e2e8f0;
    border-radius: 0 12px 12px 0;
    padding: 20px 20px 20px 24px;
    margin-bottom: 16px;
    background: #fafbfc;
    transition: border-left-color 0.3s;
}

fieldset:hover {
    border-left-color: #1a237e;
}

fieldset:nth-child(even) {
    background: #f8fafc;
}

legend {
    font-weight: 600;
    font-size: 15px;
    color: #1a237e;
    padding: 0 4px;
    margin-bottom: 4px;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 16px;
    margin-top: 12px;
}

.form-grid-full {
    margin-top: 12px;
}

.form-grid label, .form-grid-full label {
    display: flex;
    flex-direction: column;
    font-size: 13px;
    color: #475569;
    gap: 6px;
    font-weight: 500;
}

.form-grid input, .form-grid select,
.form-grid-full input, .form-grid-full textarea, .form-grid-full select {
    padding: 10px 12px;
    border: 1.5px solid #e2e8f0;
    border-radius: 8px;
    font-size: 14px;
    font-family: inherit;
    width: 100%;
    transition: all 0.2s ease;
    background: #fff;
    color: #1e293b;
}

.form-grid input:focus, .form-grid select:focus,
.form-grid-full input:focus, .form-grid-full textarea:focus, .form-grid-full select:focus {
    outline: none;
    border-color: #1a237e;
    box-shadow: 0 0 0 3px rgba(26, 35, 126, 0.1);
}

.form-grid-full textarea {
    resize: vertical;
    min-height: 80px;
}

/* Checkbox grid */
.checkbox-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 8px 20px;
    margin-top: 12px;
}

.checkbox-grid label {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: #475569;
    cursor: pointer;
    padding: 6px 8px;
    border-radius: 6px;
    transition: background 0.15s;
    font-weight: 400;
}

.checkbox-grid label:hover {
    background: #f1f5f9;
}

.checkbox-grid input[type="checkbox"] {
    width: 16px;
    height: 16px;
    margin: 0;
    accent-color: #1a237e;
    flex-shrink: 0;
}

.violations-review-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 12px;
}

.violations-review-table th {
    font-size: 12px;
    font-weight: 600;
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 8px 4px;
    border-bottom: 2px solid #e2e8f0;
}

.violations-review-table th:first-child,
.violations-review-table th:last-child {
    width: 40px;
    text-align: center;
}

.violations-review-table td {
    padding: 6px 4px;
    font-size: 13px;
    color: #475569;
    border-bottom: 1px solid #f1f5f9;
}

.violations-review-table td:first-child,
.violations-review-table td:last-child {
    text-align: center;
}

.violations-review-table input[type="checkbox"] {
    width: 16px;
    height: 16px;
    margin: 0;
    accent-color: #1a237e;
}

.violations-review-table tr:hover {
    background: #f8fafc;
}

.note {
    font-size: 12px;
    color: #94a3b8;
    margin-top: 8px;
    font-style: italic;
}

/* ─── PDF Section ─── */
.pdf-actions {
    display: flex;
    gap: 12px;
    margin-bottom: 20px;
}

.pdf-actions .btn {
    padding: 12px 28px;
    font-size: 15px;
}

.pdf-preview-frame {
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    min-height: 400px;
    padding: 24px;
    background: #fafbfc;
}

/* ─── Loading Overlay ─── */
.loading-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(255, 255, 255, 0.6);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.spinner {
    width: 48px;
    height: 48px;
    border: 4px solid #e2e8f0;
    border-top-color: #1a237e;
    border-right-color: #1a237e;
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
    position: relative;
}

.spinner::after {
    content: '';
    position: absolute;
    top: 4px;
    left: 4px;
    right: 4px;
    bottom: 4px;
    border: 3px solid transparent;
    border-top-color: #3949ab;
    border-radius: 50%;
    animation: spin 1.2s linear infinite reverse;
}

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

#loading-text {
    margin-top: 16px;
    color: #1a237e;
    font-weight: 600;
    font-size: 15px;
    letter-spacing: -0.2px;
}

/* ─── Responsive ─── */
@media (max-width: 640px) {
    .container {
        padding: 16px 12px 32px;
    }

    .wizard-nav {
        padding: 16px 8px;
        gap: 0;
    }

    .wizard-step {
        font-size: 10px;
    }

    .step-circle {
        width: 32px;
        height: 32px;
        font-size: 13px;
    }

    .wizard-step:not(:last-child)::after {
        top: 16px;
        left: calc(50% + 20px);
        width: calc(100% - 40px);
        height: 2px;
    }

    .wizard-step.active .step-circle {
        box-shadow: 0 0 0 3px rgba(26, 35, 126, 0.15);
    }

    .step-label {
        max-width: 70px;
        font-size: 10px;
    }

    .step-panel {
        padding: 20px 16px;
        border-radius: 12px;
    }

    .voice-section {
        flex-direction: column;
    }

    .voice-recorder, .voice-upload {
        min-width: unset;
    }

    .form-grid {
        grid-template-columns: 1fr;
    }

    .checkbox-grid {
        grid-template-columns: 1fr;
    }

    .step-actions {
        gap: 8px;
    }

    .btn {
        padding: 8px 16px;
        font-size: 13px;
    }

    .app-header h1 {
        font-size: 18px;
    }
}
