/* ═══════════════════════════════════════════
   Automate Loan Docs — Brand Overrides
   ═══════════════════════════════════════════ */

:root {
    --ald-midnight: #0F1720;
    --ald-steel: #2C3F52;
    --ald-gunmetal: #8E949A;
    --ald-chrome: #C7CCD1;
    --ald-charcoal: #1C1F23;
    --ald-graphite: #3A3F45;
    --ald-paper: #F5F7FA;
    --ald-cta: #223447;
    --ald-cta-hover: #3E566E;
}

* { scrollbar-width: thin; scrollbar-color: var(--ald-chrome) transparent; }
::selection { background: var(--ald-steel); color: white; }
body { font-family: 'DM Sans', 'Inter', system-ui, sans-serif; -webkit-font-smoothing: antialiased; }

/* Sidebar drawer override */
.ald-drawer { background: var(--ald-midnight) !important; }
.ald-drawer .mud-nav-link { color: rgba(255,255,255,0.5); font-size: 13px; font-weight: 500; border-radius: 6px; margin-bottom: 2px; }
.ald-drawer .mud-nav-link:hover { color: rgba(255,255,255,0.8); background: rgba(255,255,255,0.05); }
.ald-drawer .mud-nav-link.active { color: white; background: rgba(255,255,255,0.1); }
.ald-drawer .mud-nav-link.active::before {
    content: ''; position: absolute; left: 0; top: 50%; transform: translateY(-50%);
    width: 3px; height: 20px; border-radius: 0 4px 4px 0; background: var(--ald-steel);
}
.ald-drawer .mud-nav-link .mud-icon-root { opacity: 0.6; }
.ald-drawer .mud-nav-link.active .mud-icon-root { opacity: 1; }

/* Card style */
.ald-card { background: white; border-radius: 12px; border: 1px solid rgba(199,204,209,0.6); box-shadow: 0 1px 3px rgba(0,0,0,0.04); }

