/* ============================================================
   LOAN APPLICATION FORM STYLES
   ============================================================ */

/* ── Section ─────────────────────────────────────────────── */
.loan-form-section { padding: 0; }

/* ── Progress Nav ────────────────────────────────────────── */
.loan-steps-nav {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0;
    margin-bottom: 36px;
    flex-wrap: wrap;
    gap: 8px;
}

.loan-step-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    position: relative;
    cursor: pointer;
}

.loan-step-circle {
    width: 52px;
    height: 52px;
    border-radius: 50%;
    background: #e9ecef;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    color: #6c757d;
    position: relative;
    transition: all 0.3s ease;
    border: 3px solid transparent;
}

.loan-step-circle .loan-step-num {
    display: none;
}

.loan-step-item.active .loan-step-circle {
    background: var(--color-primary);
    color: #fff;
    border-color: rgba(184,0,15,.25);
    box-shadow: 0 4px 16px rgba(184,0,15,.3);
    transform: scale(1.1);
}

.loan-step-item.completed .loan-step-circle {
    background: var(--color-success);
    color: #fff;
    border-color: rgba(40, 167, 69,.15);
}

.loan-step-item.completed .loan-step-circle i { display: none; }
.loan-step-item.completed .loan-step-circle .loan-step-num {
    display: block;
    font-weight: 700;
    font-size: .85rem;
}
.loan-step-item.completed .loan-step-circle::after {
    content: '✓';
    position: absolute;
    font-size: 1.1rem;
    font-weight: 700;
}
.loan-step-item.completed .loan-step-circle i { opacity: 0; }

.loan-step-label {
    font-size: .76rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .8px;
    color: #adb5bd;
    text-align: center;
    max-width: 120px;
    transition: color 0.3s;
}

.loan-step-item.active .loan-step-label { color: var(--color-primary); }
.loan-step-item.completed .loan-step-label { color: var(--color-black,#0a0a0a); }

.loan-step-connector {
    flex: 1;
    height: 3px;
    background: #e9ecef;
    margin: 0 6px;
    margin-bottom: 28px;
    border-radius: 2px;
    min-width: 30px;
    max-width: 80px;
    transition: background 0.3s;
    position: relative;
    overflow: hidden;
}

.loan-step-connector.done {
    background: var(--color-primary,var(--color-primary));
}

/* ── Form Card ───────────────────────────────────────────── */
.loan-form-card {
    background: #fff;
    border-radius: 20px;
    box-shadow: 0 8px 40px rgba(0,0,0,.10);
    border: 1px solid #f0f0f0;
    overflow: hidden;
}

/* ── Step Panel ──────────────────────────────────────────── */
.loan-step-panel {
    display: none;
    padding: 36px 40px;
    animation: loanFadeIn .4s ease;
}

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

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

/* ── Step Header ─────────────────────────────────────────── */
.loan-step-header {
    display: flex;
    align-items: center;
    gap: 18px;
    margin-bottom: 28px;
    padding-bottom: 20px;
    border-bottom: 2px solid #f0f0f0;
}

.loan-step-icon-lg {
    width: 56px;
    height: 56px;
    min-width: 56px;
    background: var(--color-primary,var(--color-primary));
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4rem;
    color: #fff;
    box-shadow: 0 4px 14px rgba(184,0,15,.3);
}

.loan-step-header h4 {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--color-dark-gray);
    margin-bottom: 4px;
}

/* ── Form Labels ─────────────────────────────────────────── */
.form-label.required::after {
    content: ' *';
    color: var(--color-primary);
    font-weight: 700;
}

/* ── Live Estimate Strip ─────────────────────────────────── */
.loan-estimate-strip {
    display: flex;
    gap: 1px;
    border-radius: 12px;
    overflow: hidden;
    border: 1.5px solid rgba(184,0,15,.2);
    background: rgba(184,0,15,.05);
}

.loan-estimate-item {
    flex: 1;
    padding: 14px 16px;
    text-align: center;
    border-right: 1px solid rgba(184,0,15,.12);
}

.loan-estimate-item:last-child { border-right: none; }

.loan-est-label {
    font-size: .72rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--color-mid-gray);
    display: block;
    margin-bottom: 4px;
}

