/* Variables */
:root {
    --bg-primary: #0b0f19;
    --bg-secondary: #131a2c;
    --bg-card: #1c263e;
    --border-color: #2b395b;
    --text-primary: #f1f5f9;
    --text-muted: #94a3b8;
    
    --primary: #3b82f6;
    --primary-glow: rgba(59, 130, 246, 0.4);
    --secondary: #a855f7;
    
    --success: #10b981;
    --success-bg: rgba(16, 185, 129, 0.15);
    --success-border: rgba(16, 185, 129, 0.3);
    
    --warning: #f59e0b;
    --warning-bg: rgba(245, 158, 11, 0.12);
    --warning-border: rgba(245, 158, 11, 0.3);
    
    --danger: #ef4444;
    --danger-bg: rgba(239, 68, 68, 0.1);
    
    --accent-orange: #f97316;
    --accent-teal: #14b8a6;
    
    --font-sans: 'Inter', sans-serif;
    --font-display: 'Outfit', sans-serif;
    --sidebar-width: 280px;
    --radius-sm: 6px;
    --radius-md: 12px;
    --radius-lg: 18px;
    
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Global Reset */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    background-color: var(--bg-primary);
    color: var(--text-primary);
    font-family: var(--font-sans);
    line-height: 1.5;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
}

/* Scrollbar Styles */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-primary);
}

::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: var(--radius-sm);
}

::-webkit-scrollbar-thumb:hover {
    background: var(--primary);
}

/* App Container Layout */
.app-container {
    display: flex;
    min-height: 100vh;
    width: 100vw;
}

/* Sidebar Styling */
.sidebar {
    width: var(--sidebar-width);
    background-color: var(--bg-secondary);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    padding: 24px;
    position: fixed;
    height: 100vh;
    left: 0;
    top: 0;
    z-index: 100;
}

.logo-container {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 32px;
}

.logo-icon {
    width: 42px;
    height: 42px;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 20px;
    box-shadow: 0 0 15px rgba(59, 130, 246, 0.4);
}

.logo-container h2 {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 18px;
    letter-spacing: 0.5px;
}

.version-tag {
    font-size: 11px;
    color: var(--text-muted);
    background-color: var(--border-color);
    padding: 2px 6px;
    border-radius: 4px;
}

.nav-menu {
    display: flex;
    flex-direction: column;
    gap: 8px;
    flex-grow: 1;
}

.nav-item {
    background: none;
    border: none;
    outline: none;
    color: var(--text-muted);
    padding: 12px 16px;
    border-radius: var(--radius-md);
    text-align: left;
    font-family: var(--font-sans);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 12px;
    transition: var(--transition);
}

.nav-item i {
    font-size: 16px;
}

.nav-item:hover {
    color: var(--text-primary);
    background-color: rgba(255, 255, 255, 0.05);
}

.nav-item.active {
    color: white;
    background: linear-gradient(135deg, var(--primary), rgba(59, 130, 246, 0.6));
    box-shadow: 0 4px 15px var(--primary-glow);
}

/* Export Data Panel */
.download-section {
    border-top: 1px solid var(--border-color);
    padding-top: 20px;
    margin-bottom: 20px;
}

.download-section h3 {
    font-family: var(--font-display);
    font-size: 13px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-muted);
    margin-bottom: 12px;
}

.download-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    padding: 10px;
    border-radius: var(--radius-sm);
    text-decoration: none;
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 8px;
    transition: var(--transition);
}

.excel-btn {
    background-color: rgba(16, 185, 129, 0.1);
    color: #10b981;
    border: 1px solid rgba(16, 185, 129, 0.2);
}

.excel-btn:hover {
    background-color: #10b981;
    color: white;
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);
}

