@import url('https://fonts.googleapis.com/css2?family=DM+Serif+Display&family=Inter:wght@400;500;600;700&display=swap');

:root {
    --primary: #5B4B8A;
    --primary-dark: #453672;
    --primary-light: #7B6BA8;
    --primary-pale: #E8E4F0;
    --accent: #8B6EC1;
    --accent-glow: #A78BDB;
    --surface: #FAF9FC;
    --surface-alt: #F3F1F8;
    --text: #2D2640;
    --text-light: #6B6280;
    --text-muted: #9590A6;
    --success: #4CAF82;
    --warning: #E5A84B;
    --border: #E0DCE8;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background-color: #FAF9FC;
    color: #333;
    line-height: 1.6;
}

.container {
    max-width: 800px;
    margin: 0 auto;
    padding: 20px;
}

header {
    text-align: center;
    padding: 40px 20px;
    background: linear-gradient(135deg, #5B4B8A 0%, #7B6BA8 100%);
    color: white;
    border-radius: 10px 10px 0 0;
    margin-bottom: 0;
}

header h1 {
    font-family: 'DM Serif Display', serif;
    font-size: 2rem;
    margin-bottom: 10px;
}

header p {
    opacity: 0.9;
    font-size: 1.1rem;
}

#intake-form {
    background: white;
    padding: 30px;
    border-radius: 0 0 10px 10px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.form-section {
    margin-bottom: 35px;
    padding-bottom: 25px;
    border-bottom: 1px solid #eee;
}

.form-section:last-child {
    border-bottom: none;
    margin-bottom: 0;
}

.form-section h2 {
    color: #5B4B8A;
    font-size: 1.3rem;
    margin-bottom: 20px;
    padding-bottom: 10px;
    border-bottom: 2px solid #7B6BA8;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 20px;
}

@media (max-width: 600px) {
    .form-grid {
        grid-template-columns: 1fr;
    }
}

.form-group {
    display: flex;
    flex-direction: column;
}

.form-group.full-width {
    grid-column: 1 / -1;
}

.form-group label {
    font-weight: 500;
    margin-bottom: 6px;
    color: #444;
}

.form-group input,
.form-group select,
.form-group textarea {
    padding: 12px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 1rem;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: #7B6BA8;
    box-shadow: 0 0 0 3px rgba(91, 75, 138, 0.15);
}

.form-group input:invalid:not(:placeholder-shown),
.form-group select:invalid:not(:placeholder-shown) {
    border-color: #dc3545;
}

.form-group textarea {
    resize: vertical;
    min-height: 80px;
}

.checkbox-group {
    flex-direction: row;
    align-items: center;
}

.checkbox-group label {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    font-weight: normal;
}

.checkbox-group input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
}

.input-with-prefix {
    display: flex;
    align-items: stretch;
}

.input-with-prefix .prefix {
    background: #f0f0f0;
    padding: 12px 15px;
    border: 1px solid #ddd;
    border-right: none;
    border-radius: 6px 0 0 6px;
    color: #666;
    font-weight: 500;
}

.input-with-prefix input {
    border-radius: 0 6px 6px 0;
    flex: 1;
}

.file-upload {
    margin-top: 20px;
}

.file-upload input[type="file"] {
    padding: 10px;
    background: #f9f9f9;
    cursor: pointer;
}

.help-text {
    font-size: 0.85rem;
    color: #666;
    margin-top: 5px;
}


.success-icon {
    width: 80px;
    height: 80px;
    background: #4CAF82;
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto;
}

.cancel-icon {
    width: 80px;
    height: 80px;
    background: #f8d7da;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto;
}

.submit-section {
    text-align: center;
}

.submit-section .checkbox-group {
    justify-content: center;
    margin-bottom: 20px;
}

.btn-submit {
    background: linear-gradient(135deg, #4CAF82 0%, #3D9B6E 100%);
    color: white;
    border: none;
    padding: 15px 50px;
    font-size: 1.1rem;
    font-weight: 600;
    border-radius: 8px;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
}

.btn-submit:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(76, 175, 130, 0.3);
}

.btn-submit:active {
    transform: translateY(0);
}

.btn-submit:disabled {
    background: #ccc;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.btn-secondary {
    background: #6c757d;
    color: white;
    border: none;
    padding: 12px 30px;
    font-size: 1rem;
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.2s;
}

