/* ==========================================================
   Rental Application — Editorial Elegance
   Refined document form · generous spacing · clear hierarchy
   ========================================================== */

/* --- Root section --- */
.rental-application-section {
    padding: 2rem 0 3rem;
    background:
        radial-gradient(ellipse at 20% 0%, rgba(23, 32, 68, 0.04) 0%, transparent 50%),
        radial-gradient(ellipse at 80% 100%, rgba(133, 176, 43, 0.03) 0%, transparent 50%),
        var(--bg-secondary);
    overflow-x: hidden;
    min-height: 100vh;
}

/* --- Validation summary --- */
.validation-summary {
    background: linear-gradient(135deg, #fef2f2, #fff5f5);
    border-left: 4px solid #ef4444;
    padding: 1rem 1.25rem;
    border-radius: 10px;
    margin-bottom: 1.5rem;
    color: #991b1b;
    font-size: 0.88rem;
    line-height: 1.6;
    box-shadow: 0 2px 12px rgba(239, 68, 68, 0.08);
}
.validation-summary strong {
    display: block;
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-bottom: 0.5rem;
    color: #b91c1c;
}
.validation-summary ul {
    margin: 0;
    padding-left: 1.25rem;
}
.validation-summary ul li {
    margin-bottom: 0.25rem;
}

/* --- Sections --- */
.form-section {
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.6);
    border-radius: 16px;
    padding: 1.75rem 1.75rem;
    margin-bottom: 1rem;
    box-shadow:
        0 2px 16px rgba(0, 0, 0, 0.04),
        inset 0 1px 1px rgba(255, 255, 255, 0.7);
    transition: box-shadow 0.3s ease;
    overflow: visible;
    position: relative;
}
.form-section:hover {
    box-shadow:
        0 4px 24px rgba(0, 0, 0, 0.06),
        inset 0 1px 1px rgba(255, 255, 255, 0.7);
}

.form-section h2 {
    font-family: var(--font-display);
    font-size: 1rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--accent-elite);
    margin: 0 0 1.25rem;
    padding-bottom: 0.75rem;
    border-bottom: 2px solid var(--accent-green);
    line-height: 1.4;
}
.form-section h2 span {
    font-size: 0.85rem;
    text-transform: none;
    letter-spacing: normal;
    font-weight: 500;
    color: var(--text-secondary);
}

.form-section h3 {
    font-family: var(--font-body);
    font-size: 0.85rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-muted);
    margin: 1.5rem 0 0.75rem;
    padding-top: 1rem;
    border-top: 1px solid rgba(0, 0, 0, 0.06);
}

/* --- Grid layouts --- */
.rental-application-section .form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 0.75rem 1.25rem;
    margin-bottom: 0.5rem;
}
.rental-application-section .form-row > * {
    min-width: 0;
}

.rental-application-section .form-row-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem 1.25rem;
    margin-bottom: 0.5rem;
}
.rental-application-section .form-row-2 > * {
    min-width: 0;
}

/* --- Form groups --- */
.rental-application-section .form-group {
    margin-bottom: 0.85rem;
}

.rental-application-section .form-group label {
    display: block;
    margin-bottom: 0.35rem;
    font-weight: 600;
    color: var(--text-primary);
    font-size: 0.88rem;
    letter-spacing: 0.01em;
}

.rental-application-section .form-group input,
.rental-application-section .form-group select,
.rental-application-section .form-group textarea {
    width: 100%;
    padding: 0.7rem 0.9rem;
    border: 1.5px solid rgba(0, 0, 0, 0.1);
    border-radius: 10px;
    font-family: var(--font-body);
    font-size: 0.92rem;
    background: rgba(255, 255, 255, 0.7);
    color: var(--text-primary);
    transition: all 0.2s ease;
    min-height: 44px;
}
.rental-application-section .form-group input:focus,
.rental-application-section .form-group select:focus,
.rental-application-section .form-group textarea:focus {
    outline: none;
    border-color: var(--accent-green);
    background: #fff;
    box-shadow: 0 0 0 3px rgba(133, 176, 43, 0.1), 0 2px 8px rgba(0, 0, 0, 0.04);
}
.rental-application-section .form-group input::placeholder,
.rental-application-section .form-group textarea::placeholder {
    color: var(--text-muted);
    font-size: 0.88rem;
}

