/* ========================================
   INDEX (DASHBOARD) CSS
   ======================================== */

:root {
    --bg-primary: #0a0a0f;
    --bg-secondary: #12121a;
    --bg-card: #1a1a24;
    --bg-card-hover: #22222e;
    --accent-primary: #e74c3c;
    --accent-secondary: #ff6b5b;
    --accent-gradient: linear-gradient(135deg, #e74c3c 0%, #ff6b5b 100%);
    --text-primary: #ffffff;
    --text-secondary: #8a8a9a;
    --text-muted: #5a5a6a;
    --success: #00d4aa;
    --warning: #ffc107;
    --danger: #ff4757;
    --border-color: rgba(255, 255, 255, 0.08);
    --shadow-card: 0 4px 24px rgba(0, 0, 0, 0.4);
    --shadow-glow: 0 0 40px rgba(231, 76, 60, 0.15);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: 'Outfit', sans-serif;
    background-color: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
}

/* LOADING */
.loading-screen {
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: var(--bg-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    flex-direction: column;
    gap: 20px;
}
.loading-screen.hidden { display: none; }
.loading-spinner {
    width: 50px; height: 50px;
    border: 4px solid var(--border-color);
    border-top-color: var(--accent-primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}
.loading-text { color: var(--text-secondary); }
@keyframes spin { to { transform: rotate(360deg); } }

/* LAYOUT */
.dashboard-container { display: flex; min-height: 100vh; }
.dashboard-container.hidden { display: none; }

/* SIDEBAR */
.sidebar {
    width: 260px;
    min-width: 260px;
    background: var(--bg-secondary);
    border-right: 1px solid var(--border-color);
    padding: 30px 20px;
    position: fixed;
    height: 100vh;
    overflow-y: auto;
}

.logo { display: flex; align-items: center; gap: 12px; padding-bottom: 30px; border-bottom: 1px solid var(--border-color); margin-bottom: 30px; }
.logo-icon { width: 45px; height: 45px; background: var(--accent-gradient); border-radius: 12px; display: flex; align-items: center; justify-content: center; font-size: 24px; box-shadow: var(--shadow-glow); }
.logo-text { font-size: 18px; font-weight: 700; }
.logo-text span { color: var(--accent-primary); }

.nav-section { margin-bottom: 30px; }
.nav-title { font-size: 11px; text-transform: uppercase; letter-spacing: 1.5px; color: var(--text-muted); margin-bottom: 15px; padding-left: 15px; }
.nav-item { display: flex; align-items: center; gap: 12px; padding: 14px 15px; border-radius: 10px; cursor: pointer; transition: all 0.3s ease; color: var(--text-secondary); font-weight: 500; margin-bottom: 5px; text-decoration: none; }
.nav-item:hover { background: var(--bg-card); color: var(--text-primary); }
.nav-item.active { background: var(--accent-gradient); color: white; box-shadow: var(--shadow-glow); }
.nav-icon { font-size: 20px; width: 24px; text-align: center; }

/* MAIN CONTENT */
.main-content { flex: 1; margin-left: 260px; padding: 30px 40px; width: calc(100% - 260px); }

/* HEADER */
.header { display: flex; flex-direction: row; justify-content: space-between; align-items: center; margin-bottom: 30px; }
.header-left h1 { font-size: 28px; font-weight: 700; margin-bottom: 5px; }
.header-left p { color: var(--text-secondary); font-size: 15px; }
.header-right { display: flex; flex-direction: row; align-items: center; gap: 15px; }

.period-selector { display: flex; flex-direction: row; background: var(--bg-card); border-radius: 10px; padding: 4px; border: 1px solid var(--border-color); }
.period-btn { padding: 10px 18px; border: none; background: none; color: var(--text-secondary); font-family: 'Outfit', sans-serif; font-size: 14px; font-weight: 500; cursor: pointer; border-radius: 8px; transition: all 0.3s ease; }
.period-btn:hover { color: var(--text-primary); }
.period-btn.active { background: var(--accent-gradient); color: white; }

.admin-badge { display: flex; flex-direction: row; align-items: center; gap: 10px; background: var(--bg-card); padding: 10px 15px; border-radius: 10px; border: 1px solid var(--border-color); }
.admin-avatar { width: 36px; height: 36px; background: var(--accent-gradient); border-radius: 50%; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 14px; }
.admin-info .name { font-weight: 600; font-size: 14px; }
.admin-info .role { font-size: 12px; color: var(--text-muted); }

.btn-logout { background: rgba(255, 71, 87, 0.1); border: 1px solid rgba(255, 71, 87, 0.3); color: var(--danger); padding: 10px 16px; border-radius: 10px; cursor: pointer; font-family: 'Outfit', sans-serif; font-size: 14px; font-weight: 500; transition: all 0.3s ease; display: flex; align-items: center; gap: 8px; }
.btn-logout:hover { background: var(--danger); color: white; }

/* FINANCE SUMMARY */
.finance-summary { display: grid; grid-template-columns: repeat(4, 1fr); gap: 20px; margin-bottom: 30px; }

.finance-card { background: var(--bg-card); border-radius: 16px; padding: 25px; border: 1px solid var(--border-color); position: relative; overflow: hidden; transition: all 0.3s ease; }
.finance-card::before { content: ''; position: absolute; top: 0; left: 0; width: 100%; height: 4px; opacity: 0; transition: opacity 0.3s ease; }
.finance-card:hover { transform: translateY(-5px); box-shadow: var(--shadow-card); }
.finance-card:hover::before { opacity: 1; }
.finance-card.revenue::before { background: var(--accent-gradient); }
.finance-card.users::before { background: linear-gradient(135deg, #00d4aa, #00b894); }
.finance-card.subscriptions::before { background: linear-gradient(135deg, #a855f7, #8b5cf6); }
.finance-card.average::before { background: linear-gradient(135deg, #3498db, #2980b9); }

.finance-header { display: flex; flex-direction: row; justify-content: space-between; align-items: flex-start; margin-bottom: 15px; }
.finance-icon { width: 50px; height: 50px; border-radius: 12px; display: flex; align-items: center; justify-content: center; font-size: 24px; }
.finance-card.revenue .finance-icon { background: rgba(231, 76, 60, 0.15); }
.finance-card.users .finance-icon { background: rgba(0, 212, 170, 0.15); }
.finance-card.subscriptions .finance-icon { background: rgba(168, 85, 247, 0.15); }
.finance-card.average .finance-icon { background: rgba(52, 152, 219, 0.15); }

.finance-trend { display: flex; align-items: center; gap: 4px; font-size: 13px; font-weight: 600; padding: 5px 10px; border-radius: 20px; }
.finance-trend.up { color: var(--success); background: rgba(0, 212, 170, 0.1); }
.finance-trend.down { color: var(--danger); background: rgba(255, 71, 87, 0.1); }

.finance-value { font-size: 28px; font-weight: 800; font-family: 'Space Mono', monospace; margin-bottom: 5px; }
.finance-label { color: var(--text-secondary); font-size: 14px; }
.finance-comparison { margin-top: 15px; padding-top: 15px; border-top: 1px solid var(--border-color); font-size: 13px; color: var(--text-muted); }
.finance-comparison span { color: var(--text-secondary); font-weight: 600; }

/* CHARTS */
.charts-row { display: grid; grid-template-columns: 2fr 1fr; gap: 20px; margin-bottom: 30px; }

.chart-card { background: var(--bg-card); border-radius: 16px; padding: 25px; border: 1px solid var(--border-color); }
.chart-header { display: flex; flex-direction: row; justify-content: space-between; align-items: center; margin-bottom: 20px; }
.chart-title { font-size: 18px; font-weight: 600; }
.chart-actions { display: flex; flex-direction: row; gap: 8px; }
.chart-action-btn { padding: 8px 14px; background: var(--bg-secondary); border: 1px solid var(--border-color); border-radius: 8px; color: var(--text-secondary); font-family: 'Outfit', sans-serif; font-size: 12px; cursor: pointer; transition: all 0.3s ease; }
.chart-action-btn:hover, .chart-action-btn.active { background: var(--accent-primary); border-color: var(--accent-primary); color: white; }
.chart-container { height: 300px; position: relative; }
.chart-container.small { height: 250px; }

/* REVENUE BREAKDOWN */
.revenue-breakdown { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; margin-bottom: 30px; }
.breakdown-card { background: var(--bg-card); border-radius: 16px; padding: 25px; border: 1px solid var(--border-color); text-align: center; transition: all 0.3s ease; }
.breakdown-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-card); }
.breakdown-icon { width: 60px; height: 60px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 28px; margin: 0 auto 15px; }
.breakdown-card.basic .breakdown-icon { background: rgba(138, 138, 154, 0.15); }
.breakdown-card.premium .breakdown-icon { background: rgba(231, 76, 60, 0.15); }
.breakdown-card.family .breakdown-icon { background: rgba(0, 212, 170, 0.15); }
.breakdown-title { font-size: 14px; color: var(--text-secondary); margin-bottom: 5px; }
.breakdown-value { font-size: 24px; font-weight: 700; font-family: 'Space Mono', monospace; margin-bottom: 5px; }
.breakdown-card.basic .breakdown-value { color: var(--text-secondary); }
.breakdown-card.premium .breakdown-value { color: var(--accent-primary); }
.breakdown-card.family .breakdown-value { color: var(--success); }
.breakdown-count { font-size: 13px; color: var(--text-muted); }

/* TABLES */
.tables-row { display: grid; grid-template-columns: repeat(2, 1fr); gap: 20px; }
.table-card { background: var(--bg-card); border-radius: 16px; padding: 25px; border: 1px solid var(--border-color); }
.table-header { display: flex; flex-direction: row; justify-content: space-between; align-items: center; margin-bottom: 20px; }
.view-all-btn { color: var(--accent-primary); background: none; border: none; font-family: 'Outfit', sans-serif; font-size: 14px; cursor: pointer; transition: opacity 0.3s ease; }
.view-all-btn:hover { opacity: 0.8; }

.data-table { width: 100%; border-collapse: collapse; }
.data-table th { text-align: left; padding: 12px 15px; color: var(--text-muted); font-size: 11px; text-transform: uppercase; letter-spacing: 1px; border-bottom: 1px solid var(--border-color); font-weight: 600; }
.data-table td { padding: 15px; border-bottom: 1px solid var(--border-color); font-size: 14px; }
.data-table tbody tr { transition: background 0.3s ease; }
.data-table tbody tr:hover { background: var(--bg-card-hover); }

.user-cell { display: flex; flex-direction: row; align-items: center; gap: 10px; }
.user-avatar-small { width: 32px; height: 32px; border-radius: 8px; background: var(--accent-gradient); display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 700; }
.status-dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; margin-right: 8px; }
.status-dot.active { background: var(--success); }
.status-dot.pending { background: var(--warning); }

/* REGION */
.region-item { display: flex; flex-direction: row; align-items: center; justify-content: space-between; padding: 12px 0; border-bottom: 1px solid var(--border-color); }
.region-item:last-child { border-bottom: none; }
.region-info { display: flex; flex-direction: row; align-items: center; gap: 12px; }
.region-flag { font-size: 20px; }
.region-name { font-weight: 500; font-size: 14px; }
.region-stats { text-align: right; }
.region-value { font-weight: 600; font-size: 14px; }
.region-percent { font-size: 12px; color: var(--text-muted); }

/* YEAR COMPARISON */
.year-comparison { display: grid; grid-template-columns: 1fr 1fr; gap: 15px; margin-top: 20px; padding-top: 20px; border-top: 1px solid var(--border-color); }
.year-item { text-align: center; padding: 15px; background: var(--bg-secondary); border-radius: 10px; }
.year-label { font-size: 12px; color: var(--text-muted); margin-bottom: 5px; }
.year-value { font-size: 18px; font-weight: 700; font-family: 'Space Mono', monospace; }
.year-item.current .year-value { color: var(--success); }
.year-item.previous .year-value { color: var(--text-secondary); }

/* SCROLLBAR */
::-webkit-scrollbar { width: 8px; }
::-webkit-scrollbar-track { background: var(--bg-secondary); }
::-webkit-scrollbar-thumb { background: var(--text-muted); border-radius: 4px; }

/* RESPONSIVIDADE */
@media (max-width: 1400px) {
    .finance-summary { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 1200px) {
    .charts-row { grid-template-columns: 1fr; }
}
@media (max-width: 900px) {
    .sidebar { display: none; }
    .main-content { margin-left: 0; width: 100%; padding: 20px; }
    .header { flex-direction: column; align-items: flex-start; gap: 15px; }
    .header-right { flex-wrap: wrap; }
    .tables-row { grid-template-columns: 1fr; }
    .revenue-breakdown { grid-template-columns: 1fr; }
    .finance-summary { grid-template-columns: 1fr; }
}

/* ANIMATIONS */
@keyframes fadeInUp { from { opacity: 0; transform: translateY(20px); } to { opacity: 1; transform: translateY(0); } }
.finance-card, .chart-card, .breakdown-card, .table-card { animation: fadeInUp 0.5s ease forwards; }