.btn-secondary:hover {
    background: #5a6268;
}

.hidden {
    display: none !important;
}

#success-message {
    background: white;
    padding: 60px 30px;
    border-radius: 10px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    text-align: center;
}

.success-content h2 {
    color: #4CAF82;
    margin-bottom: 20px;
    font-size: 1.8rem;
}

.success-content p {
    margin-bottom: 15px;
    font-size: 1.1rem;
}

.success-content #case-reference {
    color: #5B4B8A;
    font-size: 1.3rem;
}

/* Auth banner */
.auth-banner {
    background: #fff3cd;
    color: #856404;
    padding: 15px 20px;
    border-radius: 6px;
    margin-bottom: 20px;
    border: 1px solid #ffeeba;
    text-align: center;
}

.auth-banner a {
    color: #533f03;
    font-weight: 600;
}

.auth-banner a:hover {
    color: #5B4B8A;
}

/* Error styling */
.error-message {
    background: #f8d7da;
    color: #721c24;
    padding: 15px;
    border-radius: 6px;
    margin-bottom: 20px;
    border: 1px solid #f5c6cb;
}

/* Loading state */
.loading {
    position: relative;
    pointer-events: none;
}

.loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    margin: -10px 0 0 -10px;
    border: 3px solid #fff;
    border-top-color: transparent;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* Responsive Design Improvements */

/* Tablet Breakpoint */
@media (max-width: 768px) {
    .container {
        padding: 15px;
    }

    header {
        padding: 30px 15px;
        border-radius: 0;
    }

    header h1 {
        font-size: 1.6rem;
    }

    header p {
        font-size: 1rem;
    }

    #intake-form {
        padding: 20px;
        border-radius: 0 0 8px 8px;
    }

    .form-section h2 {
        font-size: 1.15rem;
    }

    .btn-submit {
        width: 100%;
        padding: 14px;
    }
}

/* Mobile Breakpoint */
@media (max-width: 480px) {
    body {
        font-size: 14px;
    }

    .container {
        padding: 10px;
    }

    header {
        padding: 25px 15px;
    }

    header h1 {
        font-size: 1.4rem;
    }

    #intake-form {
        padding: 15px;
    }

    .form-section {
        margin-bottom: 25px;
        padding-bottom: 20px;
    }

    .form-group input,
    .form-group select,
    .form-group textarea {
        padding: 10px;
        font-size: 16px; /* Prevents iOS zoom on focus */
    }

    .input-with-prefix .prefix {
        padding: 10px 12px;
        font-size: 0.9rem;
    }

    .btn-submit {
        padding: 12px;
        font-size: 1rem;
    }

    #success-message {
        padding: 40px 20px;
    }

    .success-content h2 {
        font-size: 1.5rem;
    }

    .success-icon,
    .cancel-icon {
        width: 60px;
        height: 60px;
    }
}

/* Touch-friendly improvements */
@media (hover: none) and (pointer: coarse) {
    .form-group input,
    .form-group select,
    .form-group textarea {
        min-height: 44px; /* Apple's minimum touch target */
    }

    .checkbox-group input[type="checkbox"] {
        width: 22px;
        height: 22px;
    }

    .btn-submit,
    .btn-secondary {
        min-height: 48px;
    }
}

/* ===== Wizard Progress Bar ===== */
.wizard-progress {
    display: flex;
    align-items: center;
    justify-content: center;
    background: white;
    padding: 24px 20px 20px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.wizard-progress-step {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    position: relative;
    z-index: 1;
}

.step-circle {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: #E0DCE8;
    color: #6B6280;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 0.9rem;
    transition: background 0.3s, color 0.3s, box-shadow 0.3s;
}

.wizard-progress-step.active .step-circle {
    background: var(--primary);
    color: white;
    box-shadow: 0 2px 8px rgba(91, 75, 138, 0.35);
}

.wizard-progress-step.completed .step-circle {
    background: var(--success);
    color: white;
}

.step-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-weight: 500;
    transition: color 0.3s;
}

.wizard-progress-step.active .step-label {
    color: var(--primary);
    font-weight: 600;
}

.wizard-progress-step.completed .step-label {
    color: var(--success);
}

