/* ========================================
   UnitedLoanHub - Custom Styles
   Blue Theme with Modern Design
======================================== */

/* ========== CSS Variables ========== */
:root {
    --primary-50: #eff6ff;
    --primary-100: #dbeafe;
    --primary-200: #bfdbfe;
    --primary-300: #93c5fd;
    --primary-400: #60a5fa;
    --primary-500: #3b82f6;
    --primary-600: #2563eb;
    --primary-700: #1d4ed8;
    --primary-800: #1e40af;
    --primary-900: #1e3a8a;
    --accent-400: #fbbf24;
    --accent-500: #f59e0b;
    --accent-600: #d97706;
    --transition-base: 200ms ease;
    --shadow-soft: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -2px rgba(0, 0, 0, 0.1);
    --shadow-medium: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -4px rgba(0, 0, 0, 0.1);
}

/* ========== Base Styles ========== */
html {
    scroll-behavior: smooth;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    overflow-x: hidden;
}

/* Focus styles for accessibility */
*:focus-visible {
    outline: 2px solid var(--primary-500);
    outline-offset: 2px;
}

/* Screen reader only utility */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.sr-only.focus\:not-sr-only:focus {
    position: absolute;
    width: auto;
    height: auto;
    padding: inherit;
    margin: inherit;
    overflow: visible;
    clip: auto;
    white-space: normal;
}

/* ========== Header Styles ========== */
#header {
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}

#header.scrolled {
    box-shadow: var(--shadow-medium);
}

/* ========== Multi-Step Form ========== */
.form-step {
    display: none;
    animation: stepFadeIn 0.4s ease;
}

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

@keyframes stepFadeIn {
    from {
        opacity: 0;
        transform: translateX(20px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* ========== Form Styles ========== */
.form-input,
.form-select {
    appearance: none;
    -webkit-appearance: none;
    background-color: #fff;
}

.form-select {
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3e%3cpath stroke='%236b7280' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='M6 8l4 4 4-4'/%3e%3c/svg%3e");
    background-position: right 0.75rem center;
    background-repeat: no-repeat;
    background-size: 1.5em 1.5em;
    padding-right: 2.5rem;
}

.form-input:focus,
.form-select:focus {
    border-color: var(--primary-500);
    box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.15);
}

.form-input.error,
.form-select.error {
    border-color: #ef4444;
}

.error-msg {
    color: #ef4444;
    font-size: 0.875rem;
    margin-top: 0.25rem;
}

.error-msg.show {
    display: block;
}

/* ========== Input Glow Effect ========== */
.input-glow:focus {
    box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.2);
}

/* ========== Checkbox Styles ========== */
.checkbox-custom {
    appearance: none;
    -webkit-appearance: none;
    width: 1.25rem;
    height: 1.25rem;
    border: 2px solid #d1d5db;
    border-radius: 0.25rem;
    background-color: #fff;
    cursor: pointer;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.checkbox-custom:checked {
    background-color: var(--primary-600);
    border-color: var(--primary-600);
    background-image: url("data:image/svg+xml,%3csvg viewBox='0 0 16 16' fill='white' xmlns='http://www.w3.org/2000/svg'%3e%3cpath d='M12.207 4.793a1 1 0 010 1.414l-5 5a1 1 0 01-1.414 0l-2-2a1 1 0 011.414-1.414L6.5 9.086l4.293-4.293a1 1 0 011.414 0z'/%3e%3c/svg%3e");
    background-size: 100% 100%;
    background-position: center;
    background-repeat: no-repeat;
}

.checkbox-custom:focus {
    outline: none;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.25);
}

/* ========== Button Loading State ========== */
.btn-loading {
    position: relative;
    color: transparent !important;
}

.btn-loading::after {
    content: '';
    position: absolute;
    width: 1.25rem;
    height: 1.25rem;
    top: 50%;
    left: 50%;
    margin-left: -0.625rem;
    margin-top: -0.625rem;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: #fff;
    animation: spinner 0.8s ease infinite;
}

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

/* ========== FAQ Accordion ========== */
.faq-item {
    transition: all 0.2s ease;
}

.faq-trigger {
    cursor: pointer;
}

.faq-trigger[aria-expanded="true"] .faq-icon {
    transform: rotate(180deg);
}

.faq-icon {
    transition: transform 0.3s ease;
}

.faq-content {
    overflow: hidden;
}

.faq-content.open {
    animation: accordionOpen 0.3s ease;
}

@keyframes accordionOpen {
    from {
        opacity: 0;
        max-height: 0;
    }
    to {
        opacity: 1;
        max-height: 500px;
    }
}

/* ========== Mobile Menu ========== */
#mobile-menu {
    transition: all 0.3s ease;
    max-height: 0;
    overflow: hidden;
}

