/* Modern Dashboard Styles */
:root {
    --primary-color: #2563eb;
    --primary-hover: #474748;
    --secondary-color: #64748b;
    --success-color: #10b981;
    --warning-color: #f59e0b;
    --danger-color: #ef4444;
    --background-color: #f8fafc;
    --surface-color: #ffffff;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --border-color: #e2e8f0;
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
    --radius-sm: 0.375rem;
    --radius-md: 0.5rem;
    --radius-lg: 0.75rem;
}

* {
    box-sizing: border-box;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background-color: var(--background-color);
    color: var(--text-primary);
    line-height: 1.6;
    margin: 0;
    padding: 0;
}

/* Header Styles */
h1 {
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--text-primary);
    margin: 2rem 0 0.5rem 0;
    text-align: center;
    background: linear-gradient(135deg, var(--primary-color), #7c3aed);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.text-muted {
    color: var(--text-secondary);
    font-size: 1.1rem;
    text-align: center;
    margin-bottom: 2rem;
}

/* Card Styles */
.card {
    background: var(--surface-color);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    transition: all 0.2s ease;
    overflow: hidden;
    height: 100%;
    display: flex;
    flex-direction: column;
}

.card:hover {
    box-shadow: var(--shadow-lg);
    transform: translateY(-1px);
}

.card-header {
    background: linear-gradient(135deg, #f8fafc, #f1f5f9);
    border-bottom: 1px solid var(--border-color);
    padding: 1.5rem;
    min-height: 120px;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.card-header h5 {
    margin: 0;
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-primary);
}

.card-header small {
    color: var(--text-secondary);
    font-size: 0.875rem;
    margin-top: 0.25rem;
    display: block;
}

#chartInfo {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-top: 0.5rem;
}

.card-body {
    padding: 1.5rem;
    flex: 1;
    display: flex;
    flex-direction: column;
}

/* Table Container */
.table-container {
    height: 70vh;
    overflow-y: auto;
    overflow-x: auto;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    background: var(--surface-color);
}

/* Table Styles */
table {
    width: 100%;
    border-collapse: collapse;
    margin: 0;
}

thead {
    position: sticky;
    top: 0;
    z-index: 10;
}

th {
    background: var(--primary-color);
    color: white;
    padding: 1rem 0.75rem;
    text-align: center;
    font-weight: 600;
    font-size: 0.875rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border: none;
}

th.sortable {
    cursor: pointer;
    transition: all 0.2s ease;
    user-select: none;
}

th.sortable:hover {
    background: var(--primary-hover);
    transform: translateY(-1px);
}

.sort-indicator {
    margin-left: 0.5rem;
    font-size: 0.75rem;
    opacity: 0.7;
    transition: all 0.2s ease;
}

td {
    padding: 1rem 0.75rem;
    text-align: center;
    border-bottom: 1px solid var(--border-color);
    font-size: 0.875rem;
    transition: all 0.2s ease;
}

tbody tr {
    transition: all 0.2s ease;
}

tbody tr:hover {
    background-color: #f8fafc;
    transform: scale(1.01);
    box-shadow: var(--shadow-sm);
}

tbody tr.selected-row {
    background: linear-gradient(135deg, #dbeafe, #bfdbfe);
    border-left: 4px solid var(--primary-color);
    font-weight: 500;
}

/* Badge Styles */
.metric-badge {
    font-size: 0.75rem;
    font-weight: 600;
    padding: 0.375rem 0.75rem;
    border-radius: var(--radius-sm);
    text-transform: uppercase;
    letter-spacing: 0.025em;
}

/* Metric Value Styles with Color Gradient */
.metric-value {
    font-size: 0.875rem;
    font-weight: 600;
    padding: 0.375rem 0.75rem;
    border-radius: var(--radius-sm);
    display: inline-block;
    min-width: 3rem;
    text-align: center;
    color: black;
    text-shadow: none;
    transition: all 0.2s ease;
}

.metric-value:hover {
    transform: scale(1.05);
    box-shadow: var(--shadow-md);
}

.bg-primary {
    background: var(--primary-color) !important;
}

.bg-secondary {
    background: linear-gradient(135deg, var(--secondary-color), #475569) !important;
}

/* Chart Container */
.chart-container {
    position: relative;
    height: 70vh;
    width: 100%;
    background: var(--surface-color);
    border-radius: var(--radius-md);
    padding: 1rem;
    border: 1px solid var(--border-color);
}

/* Chart Controls */
#chartControls {
    margin-top: 1.5rem;
    display: flex;
    justify-content: center;
}

.btn-group {
    display: inline-flex;
    border-radius: var(--radius-md);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
}

.btn-check {
    position: absolute;
    clip: rect(0, 0, 0, 0);
    pointer-events: none;
}

.btn-outline-primary {
    background: var(--surface-color);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 0.75rem 1.5rem;
    font-weight: 500;
    transition: all 0.2s ease;
    cursor: pointer;
}

.btn-outline-primary:hover {
    background: var(--primary-color);
    color: white;
    transform: translateY(-1px);
}

.btn-check:checked + .btn-outline-primary {
    background: var(--primary-color);
    border-color: var(--primary-color);
    color: white;
    box-shadow: var(--shadow-md);
}

/* Loading Styles */
.loading {
    padding: 3rem;
    text-align: center;
    color: var(--text-secondary);
    font-size: 1.1rem;
}

.spinner-border {
    width: 2.5rem;
    height: 2.5rem;
    border: 0.25em solid var(--border-color);
    border-right-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 0.75s linear infinite;
    margin-bottom: 1rem;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* Error States */
.text-danger {
    color: var(--danger-color) !important;
    font-weight: 500;
}

/* Utility Classes */
.text-center {
    text-align: center !important;
}

.my-4 {
    margin-top: 2rem !important;
    margin-bottom: 2rem !important;
}

.mt-3 {
    margin-top: 1rem !important;
}

.visually-hidden {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    padding: 0 !important;
    margin: -1px !important;
    overflow: hidden !important;
    clip: rect(0, 0, 0, 0) !important;
    white-space: nowrap !important;
    border: 0 !important;
}

/* Responsive Design */
@media (max-width: 768px) {
    h1 {
        font-size: 2rem;
    }
    
    .table-container {
        max-height: 50vh;
    }
    
    th, td {
        padding: 0.75rem 0.5rem;
        font-size: 0.8rem;
    }
    
    .chart-container {
        height: 50vh;
    }
    
    .card-header, .card-body {
        padding: 1rem;
    }
    
    .btn-outline-primary {
        padding: 0.5rem 1rem;
        font-size: 0.875rem;
    }
}

@media (max-width: 576px) {
    .container-fluid {
        padding: 0.5rem;
    }
    
    h1 {
        font-size: 1.75rem;
    }
    
    th, td {
        padding: 0.5rem 0.25rem;
        font-size: 0.75rem;
    }
    
    .metric-badge {
        font-size: 0.7rem;
        padding: 0.25rem 0.5rem;
    }
}

/* Scrollbar Styling */
.table-container::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

.table-container::-webkit-scrollbar-track {
    background: var(--background-color);
    border-radius: var(--radius-sm);
}

.table-container::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: var(--radius-sm);
}

.table-container::-webkit-scrollbar-thumb:hover {
    background: var(--secondary-color);
}

/* Animation for smooth transitions */
* {
    transition: color 0.2s ease, background-color 0.2s ease, border-color 0.2s ease, transform 0.2s ease, box-shadow 0.2s ease;
}