/* ===============================================
   Smart COOP Metrics Dashboard - Professional Corporate Styles
   Tailwind CSS handles most styling - this file contains only:
   - CSS Variables for theming
   - Chart.js specific styles
   - Print styles
   - Minimal custom utilities
   =============================================== */

/* ===============================================
   shadcn/ui Inspired Color System
   Base: Zinc Neutral Scale
   Accents: Blue (#3B82F6) + Violet (#8B5CF6)
   =============================================== */

:root {
    /* --- Zinc Base Palette --- */
    --zinc-50: 0 0% 98%;
    --zinc-100: 240 4.8% 95.9%;
    --zinc-200: 240 5.9% 90%;
    --zinc-300: 240 4.9% 83.9%;
    --zinc-400: 240 5% 64.9%;
    --zinc-500: 240 3.8% 46.1%;
    --zinc-600: 240 5.2% 33.9%;
    --zinc-700: 240 5.3% 26.1%;
    --zinc-800: 240 3.7% 15.9%;
    --zinc-900: 240 5.9% 10%;
    --zinc-950: 240 10% 3.9%;

    /* --- Semantic Tokens (Light Mode) --- */
    --background: 0 0% 98%;                    /* zinc-50 */
    --foreground: 240 10% 3.9%;                /* zinc-950 */

    --card: 0 0% 100%;                         /* white */
    --card-foreground: 240 10% 3.9%;          /* zinc-950 */

    --popover: 0 0% 100%;
    --popover-foreground: 240 10% 3.9%;

    --primary: 280 97% 56%;                    /* fuchsia-600 */
    --primary-foreground: 0 0% 100%;

    --secondary: 240 4.8% 95.9%;              /* zinc-100 */
    --secondary-foreground: 240 5.9% 10%;     /* zinc-900 */

    --muted: 240 4.8% 95.9%;                  /* zinc-100 */
    --muted-foreground: 240 3.8% 46.1%;       /* zinc-500 */

    --accent: 217 83% 53%;                     /* blue-600 */
    --accent-foreground: 0 0% 100%;

    --destructive: 0 72% 51%;                  /* red-600 */
    --destructive-foreground: 0 0% 100%;

    --border: 240 5.9% 90%;                    /* zinc-200 */
    --input: 240 5.9% 90%;                     /* zinc-200 */
    --ring: 280 97% 56%;                       /* fuchsia-600 */

    /* --- Functional Colors --- */
    --success: 160 84% 39%;                    /* emerald-600 */
    --success-foreground: 0 0% 100%;

    --warning: 38 92% 50%;                     /* amber-600 */
    --warning-foreground: 0 0% 100%;

    --info: 173 80% 40%;                       /* teal-600 */
    --info-foreground: 0 0% 100%;

    /* --- Chart Colors --- */
    --chart-fuchsia: 280 97% 56%;
    --chart-blue: 217 83% 53%;
    --chart-teal: 172 66% 50%;
    --chart-indigo: 239 84% 67%;
    --chart-orange: 25 95% 53%;
    --chart-emerald: 160 84% 39%;
    --chart-violet: 262 83% 58%;
    --chart-amber: 38 92% 50%;

    /* --- Structural --- */
    --radius: 0.5rem;

    /* --- Shadows --- */
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.07);
    --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.1);

    /* --- Spacing --- */
    --spacing-sm: 12px;
    --spacing-md: 24px;
    --spacing-lg: 48px;

    /* --- Border Radius --- */
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 14px;
}

/* Dark Mode Variables */
.dark {
    --background: 240 10% 3.9%;               /* zinc-950 */
    --foreground: 0 0% 98%;                   /* zinc-50 */

    --card: 240 5.9% 10%;                     /* zinc-900 */
    --card-foreground: 0 0% 98%;              /* zinc-50 */

    --popover: 240 5.9% 10%;                  /* zinc-900 */
    --popover-foreground: 0 0% 98%;

    --primary: 280 97% 71%;                   /* fuchsia-500 (lighter) */
    --primary-foreground: 240 10% 3.9%;       /* zinc-950 */

    --secondary: 240 3.7% 15.9%;              /* zinc-800 */
    --secondary-foreground: 0 0% 98%;

    --muted: 240 3.7% 15.9%;                  /* zinc-800 */
    --muted-foreground: 240 5% 64.9%;         /* zinc-400 */

    --accent: 217 91% 60%;                    /* blue-500 (lighter) */
    --accent-foreground: 240 10% 3.9%;

    --destructive: 0 84% 60%;                 /* red-500 (lighter) */
    --destructive-foreground: 0 0% 98%;

    --border: 240 3.7% 15.9%;                 /* zinc-800 */
    --input: 240 3.7% 15.9%;
    --ring: 280 97% 71%;                      /* fuchsia-500 */

    /* Functional colors (lighter in dark mode) */
    --success: 142 71% 45%;
    --success-foreground: 0 0% 98%;

    --warning: 43 96% 56%;
    --warning-foreground: 240 10% 3.9%;

    --info: 172 66% 50%;
    --info-foreground: 240 10% 3.9%;

    /* Chart colors (lighter for dark mode) */
    --chart-fuchsia: 280 97% 71%;
    --chart-blue: 217 91% 60%;
    --chart-teal: 172 66% 65%;
    --chart-indigo: 239 84% 77%;
    --chart-orange: 25 95% 68%;
    --chart-emerald: 160 84% 54%;
    --chart-violet: 262 83% 73%;
    --chart-amber: 43 96% 66%;
}