#mobile-menu.open {
    max-height: 400px;
}

.mobile-nav-link {
    transition: all 0.2s ease;
}

/* ========== Mobile Sticky CTA ========== */
#mobile-cta {
    transform: translateY(100%);
    transition: transform 0.3s ease;
}

#mobile-cta.visible {
    transform: translateY(0);
}

/* Add padding to body when CTA is visible to prevent content overlap */
body.mobile-cta-visible {
    padding-bottom: 80px;
}

/* ========== Animations ========== */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeInLeft {
    from {
        opacity: 0;
        transform: translateX(-30px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes fadeInRight {
    from {
        opacity: 0;
        transform: translateX(30px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.7;
    }
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    10%, 30%, 50%, 70%, 90% { transform: translateX(-5px); }
    20%, 40%, 60%, 80% { transform: translateX(5px); }
}

@keyframes float {
    0%, 100% { transform: translateY(0px); }
    50% { transform: translateY(-10px); }
}

.animate-fade-in-up {
    animation: fadeInUp 0.6s ease forwards;
}

.animate-fade-in-left {
    animation: fadeInLeft 0.6s ease forwards;
}

.animate-fade-in-right {
    animation: fadeInRight 0.6s ease forwards;
}

.animate-pulse {
    animation: pulse 2s infinite;
}

.animate-shake {
    animation: shake 0.5s ease;
}

.animate-float {
    animation: float 3s ease-in-out infinite;
}

/* ========== Utility Classes ========== */
.text-balance {
    text-wrap: balance;
}

.gradient-text {
    background: linear-gradient(135deg, var(--primary-500), var(--primary-700));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.gradient-text-gold {
    background: linear-gradient(135deg, var(--accent-400), var(--accent-600));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* ========== Card Hover Effects ========== */
.card-hover {
    transition: all 0.3s ease;
}

.card-hover:hover {
    transform: translateY(-4px);
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
}

/* ========== Responsive Adjustments ========== */
@media (max-width: 640px) {
    .form-input,
    .form-select {
        font-size: 16px; /* Prevents iOS zoom on focus */
    }

    /* Fix for date input on mobile */
    input[type="date"] {
        -webkit-appearance: none;
        -moz-appearance: none;
        appearance: none;
        min-width: 0;
        width: 100% !important;
        max-width: 100% !important;
        box-sizing: border-box !important;
    }

    input[type="date"]::-webkit-calendar-picker-indicator {
        cursor: pointer;
        opacity: 0.6;
    }
}

/* ========== Print Styles ========== */
@media print {
    #header,
    #mobile-cta,
    .no-print {
        display: none !important;
    }

    body {
        padding-top: 0 !important;
    }
}

/* ========== Focus Ring Enhancement ========== */
.keyboard-navigation *:focus {
    outline: 2px solid var(--primary-500);
    outline-offset: 2px;
}

/* ========== Custom Scrollbar ========== */
@media (min-width: 1024px) {
    ::-webkit-scrollbar {
        width: 10px;
    }

    ::-webkit-scrollbar-track {
        background: #f1f5f9;
    }

    ::-webkit-scrollbar-thumb {
        background: #94a3b8;
        border-radius: 5px;
    }

    ::-webkit-scrollbar-thumb:hover {
        background: #64748b;
    }
}

/* ========== Selection Color ========== */
::selection {
    background-color: var(--primary-500);
    color: white;
}

::-moz-selection {
    background-color: var(--primary-500);
    color: white;
}

/* ========== Reduce Motion ========== */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }

    html {
        scroll-behavior: auto;
    }
}

/* ========== Shimmer Effect ========== */
.shimmer {
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.4), transparent);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
}

@keyframes shimmer {
    0% { background-position: -200% 0; }
    100% { background-position: 200% 0; }
}

/* ========== Glass Effect ========== */
.glass {
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

/* ========== Gradient Backgrounds ========== */
.bg-gradient-blue {
    background: linear-gradient(135deg, #1e3a8a 0%, #1d4ed8 50%, #3b82f6 100%);
}

.bg-gradient-blue-radial {
    background: radial-gradient(ellipse at top right, #3b82f6 0%, #1d4ed8 40%, #1e3a8a 100%);
}
