/**
 * wpDataTables - Complete Statistics CSS
 * Styles for statistics panel, categorical data, and filters
 * Version: 2.0
 */

/* ============================================
   STATISTICS PANEL - GENERAL
   ============================================ */

.wpdatatables-statistics-panel {
    margin: 30px 0;
    background: #ffffff;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    overflow: hidden;
}

/* Header */
.stats-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 20px 30px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.stats-header h3 {
    margin: 0;
    font-size: 24px;
    font-weight: 600;
}

.stats-toggle-btn {
    background: rgba(255, 255, 255, 0.2);
    color: white;
    border: 2px solid white;
    padding: 8px 16px;
    border-radius: 5px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.3s ease;
}

.stats-toggle-btn:hover {
    background: white;
    color: #667eea;
}

/* Content */
.stats-content {
    padding: 20px 30px;
}

/* Column sections */
.stats-column-section {
    margin-bottom: 40px;
    padding-bottom: 30px;
    border-bottom: 2px solid #e0e0e0;
}

.stats-column-section:last-child {
    border-bottom: none;
    margin-bottom: 0;
    padding-bottom: 0;
}

.stats-column-title {
    color: #333;
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 20px;
    padding-bottom: 10px;
    border-bottom: 3px solid #667eea;
    display: inline-block;
}

/* ============================================
   NUMERIC STATISTICS GRID
   ============================================ */

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 20px;
}

.stats-group {
    background: #f8f9fa;
    border-radius: 8px;
    padding: 20px;
    border-left: 4px solid #667eea;
}

.stats-group h5 {
    margin: 0 0 15px 0;
    font-size: 16px;
    font-weight: 600;
    color: #667eea;
}

.stat-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 0;
    border-bottom: 1px solid #e0e0e0;
}

.stat-item:last-child {
    border-bottom: none;
}

.stat-label {
    font-size: 14px;
    color: #555;
    font-weight: 500;
}

.stat-value {
    font-size: 16px;
    font-weight: 600;
    color: #333;
    background: white;
    padding: 4px 12px;
    border-radius: 4px;
}

/* Group colors */
.stats-group:nth-child(1) {
    border-left-color: #667eea;
}

.stats-group:nth-child(1) h5 {
    color: #667eea;
}

.stats-group:nth-child(2) {
    border-left-color: #f093fb;
}

.stats-group:nth-child(2) h5 {
    color: #f093fb;
}

.stats-group:nth-child(3) {
    border-left-color: #4facfe;
}

.stats-group:nth-child(3) h5 {
    color: #4facfe;
}

.stats-group:nth-child(4) {
    border-left-color: #43e97b;
}

.stats-group:nth-child(4) h5 {
    color: #43e97b;
}

/* ============================================
   CATEGORICAL DATA VISUALIZATION
   ============================================ */

.wpdt-categorical-stats {
    background: white;
    border-radius: 8px;
    padding: 30px;
    margin: 30px 0;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.wpdt-categorical-stats h3 {
    color: #333;
    font-size: 24px;
    margin-bottom: 10px;
    padding-bottom: 10px;
    border-bottom: 3px solid #667eea;
}

.wpdt-categorical-stats .subtitle {
    color: #666;
    font-size: 14px;
    margin-bottom: 25px;
}

/* Question sections */
.categorical-question {
    margin-bottom: 40px;
    padding-bottom: 30px;
    border-bottom: 2px solid #e0e0e0;
}

.categorical-question:last-child {
    border-bottom: none;
}

.question-title {
    font-size: 18px;
    font-weight: 600;
    color: #333;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.question-title .icon {
    color: #667eea;
}

/* Question summary */
.question-summary {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 15px;
    margin-bottom: 25px;
    padding: 15px;
    background: #f8f9fa;
    border-radius: 8px;
}

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

.summary-label {
    font-size: 12px;
    color: #666;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 5px;
}

.summary-value {
    font-size: 24px;
    font-weight: 700;
    color: #667eea;
}

/* Categories grid */
.categories-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
    margin-top: 20px;
}

/* Category items */
.category-item {
    background: #ffffff;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    padding: 20px;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.category-item:hover {
    border-color: #667eea;
    transform: translateY(-3px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.2);
}

.category-rank {
    position: absolute;
    top: 10px;
    right: 10px;
    background: #667eea;
    color: white;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 14px;
}

.category-rank.top {
    background: #43e97b;
}

.category-name {
    font-weight: 600;
    font-size: 15px;
    color: #333;
    margin-bottom: 15px;
    padding-right: 35px;
    min-height: 40px;
    display: flex;
    align-items: center;
}

/* Progress bars */
.category-bar-container {
    background: #e0e0e0;
    border-radius: 10px;
    height: 24px;
    overflow: hidden;
    margin-bottom: 10px;
    position: relative;
}