/* Reset & Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: hsl(var(--background));
    color: hsl(var(--foreground));
    line-height: 1.6;
    overflow-x: hidden;
    transition: background-color 0.3s, color 0.3s;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 var(--spacing-md);
}

/* Loading Overlay */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.98);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    transition: opacity 0.3s;
}

.dark .loading-overlay {
    background: rgba(15, 23, 42, 0.98);
}

.loading-overlay.hidden {
    display: none;
}

.loading-spinner {
    width: 60px;
    height: 60px;
    border: 4px solid hsl(var(--border));
    border-top-color: hsl(var(--primary));
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

.loading-overlay p {
    margin-top: var(--spacing-md);
    color: hsl(var(--muted-foreground));
    font-size: 1.1rem;
    font-weight: 500;
}

/* Error Message */
.error-message {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.98);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9998;
}

.dark .error-message {
    background: rgba(15, 23, 42, 0.98);
}

.error-message.hidden {
    display: none;
}

.error-content {
    text-align: center;
    padding: var(--spacing-lg);
}

.error-content i {
    font-size: 4rem;
    color: hsl(var(--destructive));
    margin-bottom: var(--spacing-md);
}

.error-content h3 {
    font-size: 1.8rem;
    margin-bottom: var(--spacing-sm);
    color: hsl(var(--foreground));
}

.error-content p {
    color: hsl(var(--muted-foreground));
    margin-bottom: var(--spacing-md);
}

.retry-button {
    background: hsl(var(--primary));
    color: hsl(var(--primary-foreground));
    border: none;
    padding: 12px 32px;
    border-radius: var(--radius-sm);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
}

