/**
 * Date Filter Charts Styling
 * Modern, responsive styling for date range picker and chart updates
 */

.date-filter-widget {
    background: #ffffff;
    border: 1px solid #e3e6f0;
    border-radius: 0.35rem;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    box-shadow: 0 0.15rem 1.75rem 0 rgba(58, 59, 69, 0.15);
}

.date-filter-widget .form-label {
    font-weight: 600;
    color: #5a5c69;
    margin-bottom: 0.5rem;
}

.date-filter-widget .form-control {
    border: 1px solid #d1d3e2;
    border-radius: 0.35rem;
    padding: 0.375rem 0.75rem;
    font-size: 0.875rem;
    transition: border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
}

.date-filter-widget .form-control:focus {
    border-color: #4e73df;
    box-shadow: 0 0 0 0.2rem rgba(78, 115, 223, 0.25);
}

.date-filter-widget .btn-group {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem;
}

.date-filter-widget .btn-group .btn {
    font-size: 0.75rem;
    padding: 0.25rem 0.5rem;
    border-radius: 0.25rem;
    transition: all 0.15s ease-in-out;
}

.date-filter-widget .btn-outline-primary {
    color: #4e73df;
    border-color: #4e73df;
}

.date-filter-widget .btn-outline-primary:hover,
.date-filter-widget .btn-outline-primary.active {
    background-color: #4e73df;
    border-color: #4e73df;
    color: #ffffff;
}

.date-filter-widget .btn-primary {
    background-color: #4e73df;
    border-color: #4e73df;
    font-weight: 600;
}

.date-filter-widget .btn-primary:hover {
    background-color: #2e59d9;
    border-color: #2653d4;
}

.date-filter-widget .btn-outline-secondary {
    color: #858796;
    border-color: #858796;
}

.date-filter-widget .btn-outline-secondary:hover {
    background-color: #858796;
    border-color: #858796;
    color: #ffffff;
}

.date-filter-widget .form-check {
    margin-top: 0.5rem;
}

.date-filter-widget .form-check-input:checked {
    background-color: #4e73df;
    border-color: #4e73df;
}

.date-filter-widget .form-check-label {
    color: #5a5c69;
    font-size: 0.875rem;
}

/* Loading overlay */
#loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 9999;
}

#loading-overlay .spinner {
    color: #ffffff;
    font-size: 2rem;
}

/* Chart containers */
.chart-container {
    background: #ffffff;
    border: 1px solid #e3e6f0;
    border-radius: 0.35rem;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    box-shadow: 0 0.15rem 1.75rem 0 rgba(58, 59, 69, 0.15);
    position: relative;
    min-height: 400px;
    transition: all 0.3s ease;
}

.chart-container:hover {
    box-shadow: 0 0.25rem 2rem 0 rgba(58, 59, 69, 0.2);
    transform: translateY(-2px);
}

.chart-container.comparison-enabled {
    border-left: 4px solid #4e73df;
}

.chart-container .chart-title {
    font-size: 1.125rem;
    font-weight: 600;
    color: #5a5c69;
    margin-bottom: 1rem;
    text-align: center;
}

.chart-container canvas {
    max-height: 400px !important;
}

/* Chart loading states */
.chart-loading {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 300px;
    color: #858796;
    font-size: 1rem;
}

