/**
 * MEC Key Statistics Plugin Styles
 * Primary Color: #2f4f4f (Dark Slate Gray)
 */

/* Main Container */
.mec-key-stats-wrapper {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    max-width: 100%;
    margin: 0 auto;
}

/* Key Statistics Card */
.mec-stats-card {
    background: #ffffff;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(47, 79, 79, 0.1);
    border: 1px solid rgba(47, 79, 79, 0.1);
    overflow: hidden;
    transition: all 0.3s ease;
}

.mec-stats-card:hover {
    box-shadow: 0 8px 30px rgba(47, 79, 79, 0.15);
    transform: translateY(-2px);
}

/* Card Header */
.mec-card-header {
    background: linear-gradient(135deg, #2f4f4f 0%, #3a5f5f 100%);
    color: white;
    padding: 16px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.mec-card-title {
    margin: 0;
    font-size: 1.5rem;
    font-weight: 600;
    letter-spacing: -0.025em;
    color: white !important;
    text-shadow: none !important;
}

.mec-refresh-btn {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    border-radius: 50%;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
}

.mec-refresh-btn:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: rotate(180deg);
}

.mec-refresh-icon {
    font-size: 18px;
    font-weight: bold;
}

/* Card Content */
.mec-card-content {
    padding: 8px 12px;
}

/* Loading State */
.mec-loading {
    text-align: center;
    padding: 40px 20px;
}

.mec-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #2f4f4f;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 16px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Error State */
.mec-error {
    text-align: center;
    padding: 40px 20px;
    color: #d32f2f;
}

.mec-error-icon {
    font-size: 48px;
    margin-bottom: 16px;
}

/* Statistics Content */
.mec-stats-content {
    animation: fadeIn 0.5s ease-in;
}

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

/* Stat Items */
.mec-stat-item {
    text-align: center;
    margin-bottom: 4px;
    background: #ffffff;
    border: 1px solid #e1e5e9;
    border-radius: 6px;
    padding: 8px 6px;
    transition: all 0.2s ease;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.mec-stat-item:hover {
    border-color: #2f4f4f;
    box-shadow: 0 2px 8px rgba(47,79,79,0.15);
    transform: translateY(-1px);
}

.mec-stat-primary {
    background: linear-gradient(135deg, #2f4f4f 0%, #3a5f5f 100%);
    color: white !important;
    padding: 12px;
    border-radius: 8px;
    margin-bottom: 10px;
    box-shadow: 0 2px 12px rgba(47,79,79,0.1);
}

.mec-stat-primary * {
    color: white !important;
    text-shadow: none !important;
}

.mec-stat-primary .mec-stat-number {
    font-size: 2rem;
    font-weight: 700;
    line-height: 1;
    margin-bottom: 4px;
    color: white !important;
    text-shadow: none !important;
}

.mec-stat-primary .mec-stat-label {
    font-size: 0.9rem;
    opacity: 0.9;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: white !important;
    text-shadow: none !important;
}

.mec-stat-number {
    font-size: 1.6rem;
    font-weight: 600;
    color: #2f4f4f;
    line-height: 1;
    margin-bottom: 4px;
}

.mec-stat-label {
    font-size: 0.9rem;
    color: #666;
    font-weight: 500;
    margin-bottom: 4px;
}

.mec-stat-percentage {
    font-size: 0.8rem;
    color: #2f4f4f;
    font-weight: 600;
    background: rgba(47, 79, 79, 0.1);
    padding: 2px 8px;
    border-radius: 12px;
    display: inline-block;
}

/* Stats Rows */
.mec-stats-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 6px;
    margin-bottom: 6px;
}

/* Compact Stats Row for Gender & Youth */
.mec-stats-row.mec-stats-compact {
    grid-template-columns: repeat(3, 1fr);
    gap: 4px;
    margin-bottom: 4px;
}

.mec-stats-compact .mec-stat-item {
    padding: 6px 4px;
    margin-bottom: 2px;
    border-radius: 4px;
}

.mec-stats-compact .mec-stat-number {
    font-size: 1.4rem;
    font-weight: 700;
    line-height: 1.1;
    margin-bottom: 2px;
}

.mec-stats-compact .mec-stat-label {
    font-size: 0.8rem;
    margin-bottom: 2px;
    font-weight: 500;
}

.mec-stats-compact .mec-stat-percentage {
    font-size: 0.75rem;
    font-weight: 600;
}

/* Regional Stats */
.mec-regional-stats {
    background: #f8f9fa;
    padding: 10px;
    border-radius: 6px;
    margin-bottom: 8px;
    border: 1px solid #e9ecef;
}

.mec-section-title {
    color: #2f4f4f;
    font-size: 0.9rem;
    font-weight: 600;
    margin: 0 0 8px 0;
    text-align: center;
}

/* Last Updated */
.mec-last-updated {
    text-align: center;
    color: #888;
    font-size: 0.8rem;
    margin-top: 16px;
}

/* Card Footer */
.mec-card-footer {
    padding: 20px 24px;
    background: #f8f9fa;
    border-top: 1px solid #eee;
    text-align: center;
}

/* Buttons */
.mec-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    text-decoration: none;
}

.mec-btn-primary {
    background: linear-gradient(135deg, #2f4f4f 0%, #3a5f5f 100%);
    color: white;
}

.mec-btn-primary:hover {
    background: linear-gradient(135deg, #3a5f5f 0%, #4a6f6f 100%);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(47, 79, 79, 0.3);
}

.mec-btn-secondary {
    background: #f8f9fa;
    color: #2f4f4f;
    border: 2px solid #2f4f4f;
}

.mec-btn-secondary:hover {
    background: #2f4f4f;
    color: white;
}

.mec-btn-arrow {
    transition: transform 0.3s ease;
}

.mec-btn:hover .mec-btn-arrow {
    transform: translateX(4px);
}

/* Modal Styles */
.mec-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    box-sizing: border-box;
}

.mec-modal-content {
    background: white;
    border-radius: 12px;
    max-width: 1200px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

.mec-modal-header {
    background: linear-gradient(135deg, #2f4f4f 0%, #3a5f5f 100%);
    color: white;
    padding: 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-radius: 12px 12px 0 0;
}

.mec-modal-header h2 {
    margin: 0;
    font-size: 1.5rem;
    font-weight: 600;
}

.mec-close-btn {
    background: none;
    border: none;
    color: white;
    font-size: 2rem;
    cursor: pointer;
    padding: 0;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background 0.3s ease;
}

.mec-close-btn:hover {
    background: rgba(255, 255, 255, 0.2);
}

.mec-modal-body {
    padding: 12px;
}

/* Dashboard Filters */
.mec-filters-section {
    background: #ffffff;
    border: 1px solid #e1e5e9;
    padding: 12px;
    border-radius: 8px;
    margin-bottom: 12px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.mec-filters-section h3 {
    color: white !important;
    margin: -12px -12px 12px -12px;
    font-size: 1.1rem;
    font-weight: 600;
    background: #2f4f4f !important;
    padding: 8px 12px;
    border-radius: 8px 8px 0 0;
    text-shadow: none !important;
    border-bottom: none;
}

.mec-filters-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 12px;
    align-items: end;
}

.mec-filter-group {
    display: flex;
    flex-direction: column;
}

.mec-filter-group label {
    color: #333 !important;
    font-weight: 500;
    margin-bottom: 4px;
    font-size: 0.9rem;
    text-shadow: none !important;
}

.mec-filter-select {
    padding: 10px 12px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 0.9rem;
    background: white !important;
    color: #333 !important;
    transition: all 0.2s ease;
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}

.mec-filter-select:focus {
    outline: none;
    border-color: #2f4f4f;
    box-shadow: 0 0 0 3px rgba(47,79,79,0.1);
}

.mec-filter-select:disabled {
    background-color: #f5f5f5;
    color: #999;
    cursor: not-allowed;
    border-color: #e0e0e0;
}

.mec-filter-select:disabled option {
    color: #999;
}

.mec-filter-help {
    color: #666;
    font-size: 0.8rem;
    margin-top: 4px;
    display: block;
    font-style: italic;
}

.mec-filter-status {
    background: #e3f2fd;
    border: 1px solid #2196f3;
    border-radius: 6px;
    padding: 6px 10px;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.85rem;
    color: #1976d2;
}

.mec-filter-indicator {
    font-size: 1rem;
}

.mec-filter-text {
    font-weight: 500;
}

/* Charts Container */
.mec-charts-container {
    min-height: 400px;
}

.mec-chart-loading {
    text-align: center;
    padding: 60px 20px;
}

.mec-charts-content {
    animation: fadeIn 0.5s ease-in;
}

.mec-chart-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 12px;
    margin-bottom: 12px;
}

.mec-chart-container {
    background: white;
    border: 1px solid #e1e5e9;
    border-radius: 8px;
    padding: 12px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    transition: box-shadow 0.2s ease;
    width: 100%;
}

.mec-chart-container:hover {
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}

.mec-chart-full {
    grid-column: 1 / -1;
    width: 100%;
}

/* Ensure charts use full container width */
#region-chart, #gender-chart, #trend-chart, #council-chart {
    width: 100% !important;
    min-width: 0;
}

.mec-chart-container h4 {
    color: white !important;
    margin: -12px -12px 12px -12px;
    font-size: 1rem;
    font-weight: 600;
    text-align: center;
    background: #2f4f4f !important;
    padding: 10px 12px;
    border-radius: 8px 8px 0 0;
    text-shadow: none !important;
}

/* Additional specific selectors for white headers */
#mec-dashboard-filters h3,
.mec-filters-section > h3,
.mec-chart-container > h4,
div.mec-filters-section h3,
div.mec-chart-container h4 {
    color: white !important;
    background: #2f4f4f !important;
    text-shadow: none !important;
}

/* Override any WordPress admin styles */
.wp-admin #mec-dashboard-filters h3,
.wp-admin .mec-filters-section h3,
.wp-admin .mec-chart-container h4 {
    color: white !important;
    background: #2f4f4f !important;
    text-shadow: none !important;
}

/* Ensure all text in dark sections is white */
.mec-card-header,
.mec-card-header *,
.mec-stat-primary,
.mec-stat-primary *,
.mec-filters-section h3,
.mec-chart-container h4 {
    color: white !important;
    text-shadow: none !important;
}

/* Specific overrides for main elements */
.mec-card-title,
#total-verifications,
.mec-stat-primary .mec-stat-number,
.mec-stat-primary .mec-stat-label {
    color: white !important;
    text-shadow: none !important;
}

/* Ensure filter labels and form elements are visible */
.mec-filter-group label,
.mec-filters-section label,
.mec-filter-label {
    color: #333 !important;
    font-weight: 500 !important;
    text-shadow: none !important;
}

/* Form inputs and selects */
.mec-filter-group select,
.mec-filter-group input,
.mec-filters-section select,
.mec-filters-section input {
    color: #333 !important;
    background: white !important;
    border: 1px solid #ddd !important;
}

/* Modal content text */
.mec-modal-body,
.mec-modal-body *:not(.mec-filters-section h3):not(.mec-chart-container h4) {
    color: #333 !important;
}

/* Chart area text */
.mec-charts-content,
.mec-charts-content * {
    color: #333 !important;
}

/* Chart Content Area */
.mec-chart-content {
    width: 100%;
    overflow-x: auto;
}

.mec-chart-content svg {
    width: 100% !important;
    max-width: 100%;
}

/* DC.js Chart Overrides */
.dc-chart {
    width: 100% !important;
}

.dc-chart .pie-slice {
    fill-opacity: 0.8;
    stroke: white;
    stroke-width: 2px;
}

.dc-chart .pie-slice:hover {
    fill-opacity: 1;
}

.dc-chart .bar {
    fill: #2f4f4f;
    fill-opacity: 0.8;
}

.dc-chart .bar:hover {
    fill-opacity: 1;
}

.dc-chart .line {
    stroke: #2f4f4f;
    stroke-width: 2px;
    fill: none;
}

.dc-chart .dot {
    fill: #2f4f4f;
    stroke: white;
    stroke-width: 2px;
}

.dc-chart .axis text {
    fill: #666;
    font-size: 11px;
}

.dc-chart .axis path,
.dc-chart .axis line {
    stroke: #ddd;
}

.dc-chart .grid-line {
    stroke: #f0f0f0;
}

/* Responsive Design */
@media (max-width: 768px) {
    .mec-stats-row {
        grid-template-columns: 1fr;
        gap: 8px;
    }

    /* Keep compact layout on mobile but with smaller text */
    .mec-stats-row.mec-stats-compact {
        grid-template-columns: repeat(3, 1fr);
        gap: 3px;
    }

    .mec-stats-compact .mec-stat-item {
        padding: 4px 3px;
    }

    .mec-stats-compact .mec-stat-number {
        font-size: 1.1rem;
    }

    .mec-stats-compact .mec-stat-label {
        font-size: 0.7rem;
    }

    .mec-stats-compact .mec-stat-percentage {
        font-size: 0.65rem;
    }

    .mec-card-content {
        padding: 6px 8px;
    }

    .mec-stat-primary {
        padding: 8px;
        margin-bottom: 6px;
    }

    .mec-stat-primary .mec-stat-number {
        font-size: 1.6rem;
    }

    .mec-stat-primary .mec-stat-label {
        font-size: 0.8rem;
    }

    .mec-stat-primary .mec-stat-number {
        font-size: 2.5rem;
    }

    .mec-modal {
        padding: 10px;
    }

    .mec-modal-content {
        max-height: 95vh;
    }

    .mec-filters-row {
        grid-template-columns: 1fr;
    }

    .mec-chart-row {
        grid-template-columns: 1fr;
    }

    .mec-chart-container {
        min-width: 0;
    }
}
