:root {
    --primary-color: #4361ee;
    --primary-light: #e0e7ff;
    --secondary-color: #3a0ca3;
    --accent-color: #f72585;
    --text-color: #2b2d42;
    --text-light: #6c757d;
    --bg-color: #f8f9fa;
    --card-bg: #ffffff;
    --border-color: #e9ecef;
    --success-color: #4cc9f0;
    --warning-color: #f8961e;
    --danger-color: #ef233c;
    --info-color: #8d99ae;
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.12);
    --shadow-md: 0 4px 6px rgba(0,0,0,0.1);
    --shadow-lg: 0 10px 25px rgba(0,0,0,0.1);
    --border-radius: 12px;
    --border-radius-sm: 8px;
    --transition: none;
}

.stats-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px 30px;
}

.stats-header {
    background: linear-gradient(135deg, #2b2d42 0%, #353850 100%);
    color: white;
    padding: 2rem;
    border-radius: 1rem;
    margin-bottom: 2rem;
    box-shadow: 0 0.25rem 1rem rgba(0, 0, 0, 0.1);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.header-content h1 {
    display: flex;
    align-items: center;
    gap: 1rem;
    font-size: 2rem;
    margin: 0 0 0.5rem 0;
    font-weight: 700;
    color: white;
}

.header-content p {
    margin: 0;
    opacity: 0.9;
    font-size: 1rem;
    color: white;
}

.auto-refresh-indicator {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.85rem;
    color: var(--text-light);
}

.refresh-spinner {
    width: 16px;
    height: 16px;
    border: 2px solid rgba(67, 97, 238, 0.3);
    border-radius: 50%;
    border-top-color: var(--primary-color);
    animation: spin 1s linear infinite;
}

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

.stats-summary {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 20px;
    margin-bottom: 25px;
}

.stat-card {
    background: white;
    padding: 1.5rem;
    border-radius: 1rem;
    box-shadow: 0 0.125rem 0.5rem rgba(0, 0, 0, 0.08);
    display: flex;
    align-items: flex-start;
    gap: 1rem;
    border: none;
    opacity: 0;
    transform: translateY(10px);
}

.stat-card.fade-in-delayed {
    animation: none;
}

.stat-card.fade-in-delayed.show {
    animation: fadeInUp 0.6s cubic-bezier(0.25, 0.46, 0.45, 0.94) forwards;
    animation-delay: var(--delay, 0ms);
}

.stat-card:hover {
    box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.12);
}

.stat-icon {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--border-radius-sm);
    color: white;
    flex-shrink: 0;
}

.stat-icon.primary {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
}