/* Status badges */
.ald-status-pending { background: #fef3c7; color: #92400e; border: 1px solid #fde68a; }
.ald-status-active { background: #d1fae5; color: #065f46; border: 1px solid #6ee7b7; }
.ald-status-review { background: #dbeafe; color: #1e40af; border: 1px solid #93c5fd; }
.ald-status-draft { background: #F5F7FA; color: #3A3F45; border: 1px solid #C7CCD1; }
.ald-status-closed { background: #f3f4f6; color: #374151; border: 1px solid #d1d5db; }

/* Feature toggle expansion */
.ald-feature-sub { margin-left: 24px; padding-left: 24px; border-left: 2px solid rgba(44,63,82,0.2); padding-top: 12px; padding-bottom: 12px; }

/* Section card (accordion) */
.ald-section { transition: all 0.3s ease; scroll-margin-top: 100px; }
.ald-section-complete { box-shadow: 0 0 0 1px rgba(16,185,129,0.2); }
.ald-section-error { box-shadow: 0 0 0 1px rgba(239,68,68,0.3); }

/* Wizard step indicator */
.ald-step-active { background: var(--ald-cta); color: white; }
.ald-step-done { background: #10b981; color: white; }
.ald-step-pending { background: transparent; border: 2px solid var(--ald-chrome); color: var(--ald-gunmetal); }

/* Generate bar */
.ald-generate-bar {
    position: fixed; bottom: 0; right: 0; left: 240px; z-index: 100;
    background: rgba(255,255,255,0.92); backdrop-filter: blur(16px);
    border-top: 1px solid rgba(199,204,209,0.4); padding: 12px 28px;
}

/* Loan type card */
.ald-loan-type-card { transition: all 0.2s; cursor: pointer; }
.ald-loan-type-card:hover { border-color: var(--ald-gunmetal); }
.ald-loan-type-card.selected { border-color: var(--ald-cta); background: rgba(34,52,71,0.04); box-shadow: 0 0 0 1px var(--ald-cta); }

/* ═══════════════════════════════════════════
   Authentication Pages
   ═══════════════════════════════════════════ */

.login-layout {
    min-height: 100vh;
    background: linear-gradient(135deg, var(--ald-midnight) 0%, var(--ald-charcoal) 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.login-container {
    width: 100%;
    max-width: 460px;
}

.login-card {
    background: var(--ald-paper);
    border-radius: 16px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    padding: 48px 40px;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.login-header {
    text-align: center;
    margin-bottom: 36px;
}

.login-logo {
    font-size: 32px;
    font-weight: 700;
    color: var(--ald-charcoal);
    margin: 0 0 8px 0;
    letter-spacing: -0.5px;
}

.login-tagline {
    font-size: 14px;
    color: var(--ald-gunmetal);
    margin: 0;
    font-weight: 500;
}

.login-body {
    margin-top: 24px;
}

.login-footer {
    text-align: center;
    margin-top: 32px;
    padding-top: 24px;
    border-top: 1px solid rgba(199, 204, 209, 0.3);
}

.login-footer p {
    font-size: 13px;
    color: var(--ald-gunmetal);
    margin: 0;
}

.auth-form h2 {
    font-size: 24px;
    font-weight: 700;
    color: var(--ald-charcoal);
    margin: 0 0 8px 0;
}

.auth-subtitle {
    font-size: 14px;
    color: var(--ald-graphite);
    margin: 0 0 28px 0;
}

.auth-button {
    margin-top: 8px;
    background: var(--ald-cta) !important;
    height: 48px;
    font-weight: 600;
    letter-spacing: 0.3px;
    text-transform: none;
    font-size: 15px;
}

.auth-button:hover {
    background: var(--ald-cta-hover) !important;
}

.auth-footer {
    margin-top: 24px;
    text-align: center;
}

.auth-footer p {
    font-size: 14px;
    color: var(--ald-graphite);
    margin: 0;
}

.auth-link {
    color: var(--ald-cta);
    text-decoration: none;
    font-weight: 600;
    transition: color 0.2s;
}

.auth-link:hover {
    color: var(--ald-cta-hover);
    text-decoration: underline;
}

/* ═══════════════════════════════════════════
   New Loan Wizard — React UI Parity
   ═══════════════════════════════════════════ */

/* Card Component */
.ald-card {
    background: white;
    border-radius: 12px;
    border: 1px solid var(--ald-chrome);
    padding: 16px;
    transition: all 0.2s ease;
}

.ald-card-active {
    border-color: var(--ald-steel);
    box-shadow: 0 0 0 2px rgba(44, 63, 82, 0.12);
}

.ald-card:has(> *:hover):not(.ald-card-active) {
    border-color: var(--ald-gunmetal);
}

/* Section error glow — required fields missing */
.ald-section-error {
    border: 2px solid #d32f2f !important;
    box-shadow: 0 0 12px rgba(211, 47, 47, 0.25) !important;
}

/* Badge Component */
.ald-badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.3px;
}

.ald-badge-default {
    background: rgba(199, 204, 209, 0.25);
    color: var(--ald-graphite);
}

.ald-badge-info {
    background: rgba(44, 63, 82, 0.15);
    color: var(--ald-steel);
}

.ald-badge-warning {
    background: #FFF3CD;
    color: #B45309;
}

.ald-badge-success {
    background: #D4EDDA;
    color: #2D6A4F;
}

/* Section Divider */
.ald-section-divider {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 24px 0;
}

.ald-divider-line {
    flex: 1;
    height: 1px;
    background: var(--ald-chrome);
}

.ald-divider-line-full {
    width: 100%;
    height: 1px;
    background: var(--ald-chrome);
}

.ald-divider-title {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: var(--ald-gunmetal);
}

/* Document Package Preview Panel */
.ald-doc-preview-panel {
    background: var(--ald-midnight);
    border-radius: 12px;
    border: 1px solid var(--ald-steel);
    overflow: hidden;
    position: sticky;
    top: 24px;
}

.ald-doc-preview-header {
    padding: 16px;
    border-bottom: 1px solid var(--ald-steel);
}

.ald-doc-preview-title {
    font-size: 14px;
    font-weight: 700;
    color: white;
    margin: 0;
}

.ald-doc-count {
    font-size: 11px;
    color: var(--ald-gunmetal);
    margin-left: auto;
}

.ald-status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
}

/* Preview Stats */
.ald-doc-preview-stats {
    padding: 16px;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    border-bottom: 1px solid rgba(44, 63, 82, 0.4);
}

.ald-stat-item {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.ald-stat-label {
    font-size: 11px;
    color: var(--ald-gunmetal);
}

.ald-stat-value {
    font-size: 14px;
    font-weight: 600;
    color: white;
}

.ald-stat-value-small {
    font-size: 11px;
    color: white;
}

.ald-stat-detail {
    font-size: 11px;
    color: var(--ald-chrome);
}

/* Document List */
.ald-doc-list {
    padding: 12px;
    max-height: 400px;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: var(--ald-steel) transparent;
}

.ald-doc-empty {
    padding: 48px 16px;
    text-align: center;
    font-size: 11px;
    color: var(--ald-gunmetal);
}

.ald-doc-item {
    margin-bottom: 4px;
}

.ald-doc-button {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    background: transparent;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.2s;
    text-align: left;
}

.ald-doc-button:hover {
    background: rgba(44, 63, 82, 0.3);
}

.ald-doc-button.expanded {
    background: rgba(44, 63, 82, 0.25);
}

.ald-doc-icon {
    font-size: 16px;
}

.ald-doc-name {
    flex: 1;
    font-size: 12px;
    font-weight: 500;
    color: white;
}

.ald-conditional-count {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: rgba(180, 83, 9, 0.2);
    color: #FCD34D;
    font-size: 11px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
}

.ald-expand-icon {
    font-size: 11px;
    color: var(--ald-gunmetal);
}

/* Document Details */
.ald-doc-details {
    padding: 8px 12px 12px 40px;
}

.ald-section-label,
.ald-conditional-label {
    font-size: 11px;
    color: var(--ald-gunmetal);
    margin-bottom: 6px;
}

.ald-conditional-label {
    color: #B45309;
    margin-top: 12px;
}

.ald-section-item,
.ald-conditional-item {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 3px 0;
}

.ald-section-item span:last-child,
.ald-conditional-item span:last-child {
    font-size: 11px;
    color: #d1d5db;
}

.ald-check-icon {
    color: #4ade80;
    font-size: 12px;
}

.ald-lightning-icon {
    color: #fbbf24;
    font-size: 12px;
}

/* Preview Footer */
.ald-doc-preview-footer {
    padding: 16px;
    border-top: 1px solid rgba(44, 63, 82, 0.4);
}

/* Merge Field Preview */
.ald-merge-preview {
    background: white;
    border-radius: 12px;
    border: 1px solid var(--ald-chrome);
    padding: 16px;
    margin-top: 16px;
}

.ald-merge-title {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--ald-graphite);
    margin: 0 0 12px 0;
}

.ald-merge-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.ald-merge-item {
    font-size: 11px;
    color: var(--ald-gunmetal);
}

.ald-merge-key {
    color: var(--ald-steel);
    font-weight: 600;
    font-family: 'Courier New', monospace;
}

/* Two-Column Wizard Layout */
.ald-wizard-container {
    display: flex;
    gap: 24px;
    align-items: flex-start;
}

.ald-wizard-form {
    flex: 1;
    min-width: 0;
}

.ald-wizard-preview {
    width: 360px;
    flex-shrink: 0;
}

/* Loan Type Cards */
.ald-loan-type-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
    margin-bottom: 24px;
}

.ald-loan-type-card {
    background: white;
    border: 2px solid var(--ald-chrome);
    border-radius: 12px;
    padding: 20px;
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: center;
}

.ald-loan-type-card:hover {
    border-color: var(--ald-steel);
    transform: translateY(2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

.ald-loan-type-card.selected {
    border-color: var(--ald-steel);
    background: rgba(44, 63, 82, 0.04);
    box-shadow: 0 0 0 2px rgba(44, 63, 82, 0.12);
}

.ald-loan-type-icon {
    font-size: 32px;
    margin-bottom: 8px;
}

.ald-loan-type-label {
    font-size: 14px;
    font-weight: 600;
    color: var(--ald-charcoal);
    margin-bottom: 4px;
}

.ald-loan-type-desc {
    font-size: 12px;
    color: var(--ald-gunmetal);
}

.ald-loan-type-selected {
    margin-top: 12px;
    font-size: 12px;
    font-weight: 600;
    color: #2D6A4F;
}

/* Step Navigation with Completion */
.ald-step-nav {
    display: flex;
    gap: 0;
    border-bottom: 1px solid var(--ald-chrome);
}

.ald-step-button {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 16px 20px;
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 14px;
    color: var(--ald-gunmetal);
    font-weight: 400;
}

.ald-step-button:hover {
    color: var(--ald-charcoal);
    background: rgba(44, 63, 82, 0.03);
}

.ald-step-button.active {
    color: var(--ald-charcoal);
    font-weight: 600;
    border-bottom-color: var(--ald-steel);
}

.ald-step-num {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 600;
    background: rgba(199, 204, 209, 0.4);
    color: var(--ald-gunmetal);
    transition: all 0.2s;
}

.ald-step-button.active .ald-step-num {
    background: var(--ald-chrome);
    color: white;
}

.ald-step-button.completed .ald-step-num {
    background: var(--ald-steel);
    color: white;
}

/* Property State Badges */
.ald-property-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 12px;
}

.ald-property-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--ald-steel);
}

/* Fee Calculator */
.ald-fee-row {
    display: flex;
    align-items: flex-end;
    gap: 12px;
    margin-bottom: 12px;
}

.ald-fee-computed {
    width: 120px;
    padding-bottom: 12px;
    text-align: right;
}

.ald-fee-computed-value {
    font-size: 14px;
    font-weight: 600;
    color: var(--ald-charcoal);
}

.ald-fee-total {
    background: var(--ald-paper);
    border-radius: 8px;
    padding: 16px;
    margin-top: 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.ald-fee-total-label,
.ald-fee-total-value {
    font-size: 14px;
    font-weight: 600;
    color: var(--ald-charcoal);
}

/* Responsive adjustments */
@media (max-width: 1200px) {
    .ald-wizard-preview {
        width: 320px;
    }

    .ald-loan-type-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 968px) {
    .ald-wizard-container {
        flex-direction: column;
    }

    .ald-wizard-preview {
        width: 100%;
        position: static;
    }

    .ald-loan-type-grid {
        grid-template-columns: 1fr;
    }
}

/* ═══════════════════════════════════════════
   Template Drag & Drop
   ═══════════════════════════════════════════ */

.ald-file-dropzone {
    position: relative;
}

.ald-drop-overlay {
    display: none;
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(34, 52, 71, 0.06);
    border: 2px dashed var(--ald-steel);
    border-radius: 12px;
    z-index: 20;
    align-items: center;
    justify-content: center;
    pointer-events: none;
}

.ald-file-dragover .ald-drop-overlay {
    display: flex;
}

.ald-drop-overlay-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 32px 48px;
    border-radius: 12px;
    background: white;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
}

.ald-drag-handle {
    cursor: grab;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 4px;
    border-radius: 4px;
    color: var(--ald-chrome);
    transition: color 0.15s, background 0.15s;
}

.ald-drag-handle:hover {
    color: var(--ald-steel);
    background: rgba(44, 63, 82, 0.06);
}

.ald-drag-handle:active {
    cursor: grabbing;
}

.ald-row-dragging {
    opacity: 0.4 !important;
    background: rgba(44, 63, 82, 0.03);
}

.ald-row-drop-above {
    box-shadow: inset 0 2px 0 0 var(--ald-steel);
}

.ald-row-drop-below {
    box-shadow: inset 0 -2px 0 0 var(--ald-steel);
}