.loan-est-value {
    font-size: 1.2rem;
    font-weight: 800;
    color: var(--color-primary);
    display: block;
}

/* ── Upload Area ─────────────────────────────────────────── */
.loan-upload-area {
    border: 2px dashed #dee2e6;
    border-radius: 12px;
    padding: 40px 20px;
    text-align: center;
    cursor: pointer;
    transition: all .25s ease;
    position: relative;
    background: #fafafa;
}

.loan-upload-area:hover,
.loan-upload-area.dragover {
    border-color: var(--color-primary);
    background: rgba(184,0,15,.03);
}

.loan-upload-input {
    position: absolute;
    inset: 0;
    opacity: 0;
    cursor: pointer;
    width: 100%;
    height: 100%;
}

.loan-upload-body p { margin: 0; }

/* ── File List ───────────────────────────────────────────── */
.loan-file-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    background: #f8f9fa;
    border-radius: 8px;
    margin-bottom: 6px;
    border: 1px solid #e9ecef;
    font-size: .85rem;
}

.loan-file-icon { color: var(--color-primary); font-size: 1rem; }
.loan-file-name { flex: 1; font-weight: 600; }
.loan-file-size { color: #6c757d; }
.loan-file-remove {
    background: none;
    border: none;
    color: var(--color-primary);
    cursor: pointer;
    font-size: .9rem;
    padding: 0 4px;
}

/* ── Summary Box ─────────────────────────────────────────── */
.loan-summary-box {
    background: linear-gradient(135deg, rgba(184,0,15,.04), rgba(239,49,51,.03));
    border: 1.5px solid rgba(184,0,15,.12);
    border-radius: 14px;
    padding: 24px;
}

.loan-summary-title {
    font-size: .95rem;
    font-weight: 700;
    color: var(--color-primary);
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid rgba(184,0,15,.12);
}

.loan-summary-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 12px;
}
.loan-summary-label {
    font-size: .72rem;
    text-transform: uppercase;
    letter-spacing: .8px;
    color: #6c757d;
    display: block;
    margin-bottom: 2px;
}
.loan-summary-value {
    font-size: .92rem;
    font-weight: 600;
    color: #2c2c2c;
}

/* ── Terms Checkbox ──────────────────────────────────────── */
.loan-terms-check,
.loan-cbc-check {
    padding: 16px 20px;
    background: #f8f9fa;
    border-radius: 10px;
    border: 1px solid #e9ecef;
}

/* ── Form Navigation ─────────────────────────────────────── */
.loan-form-nav {
    display: flex;
    align-items: center;
    padding: 20px 40px 28px;
    border-top: 1px solid #f0f0f0;
    gap: 12px;
    background: #fafafa;
}

.loan-step-counter {
    font-size: .78rem;
}

/* ── Success Message ─────────────────────────────────────── */
.loan-success-box {
    text-align: center;
    padding: 60px 40px;
    animation: loanFadeIn .5s ease;
}

.loan-success-icon {
    font-size: 5rem;
    color: var(--color-primary,var(--color-primary));
    margin-bottom: 20px;
    animation: successPop .5s ease;
}

@keyframes successPop {
    0%   { transform: scale(0); opacity: 0; }
    70%  { transform: scale(1.15); }
    100% { transform: scale(1); opacity: 1; }
}

.loan-success-box h3 {
    font-size: 1.8rem;
    font-weight: 800;
    color: var(--color-primary,var(--color-primary));
    margin-bottom: 14px;
}

.loan-success-box p {
    color: #6c757d;
    max-width: 480px;
    margin: 0 auto 8px;
}

.loan-success-ref {
    font-size: 1rem;
    font-weight: 700;
    color: var(--color-primary);
}