.retry-button:hover {
    background: #1E3A8A;
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

/* Header - Professional Corporate Style (no gradients) */
.header {
    background: hsl(var(--card));
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    padding: var(--spacing-md) 0;
    position: sticky;
    top: 0;
    z-index: 100;
    border-bottom: 1px solid hsl(var(--border));
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: var(--spacing-md);
    padding-left: 20px;
    border-left: 5px solid hsl(var(--primary));
    position: relative;
}

.logo-section h1 {
    font-size: 1.75rem;
    font-weight: 800;
    color: hsl(var(--foreground));
    letter-spacing: -0.025em;
    margin: 0;
    margin-bottom: 4px;
}

.logo-section h1 i {
    color: hsl(var(--primary));
    font-size: 1.5rem;
    margin-right: 12px;
}

.subtitle {
    font-size: 0.875rem;
    color: hsl(var(--muted-foreground));
    font-weight: 500;
    margin-top: 4px;
    letter-spacing: 0.025em;
}

.dark .header {
    background: hsl(var(--card));
    border-bottom-color: rgba(255, 255, 255, 0.1);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

.dark .header-content {
    border-left-color: hsl(var(--primary));
}

.dark .logo-section h1 {
    color: #E2E8F0;
}

.dark .logo-section h1 i {
    color: #60A5FA;
}

.dark .subtitle {
    color: rgba(226, 232, 240, 0.7);
}

.header-actions {
    display: flex;
    align-items: center;
    gap: var(--spacing-md);
}

.timestamp-info {
    display: flex;
    flex-direction: column;
    gap: 6px;
    font-size: 0.85rem;
    color: hsl(var(--foreground));
}

.info-item {
    display: flex;
    gap: 8px;
}

.info-item .label {
    color: hsl(var(--muted-foreground));
}

.info-item .value {
    font-weight: 600;
    color: hsl(var(--foreground));
}

.dark .timestamp-info {
    color: hsl(var(--foreground));
}

.dark .info-item .label {
    color: hsl(var(--muted-foreground));
}

.dark .info-item .value {
    color: hsl(var(--foreground));
}

.theme-toggle-button {
    background: hsl(var(--secondary));
    color: hsl(var(--secondary-foreground));
    border: 1px solid hsl(var(--border));
    padding: 10px 16px;
    border-radius: var(--radius-sm);
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.theme-toggle-button:hover {
    background: hsl(var(--background));
    transform: translateY(-1px);
}

.theme-toggle-button i {
    transition: transform 0.3s;
}

.theme-toggle-button:hover i {
    transform: scale(1.1);
}

.dark .theme-toggle-button {
    background: hsl(var(--secondary));
    color: hsl(var(--secondary-foreground));
    border-color: hsl(var(--border));
}

.dark .theme-toggle-button:hover {
    background: hsl(var(--background));
}

.refresh-button {
    background: hsl(var(--primary));
    color: hsl(var(--primary-foreground));
    border: 1px solid hsl(var(--primary));
    padding: 10px 20px;
    border-radius: var(--radius-sm);
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    gap: 8px;
}

.refresh-button:hover {
    background: #1E3A8A;
    border-color: #1E3A8A;
    transform: translateY(-1px);
}

.refresh-button i {
    transition: transform 0.5s;
}

.refresh-button:active i {
    transform: rotate(360deg);
}

.dark .refresh-button {
    background: hsl(var(--primary));
    border-color: hsl(var(--primary));
    color: hsl(var(--primary-foreground));
}

.dark .refresh-button:hover {
    background: hsl(var(--primary));
    border-color: hsl(var(--primary));
}

/* Main Content */
.main-content {
    padding: var(--spacing-lg) 0;
    animation: fadeIn 0.5s;
    flex: 1;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Section Titles */
.section {
    margin-bottom: var(--spacing-lg);
}

.section-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: hsl(var(--foreground));
    margin-bottom: var(--spacing-md);
    padding-left: 16px;
    border-left: 4px solid hsl(var(--primary));
}

.dark .section-title {
    color: hsl(var(--foreground));
    border-left-color: hsl(var(--primary));
}

/* Chart Containers */
.chart-container {
    position: relative;
    height: 280px;
    padding: var(--spacing-md);
}

.chart-card {
    background: hsl(var(--card));
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    border: 1px solid hsl(var(--border));
    transition: all 0.3s;
}

.chart-card:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.card-header {
    padding: var(--spacing-md);
    border-bottom: 1px solid hsl(var(--border));
}

.card-header h3 {
    font-size: 1.1rem;
    font-weight: 600;
    color: hsl(var(--muted-foreground));
    margin-bottom: 8px;
}

.card-header h3 i {
    margin-right: 8px;
    color: hsl(var(--primary));
}

.card-stats {
    font-size: 0.9rem;
    color: hsl(var(--muted-foreground));
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
}

.stat-value {
    font-weight: 600;
    color: hsl(var(--primary));
}

/* Metric Cards - Grid Layout */
.metric-card {
    background: hsl(var(--card));
    border-radius: var(--radius-md);
    padding: 28px;
    box-shadow: var(--shadow-sm);
    border: 1px solid hsl(var(--border));

    /* Grid Layout */
    display: grid;
    grid-template-columns: 50px 1fr;
    grid-template-rows: auto auto auto auto;
    column-gap: 16px;
    row-gap: 10px;
    align-items: start;

    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    cursor: pointer;
    position: relative;
}

.metric-card:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-4px) scale(1.02);
}

.metric-card:hover .metric-icon-flat i {
    transform: rotate(5deg);
}

.metric-card:focus {
    outline: 2px solid hsl(var(--primary));
    outline-offset: 2px;
}

.metric-icon {
    width: 60px;
    height: 60px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.8rem;
    flex-shrink: 0;
}

/* Flat Design Icons */
.metric-icon-flat {
    /* Grid Positioning */
    grid-column: 1;
    grid-row: 1;

    /* Size and Style */
    width: 50px;
    height: 50px;
    border-radius: 10px;
    font-size: 1.5rem;

    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.metric-icon-flat i {
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.card-cooperatives .metric-icon-flat {
    background: hsl(var(--chart-blue) / 0.1);
    color: hsl(var(--chart-blue));
}

.card-members .metric-icon-flat {
    background: hsl(var(--chart-emerald) / 0.1);
    color: hsl(var(--chart-emerald));
}

.card-districts .metric-icon-flat {
    background: hsl(var(--chart-amber) / 0.1);
    color: hsl(var(--chart-amber));
}

.card-provinces .metric-icon-flat {
    background: hsl(var(--chart-violet) / 0.1);
    color: hsl(var(--chart-violet));
}

.metric-content {
    display: contents; /* Children participate in parent grid */
}

.metric-value {
    /* Grid Positioning */
    grid-column: 2;
    grid-row: 1;
    align-self: center;

    /* Typography */
    font-size: 2.75rem;
    font-weight: 800;
    line-height: 1;
    letter-spacing: -0.02em;
    color: hsl(var(--foreground));
}

/* Category-specific value colors */
.card-cooperatives .metric-value {
    color: hsl(var(--chart-blue));
}

.card-members .metric-value {
    color: hsl(var(--chart-emerald));
}

.card-districts .metric-value {
    color: hsl(var(--chart-amber));
}

.card-provinces .metric-value {
    color: hsl(var(--chart-violet));
}

/* Dark mode lighter shades for better contrast */
.dark .card-cooperatives .metric-value {
    color: #60A5FA;
}

.dark .card-members .metric-value {
    color: #34D399;
}

.dark .card-districts .metric-value {
    color: #FBBF24;
}

.dark .card-provinces .metric-value {
    color: #A78BFA;
}

.metric-label {
    /* Grid Positioning */
    grid-column: 1 / -1;
    grid-row: 2;

    /* Typography */
    font-size: 0.95rem;
    color: hsl(var(--muted-foreground));
    font-weight: 500;
    margin-top: 0;
}

.metric-badge {
    display: inline-block;
    background: hsl(var(--success));
    color: hsl(var(--success-foreground));
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 600;
    margin-top: 8px;
}

.metric-description {
    font-size: 0.85rem;
    color: hsl(var(--muted-foreground));
    margin-top: 8px;
    line-height: 1.4;
}

/* Growth Trend Badges */
.metric-trend {
    /* Grid Positioning */
    grid-column: 1 / -1;
    grid-row: 3;
    justify-self: start;

    /* Badge Styling */
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 600;
    margin-top: 0;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.metric-trend.trend-up {
    background: hsl(var(--success) / 0.1);
    color: hsl(var(--success));
}

.metric-trend.trend-up i {
    color: hsl(var(--success));
}

.metric-trend.trend-down {
    background: hsl(var(--destructive) / 0.1);
    color: hsl(var(--destructive));
}

.metric-trend.trend-down i {
    color: hsl(var(--destructive));
}

.metric-trend.trend-neutral {
    background: hsl(var(--muted-foreground) / 0.1);
    color: hsl(var(--muted-foreground));
}

.metric-trend.trend-neutral i {
    color: hsl(var(--muted-foreground));
}

.metric-card:hover .metric-trend {
    transform: scale(1.05);
}

.dark .metric-trend.trend-up {
    background: hsl(var(--success) / 0.2);
    color: hsl(var(--success));
}

.dark .metric-trend.trend-down {
    background: hsl(var(--destructive) / 0.2);
    color: hsl(var(--destructive));
}

.dark .metric-trend.trend-neutral {
    background: hsl(var(--muted-foreground) / 0.2);
    color: hsl(var(--muted-foreground));
}

/* Secondary Metrics */
.metric-secondary {
    /* Grid Positioning */
    grid-column: 1 / -1;
    grid-row: 4;

    /* Typography */
    font-size: 0.85rem;
    color: hsl(var(--muted-foreground));
    margin-top: 0;
    opacity: 0.8;
    transition: opacity 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.metric-card:hover .metric-secondary {
    opacity: 1;
}

/* Hover Tooltips */
.metric-tooltip {
    position: absolute;
    bottom: calc(100% + 12px);
    left: 50%;
    transform: translateX(-50%);
    background: hsl(var(--card) / 0.98);
    backdrop-filter: blur(8px);
    color: hsl(var(--foreground));
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    border: 1px solid hsl(var(--border));
    box-shadow: var(--shadow-md);
    font-size: 0.85rem;
    white-space: nowrap;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 10;
    pointer-events: none;
}

.metric-tooltip::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 6px solid transparent;
    border-top-color: rgba(255, 255, 255, 0.98);
}

.metric-card:hover .metric-tooltip {
    opacity: 1;
    visibility: visible;
    bottom: calc(100% + 16px);
}

.tooltip-content {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.tooltip-content strong {
    font-weight: 600;
    font-size: 0.9rem;
}

.tooltip-details {
    color: hsl(var(--muted-foreground));
    font-size: 0.8rem;
    line-height: 1.4;
}

.dark .metric-tooltip {
    background: hsl(var(--card) / 0.95);
    color: hsl(var(--foreground));
}

.dark .metric-tooltip::after {
    border-top-color: hsl(var(--card) / 0.95);
}

.dark .tooltip-details {
    color: hsl(var(--muted-foreground));
}

/* Grid Layouts */
.metrics-grid,
.financial-grid,
.demographics-grid,
.services-grid {
    display: grid;
    gap: var(--spacing-md);
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
}

/* Footer */
.footer {
    background: hsl(var(--foreground));
    color: hsl(var(--background));
    padding: var(--spacing-md) 0;
    text-align: center;
    margin-top: auto;
}

.dark .footer {
    background: hsl(var(--secondary));
    border-top: 1px solid hsl(var(--border));
}

.footer p {
    margin: 4px 0;
    opacity: 0.9;
}

.footer-note {
    font-size: 0.9rem;
    opacity: 0.75;
}

/* Modal Styles */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1000;
    display: none;
    align-items: center;
    justify-content: center;
}

.modal-overlay.active {
    display: flex;
}

.modal-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(15, 23, 42, 0.75);
    backdrop-filter: blur(4px);
    animation: fadeIn 0.3s;
}

.modal-container {
    position: relative;
    background: hsl(var(--card));
    border-radius: var(--radius-lg);
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    max-width: 600px;
    width: 90%;
    max-height: 90vh;
    overflow: hidden;
    animation: slideUp 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 1001;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.modal-header {
    padding: var(--spacing-md);
    border-bottom: 1px solid hsl(var(--border));
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.modal-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: hsl(var(--foreground));
    margin: 0;
}

.modal-close {
    background: transparent;
    border: none;
    color: hsl(var(--muted-foreground));
    font-size: 1.5rem;
    cursor: pointer;
    padding: 8px;
    border-radius: var(--radius-sm);
    transition: all 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-close:hover {
    background: hsl(var(--secondary));
    color: hsl(var(--foreground));
}

.modal-body {
    padding: var(--spacing-md);
    overflow-y: auto;
    max-height: calc(90vh - 100px);
}

/* Modal Header Metric Display */
.modal-header-metric {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: var(--spacing-md);
    background: hsl(var(--background));
    border-bottom: 1px solid hsl(var(--border));
}

.modal-header-icon {
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: white;
    border-radius: var(--radius-md);
    font-size: 1.5rem;
}

.modal-header-icon.coops { color: hsl(var(--primary)); }
.modal-header-icon.members { color: hsl(var(--success)); }
.modal-header-icon.districts { color: hsl(var(--warning)); }
.modal-header-icon.provinces { color: hsl(var(--accent)); }

.modal-header-content {
    flex: 1;
}

.modal-header-label {
    font-size: 0.85rem;
    color: hsl(var(--muted-foreground));
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 600;
    margin-bottom: 4px;
}

.modal-header-value {
    font-size: 2rem;
    font-weight: 700;
    color: hsl(var(--foreground));
    line-height: 1;
}

.modal-metric-value {
    font-size: 3rem;
    font-weight: 800;
    color: hsl(var(--primary));
    text-align: center;
    margin-bottom: var(--spacing-md);
}

.modal-breakdown {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: var(--spacing-md);
    margin-bottom: var(--spacing-md);
}

.breakdown-item {
    background: hsl(var(--secondary));
    padding: var(--spacing-md);
    border-radius: var(--radius-md);
    text-align: center;
    border: 1px solid transparent;
    transition: all 0.2s ease;
}

.breakdown-item:hover {
    background: hsl(var(--card));
    border-color: hsl(var(--border));
    transform: translateY(-2px);
}

.breakdown-label {
    font-size: 0.75rem;
    color: hsl(var(--muted-foreground));
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 600;
}

.breakdown-value {
    font-size: 1.75rem;
    font-weight: 800;
    color: hsl(var(--foreground));
}

.breakdown-value.highlight {
    color: hsl(var(--primary));
}

.modal-description {
    font-size: 0.95rem;
    color: hsl(var(--muted-foreground));
    line-height: 1.6;
    text-align: left;
    margin-top: var(--spacing-md);
    padding: var(--spacing-md);
    background: hsl(var(--background));
    border-radius: var(--radius-sm);
    border-left: 3px solid hsl(var(--primary));
}

.modal-actions {
    margin-top: var(--spacing-md);
    padding-top: var(--spacing-md);
    border-top: 1px solid hsl(var(--border));
    display: flex;
    justify-content: center;
}

.modal-actions .btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

/* Dark mode modal styles */
.dark .modal-backdrop {
    background: rgba(0, 0, 0, 0.85);
}

.dark .modal-header-metric {
    background: hsl(var(--secondary));
}

.dark .modal-header-icon {
    background: hsl(var(--background));
}

.dark .modal-header-value {
    color: hsl(var(--foreground));
}

.dark .modal-metric-value {
    color: hsl(var(--primary));
}

.dark .breakdown-item {
    background: hsl(var(--background));
}

.dark .breakdown-item:hover {
    background: hsl(var(--secondary));
    border-color: hsl(var(--border));
}

.dark .breakdown-value {
    color: hsl(var(--foreground));
}

.dark .modal-description {
    background: hsl(var(--secondary));
}

/* Prevent body scroll when modal is open */
body.modal-open {
    overflow: hidden;
}

/* Print Styles */
@media print {
    .header,
    .footer,
    .refresh-button,
    .loading-overlay,
    .error-message {
        display: none !important;
    }

    body {
        background: white;
    }

    .chart-card {
        break-inside: avoid;
        page-break-inside: avoid;
    }

    .section {
        page-break-inside: avoid;
    }
}

/* Responsive Design */
@media (max-width: 768px) {
    .header-content {
        flex-direction: column;
        text-align: center;
    }

    .logo-section h1 {
        font-size: 1.5rem;
    }

    .timestamp-info {
        align-items: center;
    }

    .metrics-grid,
    .financial-grid,
    .demographics-grid,
    .services-grid {
        grid-template-columns: 1fr;
    }

    .chart-container {
        height: 240px;
    }

    /* Mobile metric card adjustments */
    .metric-card {
        padding: 20px;
        grid-template-columns: 44px 1fr;
        column-gap: 12px;
        row-gap: 8px;
    }

    .metric-icon-flat {
        width: 44px;
        height: 44px;
        font-size: 1.3rem;
    }

    .metric-value {
        font-size: 2.25rem;
    }

    .metric-label {
        font-size: 0.875rem;
    }

    .metric-secondary {
        font-size: 0.8rem;
    }
}

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

    .financial-grid,
    .demographics-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    /* Tablet metric card adjustments */
    .metric-card {
        padding: 26px;
    }

    .metric-value {
        font-size: 2.5rem;
    }
}

@media (min-width: 1400px) {
    /* Large desktop metric card enhancements */
    .metric-card {
        padding: 32px;
    }

    .metric-value {
        font-size: 3rem;
    }
}

/* ===============================================
   Cooperatives Page Styles
   =============================================== */

/* Page Header with Back Link */
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--spacing-md);
    flex-wrap: wrap;
    gap: var(--spacing-sm);
}

.page-title {
    font-size: 1.75rem;
    font-weight: 700;
    color: hsl(var(--foreground));
    margin: 0;
}

.back-link {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: hsl(var(--primary));
    text-decoration: none;
    font-weight: 500;
    font-size: 0.95rem;
    padding: 8px 16px;
    border-radius: var(--radius-sm);
    transition: all 0.2s;
}

.back-link:hover {
    background: hsl(var(--primary) / 0.1);
}

.back-link i {
    font-size: 0.85rem;
}

/* Filters Card */
.filters-card {
    background: hsl(var(--card));
    border-radius: var(--radius-md);
    border: 1px solid hsl(var(--border));
    padding: var(--spacing-md);
    margin-bottom: var(--spacing-md);
}

.filters-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: var(--spacing-md);
    align-items: end;
}

.filter-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.filter-group label {
    font-size: 0.85rem;
    font-weight: 500;
    color: hsl(var(--muted-foreground));
}

.filter-input,
.filter-select {
    padding: 10px 14px;
    border: 1px solid hsl(var(--border));
    border-radius: var(--radius-sm);
    background: hsl(var(--background));
    color: hsl(var(--foreground));
    font-size: 0.95rem;
    font-family: inherit;
    transition: all 0.2s;
}

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

.filter-input::placeholder {
    color: hsl(var(--muted-foreground));
}

.filter-actions {
    display: flex;
    gap: 8px;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 18px;
    border-radius: var(--radius-sm);
    font-size: 0.95rem;
    font-weight: 500;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.2s;
    border: 1px solid transparent;
}

.btn-primary {
    background: hsl(var(--primary));
    color: hsl(var(--primary-foreground));
    border-color: hsl(var(--primary));
}

.btn-primary:hover {
    opacity: 0.9;
    transform: translateY(-1px);
}

.btn-secondary {
    background: hsl(var(--secondary));
    color: hsl(var(--secondary-foreground));
    border-color: hsl(var(--border));
}

.btn-secondary:hover {
    background: hsl(var(--background));
}

.btn-outline {
    background: transparent;
    color: hsl(var(--primary));
    border-color: hsl(var(--primary));
}

.btn-outline:hover {
    background: hsl(var(--primary) / 0.1);
}

.btn-success {
    background: hsl(var(--success));
    color: hsl(var(--success-foreground));
}

.btn-danger {
    background: hsl(var(--destructive));
    color: hsl(var(--destructive-foreground));
}

.btn-sm {
    padding: 6px 12px;
    font-size: 0.85rem;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Data Table */
.table-card {
    background: hsl(var(--card));
    border-radius: var(--radius-md);
    border: 1px solid hsl(var(--border));
    overflow: hidden;
}

.table-responsive {
    overflow-x: auto;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.95rem;
}

.data-table th,
.data-table td {
    padding: 14px 16px;
    text-align: left;
    border-bottom: 1px solid hsl(var(--border));
}

.data-table th {
    background: hsl(var(--secondary));
    font-weight: 600;
    color: hsl(var(--foreground));
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    white-space: nowrap;
}

.data-table tbody tr {
    transition: background 0.2s;
}

.data-table tbody tr:hover {
    background: hsl(var(--secondary) / 0.5);
}

.data-table tbody tr:last-child td {
    border-bottom: none;
}

/* Status Badges */
.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 600;
}

.status-badge.active {
    background: hsl(var(--success) / 0.1);
    color: hsl(var(--success));
}

.status-badge.inactive {
    background: hsl(var(--muted-foreground) / 0.1);
    color: hsl(var(--muted-foreground));
}

/* Table Action Buttons */
.table-actions {
    display: flex;
    gap: 8px;
}

.btn-icon {
    width: 36px;
    height: 36px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    border: 1px solid hsl(var(--border));
    background: hsl(var(--background));
    color: hsl(var(--muted-foreground));
    cursor: pointer;
    transition: all 0.2s;
}

.btn-icon:hover {
    background: hsl(var(--secondary));
    color: hsl(var(--foreground));
}

.btn-icon.edit:hover {
    border-color: hsl(var(--primary));
    color: hsl(var(--primary));
}

.btn-icon.toggle-active:hover {
    border-color: hsl(var(--warning));
    color: hsl(var(--warning));
}

.btn-icon.toggle-inactive:hover {
    border-color: hsl(var(--success));
    color: hsl(var(--success));
}

/* Pagination */
.pagination-container {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--spacing-md);
    border-top: 1px solid hsl(var(--border));
    flex-wrap: wrap;
    gap: var(--spacing-sm);
}