.wizard-progress-line {
    flex: 1;
    height: 3px;
    background: #E0DCE8;
    margin: 0 8px;
    margin-bottom: 22px;
    border-radius: 2px;
    transition: background 0.3s;
    max-width: 80px;
}

.wizard-progress-line.completed {
    background: var(--success);
}

/* ===== Wizard Steps ===== */
.wizard-step {
    display: none;
}

.wizard-step.active {
    display: block;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ===== Wizard Navigation ===== */
.wizard-nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 0 10px;
    margin-top: 10px;
    border-top: 1px solid #eee;
}

.btn-next,
.btn-back {
    border: none;
    padding: 12px 32px;
    font-size: 1rem;
    font-weight: 600;
    border-radius: 8px;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s, background 0.2s;
}

.btn-next {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
    color: white;
}

.btn-next:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(91, 75, 138, 0.3);
}

.btn-back {
    background: transparent;
    color: var(--text-light);
    border: 1px solid var(--border);
}

.btn-back:hover {
    background: var(--surface-alt);
    color: var(--text);
}

/* ===== Drop Zone ===== */
.drop-zone {
    border: 2px dashed var(--border);
    border-radius: 12px;
    padding: 40px 20px;
    text-align: center;
    cursor: pointer;
    transition: border-color 0.3s, background 0.3s;
    margin-top: 16px;
    position: relative;
}

.drop-zone:hover,
.drop-zone.dragover {
    border-color: var(--primary-light);
    background: var(--primary-pale);
}

.drop-zone-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.drop-zone-icon {
    color: var(--text-muted);
    margin-bottom: 4px;
}

.drop-zone.dragover .drop-zone-icon {
    color: var(--primary);
}

.drop-zone-text {
    font-size: 1rem;
    color: var(--text-light);
    font-weight: 500;
}

.drop-zone-or {
    font-size: 0.85rem;
    color: var(--text-muted);
}

.btn-browse {
    display: inline-block;
    background: var(--primary);
    color: white;
    padding: 8px 24px;
    border-radius: 6px;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s;
}

.btn-browse:hover {
    background: var(--primary-dark);
}

.drop-zone-input {
    position: absolute;
    width: 0;
    height: 0;
    opacity: 0;
    overflow: hidden;
}

/* ===== Image Preview Grid ===== */
.image-preview-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 12px;
    margin-top: 16px;
}

.image-preview-item {
    position: relative;
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid var(--border);
    background: var(--surface-alt);
    aspect-ratio: 1;
}

.image-preview-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.image-preview-item .file-name {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: rgba(0, 0, 0, 0.6);
    color: white;
    font-size: 0.7rem;
    padding: 4px 6px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.image-preview-item .btn-remove {
    position: absolute;
    top: 4px;
    right: 4px;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.6);
    color: white;
    border: none;
    cursor: pointer;
    font-size: 14px;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.image-preview-item .btn-remove:hover {
    background: #dc3545;
}

.pdf-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    color: var(--text-muted);
    font-size: 0.8rem;
    gap: 4px;
}

.pdf-placeholder svg {
    width: 32px;
    height: 32px;
}

/* Size info line inside file-name overlay */
.image-preview-item .file-name {
    /* Allow two lines so the size info fits */
    white-space: normal;
}

