/* ============================================
   FECdesk - Analytics Page Styles
   Material Design 3 - Light theme matching dashboard
   ============================================ */

/* Period selector */
.analytics-period-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
}

.period-btn {
    padding: 0.5rem 1rem;
    border-radius: 9999px;
    font-size: 0.8125rem;
    font-weight: 500;
    border: 1px solid #c3c5d8;
    background: transparent;
    color: #434655;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.period-btn:hover {
    background: #e5eeff;
    border-color: #0d59f2;
    color: #0043c0;
}

.period-btn.active {
    background: #0043c0;
    color: #ffffff;
    border-color: #0043c0;
}

/* Date range inputs */
.date-range-container {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.date-range-container input[type="date"] {
    padding: 0.4rem 0.75rem;
    border-radius: 0.5rem;
    border: 1px solid #c3c5d8;
    font-size: 0.8125rem;
    background: #ffffff;
    color: #0b1c30;
    outline: none;
    transition: border-color 0.2s;
}

.date-range-container input[type="date"]:focus {
    border-color: #0d59f2;
    box-shadow: 0 0 0 2px rgba(13, 89, 242, 0.15);
}

/* Comparison toggle */
.comparison-toggle {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.8125rem;
    color: #434655;
    cursor: pointer;
    user-select: none;
}

.comparison-toggle input[type="checkbox"] {
    width: 2.5rem;
    height: 1.25rem;
    appearance: none;
    background: #c3c5d8;
    border-radius: 9999px;
    position: relative;
    cursor: pointer;
    transition: background 0.2s;
}

.comparison-toggle input[type="checkbox"]::after {
    content: '';
    position: absolute;
    width: 1rem;
    height: 1rem;
    border-radius: 50%;
    background: white;
    top: 0.125rem;
    left: 0.125rem;
    transition: transform 0.2s;
    box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

.comparison-toggle input[type="checkbox"]:checked {
    background: #0043c0;
}

.comparison-toggle input[type="checkbox"]:checked::after {
    transform: translateX(1.25rem);
}

/* Metric cards grid */
.metrics-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1rem;
    margin-bottom: 1.5rem;
}

@media (max-width: 1200px) {
    .metrics-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 640px) {
    .metrics-grid {
        grid-template-columns: 1fr;
    }
}

/* Metric card */
.metric-card {
    background: #ffffff;
    border: 1px solid #e5eeff;
    border-radius: 1rem;
    padding: 1.25rem;
    transition: box-shadow 0.2s, transform 0.15s;
}

.metric-card:hover {
    box-shadow: 0 8px 24px -4px rgba(11, 28, 48, 0.08);
    transform: translateY(-1px);
}

.metric-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.75rem;
}

.metric-card-icon {
    width: 2.5rem;
    height: 2.5rem;
    border-radius: 0.75rem;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
}