.stat-icon.success {
    background: linear-gradient(135deg, var(--success-color) 0%, #4895ef 100%);
}

.stat-icon.warning {
    background: linear-gradient(135deg, var(--warning-color) 0%, #f3722c 100%);
}

.stat-icon.danger {
    background: linear-gradient(135deg, var(--danger-color) 0%, #d90429 100%);
}

.stat-icon.info {
    background: linear-gradient(135deg, var(--info-color) 0%, #6c757d 100%);
}

.stat-icon.secondary {
    background: linear-gradient(135deg, #6c757d 0%, #495057 100%);
}

.stat-info {
    display: flex;
    flex-direction: column;
    min-width: 0;
    flex: 1;
}

.stat-number-group {
    display: flex;
    flex-direction: row;
    align-items: baseline;
    gap: 0.5rem;
    line-height: 1.1;
}

.stat-number {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--text-color);
    line-height: 1;
}

.stat-unit {
    font-size: 0.75rem;
    font-weight: 300 !important;
    color: var(--text-light);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.stat-label {
    font-size: 0.7rem;
    color: var(--text-color);
    font-weight: 300 !important;
    margin-top: 3px;
    line-height: 1.3;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.stat-subtext {
    font-size: 0.7rem;
    color: var(--text-light);
    margin-top: 2px;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(350px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.stats-chart-card, .stats-data-card {
    background: white;
    border-radius: 1rem;
    padding: 1.5rem;
    box-shadow: 0 0.125rem 0.5rem rgba(0, 0, 0, 0.08);
    border: none;
    position: relative;
}

.stats-chart-card:hover, .stats-data-card:hover {
    box-shadow: 0 0.25rem 0.75rem rgba(0, 0, 0, 0.12);
}

.stats-chart-card.full-width {
    grid-column: 1 / -1;
}

.chart-header {
    margin-bottom: 15px;
}

.chart-header h3 {
    margin: 0;
    color: var(--text-color);
    font-size: 1.1rem;
    font-weight: 600;
}

.chart-subtitle {
    font-size: 0.8rem;
    color: var(--text-light);
    margin-top: 3px;
}

.chart-container {
    position: relative;
    height: 250px;
    width: 100%;
    will-change: auto;
    backface-visibility: hidden;
    transform: translateZ(0);
    overflow: hidden;
}

.chart-container svg {
    max-width: 100%;
    height: auto;
    display: block;
}

.chart-legend {
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid var(--border-color);
}

.chart-legend p {
    margin: 0;
    font-size: 0.8rem;
    color: var(--text-light);
    font-style: italic;
}

.data-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}

.data-card-header h3 {
    margin: 0;
    color: var(--text-color);
    font-size: 1.1rem;
    font-weight: 600;
}

.data-card-badge {
    font-size: 0.7rem;
    padding: 4px 8px;
    background: var(--bg-color);
    border-radius: 12px;
    color: var(--text-light);
}

.data-card-content {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.data-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 0;
    border-bottom: 1px solid var(--border-color);
}

.data-row:last-child {
    border-bottom: none;
}

.data-label {
    flex: 1;
    color: var(--text-color);
    font-weight: 500;
    font-size: 0.85rem;
}

.data-value {
    font-weight: 600;
    color: var(--text-color);
    margin: 0 8px;
    font-size: 0.85rem;
}

.data-change {
    font-size: 0.8rem;
    font-weight: 600;
    min-width: 50px;
    text-align: right;
    color: var(--text-light);
}

/* ============================================================================
   FILTERS SECTION STYLES
   ============================================================================ */

.filters-form {
    margin-bottom: 20px;
}

.filter-select {
    padding: 8px 12px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    background: white;
    cursor: pointer;
    font-size: 0.9rem;
    color: var(--text-color);
}

.filter-select:hover {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px rgba(67, 97, 238, 0.1);
}

.filter-select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(67, 97, 238, 0.2);
}

.btn-reset {
    padding: 8px 16px;
    background: var(--bg-color);
    color: var(--text-color);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 500;
    text-decoration: none;
    display: inline-block;
}

.btn-reset:hover {
    background: var(--border-color);
    border-color: var(--text-light);
}

/* ============================================================================
   SKELETON LOADERS AND LOADING ANIMATIONS
   ============================================================================ */

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

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

.skeleton-loader {
    background: linear-gradient(
        90deg,
        var(--bg-color) 0%,
        rgba(255, 255, 255, 0.3) 20%,
        var(--bg-color) 40%,
        var(--bg-color) 100%
    );
    background-size: 1000px 100%;
    animation: shimmer 2s infinite;
    border-radius: 1rem;
    min-height: 120px;
}

.skeleton-loader::before {
    content: '';
    display: block;
    background: linear-gradient(
        90deg,
        rgba(255, 255, 255, 0.05) 0%,
        rgba(255, 255, 255, 0.15) 50%,
        rgba(255, 255, 255, 0.05) 100%
    );
    height: 100%;
    border-radius: 1rem;
}

/* Skeleton loading state for chart containers */
.chart-container.loading {
    background: linear-gradient(
        90deg,
        var(--bg-color) 0%,
        rgba(255, 255, 255, 0.3) 20%,
        var(--bg-color) 40%,
        var(--bg-color) 100%
    );
    background-size: 1000px 100%;
    animation: shimmer 2s infinite;
}

/* Fade in animation for loaded content */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.fade-in {
    animation: fadeInUp 0.5s ease-out forwards;
}

/* Stagger delays for stat cards */
#stats-summary-actual .stat-card:nth-child(1) { --delay: 0ms; }
#stats-summary-actual .stat-card:nth-child(2) { --delay: 60ms; }
#stats-summary-actual .stat-card:nth-child(3) { --delay: 120ms; }
#stats-summary-actual .stat-card:nth-child(4) { --delay: 180ms; }
#stats-summary-actual .stat-card:nth-child(5) { --delay: 240ms; }
#stats-summary-actual .stat-card:nth-child(6) { --delay: 300ms; }

/* Keyframe animations for stats */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Initial state for summary section - fade in animation */
#stats-summary-actual {
    opacity: 0;
}

#stats-summary-actual.loaded {
    opacity: 1;
}

/* Chart card loading state */
.stats-chart-card.loading,
.stats-data-card.loading {
    pointer-events: none;
}

.stats-chart-card.loading::after,
.stats-data-card.loading::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(
        90deg,
        transparent 0%,
        rgba(255, 255, 255, 0.3) 50%,
        transparent 100%
    );
    background-size: 200% 100%;
    animation: shimmer 2s infinite;
    border-radius: 1rem;
    pointer-events: none;
    z-index: 10;
}

/* Hide ApexCharts legend scrollbar */
.apexcharts-legend {
    overflow: hidden !important;
}

.apexcharts-legend-series {
    display: inline-flex !important;
    flex-wrap: wrap !important;
    gap: 12px !important;
}

.apexcharts-legend-container {
    max-height: none !important;
    overflow: visible !important;
}

/* Custom Dropdown Styles - matching property_list.css */
.filter-select, .filter-input {
    padding: 10px 11px;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-sm);
    font-size: 14px;
    background-color: var(--bg-color);
}

.filter-select:focus, .filter-input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(67, 97, 238, 0.1);
}

/* Custom Select Wrapper */
.custom-select {
    position: relative;
    width: 100%;
    min-width: 0;
    z-index: 100;
}

.custom-select-trigger {
    padding: 10px 32px 10px 11px;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-sm);
    font-size: 14px;
    background-color: var(--bg-color);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: space-between;
    user-select: none;
    position: relative;
    color: var(--text-color);
}

