/* Alpine.js Enhanced Styles for FNL Budget Application */

/* Smooth transitions for Alpine.js components */
[x-cloak] { 
    display: none !important; 
}

/* Alpine transition classes */
.x-transition-enter {
    transition-property: opacity, transform;
    transition-duration: 150ms;
    transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
}

.x-transition-enter-from {
    opacity: 0;
    transform: translateY(-10px);
}

.x-transition-enter-to {
    opacity: 1;
    transform: translateY(0);
}

.x-transition-leave {
    transition-property: opacity, transform;
    transition-duration: 100ms;
    transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
}

.x-transition-leave-from {
    opacity: 1;
    transform: translateY(0);
}

.x-transition-leave-to {
    opacity: 0;
    transform: translateY(-10px);
}

/* Enhanced card hover effects with theme support */
.card {
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    /* backdrop-filter removed — it creates a stacking context that traps Bootstrap modals inside cards */
}

.card:hover {
    box-shadow: 0 12px 35px rgba(0, 0, 0, 0.15);
    transform: translateY(-3px);
}

/* Dark theme enhancements */
[data-bs-theme="dark"] .card {
    background-color: rgba(255, 255, 255, 0.05) !important;
    border: 1px solid rgba(255, 255, 255, 0.1) !important;
}

[data-bs-theme="dark"] .card:hover {
    background-color: rgba(255, 255, 255, 0.1) !important;
    box-shadow: 0 12px 35px rgba(0, 0, 0, 0.3);
}

/* Gradient backgrounds for light theme */
.bg-gradient {
    background: linear-gradient(135deg, var(--bs-bg-opacity, 1), rgba(255, 255, 255, 0.8)) !important;
}

/* Theme toggle button */
.btn-theme-toggle {
    transition: all 0.3s ease;
    border-radius: 50px;
}

.btn-theme-toggle:hover {
    transform: scale(1.1);
}

/* Enhanced dashboard colors */
:root {
    --income-color: #10b981;
    --expense-color: #ef4444;
    --balance-color: #3b82f6;
    --remaining-color: #8b5cf6;
    
    --income-bg: rgba(16, 185, 129, 0.1);
    --expense-bg: rgba(239, 68, 68, 0.1);
    --balance-bg: rgba(59, 130, 246, 0.1);
    --remaining-bg: rgba(139, 92, 246, 0.1);
}

/* Interactive filter controls */
.filter-control {
    transition: all 0.2s ease;
}

.filter-control:focus-within {
    box-shadow: 0 0 0 3px rgba(var(--bs-primary-rgb), 0.25);
    border-radius: 8px;
}

/* Enhanced transaction rows */
.transaction-row {
    transition: all 0.2s ease;
    cursor: pointer;
}

.transaction-row:hover {
    background-color: rgba(var(--bs-primary-rgb), 0.05) !important;
    border-left: 4px solid var(--bs-primary);
    padding-left: calc(0.75rem - 4px);
}

/* Loading states */
.loading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
}

[data-bs-theme="dark"] .loading-overlay {
    background: rgba(15, 23, 42, 0.85);
}

.loading-pulse {
    animation: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

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

/* Enhanced statistics cards */
.stat-card {
    position: relative;
    overflow: hidden;
}

.stat-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(45deg, transparent 30%, rgba(255, 255, 255, 0.1) 50%, transparent 70%);
    transform: translateX(-100%);
    transition: transform 0.6s ease;
}

.stat-card:hover::before {
    transform: translateX(100%);
}

/* Interactive filter badges */
.filter-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    background: var(--bs-light);
    border: 1px solid var(--bs-border-color);
    border-radius: 20px;
    font-size: 0.875rem;
    margin: 0.25rem;
    transition: all 0.2s ease;
}

.filter-badge:hover {
    background: var(--bs-primary);
    color: white;
}

.filter-badge .remove-btn {
    background: none;
    border: none;
    padding: 0;
    margin-left: 0.5rem;
    opacity: 0.7;
    cursor: pointer;
    transition: opacity 0.2s ease;
}

.filter-badge .remove-btn:hover {
    opacity: 1;
}