.category-bar {
    background: linear-gradient(90deg, #667eea 0%, #764ba2 100%);
    height: 100%;
    border-radius: 10px;
    transition: width 0.8s ease-out;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    padding-right: 10px;
}

.category-bar-label {
    color: white;
    font-weight: 700;
    font-size: 12px;
}

/* Category statistics */
.category-stats {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 10px;
}

.stat-count {
    font-size: 14px;
    color: #666;
}

.stat-count strong {
    color: #333;
    font-weight: 700;
}

.stat-percentage {
    font-size: 18px;
    font-weight: 700;
    color: #667eea;
}

/* Most frequent highlight */
.category-item.most-frequent {
    border-color: #43e97b;
    background: #f0fff4;
}

.category-item.most-frequent .category-bar {
    background: linear-gradient(90deg, #43e97b 0%, #38f9d7 100%);
}

/* Compact view */
.compact-view .categories-grid {
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
}

.compact-view .category-item {
    padding: 15px;
}

.compact-view .category-name {
    font-size: 13px;
    min-height: 35px;
}

/* View toggle button */
.view-toggle {
    text-align: right;
    margin-bottom: 20px;
}

.view-toggle button {
    background: #667eea;
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 5px;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.3s ease;
}

.view-toggle button:hover {
    background: #5568d3;
    transform: translateY(-2px);
}

/* ============================================
   COUNTRY FILTERS
   ============================================ */

.wpdt-country-filters {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    padding: 25px;
    border-radius: 8px;
    margin: 30px 0 20px 0;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

.wpdt-country-filters h3 {
    color: white;
    margin: 0 0 20px 0;
    font-size: 20px;
    font-weight: 600;
}

.wpdt-filters-container {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: center;
}

.wpdt-filter-label {
    color: white;
    font-weight: 500;
    font-size: 16px;
    margin-right: 10px;
}

.wpdt-country-btn {
    padding: 12px 24px;
    border: 2px solid white;
    background: rgba(255, 255, 255, 0.2);
    color: white;
    font-size: 15px;
    font-weight: 600;
    border-radius: 25px;
    cursor: pointer;
    transition: all 0.3s ease;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.wpdt-country-btn:hover {
    background: white;
    color: #667eea;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.wpdt-country-btn.active {
    background: white;
    color: #667eea;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    border-color: white;
}

/* Country flags */
.wpdt-country-btn::before {
    margin-right: 8px;
    font-size: 18px;
}

.wpdt-country-btn[data-country="all"]::before {
    content: "🌍";
}

.wpdt-country-btn[data-country="Spain"]::before {
    content: "🇪🇸";
}

.wpdt-country-btn[data-country="Portugal"]::before {
    content: "🇵🇹";
}

.wpdt-country-btn[data-country="Italy"]::before {
    content: "🇮🇹";
}

.wpdt-country-btn[data-country="Slovenia"]::before {
    content: "🇸🇮";
}

.wpdt-filter-info {
    background: rgba(255, 255, 255, 0.15);
    color: white;
    padding: 10px 20px;
    border-radius: 20px;
    font-size: 14px;
    font-weight: 500;
    margin-left: auto;
}

/* No data message */
.wpdt-no-data-message {
    background: #fff3cd;
    border: 2px solid #ffc107;
    color: #856404;
    padding: 20px;
    border-radius: 8px;
    margin: 20px 0;
    text-align: center;
    font-size: 16px;
    font-weight: 600;
}

/* ============================================
   ANIMATIONS
   ============================================ */

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

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

.stats-column-section {
    animation: fadeIn 0.5s ease-out;
}

.category-item {
    animation: slideIn 0.5s ease-out;
}

.category-item:nth-child(1) { animation-delay: 0.1s; }
.category-item:nth-child(2) { animation-delay: 0.2s; }
.category-item:nth-child(3) { animation-delay: 0.3s; }
.category-item:nth-child(4) { animation-delay: 0.4s; }
.category-item:nth-child(5) { animation-delay: 0.5s; }

/* ============================================
   RESPONSIVE DESIGN
   ============================================ */

@media (max-width: 768px) {
    /* Statistics panel */
    .stats-grid {
        grid-template-columns: 1fr;
    }

    .stats-header {
        flex-direction: column;
        gap: 15px;
        text-align: center;
    }

    .stats-header h3 {
        font-size: 20px;
    }

    .stats-content {
        padding: 15px;
    }

    .stat-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 5px;
    }

    .stat-value {
        width: 100%;
        text-align: center;
    }

    /* Categorical data */
    .categories-grid {
        grid-template-columns: 1fr;
    }
    
    .question-summary {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .wpdt-categorical-stats {
        padding: 20px 15px;
    }

    /* Filters */
    .wpdt-filters-container {
        flex-direction: column;
        align-items: stretch;
    }
    
    .wpdt-country-btn {
        width: 100%;
        justify-content: center;
    }
    
    .wpdt-filter-info {
        margin-left: 0;
        text-align: center;
    }
}

/* ============================================
   PRINT STYLES
   ============================================ */

@media print {
    .stats-toggle-btn,
    .view-toggle button,
    .wpdt-country-btn {
        display: none;
    }

    .stats-content,
    .categories-grid {
        display: block !important;
    }

    .wpdatatables-statistics-panel,
    .wpdt-categorical-stats {
        box-shadow: none;
        border: 1px solid #ddd;
    }

    .stats-group,
    .category-item {
        page-break-inside: avoid;
    }

    .category-bar {
        print-color-adjust: exact;
        -webkit-print-color-adjust: exact;
    }
}

/* ============================================
   UTILITY CLASSES
   ============================================ */

.wpdt-loading {
    text-align: center;
    padding: 20px;
    color: #667eea;
    font-weight: 600;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.wpdt-loading {
    animation: pulse 1.5s ease-in-out infinite;
}

/* Force visibility (for troubleshooting) */
.wpdatatables-statistics-panel,
.wpdt-categorical-stats {
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
}