.csv-btn {
    background-color: rgba(255, 255, 255, 0.03);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

.csv-btn:hover {
    background-color: var(--border-color);
}

/* Status Indicator Card */
.status-card {
    background-color: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 16px;
}

.status-indicator {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
}

.pulse-dot {
    width: 8px;
    height: 8px;
    background-color: var(--success);
    border-radius: 50%;
    position: relative;
}

.pulse-dot::after {
    content: '';
    position: absolute;
    width: 100%;
    height: 100%;
    background-color: var(--success);
    border-radius: 50%;
    animation: pulse 1.5s infinite;
}

@keyframes pulse {
    0% { transform: scale(1); opacity: 0.8; }
    100% { transform: scale(2.5); opacity: 0; }
}

.status-text {
    font-size: 13px;
    font-weight: 600;
    color: var(--success);
}

.status-card p {
    font-size: 11px;
    color: var(--text-muted);
    line-height: 1.4;
    margin-bottom: 8px;
}

.last-refreshed {
    font-size: 10px;
    color: var(--text-muted);
    font-family: monospace;
}

/* Main Content Area */
.main-content {
    margin-left: var(--sidebar-width);
    flex-grow: 1;
    padding: 32px;
    width: calc(100vw - var(--sidebar-width));
}

/* Header bar styling */
.main-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 32px;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 24px;
}

.header-title h1 {
    font-family: var(--font-display);
    font-weight: 800;
    font-size: 28px;
    letter-spacing: -0.5px;
    margin-bottom: 4px;
}

.header-title p {
    color: var(--text-muted);
    font-size: 14px;
}

.quick-stats-row {
    display: flex;
    gap: 16px;
}

.quick-stat-box {
    background-color: var(--bg-secondary);
    border: 1px solid var(--border-color);
    padding: 12px 20px;
    border-radius: var(--radius-md);
    text-align: right;
}

.qs-label {
    display: block;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-muted);
    margin-bottom: 4px;
}

.qs-value {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 20px;
    color: var(--primary);
}

/* View switcher styling */
.content-view {
    display: none;
    animation: fadeIn 0.4s ease-out;
}

.content-view.active {
    display: block;
}

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

/* Dashboard Grid */
.grid-layout {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 20px;
    margin-bottom: 24px;
}

/* Stat Cards */
.card {
    background-color: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    box-shadow: 0 10px 25px rgba(0,0,0,0.15);
    overflow: hidden;
    transition: var(--transition);
}

.card:hover {
    transform: translateY(-2px);
    box-shadow: 0 15px 30px rgba(0,0,0,0.25);
    border-color: rgba(59, 130, 246, 0.3);
}

.stat-card {
    padding: 24px;
    border-radius: var(--radius-lg);
    position: relative;
    overflow: hidden;
}

.stat-card::after {
    content: '';
    position: absolute;
    top: -50%;
    right: -20%;
    width: 150px;
    height: 150px;
    background: radial-gradient(circle, rgba(255,255,255,0.05) 0%, rgba(255,255,255,0) 70%);
    border-radius: 50%;
}

.stat-card.gradient-1 {
    border-left: 5px solid var(--primary);
}
.stat-card.gradient-2 {
    border-left: 5px solid var(--secondary);
}
.stat-card.gradient-3 {
    border-left: 5px solid var(--accent-orange);
}

.stat-card .card-body {
    display: flex;
    align-items: center;
    gap: 20px;
}

.stat-icon-wrapper {
    width: 52px;
    height: 52px;
    border-radius: var(--radius-md);
    background-color: rgba(255,255,255,0.03);
    border: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    color: var(--text-primary);
}

.gradient-1 .stat-icon-wrapper { color: var(--primary); background: rgba(59, 130, 246, 0.1); }
.gradient-2 .stat-icon-wrapper { color: var(--secondary); background: rgba(168, 85, 247, 0.1); }
.gradient-3 .stat-icon-wrapper { color: var(--accent-orange); background: rgba(249, 115, 22, 0.1); }

.stat-value {
    font-family: var(--font-display);
    font-weight: 800;
    font-size: 22px;
    margin-bottom: 2px;
    letter-spacing: -0.5px;
}

.stat-label {
    font-size: 12px;
    font-weight: 500;
    color: var(--text-muted);
}

/* Charts Panel */
.charts-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(450px, 1fr));
    gap: 20px;
}

.chart-card {
    padding: 24px;
}

