/**
 * Legislative Dashboard Styles
 * SP Pagadian Archive
 * Chart.js Dashboard with responsive design and dark mode support
 */

/* ========================================
   Dashboard Container
   ======================================== */

#legislative-dashboard {
    width: 100%;
    max-width: 1400px;
    margin: 0 auto;
    padding: 2rem 1rem;
}

#dashboard-container {
    position: relative;
    transition: opacity 0.3s ease;
}

#dashboard-container.loading {
    opacity: 0.6;
    pointer-events: none;
}

/* Dashboard Header */
.dashboard-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    flex-wrap: wrap;
    gap: 1rem;
}

.dashboard-header h1 {
    font-size: 2rem;
    font-weight: 700;
    color: var(--text-primary, #1a202c);
    margin: 0;
}

.dashboard-controls {
    display: flex;
    gap: 1rem;
    align-items: center;
    flex-wrap: wrap;
}

.dashboard-controls label {
    font-weight: 500;
    color: var(--text-secondary, #4a5568);
}

.dashboard-controls select,
.dashboard-controls button {
    padding: 0.5rem 1rem;
    border: 1px solid var(--border-color, #e2e8f0);
    border-radius: 0.375rem;
    font-size: 0.875rem;
    background: var(--bg-primary, #ffffff);
    color: var(--text-primary, #1a202c);
    cursor: pointer;
    transition: all 0.2s ease;
}

.dashboard-controls select:hover,
.dashboard-controls button:hover {
    border-color: var(--primary-color, #3b82f6);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.dashboard-controls select:focus,
.dashboard-controls button:focus {
    outline: none;
    border-color: var(--primary-color, #3b82f6);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
}

.dashboard-controls button {
    background: var(--primary-color, #3b82f6);
    color: white;
    border-color: var(--primary-color, #3b82f6);
}

.dashboard-controls button:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* ========================================
   Statistics Cards Grid
   ======================================== */

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.stat-card {
    background: var(--bg-primary, #ffffff);
    border: 1px solid var(--border-color, #e2e8f0);
    border-radius: 0.75rem;
    padding: 1.5rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    transition: all 0.3s ease;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
    position: relative;
    overflow: hidden;
}

.stat-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 4px;
    height: 100%;
    background: var(--card-color, #3b82f6);
    transition: width 0.3s ease;
}

.stat-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.1);
}

.stat-card:hover::before {
    width: 8px;
}

.stat-icon {
    font-size: 2.5rem;
    width: 60px;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 0.5rem;
    background: var(--card-color, #3b82f6);
    opacity: 0.1;
    flex-shrink: 0;
}

.stat-content {
    flex: 1;
}

.stat-title {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-secondary, #64748b);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.25rem;
}

.stat-value {
    font-size: 2rem;
    font-weight: 700;
    color: var(--text-primary, #1a202c);
    line-height: 1;
}

/* Skeleton Loading State */
.stat-card.skeleton .stat-value,
.stat-card.skeleton .stat-title {
    background: linear-gradient(90deg, #e2e8f0 25%, #f1f5f9 50%, #e2e8f0 75%);
    background-size: 200% 100%;
    animation: skeleton-loading 1.5s infinite;
    color: transparent;
    border-radius: 0.25rem;
}

@keyframes skeleton-loading {
    0% {
        background-position: 200% 0;
    }
    100% {
        background-position: -200% 0;
    }
}

/* ========================================
   Charts Grid
   ======================================== */

.charts-grid {
    display: grid;
    gap: 1.5rem;
    margin-bottom: 1.5rem;
}

.chart-container {
    background: var(--bg-primary, #ffffff);
    border: 1px solid var(--border-color, #e2e8f0);
    border-radius: 0.75rem;
    padding: 1.5rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.chart-wrapper {
    position: relative;
    height: 400px;
}

/* Two column layout for larger screens */
.charts-row {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1.5rem;
}

@media (min-width: 768px) {
    .charts-row {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* Full width monthly chart */
.chart-full {
    grid-column: 1 / -1;
}

/* ========================================
   Error State
   ======================================== */

.error-message {
    background: #fee;
    border: 1px solid #fcc;
    border-radius: 0.75rem;
    padding: 3rem 2rem;
    text-align: center;
    color: #c00;
}

.error-message svg {
    margin: 0 auto 1rem;
    display: block;
}

.error-message h3 {
    font-size: 1.5rem;
    margin-bottom: 0.5rem;
}

.error-message p {
    margin-bottom: 1.5rem;
    color: #666;
}

.retry-btn {
    background: #c00;
    color: white;
    border: none;
    padding: 0.75rem 2rem;
    border-radius: 0.5rem;
    font-size: 1rem;
    cursor: pointer;
    transition: background 0.2s;
}

.retry-btn:hover {
    background: #a00;
}

/* ========================================
   Dark Mode Support
   ======================================== */

@media (prefers-color-scheme: dark) {
    #legislative-dashboard {
        --bg-primary: #1a202c;
        --bg-secondary: #2d3748;
        --text-primary: #f7fafc;
        --text-secondary: #cbd5e0;
        --border-color: #4a5568;
    }

    .stat-card,
    .chart-container {
        background: var(--bg-secondary);
        border-color: var(--border-color);
    }

    .dashboard-controls select,
    .dashboard-controls button {
        background: var(--bg-secondary);
        color: var(--text-primary);
        border-color: var(--border-color);
    }

    .stat-card.skeleton .stat-value,
    .stat-card.skeleton .stat-title {
        background: linear-gradient(90deg, #2d3748 25%, #4a5568 50%, #2d3748 75%);
        background-size: 200% 100%;
    }
}

/* Explicit dark mode class */
[data-theme="dark"] #legislative-dashboard {
    --bg-primary: #1a202c;
    --bg-secondary: #2d3748;
    --text-primary: #f7fafc;
    --text-secondary: #cbd5e0;
    --border-color: #4a5568;
}

[data-theme="dark"] .stat-card,
[data-theme="dark"] .chart-container {
    background: var(--bg-secondary);
    border-color: var(--border-color);
}

[data-theme="dark"] .dashboard-controls select,
[data-theme="dark"] .dashboard-controls button {
    background: var(--bg-secondary);
    color: var(--text-primary);
    border-color: var(--border-color);
}

/* ========================================
   Print Styles
   ======================================== */

@media print {
    #legislative-dashboard {
        padding: 0;
    }

    .dashboard-controls {
        display: none;
    }

    .stat-card {
        break-inside: avoid;
        box-shadow: none;
        border: 1px solid #000;
    }

    .chart-container {
        break-inside: avoid;
        box-shadow: none;
        border: 1px solid #000;
        page-break-inside: avoid;
    }

    .charts-row {
        display: block;
    }

    .chart-container {
        margin-bottom: 2rem;
    }

    .stat-card:hover {
        transform: none;
        box-shadow: none;
    }
}

/* ========================================
   Responsive Design
   ======================================== */

@media (max-width: 768px) {
    .dashboard-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .dashboard-header h1 {
        font-size: 1.5rem;
    }

    .stats-grid {
        grid-template-columns: 1fr;
    }

    .chart-wrapper {
        height: 300px;
    }

    .stat-card {
        padding: 1rem;
    }

    .stat-icon {
        font-size: 2rem;
        width: 50px;
        height: 50px;
    }

    .stat-value {
        font-size: 1.5rem;
    }
}

@media (max-width: 480px) {
    #legislative-dashboard {
        padding: 1rem 0.5rem;
    }

    .dashboard-header h1 {
        font-size: 1.25rem;
    }

    .dashboard-controls {
        width: 100%;
    }

    .dashboard-controls select,
    .dashboard-controls button {
        width: 100%;
    }

    .stat-value {
        font-size: 1.25rem;
    }

    .chart-container {
        padding: 1rem;
    }
}

/* ========================================
   Accessibility
   ======================================== */

.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* Focus visible styles */
.dashboard-controls select:focus-visible,
.dashboard-controls button:focus-visible {
    outline: 2px solid var(--primary-color, #3b82f6);
    outline-offset: 2px;
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
    .stat-card,
    .stat-card::before,
    .dashboard-controls select,
    .dashboard-controls button,
    #dashboard-container {
        transition: none;
    }

    .stat-card:hover {
        transform: none;
    }

    @keyframes skeleton-loading {
        0%, 100% {
            background-position: 0 0;
        }
    }
}

/* High contrast mode */
@media (prefers-contrast: high) {
    .stat-card,
    .chart-container {
        border: 2px solid currentColor;
    }

    .dashboard-controls select,
    .dashboard-controls button {
        border: 2px solid currentColor;
    }
}