.pagination-info {
    font-size: 0.9rem;
    color: hsl(var(--muted-foreground));
}

.pagination-controls {
    display: flex;
    align-items: center;
    gap: 8px;
}

.pagination-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 36px;
    height: 36px;
    padding: 0 12px;
    border: 1px solid hsl(var(--border));
    border-radius: var(--radius-sm);
    background: hsl(var(--background));
    color: hsl(var(--foreground));
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.2s;
}

.pagination-btn:hover:not(:disabled) {
    background: hsl(var(--secondary));
    border-color: hsl(var(--primary));
}

.pagination-btn.active {
    background: hsl(var(--primary));
    color: hsl(var(--primary-foreground));
    border-color: hsl(var(--primary));
}

.pagination-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.page-size-select {
    padding: 8px 12px;
    border: 1px solid hsl(var(--border));
    border-radius: var(--radius-sm);
    background: hsl(var(--background));
    color: hsl(var(--foreground));
    font-size: 0.9rem;
    cursor: pointer;
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: var(--spacing-lg);
    color: hsl(var(--muted-foreground));
}

.empty-state i {
    font-size: 4rem;
    margin-bottom: var(--spacing-md);
    opacity: 0.5;
}

.empty-state h3 {
    font-size: 1.25rem;
    color: hsl(var(--foreground));
    margin-bottom: 8px;
}