/* --- Hide native select when custom dropdown is active --- */
.rental-application-section .form-group select.has-custom-dd {
    position: absolute;
    opacity: 0;
    pointer-events: none;
    height: 0;
    width: 0;
    overflow: hidden;
}

/* --- Custom dropdown trigger --- */
.custom-dd {
    position: relative;
    width: 100%;
}
.custom-dd-trigger {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding: 0.7rem 0.9rem;
    border: 1.5px solid rgba(0, 0, 0, 0.1);
    border-radius: 10px;
    font-family: var(--font-body);
    font-size: 0.92rem;
    background: rgba(255, 255, 255, 0.7);
    color: var(--text-primary);
    cursor: pointer;
    min-height: 44px;
    transition: all 0.2s ease;
    user-select: none;
    gap: 0.5rem;
}
.custom-dd-trigger:hover {
    border-color: rgba(133, 176, 43, 0.4);
    background: rgba(255, 255, 255, 0.95);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}
.custom-dd.open {
    z-index: 200;
}
.custom-dd.open .custom-dd-trigger {
    border-color: var(--accent-green);
    background: #fff;
    box-shadow: 0 0 0 3px rgba(133, 176, 43, 0.1), 0 2px 8px rgba(0, 0, 0, 0.04);
}
.custom-dd-trigger.placeholder {
    color: var(--text-muted);
}

/* Chevron icon */
.custom-dd-chevron {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
    transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    color: var(--text-muted);
}
.custom-dd.open .custom-dd-chevron {
    transform: rotate(180deg);
    color: var(--accent-green);
}

/* --- Dropdown panel --- */
.custom-dd-panel {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    background: #fff;
    border: 1.5px solid rgba(0, 0, 0, 0.08);
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1), 0 2px 8px rgba(0, 0, 0, 0.04);
    z-index: 100;
    padding: 0.35rem;
    max-height: 240px;
    overflow-y: auto;
    opacity: 0;
    transform: translateY(-6px);
    pointer-events: none;
    transition: opacity 0.2s ease, transform 0.2s ease;
}
.custom-dd.open .custom-dd-panel {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}

/* Scrollbar */
.custom-dd-panel::-webkit-scrollbar {
    width: 5px;
}
.custom-dd-panel::-webkit-scrollbar-track {
    background: transparent;
}
.custom-dd-panel::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.12);
    border-radius: 10px;
}

/* --- Dropdown items --- */
.custom-dd-item {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.6rem 0.75rem;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.9rem;
    font-family: var(--font-body);
    color: var(--text-primary);
    transition: all 0.15s ease;
    position: relative;
}
.custom-dd-item:hover {
    background: rgba(133, 176, 43, 0.06);
    color: var(--accent-elite);
}
.custom-dd-item.selected {
    background: rgba(133, 176, 43, 0.1);
    color: var(--accent-elite);
    font-weight: 600;
}
.custom-dd-item.selected::after {
    content: '';
    margin-left: auto;
    width: 16px;
    height: 16px;
    background: var(--accent-green);
    border-radius: 50%;
    flex-shrink: 0;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none'%3E%3Cpath d='M4.5 8.5l2.5 2.5 4.5-4.5' stroke='%23fff' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: center;
    background-size: 12px;
}
.custom-dd-item.disabled {
    color: var(--text-muted);
    cursor: default;
    font-style: italic;
}
.custom-dd-item.disabled:hover {
    background: none;
    color: var(--text-muted);
}

.rental-application-section .text-danger {
    color: #dc2626;
    font-size: 0.8rem;
    margin-top: 0.3rem;
    display: block;
    font-weight: 500;
}