/* ── Validation States ───────────────────────────────────── */
.form-control.is-invalid,
.was-validated .form-control:invalid {
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(220,53,69,.12);
}

.loan-field-error {
    display: block;
    font-size: .8rem;
    color: var(--color-primary);
    margin-top: 4px;
}

/* ── Responsive ──────────────────────────────────────────── */
@media (max-width: 768px) {
    .loan-step-panel { padding: 24px 20px; }
    .loan-form-nav   { padding: 16px 20px; }
    .loan-step-connector { display: none; }
    .loan-steps-nav { gap: 6px;justify-content: space-evenly; }
    .loan-step-circle { width: 42px; height: 42px; font-size: .9rem; }
    .loan-step-label  { font-size: .68rem; max-width: 60px; }
    .loan-estimate-item { border-right: none; border-bottom: 1px solid rgba(184,0,15,.12);width: 100%; }
    .loan-summary-grid { grid-template-columns: 1fr 1fr; }
}

/* ── Field error state ───────────────────────────────────────
   Applied to the .col wrapper — NOT to <input> directly,
   so Bootstrap's sibling selectors never reach the <label>.
──────────────────────────────────────────────────────────── */
.apmfi-has-error .form-control,
.apmfi-has-error .form-select {
    border-color: var(--color-primary) !important;
    box-shadow:   0 0 0 3px rgba(220, 53, 69, 0.12) !important;
}

/* Show the existing .invalid-feedback div */
.apmfi-has-error .invalid-feedback {
    display: block !important;
    color:   var(--color-primary);
    font-size: .8rem;
    margin-top: 4px;
}

/* Inline appended error message */
.apmfi-error-msg {
    color:      var(--color-primary);
    font-size:  .8rem;
    margin-top: 4px;
}

/* ── jQuery UI selectmenu – invalid state ────────────────────
   Applied to the #id-button span, NOT the hidden <select>.
──────────────────────────────────────────────────────────── */
span.ui-selectmenu-button.apmfi-sm-invalid {
    border-color: var(--color-primary) !important;
    box-shadow:   0 0 0 3px rgba(220, 53, 69, 0.12) !important;
}

/* ── Explicitly stop Bootstrap coloring the label ────────────
   Bootstrap's .was-validated and .is-invalid rules use
   .form-control:invalid ~ .form-label etc.
   We never add .is-invalid to inputs, but belt+braces:
──────────────────────────────────────────────────────────── */
.loan-form-card .form-label {
    color: inherit !important;
    text-decoration: none !important;
}

/* Terms error */
.loan-terms-error,.loan-cbc-error {
    color:     var(--color-primary);
    font-size: .8rem;
    margin-top: 6px;
}

/* ── Loan Purpose free-text input with datalist ──────────── */
#loanPurpose {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23b8000f' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 32px;
    cursor: pointer;
}
#loanPurpose:focus {
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(184,0,15,.12);
}
.form-check-input:checked{
    background-color: var(--color-primary);
    border-color: var(--color-primary-dark);
}
@media (max-width: 767px) {
    .image-preview{
        max-height:150px;
    }
}
.image-preview{
    max-height:350px;
    margin-top:10px;
    cursor: pointer;
}
.image-modal {
    display: none;
    position: fixed;
    z-index: 9999;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.9);
    cursor: pointer;
}
.image-modal-content {
    position: relative;
    margin: auto;
    padding: 20px;
    width: 90%;
    max-width: 90%;
    top: 50%;
    transform: translateY(-50%);
    text-align: center;
}
.image-modal-img {
    max-width: 100%;
    max-height: 90vh;
    object-fit: contain;
    border-radius: 5px;
    box-shadow: 0 0 20px rgba(0,0,0,0.5);
}
.image-modal-close {
    position: absolute;
    top: -40px;
    right: 0;
    color: white;
    font-size: 35px;
    font-weight: bold;
    cursor: pointer;
    z-index: 10000;
}
.image-modal-close:hover {
    color: #ccc;
}