.custom-select-trigger:hover {
    border-color: var(--primary-color);
}

.custom-select.open .custom-select-trigger {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(67, 97, 238, 0.1);
}

.custom-select-trigger::after {
    content: '';
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    width: 0;
    height: 0;
    border-left: 4px solid transparent;
    border-right: 4px solid transparent;
    border-top: 4px solid var(--text-color);
    transition: transform 0.3s ease;
}

.custom-select.open .custom-select-trigger::after {
    transform: translateY(-50%) rotate(180deg);
}

.custom-select-options {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    background-color: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-sm);
    box-shadow: var(--shadow-md);
    z-index: 9999 !important;
    max-height: 0;
    overflow: hidden;
    opacity: 0;
    transform: translateY(-10px);
    transition: max-height 0.4s ease, opacity 0.3s ease, transform 0.3s ease;
}

.custom-select.open .custom-select-options {
    max-height: 300px;
    opacity: 1;
    transform: translateY(0);
    overflow-y: auto;
}

.custom-select-option {
    padding: 10px 12px;
    cursor: pointer;
    font-size: 14px;
    color: var(--text-color);
}

.custom-select-option:hover {
    background-color: var(--primary-light);
    color: var(--primary-color);
}

.custom-select-option.selected {
    background-color: var(--primary-color);
    color: white;
    font-weight: 600;
}

.custom-select-option.selected:hover {
    background-color: var(--secondary-color);
}

/* Hide original select */
.filter-select.hidden {
    display: none;
}

/* Scrollbar styling for dropdown */
.custom-select-options::-webkit-scrollbar {
    width: 6px;
}

.custom-select-options::-webkit-scrollbar-track {
    background: var(--bg-color);
    border-radius: 3px;
}

.custom-select-options::-webkit-scrollbar-thumb {
    background: var(--primary-color);
    border-radius: 3px;
}

.custom-select-options::-webkit-scrollbar-thumb:hover {
    background: var(--secondary-color);
}

/* Hide scrollbar for short lists */
.custom-select.short-list .custom-select-options {
    overflow-y: hidden !important;
    scrollbar-width: none; /* Firefox */
    -ms-overflow-style: none; /* IE/Edge */
}

.custom-select.short-list .custom-select-options::-webkit-scrollbar {
    display: none; /* Chrome/Safari/Opera */
}

/* Responsive Design */
@media (max-width: 1024px) {
    .stats-summary {
        grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    }
}

@media (max-width: 768px) {
    .stats-container {
        padding: 15px;
    }

    .stats-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
        padding: 1.5rem;
    }

    .header-content h1 {
        font-size: 1.5rem;
    }

    .stats-summary {
        grid-template-columns: repeat(2, 1fr);
        gap: 1rem;
    }

    .stat-card {
        padding: 1rem;
        flex-direction: column;
        align-items: flex-start;
    }

    .stat-number {
        font-size: 1.2rem;
    }

    .stats-grid {
        grid-template-columns: 1fr !important;
        gap: 1rem;
        margin-bottom: 20px;
    }

    .stats-chart-card, .stats-data-card {
        padding: 1rem;
        width: 100% !important;
        box-sizing: border-box;
    }

    .chart-container {
        height: 300px;
        min-height: 250px;
        overflow: visible;
    }

    .chart-container svg {
        max-width: 100%;
        width: 100%;
    }
}

@media (max-width: 480px) {
    .stats-container {
        padding: 10px;
    }

    .stats-header {
        padding: 1rem;
    }

    .header-content h1 {
        font-size: 1.3rem;
    }

    .stats-summary {
        grid-template-columns: 1fr;
    }

    .stat-card {
        flex-direction: row;
        align-items: center;
    }

    .stats-grid {
        grid-template-columns: 1fr !important;
        gap: 15px;
        margin-bottom: 20px;
    }

    .stats-chart-card, .stats-data-card {
        width: 100% !important;
        box-sizing: border-box !important;
        padding: 0.75rem;
    }

    .chart-container {
        height: 250px;
        min-height: 250px;
        overflow: visible;
    }

    .chart-container svg {
        max-width: 100%;
        width: 100%;
    }

    .chart-header h3 {
        font-size: 1rem;
    }

    .chart-subtitle {
        font-size: 0.75rem;
    }
}