/* --- Radio & Checkbox groups --- */
.radio-group,
.checkbox-group {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.radio-group-compact,
.checkbox-group-compact {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.radio-label,
.checkbox-label {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    padding: 0.55rem 1rem;
    border-radius: 10px;
    border: 1.5px solid rgba(0, 0, 0, 0.08);
    background: rgba(255, 255, 255, 0.6);
    font-size: 0.88rem;
    transition: all 0.2s ease;
    min-width: 0;
    min-height: 44px;
}
.radio-label:hover,
.checkbox-label:hover {
    border-color: rgba(133, 176, 43, 0.4);
    background: rgba(255, 255, 255, 0.9);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}

/* Kill old glass overlay */
.radio-label::before,
.checkbox-label::before {
    display: none;
}

/* Selected state */
.radio-label:has(input:checked),
.checkbox-label:has(input:checked) {
    background: rgba(133, 176, 43, 0.08);
    border-color: rgba(133, 176, 43, 0.5);
    box-shadow: 0 2px 8px rgba(133, 176, 43, 0.08);
}
.radio-label:has(input:checked)::before,
.checkbox-label:has(input:checked)::before {
    display: none;
}

.radio-label input[type="radio"],
.checkbox-label input[type="checkbox"] {
    width: 18px;
    height: 18px;
    margin: 0;
    accent-color: var(--accent-green);
    flex-shrink: 0;
}

.radio-label span,
.checkbox-label span {
    color: var(--text-primary);
    font-weight: 500;
    font-size: 0.88rem;
}
.radio-label input:checked + span,
.checkbox-label input:checked + span {
    color: var(--accent-elite);
    font-weight: 600;
}

/* Compact variant */
.radio-group-compact .radio-label,
.radio-group-compact .checkbox-label,
.checkbox-group-compact .radio-label,
.checkbox-group-compact .checkbox-label {
    padding: 0.45rem 0.85rem;
    font-size: 0.85rem;
    gap: 0.4rem;
}
.radio-group-compact .radio-label input[type="radio"],
.radio-group-compact .checkbox-label input[type="checkbox"],
.checkbox-group-compact .radio-label input[type="radio"],
.checkbox-group-compact .checkbox-label input[type="checkbox"] {
    width: 16px;
    height: 16px;
}

/* --- Toggle section (Add Applicant 2, Add Surety) --- */
.toggle-section {
    background: linear-gradient(135deg, rgba(133, 176, 43, 0.04), rgba(133, 176, 43, 0.08));
    border: 1.5px solid rgba(133, 176, 43, 0.2);
    padding: 0.85rem 1.1rem;
    border-radius: 12px;
    margin-bottom: 1rem;
    transition: all 0.2s ease;
}
.toggle-section:hover {
    border-color: rgba(133, 176, 43, 0.35);
}
.toggle-section label {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    cursor: pointer;
    font-weight: 600;
    font-size: 0.92rem;
    color: var(--accent-elite);
}
.toggle-section input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: var(--accent-green);
}

/* --- Conditional sections --- */
.conditional-section {
    display: none;
    animation: revealSection 0.3s ease;
}
.conditional-section.show {
    display: block;
}
@keyframes revealSection {
    from { opacity: 0; transform: translateY(-8px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* --- Toggle switch (marketing) --- */
.toggle-switch-container {
    display: flex;
    align-items: center;
    gap: 0.7rem;
    padding: 0.35rem 0;
}
.toggle-switch-label {
    font-weight: 600;
    color: var(--text-primary);
    font-size: 0.88rem;
}
.toggle-switch {
    position: relative;
    width: 44px;
    height: 24px;
    background: var(--bg-tertiary);
    border-radius: 12px;
    cursor: pointer;
    transition: background 0.25s ease;
    border: 1.5px solid rgba(0, 0, 0, 0.1);
    flex-shrink: 0;
}
.toggle-switch::before {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    width: 18px;
    height: 18px;
    background: #fff;
    border-radius: 50%;
    transition: transform 0.25s cubic-bezier(0.68, -0.3, 0.265, 1.3);
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.15);
}
.toggle-switch.active {
    background: var(--accent-green);
    border-color: var(--accent-green);
}
.toggle-switch.active::before {
    transform: translateX(20px);
}
.toggle-switch-status {
    font-size: 0.85rem;
    font-weight: 600;
    min-width: 24px;
    color: var(--text-muted);
}
.toggle-switch-status.active {
    color: var(--accent-green);
}
.toggle-switch-container input[type="radio"] {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

/* --- Helper text --- */
.sa-id-warning {
    color: #b45309;
    font-size: 0.82rem;
    margin-top: 0.3rem;
    font-style: italic;
}
.char-counter {
    font-size: 0.78rem;
    color: var(--text-muted);
    margin-top: 0.2rem;
}
.char-counter.warning { color: #d97706; }
.char-counter.limit { color: #dc2626; }

/* --- Occupants --- */
.occupant-number-input {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1rem;
}
.occupant-number-input label {
    font-weight: 600;
    color: var(--text-primary);
    font-size: 0.9rem;
}
.occupant-number-input input[type="number"] {
    width: 64px;
    padding: 0.5rem 0.6rem;
    border: 1.5px solid rgba(0, 0, 0, 0.1);
    border-radius: 10px;
    font-size: 0.92rem;
    font-family: var(--font-body);
    text-align: center;
    background: rgba(255, 255, 255, 0.7);
    min-height: 44px;
}
.occupant-number-input input[type="number"]:focus {
    outline: none;
    border-color: var(--accent-green);
    box-shadow: 0 0 0 3px rgba(133, 176, 43, 0.1);
}
.occupant-pdf-note {
    font-size: 0.82rem;
    color: #b45309;
    font-style: italic;
    margin: 0.25rem 0 0.75rem;
}

.occupant-row {
    display: grid;
    grid-template-columns: 1fr 80px;
    gap: 0.75rem;
    align-items: end;
    padding: 0.85rem 1rem;
    background: var(--bg-secondary);
    border-radius: 12px;
    margin-bottom: 0.5rem;
    border: 1px solid rgba(0, 0, 0, 0.04);
}
.occupant-row > * {
    min-width: 0;
}
.occupant-row .form-group {
    margin-bottom: 0;
}
.occupant-row .remove-btn {
    background: #ef4444;
    color: #fff;
    border: none;
    padding: 0.55rem 0.75rem;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.82rem;
    font-weight: 600;
    transition: background 0.15s ease;
    min-height: 44px;
}
.occupant-row .remove-btn:hover {
    background: #dc2626;
}

.add-btn {
    background: var(--accent-green);
    color: #fff;
    border: none;
    padding: 0.6rem 1.25rem;
    border-radius: 10px;
    cursor: pointer;
    font-family: var(--font-body);
    font-size: 0.88rem;
    font-weight: 600;
    transition: all 0.2s ease;
    min-height: 44px;
}
.add-btn:hover {
    background: var(--accent-green-light);
    box-shadow: 0 4px 12px rgba(133, 176, 43, 0.25);
}
.add-btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* --- Terms & Conditions --- */
.terms-content {
    background: var(--bg-secondary);
    padding: 1rem 1.25rem;
    border-radius: 12px;
    margin-bottom: 1rem;
    font-size: 0.85rem;
    line-height: 1.65;
    text-align: justify;
    color: var(--text-secondary);
    border: 1px solid rgba(0, 0, 0, 0.05);
    max-height: none;
    overflow-y: visible;
}
.terms-content ol {
    padding-left: 1.25rem;
}
.terms-content li {
    margin-bottom: 0.5rem;
}

/* Terms checkbox states */
.terms-checkbox-unchecked {
    border-color: #ef4444 !important;
    background: rgba(239, 68, 68, 0.03) !important;
}
.terms-checkbox-checked {
    border-color: var(--accent-green) !important;
    background: rgba(133, 176, 43, 0.06) !important;
}

/* --- Consent section --- */
#consentVerificationSection {
    margin-top: 1rem;
    padding: 1rem 1.25rem;
    background: var(--bg-secondary);
    border-radius: 12px;
    border: 1px solid rgba(0, 0, 0, 0.05);
}
#consentVerificationSection h3 {
    margin-top: 0;
    border-top: none;
    padding-top: 0;
}

.consent-status-message {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.75rem 1rem;
    background: rgba(59, 130, 246, 0.05);
    border: 1.5px solid rgba(59, 130, 246, 0.2);
    border-radius: 10px;
    color: #2563eb;
    font-size: 0.88rem;
    font-weight: 500;
}
.bio-pulse {
    display: inline-block;
    width: 8px;
    height: 8px;
    background: #3b82f6;
    border-radius: 50%;
    animation: bioP 1s ease-in-out infinite;
    flex-shrink: 0;
}
@keyframes bioP {
    0%, 100% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.5); opacity: 0.4; }
}

.consent-success {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.75rem 1rem;
    background: rgba(34, 197, 94, 0.05);
    border: 1.5px solid rgba(34, 197, 94, 0.25);
    border-radius: 10px;
    color: #16a34a;
    font-size: 0.88rem;
    font-weight: 600;
}
.consent-fallback-notice {
    padding: 0.75rem 1rem;
    background: rgba(245, 158, 11, 0.05);
    border: 1.5px solid rgba(245, 158, 11, 0.2);
    border-radius: 10px;
    color: #b45309;
    font-size: 0.85rem;
    margin-bottom: 0.75rem;
}

/* --- Signature pad --- */
#signaturePadContainer label {
    display: block;
    font-weight: 600;
    margin-bottom: 0.4rem;
    font-size: 0.88rem;
    color: var(--text-primary);
}
.signature-pad-wrapper {
    border: 2px dashed rgba(0, 0, 0, 0.12);
    border-radius: 12px;
    overflow: hidden;
    touch-action: none;
    background: #fff;
}
.signature-pad-wrapper canvas {
    display: block;
    width: 100%;
    height: 160px;
    cursor: crosshair;
}
.btn-clear-signature {
    background: transparent;
    color: #dc2626;
    border: 1.5px solid rgba(220, 38, 38, 0.25);
    padding: 0.5rem 1rem;
    border-radius: 8px;
    cursor: pointer;
    font-family: var(--font-body);
    font-size: 0.85rem;
    font-weight: 600;
    min-height: 44px;
    min-width: 44px;
    transition: all 0.15s ease;
}
.btn-clear-signature:hover {
    background: #ef4444;
    border-color: #ef4444;
    color: #fff;
}
.signature-hint {
    font-size: 0.8rem;
    color: var(--text-muted);
    font-style: italic;
}

/* --- Form actions (submit) --- */
.form-actions {
    text-align: center;
    margin-top: 1.5rem;
    padding-top: 1rem;
}
.form-actions .btn {
    padding: 0.85rem 2.5rem;
    font-size: 1rem;
    font-weight: 700;
    border-radius: 12px;
    min-height: 48px;
    letter-spacing: 0.02em;
    transition: all 0.2s ease;
}
.form-actions .btn:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.15);
}