.empty-state p {
    font-size: 0.95rem;
}

/* Edit Modal Form */
.form-group {
    margin-bottom: var(--spacing-md);
}

.form-group label {
    display: block;
    font-size: 0.9rem;
    font-weight: 500;
    color: hsl(var(--foreground));
    margin-bottom: 8px;
}

.form-group label .required {
    color: hsl(var(--destructive));
}

.form-input {
    width: 100%;
    padding: 12px 14px;
    border: 1px solid hsl(var(--border));
    border-radius: var(--radius-sm);
    background: hsl(var(--background));
    color: hsl(var(--foreground));
    font-size: 0.95rem;
    font-family: inherit;
    transition: all 0.2s;
}

.form-input:focus {
    outline: none;
    border-color: hsl(var(--primary));
    box-shadow: 0 0 0 3px hsl(var(--primary) / 0.1);
}

.form-input:disabled {
    background: hsl(var(--secondary));
    cursor: not-allowed;
}

.form-input.readonly {
    background: hsl(var(--secondary));
    color: hsl(var(--muted-foreground));
}

/* Form Select (dropdown) */
.form-select {
    width: 100%;
    padding: 12px 14px;
    border: 1px solid hsl(var(--border));
    border-radius: var(--radius-sm);
    background: hsl(var(--background));
    color: hsl(var(--foreground));
    font-size: 0.95rem;
    font-family: inherit;
    transition: all 0.2s;
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%236b7280' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 36px;
}