.chart-loading i {
    margin-right: 0.5rem;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Summary cards */
.summary-card {
    background: linear-gradient(90deg, #4e73df 0%, #224abe 100%);
    border: none;
    border-radius: 0.35rem;
    color: #ffffff;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    box-shadow: 0 0.15rem 1.75rem 0 rgba(58, 59, 69, 0.15);
    transition: transform 0.15s ease-in-out;
}

.summary-card:hover {
    transform: translateY(-2px);
}

.summary-card .card-body {
    padding: 0;
}

.summary-card .card-title {
    font-size: 0.875rem;
    font-weight: 600;
    text-transform: uppercase;
    margin-bottom: 0.5rem;
    opacity: 0.8;
}

.summary-card .card-text {
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: 0;
}

.summary-card.success {
    background: linear-gradient(90deg, #1cc88a 0%, #13855c 100%);
}

.summary-card.warning {
    background: linear-gradient(90deg, #f6c23e 0%, #dda20a 100%);
}

.summary-card.danger {
    background: linear-gradient(90deg, #e74a3b 0%, #c0392b 100%);
}

.summary-card.info {
    background: linear-gradient(90deg, #36b9cc 0%, #258391 100%);
}

/* Comparison data styling */
.comparison-data {
    border-left: 3px solid #4e73df;
    padding-left: 1rem;
    margin-top: 1rem;
    background-color: #f8f9fc;
    padding: 1rem;
    border-radius: 0.25rem;
}

.comparison-data .comparison-title {
    font-size: 0.875rem;
    font-weight: 600;
    color: #5a5c69;
    margin-bottom: 0.5rem;
}

.comparison-data .comparison-value {
    font-size: 1.25rem;
    font-weight: 600;
}

.comparison-data .comparison-change {
    font-size: 0.75rem;
    margin-left: 0.5rem;
}

.comparison-data .comparison-change.positive {
    color: #1cc88a;
}

.comparison-data .comparison-change.negative {
    color: #e74a3b;
}

/* Error container */
#error-container {
    margin-bottom: 1rem;
}

#error-container .alert {
    border: none;
    border-radius: 0.35rem;
    font-size: 0.875rem;
}

/* Responsive design */
@media (max-width: 768px) {
    .date-filter-widget {
        padding: 1rem;
    }
    
    .date-filter-widget .row > div {
        margin-bottom: 1rem;
    }
    
    .date-filter-widget .btn-group {
        justify-content: center;
    }
    
    .chart-container {
        padding: 1rem;
    }
    
    .summary-card .card-text {
        font-size: 1.5rem;
    }
}

@media (max-width: 576px) {
    .date-filter-widget .btn-group .btn {
        font-size: 0.7rem;
        padding: 0.2rem 0.4rem;
    }
    
    .summary-card .card-text {
        font-size: 1.25rem;
    }
}

/* Animation classes */
.fade-in {
    animation: fadeIn 0.5s ease-in-out;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.slide-in {
    animation: slideIn 0.3s ease-out;
}

@keyframes slideIn {
    from { transform: translateX(-20px); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

/* Chart-specific styling */
.plotly-chart {
    width: 100% !important;
    height: 400px !important;
}

.chartjs-chart {
    position: relative;
    height: 400px;
    width: 100%;
}

/* Tooltip styling */
.chart-tooltip {
    background-color: rgba(0, 0, 0, 0.8);
    color: #ffffff;
    padding: 0.5rem;
    border-radius: 0.25rem;
    font-size: 0.75rem;
    pointer-events: none;
    z-index: 1000;
}

/* Input validation styles */
.form-control.is-invalid {
    border-color: #e74a3b;
    box-shadow: 0 0 0 0.2rem rgba(231, 74, 59, 0.25);
}

.form-control.is-valid {
    border-color: #1cc88a;
    box-shadow: 0 0 0 0.2rem rgba(28, 200, 138, 0.25);
}

/* Keyboard shortcut indicators */
.keyboard-shortcut {
    font-size: 0.7rem;
    color: #858796;
    margin-left: 0.5rem;
    opacity: 0.7;
}

.btn:hover .keyboard-shortcut {
    opacity: 1;
}

/* Custom range modal */
.modal-content {
    border: none;
    border-radius: 0.5rem;
    box-shadow: 0 1rem 3rem rgba(0, 0, 0, 0.175);
}

.modal-header {
    border-bottom: 1px solid #e3e6f0;
    background: linear-gradient(90deg, #4e73df 0%, #224abe 100%);
    color: #ffffff;
}

.modal-header .btn-close {
    filter: invert(1);
}

/* Theme support */
.chart-container.dark-theme {
    background: #2c3e50;
    border-color: #34495e;
    color: #ffffff;
}

.chart-container.dark-theme .chart-title {
    color: #ffffff;
}

/* Accessibility improvements */
.chart-container:focus-within {
    outline: 2px solid #4e73df;
    outline-offset: 2px;
}

.btn:focus {
    box-shadow: 0 0 0 0.2rem rgba(78, 115, 223, 0.5);
}

/* Loading states */
.chart-container.loading {
    pointer-events: none;
    opacity: 0.7;
}

.chart-container.loading::after {
    content: '';
    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;
}

/* Enhanced animations */
.chart-update-animation {
    animation: chartUpdate 0.5s ease-in-out;
}

@keyframes chartUpdate {
    0% { opacity: 0.5; transform: scale(0.98); }
    50% { opacity: 0.7; transform: scale(1.01); }
    100% { opacity: 1; transform: scale(1); }
}

/* Print styles */
@media print {
    .date-filter-widget {
        display: none;
    }
    
    .chart-container {
        break-inside: avoid;
        box-shadow: none;
        border: 1px solid #000;
        page-break-inside: avoid;
    }
    
    .comparison-data {
        border-left-color: #000;
    }
}