/* ==========================================================
   Responsive
   ========================================================== */
@media (max-width: 768px) {
    .rental-application-section {
        padding: 1rem 0 2rem;
    }
    .rental-application-section .container {
        padding-left: 0.75rem;
        padding-right: 0.75rem;
    }
    .form-section {
        padding: 1.25rem 1rem;
        margin-bottom: 0.75rem;
        border-radius: 12px;
    }
    .form-section h2 {
        font-size: 0.88rem;
        margin-bottom: 1rem;
    }
    .form-section h3 {
        font-size: 0.8rem;
        margin: 1.25rem 0 0.6rem;
    }
    .rental-application-section .form-row {
        grid-template-columns: 1fr;
        gap: 0.5rem;
    }
    .rental-application-section .form-row-2 {
        grid-template-columns: 1fr 1fr;
        gap: 0.5rem 0.75rem;
    }
    .rental-application-section .form-group {
        margin-bottom: 0.6rem;
    }
    .rental-application-section .form-group label {
        font-size: 0.84rem;
        margin-bottom: 0.25rem;
    }
    .rental-application-section .form-group input,
    .rental-application-section .form-group textarea {
        padding: 0.6rem 0.8rem;
        font-size: 0.88rem;
    }
    .custom-dd-trigger {
        padding: 0.6rem 0.8rem;
        font-size: 0.88rem;
    }
    .custom-dd-item {
        padding: 0.55rem 0.7rem;
        font-size: 0.86rem;
    }
    .radio-group, .checkbox-group,
    .radio-group-compact, .checkbox-group-compact {
        gap: 0.4rem;
    }
    .radio-label, .checkbox-label {
        padding: 0.45rem 0.8rem;
        font-size: 0.84rem;
        gap: 0.4rem;
    }
    .radio-label input[type="radio"],
    .checkbox-label input[type="checkbox"] {
        width: 16px;
        height: 16px;
    }
    .radio-group-compact .radio-label,
    .radio-group-compact .checkbox-label,
    .checkbox-group-compact .radio-label,
    .checkbox-group-compact .checkbox-label {
        padding: 0.4rem 0.7rem;
        font-size: 0.82rem;
    }
    .occupant-row {
        grid-template-columns: 1fr 68px;
        gap: 0.5rem;
        padding: 0.7rem 0.8rem;
    }
    .terms-content {
        padding: 0.85rem 1rem;
        font-size: 0.82rem;
    }
    .toggle-section {
        padding: 0.7rem 0.9rem;
    }
    #consentVerificationSection {
        padding: 0.85rem 1rem;
    }
    .signature-pad-wrapper canvas {
        height: 130px;
    }
    .toggle-switch {
        width: 40px;
        height: 22px;
    }
    .toggle-switch::before {
        width: 16px;
        height: 16px;
        top: 2px;
        left: 2px;
    }
    .toggle-switch.active::before {
        transform: translateX(18px);
    }
}

@media (max-width: 480px) {
    .rental-application-section .form-row-2 {
        grid-template-columns: 1fr;
    }
}