.form-select:focus {
    outline: none;
    border-color: hsl(var(--primary));
    box-shadow: 0 0 0 3px hsl(var(--primary) / 0.1);
}

.form-select:disabled {
    background-color: hsl(var(--secondary));
    cursor: not-allowed;
}

/* Unknown/invalid option styling */
.form-select option.unknown-option {
    color: hsl(var(--warning));
    font-style: italic;
    background: hsl(var(--warning) / 0.1);
}

/* Checkbox Toggle */
.checkbox-group {
    display: flex;
    align-items: center;
    gap: 12px;
}

.toggle-switch {
    position: relative;
    width: 48px;
    height: 26px;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: hsl(var(--muted-foreground) / 0.3);
    border-radius: 26px;
    transition: all 0.3s;
}

.toggle-slider:before {
    position: absolute;
    content: "";
    height: 20px;
    width: 20px;
    left: 3px;
    bottom: 3px;
    background: white;
    border-radius: 50%;
    transition: all 0.3s;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.toggle-switch input:checked + .toggle-slider {
    background: hsl(var(--success));
}

.toggle-switch input:checked + .toggle-slider:before {
    transform: translateX(22px);
}

.toggle-label {
    font-size: 0.95rem;
    color: hsl(var(--foreground));
}

/* Modal Footer */
.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    padding: var(--spacing-md);
    border-top: 1px solid hsl(var(--border));
    background: hsl(var(--secondary) / 0.5);
}

