/* === VARIABLES === */
:root {
    --bg-primary: #0a0a0f;
    --bg-secondary: #12121a;
    --bg-card: #1a1a24;
    --bg-card-hover: #22222e;
    --accent: #6366f1;
    --accent-light: #818cf8;
    --accent-glow: rgba(99, 102, 241, 0.3);
    --success: #22c55e;
    --success-bg: rgba(34, 197, 94, 0.1);
    --danger: #ef4444;
    --danger-bg: rgba(239, 68, 68, 0.1);
    --warning: #f59e0b;
    --warning-bg: rgba(245, 158, 11, 0.1);
    --text-primary: #ffffff;
    --text-secondary: #9ca3af;
    --text-muted: #6b7280;
    --border: #2d2d3a;
    --radius: 12px;
    --radius-lg: 16px;
    --shadow: 0 4px 24px rgba(0, 0, 0, 0.3);
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* === RESET === */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
}

/* === APP LAYOUT === */
.app {
    display: flex;
    min-height: 100vh;
}

/* === SIDEBAR === */
.sidebar {
    width: 260px;
    background: var(--bg-secondary);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    padding: 24px 16px;
    position: fixed;
    height: 100vh;
}

.logo {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0 12px 24px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 24px;
}

.logo-icon {
    font-size: 32px;
}

.logo-text {
    font-size: 14px;
    font-weight: 600;
    line-height: 1.3;
    background: linear-gradient(135deg, var(--accent), var(--accent-light));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.nav {
    display: flex;
    flex-direction: column;
    gap: 4px;
    flex: 1;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border-radius: var(--radius);
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    transition: var(--transition);
}

.nav-item:hover {
    background: var(--bg-card);
    color: var(--text-primary);
}

.nav-item.active {
    background: linear-gradient(135deg, var(--accent), var(--accent-light));
    color: white;
    box-shadow: 0 4px 12px var(--accent-glow);
}

.nav-icon {
    font-size: 18px;
}

.sidebar-footer {
    padding-top: 16px;
    border-top: 1px solid var(--border);
}

.last-update {
    font-size: 12px;
    color: var(--text-muted);
    text-align: center;
}

.last-update span {
    color: var(--accent-light);
    font-weight: 500;
}

/* === MAIN CONTENT === */
.main {
    flex: 1;
    margin-left: 260px;
    padding: 24px 32px;
    background: var(--bg-primary);
}

/* === HEADER === */
.header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 32px;
}

.header h1 {
    font-size: 28px;
    font-weight: 700;
    margin-bottom: 4px;
}

.subtitle {
    color: var(--text-secondary);
    font-size: 14px;
}

.filter-group {
    display: flex;
    gap: 12px;
}

.filter-select {
    background: var(--bg-card);
    border: 1px solid var(--border);
    color: var(--text-primary);
    padding: 10px 16px;
    border-radius: var(--radius);
    font-size: 14px;
    cursor: pointer;
    transition: var(--transition);
}

.filter-select:hover {
    border-color: var(--accent);
}

.filter-select:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

/* === STATS GRID === */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 20px;
    margin-bottom: 32px;
}

.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 24px;
    display: flex;
    align-items: center;
    gap: 16px;
    transition: var(--transition);
}

.stat-card:hover {
    transform: translateY(-2px);
    border-color: var(--accent);
    box-shadow: var(--shadow);
}

.stat-icon {
    font-size: 32px;
    padding: 12px;
    background: var(--bg-secondary);
    border-radius: var(--radius);
}

.stat-content {
    display: flex;
    flex-direction: column;
}

.stat-value {
    font-size: 28px;
    font-weight: 700;
    line-height: 1;
    margin-bottom: 4px;
}

.stat-label {
    font-size: 13px;
    color: var(--text-secondary);
}

.stat-card.trending-up .stat-value {
    color: var(--success);
}

.stat-card.trending-down .stat-value {
    color: var(--danger);
}

.stat-card.new-entry .stat-value {
    color: var(--warning);
}

/* === CHARTS === */
.charts-row {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 20px;
    margin-bottom: 32px;
}

.chart-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 24px;
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.card-header h3 {
    font-size: 16px;
    font-weight: 600;
}

.badge {
    font-size: 10px;
    font-weight: 600;
    padding: 4px 8px;
    border-radius: 20px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.badge.live {
    background: var(--danger);
    color: white;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.6; }
}

.chart-container {
    height: 250px;
    position: relative;
}

/* === TABLE === */
.table-section .card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
}

.table-section .card-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--border);
}

.table-tabs {
    display: flex;
    gap: 8px;
}

.tab-btn {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-secondary);
    padding: 8px 16px;
    border-radius: var(--radius);
    font-size: 13px;
    cursor: pointer;
    transition: var(--transition);
}

.tab-btn:hover {
    border-color: var(--accent);
    color: var(--text-primary);
}

.tab-btn.active {
    background: var(--accent);
    border-color: var(--accent);
    color: white;
}

.table-wrapper {
    overflow-x: auto;
}

.apps-table {
    width: 100%;
    border-collapse: collapse;
}

.apps-table th,
.apps-table td {
    padding: 16px 24px;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

.apps-table th {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    background: var(--bg-secondary);
}

.apps-table tr:hover {
    background: var(--bg-card-hover);
}

.apps-table .rank {
    font-weight: 700;
    color: var(--accent-light);
}

.apps-table .app-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.apps-table .app-icon {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    background: var(--bg-secondary);
}

.apps-table .app-name {
    font-weight: 500;
}

.apps-table .app-developer {
    font-size: 12px;
    color: var(--text-muted);
}

.apps-table .change {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 8px;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 500;
}

.apps-table .change.up {
    background: var(--success-bg);
    color: var(--success);
}

.apps-table .change.down {
    background: var(--danger-bg);
    color: var(--danger);
}

.apps-table .change.stable {
    background: var(--bg-secondary);
    color: var(--text-muted);
}

/* === RESPONSIVE === */
@media (max-width: 1200px) {
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    .charts-row {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .sidebar {
        display: none;
    }
    .main {
        margin-left: 0;
        padding: 16px;
    }
    .header {
        flex-direction: column;
        gap: 16px;
    }
    .filter-group {
        flex-wrap: wrap;
    }
    .stats-grid {
        grid-template-columns: 1fr;
    }
}
