/**
 * PNMA Quest Event - Statistics Styles
 * Airbnb-inspired Minimal Design
 * Version: 1.0.0
 */

/* CSS Variables */
:root {
    --pnma-primary: #2563EB;
    --pnma-primary-hover: #1D4ED8;
    --pnma-primary-light: #DBEAFE;
    --pnma-primary-dark: #1E3A8A;
    --pnma-success: #10B981;
    --pnma-success-light: #D1FAE5;
    --pnma-warning: #F59E0B;
    --pnma-info: #06B6D4;
    --pnma-info-light: #CFFAFE;
    --pnma-error: #EF4444;
    --pnma-dark: #111827;
    --pnma-gray-900: #1F2937;
    --pnma-gray-700: #374151;
    --pnma-gray-500: #6B7280;
    --pnma-gray-400: #9CA3AF;
    --pnma-gray-300: #D1D5DB;
    --pnma-gray-200: #E5E7EB;
    --pnma-gray-100: #F3F4F6;
    --pnma-gray-50: #F9FAFB;
    --pnma-white: #FFFFFF;
    --pnma-font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Noto Sans Thai', sans-serif;
    --pnma-radius-sm: 8px;
    --pnma-radius-md: 12px;
    --pnma-radius-lg: 16px;
    --pnma-radius-xl: 24px;
    --pnma-shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
    --pnma-shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --pnma-shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --pnma-transition: 200ms ease;
}

/* Reset */
.pnma-stat-wrapper,
.pnma-stat-wrapper * {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

/* Wrapper */
.pnma-stat-wrapper {
    font-family: var(--pnma-font);
    max-width: 1200px;
    margin: 0 auto;
    padding: 32px 24px;
    background: var(--pnma-gray-50);
    min-height: 100vh;
}

/* Header */
.pnma-stat-header {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 32px;
    padding-bottom: 24px;
    border-bottom: 1px solid var(--pnma-gray-200);
}

.pnma-stat-header-content {
    flex: 1;
    min-width: 200px;
}

.pnma-stat-title {
    font-size: 28px;
    font-weight: 700;
    color: var(--pnma-dark);
    margin: 0 0 4px 0;
}

.pnma-stat-subtitle {
    font-size: 14px;
    color: var(--pnma-gray-500);
    margin: 0;
}

/* Header Actions */
.pnma-stat-actions {
    display: flex;
    gap: 12px;
}

/* Buttons */
.pnma-stat-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    font-size: 14px;
    font-weight: 500;
    font-family: inherit;
    border: none;
    border-radius: var(--pnma-radius-md);
    cursor: pointer;
    transition: var(--pnma-transition);
}

.pnma-stat-btn-icon {
    width: 18px;
    height: 18px;
}

.pnma-stat-btn-primary {
    background: var(--pnma-primary);
    color: var(--pnma-white);
}

.pnma-stat-btn-primary:hover {
    background: var(--pnma-primary-hover);
}

.pnma-stat-btn-outline {
    background: var(--pnma-white);
    color: var(--pnma-gray-700);
    border: 1px solid var(--pnma-gray-300);
}

.pnma-stat-btn-outline:hover {
    background: var(--pnma-gray-50);
    border-color: var(--pnma-gray-400);
}

/* Loading State */
.pnma-stat-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 80px 24px;
    text-align: center;
}

.pnma-stat-spinner {
    width: 48px;
    height: 48px;
    color: var(--pnma-primary);
    animation: pnma-spin 1s linear infinite;
}

.pnma-stat-spinner svg {
    width: 100%;
    height: 100%;
}

.pnma-stat-loading p {
    margin-top: 16px;
    font-size: 15px;
    color: var(--pnma-gray-500);
}

@keyframes pnma-spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* Error State */
.pnma-stat-error {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 80px 24px;
    text-align: center;
}

.pnma-stat-error-icon {
    width: 48px;
    height: 48px;
    color: var(--pnma-error);
    margin-bottom: 16px;
}

.pnma-stat-error p {
    font-size: 15px;
    color: var(--pnma-gray-500);
    margin-bottom: 20px;
}

/* Main Content */
.pnma-stat-content {
    animation: pnma-fade-in 0.3s ease;
}

@keyframes pnma-fade-in {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Sections */
.pnma-stat-section {
    background: var(--pnma-white);
    border-radius: var(--pnma-radius-lg);
    padding: 24px;
    margin-bottom: 24px;
    box-shadow: var(--pnma-shadow-sm);
}

.pnma-stat-section-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--pnma-gray-700);
    margin: 0 0 20px 0;
    display: flex;
    align-items: center;
    gap: 8px;
}

