/* ============================================================================
   Voucher Dashboard - Main Styles
   Professional, responsive design with modern CSS
   ============================================================================ */

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    padding: 20px;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
}

/* Header Styles */
header {
    text-align: center;
    color: white;
    margin-bottom: 30px;
}

h1 {
    font-size: 2.5rem;
    margin-bottom: 10px;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.3);
    font-weight: bold;
    color: #fff;
}

.subtitle {
    font-size: 1.1rem;
    opacity: 0.9;
    margin-bottom: 20px;
}

/* KPI Filter */
.kpi-filter {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 12px;
    padding-bottom: 10px;
    border-bottom: 1px solid #e2e8f0;
}

.kpi-filter label {
    font-size: 0.75rem;
    color: #718096;
    font-weight: 600;
}

.kpi-filter-select {
    flex: 1;
    padding: 4px 8px;
    font-size: 0.8rem;
    border: 1px solid #e2e8f0;
    border-radius: 4px;
    background: white;
    color: #2d3748;
    cursor: pointer;
    transition: all 0.2s ease;
}

.kpi-filter-select:hover {
    border-color: #cbd5e0;
}

.kpi-filter-select:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 2px rgba(102, 126, 234, 0.1);
}

/* Chart Filter */
.chart-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.chart-filter {
    display: flex;
    align-items: center;
    gap: 8px;
}

.chart-filter label {
    font-size: 0.85rem;
    color: #718096;
    font-weight: 600;
}

.chart-filter-select {
    padding: 6px 12px;
    font-size: 0.9rem;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    background: white;
    color: #2d3748;
    cursor: pointer;
    min-width: 150px;
    transition: all 0.2s ease;
}

.chart-filter-select:hover {
    border-color: #cbd5e0;
}

.chart-filter-select:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 2px rgba(102, 126, 234, 0.1);
}

/* Language Selector */
.lang-selector {
    position: absolute;
    top: 20px;
    right: 20px;
    display: flex;
    gap: 10px;
    background: rgba(255, 255, 255, 0.15);
    padding: 8px 12px;
    border-radius: 20px;
    backdrop-filter: blur(10px);
}

.lang-btn {
    background: rgba(255, 255, 255, 0.2);
    color: white;
    border: 2px solid transparent;
    padding: 6px 16px;
    border-radius: 15px;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 600;
    transition: all 0.3s ease;
}

.lang-btn:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: translateY(-2px);
}

.lang-btn.active {
    background: white;
    color: #667eea;
    border-color: white;
}

/* Loading Spinner */
.loading {
    text-align: center;
    color: white;
    font-size: 1.2rem;
    margin: 50px 0;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid rgba(255, 255, 255, 0.3);
    border-top: 4px solid white;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 20px;
}

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

/* KPI Cards */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.kpi-card {
    background: rgba(255, 255, 255, 0.95);
    padding: 25px;
    border-radius: 15px;
    box-shadow: 0 8px 32px rgba(220, 38, 38, 0.1);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(220, 38, 38, 0.2);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.kpi-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.15);
}

.kpi-label {
    font-size: 0.9rem;
    color: #666;
    margin-bottom: 8px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.kpi-value {
    font-size: 2.5rem;
    font-weight: 700;
    color: #2d3748;
    margin-bottom: 5px;
}

.kpi-subtext {
    font-size: 0.85rem;
    color: #718096;
}

/* Chart Grid */
.chart-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.chart-card {
    background: rgba(255, 255, 255, 0.95);
    padding: 25px;
    border-radius: 15px;
    box-shadow: 0 8px 32px rgba(220, 38, 38, 0.08);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(220, 38, 38, 0.15);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.chart-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.15);
}

.chart-card.full-width {
    grid-column: 1 / -1;
}

.chart-title {
    font-size: 1.3rem;
    font-weight: 600;
    color: #2d3748;
    margin-bottom: 20px;
    text-align: center;
}

.chart-container {
    position: relative;
    height: 300px;
}

.chart-container.tall {
    height: 400px;
}

/* Mobile-friendly pie chart */
#segmentationChart {
    max-height: 300px;
}

@media (max-width: 768px) {
    #segmentationChart {
        max-height: 350px; /* Increased height for mobile */
    }
    
    /* Adjust legend for mobile */
    .chart-card:has(#segmentationChart) .chart-container {
        padding-bottom: 60px; /* Extra space for legend */
        height: 400px; /* Ensure enough space for chart + legend */
    }
}

/* Table Styles */
.table-card {
    background: rgba(255, 255, 255, 0.95);
    padding: 25px;
    border-radius: 15px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    margin-bottom: 30px;
}

table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 15px;
}

th, td {
    padding: 12px 15px;
    text-align: left;
    border-bottom: 1px solid #e2e8f0;
}

th {
    background: #f7fafc;
    font-weight: 600;
    color: #4a5568;
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

tr:hover {
    background: #f7fafc;
}

/* Footer */
footer {
    text-align: center;
    color: white;
    margin-top: 40px;
    padding: 20px;
    opacity: 0.8;
}

/* Responsive Design */
@media (max-width: 768px) {
    body {
        padding: 10px;
    }
    
    h1 {
        font-size: 2rem;
    }
    
    .chart-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }
    
    .chart-filter {
        width: 100%;
    }
    
    .chart-filter-select {
        width: 100%;
        min-width: auto;
    }
    
    .kpi-grid {
        grid-template-columns: 1fr;
    }
    
    .chart-grid {
        grid-template-columns: 1fr;
    }
    
    .chart-container {
        height: 250px;
    }
    
    .chart-container.tall {
        height: 300px;
    }
    
    .lang-selector {
        top: 10px;
        right: 10px;
        padding: 6px 10px;
    }
    
    .lang-btn {
        padding: 5px 12px;
        font-size: 0.85rem;
    }
    
    table {
        font-size: 0.85rem;
    }
    
    th, td {
        padding: 8px 10px;
    }
}

@media (max-width: 480px) {
    .kpi-value {
        font-size: 2rem;
    }
    
    .chart-container {
        height: 200px;
    }
    
    .chart-container.tall {
        height: 250px;
    }
}