.image-preview-item .file-size-info {
    display: block;
    font-size: 0.65rem;
    opacity: 0.85;
    margin-top: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* "Compressing images..." indicator inside the drop zone */
.compressing-indicator {
    margin-top: 10px;
    font-size: 0.85rem;
    color: var(--primary);
    font-style: italic;
    text-align: center;
}

/* Upload progress bar */
.upload-progress-wrapper {
    margin-bottom: 14px;
}

.upload-progress-label {
    font-size: 0.85rem;
    color: var(--text-light);
    margin-bottom: 6px;
    text-align: center;
}

.upload-progress-track {
    height: 8px;
    background: var(--border);
    border-radius: 4px;
    overflow: hidden;
}

.upload-progress-bar {
    height: 100%;
    background: var(--primary);
    border-radius: 4px;
    width: 0;
    transition: width 0.3s ease;
}

/* Indeterminate animation for when we don't yet have real progress */
@keyframes progress-indeterminate {
    0%   { left: -30%; width: 30%; }
    100% { left: 100%; width: 30%; }
}

.upload-progress-bar.indeterminate {
    position: relative;
    width: 30% !important;
    animation: progress-indeterminate 1.2s ease-in-out infinite;
}

/* Step description text */
.step-description {
    color: var(--text-light);
    font-size: 0.95rem;
    margin-bottom: 8px;
}

/* Field validation highlight */
.field-invalid {
    border-color: #dc3545 !important;
    box-shadow: 0 0 0 3px rgba(220, 53, 69, 0.15) !important;
}

/* Draft restored banner */
.draft-banner {
    background: #d4edda;
    color: #155724;
    padding: 10px 16px;
    border-radius: 6px;
    margin-bottom: 12px;
    border: 1px solid #c3e6cb;
    font-size: 0.9rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.draft-banner button {
    background: none;
    border: none;
    color: #155724;
    font-weight: 600;
    cursor: pointer;
    text-decoration: underline;
    font-size: 0.85rem;
}

/* ===== Wizard Responsive ===== */
@media (max-width: 768px) {
    .wizard-progress {
        padding: 16px 10px 14px;
    }

    .step-circle {
        width: 30px;
        height: 30px;
        font-size: 0.8rem;
    }

    .step-label {
        font-size: 0.65rem;
    }

    .wizard-progress-line {
        max-width: 50px;
        margin-bottom: 20px;
    }

    .btn-next,
    .btn-back {
        padding: 10px 24px;
        font-size: 0.9rem;
    }

    .drop-zone {
        padding: 30px 15px;
    }
}

@media (max-width: 480px) {
    .wizard-progress {
        padding: 14px 6px 10px;
    }

    .step-circle {
        width: 28px;
        height: 28px;
        font-size: 0.75rem;
    }

    .step-label {
        font-size: 0.6rem;
    }

    .wizard-progress-line {
        max-width: 30px;
        margin: 0 4px;
        margin-bottom: 18px;
    }

    .btn-next,
    .btn-back {
        padding: 10px 18px;
        font-size: 0.85rem;
    }

    .image-preview-grid {
        grid-template-columns: repeat(auto-fill, minmax(90px, 1fr));
        gap: 8px;
    }
}

/* ===== Auth Prompt Modal ===== */
.auth-prompt-overlay {
    position: fixed;
    inset: 0;
    background: rgba(45, 38, 64, 0.6);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    padding: 20px;
    animation: fadeIn 0.2s ease;
}

.auth-prompt-modal {
    background: white;
    border-radius: 16px;
    padding: 40px 36px;
    max-width: 420px;
    width: 100%;
    text-align: center;
    box-shadow: 0 20px 60px rgba(45, 38, 64, 0.25);
}

.auth-prompt-modal h3 {
    font-family: 'DM Serif Display', serif;
    color: var(--primary);
    font-size: 1.4rem;
    margin-bottom: 12px;
}

.auth-prompt-modal p {
    color: var(--text-light);
    font-size: 0.95rem;
    line-height: 1.6;
    margin-bottom: 24px;
}

.auth-prompt-actions {
    display: flex;
    gap: 12px;
    margin-bottom: 16px;
}

.auth-prompt-btn {
    flex: 1;
    display: inline-block;
    padding: 14px 20px;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    text-decoration: none;
    text-align: center;
    transition: transform 0.2s, box-shadow 0.2s;
    cursor: pointer;
}

.auth-prompt-btn:hover {
    transform: translateY(-2px);
}

.auth-prompt-login {
    background: var(--primary);
    color: white;
}

.auth-prompt-login:hover {
    box-shadow: 0 4px 15px rgba(91, 75, 138, 0.35);
}

.auth-prompt-register {
    background: var(--success);
    color: white;
}

.auth-prompt-register:hover {
    box-shadow: 0 4px 15px rgba(76, 175, 130, 0.35);
}

.auth-prompt-close {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 0.9rem;
    cursor: pointer;
    padding: 8px 16px;
    transition: color 0.2s;
}

.auth-prompt-close:hover {
    color: var(--text);
}

@media (max-width: 480px) {
    .auth-prompt-modal {
        padding: 28px 24px;
    }

    .auth-prompt-actions {
        flex-direction: column;
    }
}

/* Print styles */
@media print {
    header {
        background: #5B4B8A !important;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }

    .btn-submit,
    .btn-secondary {
        display: none;
    }
}
