/* ============================================================================
   Custom CSS - Minimal overrides and animations on top of Tailwind
   ============================================================================ */

/* Custom Animations */
@keyframes fade-in {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes slide-down {
    from {
        opacity: 0;
        max-height: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        max-height: 1000px;
        transform: translateY(0);
    }
}

@keyframes slide-up {
    from {
        opacity: 1;
        max-height: 1000px;
        transform: translateY(0);
    }
    to {
        opacity: 0;
        max-height: 0;
        transform: translateY(-10px);
    }
}

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

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

/* Animation Classes */
.animate-fade-in {
    animation: fade-in 0.5s ease-out;
}

.animate-slide-down {
    animation: slide-down 0.3s ease-out;
}

.animate-slide-up {
    animation: slide-up 0.3s ease-out;
}

/* Modal Styles */
.modal {
    transition: opacity 0.3s ease-in-out;
}

.modal:not(.hidden) {
    animation: fade-in 0.3s ease-out;
}

.modal .fixed.inset-0 {
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}

/* Input Focus States */
input:focus,
select:focus {
    outline: none;
}

/* Custom Range Slider Styling */
input[type="range"] {
    -webkit-appearance: none;
    appearance: none;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #3B82F6;
    cursor: pointer;
    border: 2px solid white;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

input[type="range"]::-moz-range-thumb {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #3B82F6;
    cursor: pointer;
    border: 2px solid white;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

/* Dark mode range slider */
.dark input[type="range"]::-webkit-slider-thumb {
    border-color: #1F2937;
}

.dark input[type="range"]::-moz-range-thumb {
    border-color: #1F2937;
}

/* Loading Spinner */
.fa-spinner {
    animation: spin 1s linear infinite;
}

/* Print Styles for PDF Export */
@media print {
    body {
        background: white !important;
        color: black !important;
    }

    header,
    footer,
    .bg-gray-100,
    .bg-gray-50,
    button,
    #darkModeToggle,
    .modal,
    #scrollToTop,
    #tipsSection,
    #presetsBtn {
        display: none !important;
    }

    .bg-white {
        background: white !important;
        box-shadow: none !important;
    }

    table {
        page-break-inside: avoid;
    }

    .rounded-lg,
    .rounded-xl {
        border-radius: 0 !important;
    }
    
    /* Ensure results are visible */
    #resultsSection {
        display: block !important;
    }
    
    /* Better print layout */
    @page {
        margin: 1cm;
    }
    
    /* Hide charts in print (optional - can keep if needed) */
    canvas {
        max-width: 100% !important;
    }
}

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

/* Custom Scrollbar (Webkit browsers) */
::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

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

.dark ::-webkit-scrollbar-track {
    background: #1F2937;
}

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

::-webkit-scrollbar-thumb:hover {
    background: #555;
}

.dark ::-webkit-scrollbar-thumb {
    background: #4B5563;
}

.dark ::-webkit-scrollbar-thumb:hover {
    background: #6B7280;
}

/* Chart Container Specific Styles */
canvas {
    max-width: 100%;
    height: auto;
}

/* Error State Styles */
.input-error {
    border-color: #EF4444 !important;
    background-color: #FEF2F2 !important;
}

.dark .input-error {
    border-color: #DC2626 !important;
    background-color: #7F1D1D !important;
}

/* Success State Styles */
.input-success {
    border-color: #10B981 !important;
}

.dark .input-success {
    border-color: #059669 !important;
}

/* Smooth Transitions for All Interactive Elements */
button,
a,
input,
select {
    transition: all 0.2s ease-in-out;
}

/* Focus Visible for Better Accessibility */
*:focus-visible {
    outline: 2px solid #3B82F6;
    outline-offset: 2px;
}

/* Table Row Hover Effect */
tbody tr:hover {
    background-color: rgba(59, 130, 246, 0.05);
}

.dark tbody tr:hover {
    background-color: rgba(59, 130, 246, 0.1);
}

/* Gradient Text (Optional - for hero if needed) */
.gradient-text {
    background: linear-gradient(135deg, #1E3A8A 0%, #3B82F6 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* Ensure modals are above everything */
.modal {
    z-index: 9999;
}

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

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

/* Presets menu animation */
#presetsMenu {
    animation: fade-in 0.2s ease-out;
}

/* Number animation */
@keyframes count-up {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.animate-count-up {
    animation: count-up 0.5s ease-out;
}

/* Pulse animation for highlights */
@keyframes pulse-glow {
    0%, 100% {
        box-shadow: 0 0 0 0 rgba(59, 130, 246, 0.4);
    }
    50% {
        box-shadow: 0 0 0 8px rgba(59, 130, 246, 0);
    }
}

.pulse-glow {
    animation: pulse-glow 2s ease-in-out infinite;
}

/* Smooth scroll behavior */
html {
    scroll-behavior: smooth;
}

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

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

.dark .card-hover:hover {
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.3);
}

/* Smooth height transitions for collapsible sections */
.collapsible {
    overflow: hidden;
    transition: max-height 0.3s ease-out, opacity 0.3s ease-out;
}

.collapsible.hidden {
    max-height: 0;
    opacity: 0;
}

.collapsible:not(.hidden) {
    max-height: 2000px;
    opacity: 1;
}