.chart-card .card-header {
    margin-bottom: 20px;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 12px;
}

.chart-card h3 {
    font-family: var(--font-display);
    font-weight: 600;
    font-size: 16px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.chart-container {
    position: relative;
    height: 280px;
    width: 100%;
}

/* Filters Card */
.filter-card {
    padding: 20px;
    margin-bottom: 24px;
}

.filter-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
}

.input-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.input-group label {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.input-group input,
.input-group select {
    background-color: var(--bg-primary);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    outline: none;
    font-family: var(--font-sans);
    font-size: 14px;
    transition: var(--transition);
}

.input-group input:focus,
.input-group select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

/* Tables Styling */
.table-card {
    margin-bottom: 24px;
}

.table-card .card-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--border-color);
}

.table-card h3 {
    font-family: var(--font-display);
    font-weight: 600;
    font-size: 16px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.flex-between {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.text-link-btn {
    background: none;
    border: none;
    color: var(--primary);
    font-weight: 600;
    font-size: 13px;
    cursor: pointer;
    transition: var(--transition);
}

.text-link-btn:hover {
    color: white;
    text-decoration: underline;
}

.count-badge {
    background-color: var(--border-color);
    color: var(--text-primary);
    font-size: 12px;
    font-weight: 600;
    padding: 4px 10px;
    border-radius: 20px;
}

.table-responsive {
    width: 100%;
    overflow-x: auto;
}

.max-height-table {
    max-height: 580px;
    overflow-y: auto;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
    font-size: 13px;
}

.data-table th,
.data-table td {
    padding: 12px 18px;
    border-bottom: 1px solid var(--border-color);
}

.data-table th {
    background-color: rgba(255, 255, 255, 0.015);
    color: var(--text-muted);
    font-weight: 600;
    position: sticky;
    top: 0;
    z-index: 5;
    text-transform: uppercase;
    font-size: 11px;
    letter-spacing: 0.5px;
    backdrop-filter: blur(8px);
}

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

.data-table tbody tr:hover {
    background-color: rgba(255, 255, 255, 0.02);
}

/* Styled Specific Cells */
.winner-badge {
    background-color: rgba(59, 130, 246, 0.12);
    color: var(--primary);
    border: 1px solid rgba(59, 130, 246, 0.25);
    padding: 3px 8px;
    border-radius: 4px;
    font-weight: 600;
    font-size: 12px;
    display: inline-block;
}

.cell-highlight-yellow {
    background-color: var(--warning-bg) !important;
    border-left: 2px solid var(--warning) !important;
    color: #fbbf24 !important;
    font-weight: 500;
}

.cell-highlight-green {
    background-color: var(--success-bg) !important;
    border-left: 2px solid var(--success) !important;
    color: #34d399 !important;
    font-weight: 500;
}

.highlight-yellow-header {
    border-bottom: 2px solid var(--warning) !important;
}

.text-center { text-align: center; }
.text-muted { color: var(--text-muted); }
.margin-top { margin-top: 24px; }

/* Responsive adjustments */
@media (max-width: 1024px) {
    .app-container {
        flex-direction: column;
    }
    .sidebar {
        width: 100%;
        height: auto;
        position: relative;
        border-right: none;
        border-bottom: 1px solid var(--border-color);
        padding: 20px;
    }
    .main-content {
        margin-left: 0;
        width: 100%;
        padding: 20px;
    }
    .nav-menu {
        flex-direction: row;
        flex-wrap: wrap;
        margin-bottom: 16px;
    }
    .download-section {
        display: flex;
        flex-wrap: wrap;
        gap: 8px;
        padding-top: 12px;
        margin-bottom: 12px;
    }
    .download-btn {
        width: auto;
        flex-grow: 1;
        margin-bottom: 0;
    }
    .status-card {
        display: none; /* Hide status card on small screens */
    }
    .main-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 16px;
    }
    .quick-stats-row {
        width: 100%;
    }
    .quick-stat-box {
        flex-grow: 1;
        text-align: left;
    }
    .charts-grid {
        grid-template-columns: 1fr;
    }
}