/* Enhanced progress bars */
.category-progress {
    height: 8px;
    border-radius: 4px;
    background-color: var(--bs-gray-200);
    overflow: hidden;
    position: relative;
}

.category-progress::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.4), transparent);
    animation: shimmer 2s infinite;
}

@keyframes shimmer {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(100%); }
}

/* Category ranking indicators */
.rank-badge {
    position: relative;
}

.rank-badge .badge {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
}

.rank-badge.top-3 .badge {
    background: linear-gradient(135deg, #ffd700, #ffed4e);
    color: #333;
    box-shadow: 0 2px 8px rgba(255, 215, 0, 0.3);
}

/* Trend indicators */
.trend-up {
    color: var(--bs-danger) !important;
    animation: bounce-up 2s infinite;
}

.trend-down {
    color: var(--bs-success) !important;
    animation: bounce-down 2s infinite;
}

.trend-stable {
    color: var(--bs-secondary) !important;
}

@keyframes bounce-up {
    0%, 20%, 50%, 80%, 100% { transform: translateY(0); }
    40% { transform: translateY(-3px); }
    60% { transform: translateY(-1px); }
}

@keyframes bounce-down {
    0%, 20%, 50%, 80%, 100% { transform: translateY(0); }
    40% { transform: translateY(3px); }
    60% { transform: translateY(1px); }
}

/* Advanced filter panel */
.advanced-filters {
    background: linear-gradient(135deg, var(--bs-light) 0%, rgba(var(--bs-primary-rgb), 0.05) 100%);
    border-radius: 12px;
    border: 2px dashed var(--bs-border-color);
    padding: 1.5rem;
    margin-top: 1rem;
}

/* Chart placeholder enhancements */
.chart-placeholder {
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    min-height: 300px;
    transition: all 0.3s ease;
}

.chart-placeholder:hover {
    background: linear-gradient(135deg, #e9ecef 0%, #dee2e6 100%);
}

/* Export button enhancements */
.export-btn {
    position: relative;
    overflow: hidden;
}

.export-btn::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.3);
    transform: translate(-50%, -50%);
    transition: width 0.3s ease, height 0.3s ease;
}

.export-btn:hover::after {
    width: 100%;
    height: 100%;
}

/* Toast notifications */
.toast {
    backdrop-filter: blur(10px);
    border: none;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
}

/* Mobile responsive enhancements */
@media (max-width: 768px) {
    .transaction-row:hover {
        border-left: none;
        background-color: rgba(var(--bs-primary-rgb), 0.1) !important;
        transform: scale(0.98);
    }
    
    .card:hover {
        transform: none;
        box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    }
    
    .advanced-filters {
        padding: 1rem;
    }
}

/* Dark mode support (if implementing) */
@media (prefers-color-scheme: dark) {
    .chart-placeholder {
        background: linear-gradient(135deg, #343a40 0%, #495057 100%);
        color: #fff;
    }
    
    .filter-badge {
        background: var(--bs-dark);
        border-color: var(--bs-secondary);
        color: #fff;
    }
    
    .advanced-filters {
        background: linear-gradient(135deg, var(--bs-dark) 0%, rgba(var(--bs-light-rgb), 0.05) 100%);
    }
}

/* Performance optimizations */
.gpu-accelerated {
    transform: translateZ(0);
    backface-visibility: hidden;
    perspective: 1000px;
}

/* Accessibility enhancements */
:focus-visible {
    outline: 2px solid var(--primary, #6366f1);
    outline-offset: 3px;
    border-radius: 4px;
}

[data-bs-theme="dark"] :focus-visible {
    outline-color: var(--primary-light, #a5b4fc);
}

.focus-visible:focus {
    outline: 2px solid var(--primary, #6366f1);
    outline-offset: 3px;
    border-radius: 4px;
}

/* Print styles */
@media print {
    .no-print {
        display: none !important;
    }
    
    .card {
        border: 1px solid #000 !important;
        break-inside: avoid;
    }
    
    .transaction-row:hover {
        background: transparent !important;
        transform: none;
    }
}