/**
 * My Lease Builder Custom Styles
 * Additional styles on top of Tailwind CSS for the questionnaire app
 */

/* CSS Variables — brand palette from JW logo */
:root {
    --mlb-primary: #455878;
    --mlb-primary-dark: #2f2e50;
    --mlb-primary-mid: #3f4e6f;
    --mlb-primary-light: #dde3ec;
    --mlb-primary-lighter: #eef1f6;
    --mlb-green: #059669;
    --mlb-red: #dc2626;
    --mlb-yellow: #d97706;
    --mlb-gray: #6b7280;

    /* Legacy aliases — Tailwind config in base.html uses these */
    --ppma-blue: #455878;
    --ppma-blue-dark: #2f2e50;
    --ppma-blue-light: #dde3ec;
}

/* Base improvements */
body {
    font-feature-settings: "kern" 1, "liga" 1;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Focus improvements for accessibility */
input:focus,
select:focus,
textarea:focus,
button:focus {
    outline: none;
    box-shadow: 0 0 0 3px rgba(69, 88, 120, 0.15);
}

/* Custom scrollbar for webkit browsers */
::-webkit-scrollbar {
    width: 8px;
}

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

::-webkit-scrollbar-thumb {
    background: #d1d5db;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #9ca3af;
}

/* Loading animation improvements */
.animate-spin {
    animation: spin 1s linear infinite;
}

@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* Progress bar animation */
.progress-bar {
    transition: width 0.3s ease-in-out;
}

/* Form field enhancements */
.form-field {
    position: relative;
}

.form-field input,
.form-field select,
.form-field textarea {
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.form-field input:focus,
.form-field select:focus,
.form-field textarea:focus {
    border-color: var(--mlb-primary);
    box-shadow: 0 0 0 1px var(--mlb-primary);
}

.form-field.error input,
.form-field.error select,
.form-field.error textarea {
    border-color: var(--mlb-red);
}

/* Conditional field animations */
.conditional-field {
    transition: all 0.3s ease-in-out;
    overflow: hidden;
}

.conditional-field.hidden {
    max-height: 0;
    opacity: 0;
    margin: 0;
    padding: 0;
}

/* Button hover effects */
button,
.btn {
    transition: all 0.2s ease;
    position: relative;
    overflow: hidden;
}

button:hover,
.btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

button:active,
.btn:active {
    transform: translateY(0);
}

/* Success/error states */
.success-state {
    animation: successPulse 0.6s ease-in-out;
}

@keyframes successPulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.05); }
    100% { transform: scale(1); }
}

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

.card-hover:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.1);
}

/* Mobile-specific improvements */
@media (max-width: 768px) {
    body.mobile {
        -webkit-text-size-adjust: 100%;
    }

    button,
    .btn,
    input[type="radio"],
    input[type="checkbox"] {
        min-height: 44px;
        min-width: 44px;
    }

    .form-field {
        margin-bottom: 1.5rem;
    }

    .mobile-nav {
        position: sticky;
        top: 0;
        z-index: 40;
        backdrop-filter: blur(8px);
        -webkit-backdrop-filter: blur(8px);
    }

    .mobile-table {
        display: block;
        overflow-x: auto;
        white-space: nowrap;
    }
}