/* Toast Notifications */
.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.toast {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 18px;
    background: hsl(var(--card));
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    border: 1px solid hsl(var(--border));
    min-width: 300px;
    max-width: 450px;
    animation: slideInRight 0.3s ease;
}

@keyframes slideInRight {
    from {
        opacity: 0;
        transform: translateX(100px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.toast.success {
    border-left: 4px solid hsl(var(--success));
}

.toast.success .toast-icon {
    color: hsl(var(--success));
}

.toast.error {
    border-left: 4px solid hsl(var(--destructive));
}

.toast.error .toast-icon {
    color: hsl(var(--destructive));
}

.toast.info {
    border-left: 4px solid hsl(var(--info));
}

.toast.info .toast-icon {
    color: hsl(var(--info));
}

.toast-icon {
    font-size: 1.25rem;
    flex-shrink: 0;
}

.toast-content {
    flex: 1;
}

.toast-title {
    font-weight: 600;
    color: hsl(var(--foreground));
    margin-bottom: 2px;
}

.toast-message {
    font-size: 0.9rem;
    color: hsl(var(--muted-foreground));
}

.toast-close {
    background: none;
    border: none;
    color: hsl(var(--muted-foreground));
    cursor: pointer;
    padding: 4px;
    font-size: 1rem;
    transition: color 0.2s;
}

.toast-close:hover {
    color: hsl(var(--foreground));
}

/* Loading State for Table */
.table-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--spacing-lg);
    gap: 12px;
    color: hsl(var(--muted-foreground));
}

.table-loading .loading-spinner {
    width: 24px;
    height: 24px;
    border-width: 3px;
}

/* Confirmation Modal */
.confirm-modal .modal-body {
    text-align: center;
    padding: var(--spacing-lg);
}

.confirm-modal .confirm-icon {
    font-size: 4rem;
    color: hsl(var(--warning));
    margin-bottom: var(--spacing-md);
}

.confirm-modal h3 {
    font-size: 1.25rem;
    color: hsl(var(--foreground));
    margin-bottom: 8px;
}

.confirm-modal p {
    color: hsl(var(--muted-foreground));
    margin-bottom: var(--spacing-md);
}

.confirm-actions {
    display: flex;
    justify-content: center;
    gap: 12px;
}

/* Nav Link Button */
.nav-link-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 18px;
    background: hsl(var(--secondary));
    color: hsl(var(--secondary-foreground));
    border: 1px solid hsl(var(--border));
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    font-weight: 500;
    text-decoration: none;
    transition: all 0.2s;
}

.nav-link-btn:hover {
    background: hsl(var(--background));
    border-color: hsl(var(--primary));
    color: hsl(var(--primary));
}

/* Utility Classes */
.hidden {
    display: none !important;
}

.text-center {
    text-align: center;
}

.mt-4 {
    margin-top: 1rem;
}

.mb-4 {
    margin-bottom: 1rem;
}