.pnma-stat-section-title::before {
    content: '';
    width: 4px;
    height: 20px;
    background: var(--pnma-primary);
    border-radius: 2px;
}

/* Question Section */
.pnma-stat-question-section {
    background: linear-gradient(135deg, var(--pnma-primary) 0%, var(--pnma-primary-dark) 100%);
    color: var(--pnma-white);
}

.pnma-stat-question-section .pnma-stat-section-title {
    color: var(--pnma-white);
}

.pnma-stat-question-section .pnma-stat-section-title::before {
    background: rgba(255, 255, 255, 0.5);
}

.pnma-stat-question-box {
    font-size: 16px;
    line-height: 1.7;
    opacity: 0.95;
}

/* Summary Cards */
.pnma-stat-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 24px;
}

.pnma-stat-card {
    display: flex;
    align-items: flex-start;
    gap: 16px;
    background: var(--pnma-white);
    border-radius: var(--pnma-radius-lg);
    padding: 24px;
    box-shadow: var(--pnma-shadow-sm);
    transition: var(--pnma-transition);
}

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

.pnma-stat-card-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 48px;
    height: 48px;
    min-width: 48px;
    border-radius: var(--pnma-radius-md);
}

.pnma-stat-card-icon svg {
    width: 24px;
    height: 24px;
}

.pnma-stat-card-primary .pnma-stat-card-icon {
    background: var(--pnma-primary-light);
    color: var(--pnma-primary);
}

.pnma-stat-card-success .pnma-stat-card-icon {
    background: var(--pnma-success-light);
    color: var(--pnma-success);
}

.pnma-stat-card-info .pnma-stat-card-icon {
    background: var(--pnma-info-light);
    color: var(--pnma-info);
}

.pnma-stat-card-content {
    flex: 1;
}

.pnma-stat-card-label {
    font-size: 13px;
    font-weight: 500;
    color: var(--pnma-gray-500);
    margin: 0 0 4px 0;
}

.pnma-stat-card-value {
    font-size: 28px;
    font-weight: 700;
    color: var(--pnma-dark);
    margin: 0;
}

/* Charts Grid */
.pnma-stat-charts {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
    gap: 24px;
    margin-bottom: 24px;
}

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

.pnma-stat-chart-section {
    margin-bottom: 0;
}

.pnma-stat-chart-wrapper {
    position: relative;
    height: 300px;
}

.pnma-stat-chart-wrapper canvas {
    width: 100% !important;
    height: 100% !important;
}

/* Tables */
.pnma-stat-table-wrapper {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.pnma-stat-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

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

.pnma-stat-table th {
    font-weight: 600;
    color: var(--pnma-gray-700);
    background: var(--pnma-gray-50);
    white-space: nowrap;
}

.pnma-stat-table tbody tr {
    transition: var(--pnma-transition);
}

.pnma-stat-table tbody tr:hover {
    background: var(--pnma-gray-50);
}

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

/* Progress Bar in Table */
.pnma-stat-progress {
    width: 100%;
    min-width: 100px;
    height: 8px;
    background: var(--pnma-gray-100);
    border-radius: 4px;
    overflow: hidden;
}

.pnma-stat-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--pnma-primary) 0%, var(--pnma-info) 100%);
    border-radius: 4px;
    transition: width 0.5s ease;
}

/* Answer Badge */
.pnma-stat-answer-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    background: var(--pnma-primary-light);
    color: var(--pnma-primary);
    font-weight: 600;
    border-radius: 50%;
}

/* Footer */
.pnma-stat-footer {
    text-align: center;
    padding: 24px;
    color: var(--pnma-gray-400);
    font-size: 13px;
}

/* Responsive */
@media (max-width: 768px) {
    .pnma-stat-wrapper {
        padding: 16px;
    }

    .pnma-stat-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .pnma-stat-title {
        font-size: 22px;
    }

    .pnma-stat-actions {
        width: 100%;
    }

    .pnma-stat-btn {
        flex: 1;
        justify-content: center;
    }

    .pnma-stat-cards {
        grid-template-columns: 1fr;
    }

    .pnma-stat-card-value {
        font-size: 24px;
    }

    .pnma-stat-section {
        padding: 20px 16px;
    }

    .pnma-stat-chart-wrapper {
        height: 250px;
    }
}

@media (max-width: 480px) {
    .pnma-stat-btn span {
        display: none;
    }

    .pnma-stat-btn {
        padding: 10px 14px;
    }
}