/* Print styles */
@media print {
    .no-print {
        display: none !important;
    }

    body {
        font-size: 12pt;
        line-height: 1.5;
    }

    h1 { font-size: 18pt; }
    h2 { font-size: 16pt; }
    h3 { font-size: 14pt; }

    .page-break-before {
        page-break-before: always;
    }

    .page-break-avoid {
        page-break-inside: avoid;
    }

    .bg-blue-50,
    .bg-green-50,
    .bg-yellow-50,
    .bg-red-50 {
        background-color: #f9f9f9 !important;
    }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    :root {
        --mlb-primary: #1a2744;
        --mlb-primary-dark: #0f1830;
        --mlb-green: #008000;
        --mlb-red: #cc0000;
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* ═══════════════════════════════════════════════════
   DARK MODE
   ═══════════════════════════════════════════════════ */

/* Manual dark mode toggle class (for user override) */
body.dark-mode {
    --mlb-bg: #1a1b2e;
    --mlb-surface: #252640;
    --mlb-surface-raised: #2e3050;
    --mlb-text: #e2e4ea;
    --mlb-text-muted: #cbd5e1;
    --mlb-border: #3a3c55;
    background-color: var(--mlb-bg);
    color: var(--mlb-text);
}

body.dark-mode header,
body.dark-mode .bg-ppma-blue,
body.dark-mode [class*="bg-ppma-blue"] {
    background-color: var(--mlb-primary-dark) !important;
}

body.dark-mode .bg-white,
body.dark-mode [class*="bg-white"] {
    background-color: var(--mlb-surface) !important;
    color: var(--mlb-text) !important;
}

body.dark-mode [class*="border-gray"],
body.dark-mode [class*="border-blue"] {
    border-color: var(--mlb-border) !important;
}

body.dark-mode [class*="text-gray-900"],
body.dark-mode [class*="text-gray-800"],
body.dark-mode [class*="text-gray-700"] {
    color: var(--mlb-text) !important;
}

body.dark-mode [class*="text-gray-600"],
body.dark-mode [class*="text-gray-500"] {
    color: var(--mlb-text-muted) !important;
}

body.dark-mode input,
body.dark-mode select,
body.dark-mode textarea {
    background-color: var(--mlb-surface-raised) !important;
    color: var(--mlb-text) !important;
    border-color: var(--mlb-border) !important;
}

body.dark-mode .bg-blue-50 { background-color: #1e293b !important; }
body.dark-mode .bg-gray-50 { background-color: var(--mlb-surface) !important; }
body.dark-mode thead.bg-gray-50 th { color: var(--mlb-text-muted) !important; }
body.dark-mode tbody.bg-white { background-color: var(--mlb-surface-raised) !important; }
body.dark-mode tr.hover\:bg-gray-50:hover { background-color: var(--mlb-surface) !important; }
body.dark-mode .divide-gray-200 > * { border-color: var(--mlb-border) !important; }
body.dark-mode .bg-green-50 { background-color: rgba(5, 150, 105, 0.15) !important; }
body.dark-mode .bg-yellow-50 { background-color: rgba(217, 119, 6, 0.15) !important; }
body.dark-mode .bg-red-50 { background-color: rgba(220, 38, 38, 0.15) !important; }

body.dark-mode footer {
    background-color: var(--mlb-surface) !important;
    border-color: var(--mlb-border) !important;
}

/* ═══════════════════════════════════════════════════ */

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

.glass {
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    background-color: rgba(255, 255, 255, 0.8);
}

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

/* Custom components */
.verification-item {
    transition: all 0.3s ease;
}

.verification-item.completed {
    opacity: 0.6;
    text-decoration: line-through;
}

.document-card {
    transition: all 0.3s ease;
    border: 2px solid transparent;
}

.document-card:hover {
    border-color: var(--mlb-primary-light);
    box-shadow: 0 8px 25px rgba(69, 88, 120, 0.1);
}

.status-badge {
    display: inline-flex;
    align-items: center;
    padding: 0.25rem 0.75rem;
    font-size: 0.75rem;
    font-weight: 600;
    border-radius: 9999px;
    text-transform: uppercase;
    letter-spacing: 0.025em;
}

.status-badge.success { background-color: #dcfce7; color: #166534; }
.status-badge.error { background-color: #fecaca; color: #991b1b; }
.status-badge.warning { background-color: #fef3c7; color: #92400e; }
.status-badge.info { background-color: #dde3ec; color: #2f2e50; }

/* Form validation styles */
.field-error {
    animation: fadeInUp 0.3s ease;
}

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

/* Custom checkbox and radio */
input[type="radio"],
input[type="checkbox"] {
    width: 1.25rem;
    height: 1.25rem;
    border: 2px solid #d1d5db;
    border-radius: 0.25rem;
    appearance: none;
    background: white;
    cursor: pointer;
    position: relative;
}

input[type="radio"] { border-radius: 50%; }

input[type="radio"]:checked::before {
    content: '';
    position: absolute;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    width: 0.5rem; height: 0.5rem;
    border-radius: 50%;
    background: var(--mlb-primary);
}

input[type="checkbox"]:checked::before {
    content: '✓';
    position: absolute;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    color: var(--mlb-primary);
    font-weight: bold;
    font-size: 0.875rem;
}

input[type="radio"]:checked,
input[type="checkbox"]:checked {
    border-color: var(--mlb-primary);
    background-color: var(--mlb-primary-light);
}

/* Notification system */
.notification {
    position: fixed;
    top: 1rem; right: 1rem;
    z-index: 9999;
    max-width: 20rem;
    padding: 1rem;
    border-radius: 0.5rem;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

/* Loading states */
.loading-skeleton {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: loading 2s infinite;
}

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

/* PWA install prompt */
.pwa-install-prompt {
    position: fixed;
    bottom: 1rem; left: 1rem; right: 1rem;
    background: var(--mlb-primary);
    color: white;
    padding: 1rem;
    border-radius: 0.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
    z-index: 1000;
}

@media (min-width: 768px) {
    .pwa-install-prompt {
        left: auto; right: 1rem;
        max-width: 20rem;
    }
}

body.dark-mode [class*="text-blue-900"],
body.dark-mode [class*="text-blue-800"],
body.dark-mode [class*="text-blue-700"] {
    color: #e5e7eb !important;
}
body.dark-mode .text-ppma-blue {
    color: #e5e7eb !important;
}
body.dark-mode .mlb-info-box {
    background-color: #1e293b !important;
    border-color: #334155 !important;
}
body.dark-mode .mlb-info-text {
    color: #e5e7eb !important;
}
body.dark-mode .mlb-review-btn {
    background-color: #334155 !important;
    color: #e5e7eb !important;
}
body.dark-mode [class*="text-green-900"],
body.dark-mode [class*="text-green-800"],
body.dark-mode [class*="text-green-700"] {
    color: #86efac !important;
}
body.dark-mode [class*="text-red-900"],
body.dark-mode [class*="text-red-800"],
body.dark-mode [class*="text-red-700"] {
    color: #fca5a5 !important;
}
body.dark-mode [class*="text-yellow-900"],
body.dark-mode [class*="text-yellow-800"],
body.dark-mode [class*="text-yellow-700"] {
    color: #fcd34d !important;
}
body.dark-mode [class*="text-purple-900"],
body.dark-mode [class*="text-purple-800"],
body.dark-mode [class*="text-purple-700"] {
    color: #c4b5fd !important;
}
body.dark-mode [class*="bg-green-100"] {
    background-color: rgba(5, 150, 105, 0.2) !important;
}
body.dark-mode [class*="bg-blue-100"] {
    background-color: rgba(69, 88, 120, 0.2) !important;
}