.metric-card-icon.blue { background: #e5eeff; color: #0043c0; }
.metric-card-icon.green { background: #e6f7f0; color: #007650; }
.metric-card-icon.purple { background: #f0e8ff; color: #6b3fa0; }
.metric-card-icon.orange { background: #fff3e0; color: #e65100; }

.metric-card-label {
    font-size: 0.75rem;
    font-weight: 500;
    color: #434655;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.metric-card-value {
    font-size: 1.75rem;
    font-weight: 700;
    color: #0b1c30;
    line-height: 1.2;
}

.metric-card-sub {
    font-size: 0.75rem;
    color: #737687;
    margin-top: 0.25rem;
}

/* Comparison indicator */
.comparison-indicator {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    font-size: 0.75rem;
    font-weight: 600;
    padding: 0.125rem 0.5rem;
    border-radius: 9999px;
}

.comparison-indicator.up {
    color: #007650;
    background: #e6f7f0;
}

.comparison-indicator.down {
    color: #ba1a1a;
    background: #ffdad6;
}

.comparison-indicator.neutral {
    color: #737687;
    background: #f0f1f5;
}

/* Charts grid */
.charts-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
    margin-bottom: 1.5rem;
}

@media (max-width: 1024px) {
    .charts-grid {
        grid-template-columns: 1fr;
    }
}

.chart-card {
    background: #ffffff;
    border: 1px solid #e5eeff;
    border-radius: 1rem;
    padding: 1.25rem;
    min-height: 320px;
    display: flex;
    flex-direction: column;
}

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

.chart-card-title {
    font-size: 0.875rem;
    font-weight: 600;
    color: #0b1c30;
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.chart-card-title .material-symbols-outlined {
    font-size: 1.125rem;
    color: #0043c0;
}

.chart-container {
    flex: 1;
    position: relative;
    min-height: 250px;
}

.chart-container canvas {
    max-height: 100%;
}

/* Calendar heatmap */
.heatmap-container {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    overflow-x: auto;
    padding-bottom: 0.5rem;
}

.heatmap-row {
    display: flex;
    gap: 3px;
    align-items: center;
}

.heatmap-label {
    width: 2rem;
    font-size: 0.625rem;
    color: #737687;
    text-align: right;
    flex-shrink: 0;
}

.heatmap-cell {
    width: 18px;
    height: 18px;
    border-radius: 3px;
    transition: transform 0.1s;
    cursor: default;
    position: relative;
}

.heatmap-cell:hover {
    transform: scale(1.3);
    z-index: 1;
}

.heatmap-cell[data-count="0"] { background: #f0f1f5; }
.heatmap-cell[data-count="1"] { background: #bdd4ff; }
.heatmap-cell[data-count="2"] { background: #7aadff; }
.heatmap-cell[data-count="3"] { background: #3d85ff; }
.heatmap-cell[data-count="4"] { background: #0d59f2; }
.heatmap-cell.high { background: #0043c0; }

.heatmap-legend {
    display: flex;
    align-items: center;
    gap: 0.375rem;
    font-size: 0.6875rem;
    color: #737687;
    margin-top: 0.5rem;
    justify-content: flex-end;
}

.heatmap-legend-cell {
    width: 14px;
    height: 14px;
    border-radius: 2px;
}

/* Filter bar */
.analytics-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    align-items: center;
}

.analytics-filter-select {
    padding: 0.4rem 2rem 0.4rem 0.75rem;
    border-radius: 0.5rem;
    border: 1px solid #c3c5d8;
    font-size: 0.8125rem;
    background: #ffffff;
    color: #0b1c30;
    outline: none;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23737687' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
    cursor: pointer;
    transition: border-color 0.2s;
}

.analytics-filter-select:focus {
    border-color: #0d59f2;
    box-shadow: 0 0 0 2px rgba(13, 89, 242, 0.15);
}

/* Export buttons */
.export-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.4rem 0.875rem;
    border-radius: 0.5rem;
    font-size: 0.8125rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    border: 1px solid #c3c5d8;
    background: #ffffff;
    color: #434655;
}

.export-btn:hover {
    background: #e5eeff;
    border-color: #0d59f2;
    color: #0043c0;
}

.export-btn .material-symbols-outlined {
    font-size: 1rem;
}

/* Loading skeleton */
.analytics-skeleton {
    background: linear-gradient(90deg, #f0f1f5 25%, #e5eeff 50%, #f0f1f5 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: 0.5rem;
}

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

/* Tooltip styling override for chart.js */
.analytics-tooltip {
    background: #0b1c30 !important;
    border-radius: 0.5rem !important;
    padding: 0.5rem 0.75rem !important;
    font-size: 0.75rem !important;
}

/* Room utilization bars */
.room-util-bar {
    height: 0.5rem;
    border-radius: 9999px;
    background: #e5eeff;
    overflow: hidden;
}

.room-util-fill {
    height: 100%;
    border-radius: 9999px;
    transition: width 0.5s ease;
}

/* Attendance rate circle */
.attendance-ring {
    width: 3rem;
    height: 3rem;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .analytics-period-bar {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .date-range-container {
        width: 100%;
    }
    
    .metric-card-value {
        font-size: 1.5rem;
    }
}
