/**
 * Afiliados Hub - Folha de Estilos Unificada
 * Design moderno, dark sidebar, clean main content, responsivo
 */

:root {
    --bg-main: #f0f4f8;
    --sidebar-bg: #141b2d;
    --sidebar-hover: #1f2940;
    --sidebar-active: #2563eb;
    --sidebar-text: #94a3b8;
    --sidebar-text-active: #ffffff;
    
    --header-bg-start: #0f172a;
    --header-bg-end: #1e3a8a;
    
    --card-bg: #ffffff;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --text-muted: #94a3b8;
    
    --primary: #2563eb;
    --primary-hover: #1d4ed8;
    --success: #10b981;
    --success-bg: #ecfdf5;
    --danger: #ef4444;
    --danger-bg: #fef2f2;
    --warning: #f59e0b;
    --warning-bg: #fffbeb;
    --info: #0ea5e9;
    --info-bg: #f0f9ff;
    
    --border-color: #e2e8f0;
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 25px rgba(0, 0, 0, 0.08);
    
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

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

body {
    font-family: var(--font-family);
    background-color: var(--bg-main);
    color: var(--text-primary);
    min-height: 100vh;
    display: flex;
    font-size: 14px;
    line-height: 1.5;
}

/* ========================================================
   ESTRUTURA PRINCIPAL (LAYOUT)
   ======================================================== */
.app-container {
    display: flex;
    width: 100%;
    min-height: 100vh;
}

/* Sidebar */
.sidebar {
    width: 250px;
    background-color: var(--sidebar-bg);
    color: var(--sidebar-text);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    transition: transform 0.3s ease;
    z-index: 1000;
}

.sidebar-brand {
    padding: 24px 20px;
    display: flex;
    align-items: center;
    gap: 12px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.brand-icon {
    width: 36px;
    height: 36px;
    background: linear-gradient(135deg, #3b82f6, #1d4ed8);
    color: #fff;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 18px;
    box-shadow: 0 4px 10px rgba(37, 99, 235, 0.3);
}

.brand-name {
    font-size: 17px;
    font-weight: 700;
    color: #ffffff;
    letter-spacing: -0.3px;
}

.sidebar-menu {
    list-style: none;
    padding: 20px 12px;
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.menu-label {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: #475569;
    padding: 12px 14px 6px;
    font-weight: 600;
}

.menu-item a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 16px;
    color: var(--sidebar-text);
    text-decoration: none;
    font-weight: 500;
    font-size: 13.5px;
    border-radius: var(--radius-sm);
    transition: all 0.2s ease;
}

.menu-item a svg {
    width: 18px;
    height: 18px;
    stroke-width: 2;
    opacity: 0.8;
}

.menu-item a:hover {
    background-color: var(--sidebar-hover);
    color: #ffffff;
}

.menu-item.active a {
    background-color: var(--sidebar-active);
    color: var(--sidebar-text-active);
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.35);
}

.menu-item.active a svg {
    opacity: 1;
}

.sidebar-footer {
    padding: 18px;
    border-top: 1px solid rgba(255, 255, 255, 0.06);
}

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

.user-info-text {
    overflow: hidden;
}

.user-name-small {
    font-weight: 600;
    color: #fff;
    font-size: 13px;
    white-space: nowrap;
    text-overflow: ellipsis;
    overflow: hidden;
}

.user-role-small {
    font-size: 11px;
    color: #64748b;
}

.btn-logout {
    color: #94a3b8;
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 6px;
    border-radius: 6px;
    transition: color 0.2s;
}

.btn-logout:hover {
    color: #ef4444;
}

/* Área Principal */
.main-wrapper {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

/* Header escuro com degradê azul */
.top-header {
    background: linear-gradient(135deg, var(--header-bg-start) 0%, var(--header-bg-end) 100%);
    color: #ffffff;
    padding: 24px 32px 36px 32px;
    position: relative;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.12);
}

.header-top-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
}

.mobile-menu-toggle {
    display: none;
    background: transparent;
    border: none;
    color: #fff;
    cursor: pointer;
}

.header-greeting h1 {
    font-size: 22px;
    font-weight: 700;
    margin-bottom: 4px;
}

.header-greeting p {
    color: #94a3b8;
    font-size: 13px;
}

/* Cards de Resumo no Cabeçalho */
.header-financial-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px;
    margin-top: 10px;
}

.fin-card {
    background: rgba(255, 255, 255, 0.08);
    backdrop-filter: blur(8px);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: var(--radius-md);
    padding: 16px 20px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.fin-label {
    font-size: 12px;
    font-weight: 500;
    color: #cbd5e1;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.fin-value {
    font-size: 24px;
    font-weight: 700;
    color: #ffffff;
}

.fin-value.success {
    color: #34d399;
}

.fin-notice {
    font-size: 11.5px;
    color: #93c5fd;
    line-height: 1.4;
}

.fin-notice.warning {
    color: #fca5a5;
    background: rgba(239, 68, 68, 0.15);
    padding: 6px 10px;
    border-radius: 6px;
    border-left: 3px solid #ef4444;
}

/* Conteúdo da Página */
.page-content {
    padding: 28px 32px 40px;
    flex-grow: 1;
}

/* Barra de Filtros de Período */
.period-filter-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 24px;
}

.filter-buttons {
    display: inline-flex;
    background: #e2e8f0;
    padding: 4px;
    border-radius: var(--radius-sm);
    gap: 2px;
}

.filter-btn {
    padding: 6px 14px;
    font-size: 12.5px;
    font-weight: 600;
    color: var(--text-secondary);
    text-decoration: none;
    border-radius: 6px;
    transition: all 0.2s ease;
}

.filter-btn:hover {
    color: var(--text-primary);
}

.filter-btn.active {
    background: #ffffff;
    color: var(--primary);
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
}

.period-badge-info {
    font-size: 13px;
    color: var(--text-secondary);
    font-weight: 500;
}

/* ========================================================
   GRID DE MÉTRICAS (CARDS BRANCOS)
   ======================================================== */
.metrics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
    gap: 20px;
    margin-bottom: 28px;
}

.metric-card {
    background: var(--card-bg);
    border-radius: var(--radius-md);
    padding: 20px;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.metric-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.metric-card.negative-ngr {
    border-left: 4px solid var(--danger);
    background: #fffafa;
}

.metric-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.metric-title {
    font-size: 12.5px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.4px;
}

.metric-icon-bubble {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f1f5f9;
    color: var(--primary);
}

.metric-value {
    font-size: 26px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.metric-value.red {
    color: var(--danger);
}

.metric-sub {
    font-size: 11.5px;
    color: var(--text-muted);
    margin-bottom: 10px;
}

.metric-footer {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    border-top: 1px solid #f1f5f9;
    padding-top: 10px;
    margin-top: 4px;
}

.badge-trend {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    padding: 2px 7px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 700;
}

.badge-trend.up {
    background: var(--success-bg);
    color: var(--success);
}

.badge-trend.down {
    background: var(--danger-bg);
    color: var(--danger);
}

.badge-trend.neutral {
    background: #f1f5f9;
    color: var(--text-secondary);
}

.trend-desc {
    color: var(--text-muted);
    font-size: 11.5px;
}

/* ========================================================
   SEÇÃO DO GRÁFICO (TURNOVER POR DIA)
   ======================================================== */
.chart-card {
    background: var(--card-bg);
    border-radius: var(--radius-md);
    padding: 24px;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-color);
    margin-bottom: 28px;
}

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

.chart-title {
    font-size: 16px;
    font-weight: 700;
    color: var(--text-primary);
}

.chart-legend {
    display: flex;
    gap: 16px;
    font-size: 12px;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 6px;
    color: var(--text-secondary);
}

.legend-color {
    width: 12px;
    height: 12px;
    border-radius: 3px;
}

.legend-color.blue { background-color: #2563eb; }
.legend-color.indigo { background-color: #8b5cf6; }

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

/* SVG Chart Styles */
.chart-svg {
    width: 100%;
    height: 100%;
    overflow: visible;
}

.chart-grid-line {
    stroke: #f1f5f9;
    stroke-width: 1;
}

.chart-axis-text {
    font-size: 10px;
    fill: #94a3b8;
    text-anchor: middle;
}

.chart-line {
    fill: none;
    stroke-width: 3;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.chart-line.real {
    stroke: #2563eb;
}

.chart-area {
    fill-opacity: 0.12;
}

.chart-area.real {
    fill: #2563eb;
}

.chart-dot {
    fill: #ffffff;
    stroke: #2563eb;
    stroke-width: 2.5;
    cursor: pointer;
    transition: r 0.2s ease;
}

.chart-dot:hover {
    r: 6;
}

/* ========================================================
   TABELAS E RELATÓRIOS
   ======================================================== */
.table-card {
    background: var(--card-bg);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-color);
    overflow: hidden;
    margin-bottom: 28px;
}

.table-header {
    padding: 18px 24px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #ffffff;
}

.table-title {
    font-size: 16px;
    font-weight: 700;
}

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

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

table.data-table th {
    background: #f8fafc;
    color: var(--text-secondary);
    font-weight: 600;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 12px 18px;
    border-bottom: 1px solid var(--border-color);
    white-space: nowrap;
}

table.data-table td {
    padding: 14px 18px;
    border-bottom: 1px solid #f1f5f9;
    font-size: 13px;
    color: var(--text-primary);
    white-space: nowrap;
}

table.data-table tr:hover td {
    background-color: #f8fafc;
}

.badge-status {
    display: inline-block;
    padding: 3px 8px;
    border-radius: 6px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
}

.badge-status.pago, .badge-status.ativo, .badge-status.fechado {
    background: var(--success-bg);
    color: var(--success);
}

.badge-status.pendente {
    background: var(--warning-bg);
    color: var(--warning);
}

.badge-status.recusado, .badge-status.inativo {
    background: var(--danger-bg);
    color: var(--danger);
}

/* ========================================================
   FORMULÁRIOS E BOTÕES
   ======================================================== */
.form-card {
    background: var(--card-bg);
    border-radius: var(--radius-md);
    padding: 24px;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-color);
    margin-bottom: 24px;
}

.form-group {
    margin-bottom: 18px;
}

.form-group label {
    display: block;
    margin-bottom: 6px;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
}

.form-control {
    width: 100%;
    padding: 10px 14px;
    font-size: 13.5px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    outline: none;
    transition: border-color 0.2s;
    font-family: inherit;
    background-color: #ffffff;
}

.form-control:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

.form-help {
    font-size: 11.5px;
    color: var(--text-muted);
    margin-top: 4px;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 18px;
    font-size: 13.5px;
    font-weight: 600;
    border-radius: var(--radius-sm);
    cursor: pointer;
    border: none;
    text-decoration: none;
    transition: all 0.2s ease;
}

.btn-primary {
    background: var(--primary);
    color: #ffffff;
}

.btn-primary:hover {
    background: var(--primary-hover);
}

.btn-success {
    background: var(--success);
    color: #ffffff;
}

.btn-success:hover {
    background: #059669;
}

.btn-danger {
    background: var(--danger);
    color: #ffffff;
}

.btn-danger:hover {
    background: #dc2626;
}

.btn-secondary {
    background: #e2e8f0;
    color: var(--text-primary);
}

.btn-secondary:hover {
    background: #cbd5e1;
}

.btn-sm {
    padding: 6px 12px;
    font-size: 12px;
}

.alert {
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    margin-bottom: 20px;
    font-size: 13px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.alert-success {
    background: var(--success-bg);
    color: #065f46;
    border: 1px solid #a7f3d0;
}

.alert-danger {
    background: var(--danger-bg);
    color: #991b1b;
    border: 1px solid #fecaca;
}

.alert-warning {
    background: var(--warning-bg);
    color: #92400e;
    border: 1px solid #fde68a;
}

/* ========================================================
   TELA DE LOGIN
   ======================================================== */
.login-body {
    background: #0b0f19;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 20px;
}

.login-card {
    width: 100%;
    max-width: 420px;
    background: #111827;
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: var(--radius-lg);
    padding: 36px 32px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.4);
    color: #f3f4f6;
}

.login-header {
    text-align: center;
    margin-bottom: 28px;
}

.login-brand-icon {
    width: 48px;
    height: 48px;
    background: linear-gradient(135deg, #2563eb, #1d4ed8);
    color: #fff;
    border-radius: 12px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    font-weight: 700;
    margin-bottom: 12px;
}

.login-header h2 {
    font-size: 20px;
    font-weight: 700;
    color: #ffffff;
}

.login-header p {
    color: #9ca3af;
    font-size: 13px;
    margin-top: 4px;
}

.login-card .form-control {
    background: #1f2937;
    border: 1px solid #374151;
    color: #ffffff;
}

.login-card .form-control:focus {
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
}

.login-card label {
    color: #d1d5db;
}

/* ========================================================
   TELA DO ACORDO (TRANSPARENTE E OBJETIVA)
   ======================================================== */
.acordo-hero {
    background: #ffffff;
    border-radius: var(--radius-md);
    padding: 32px;
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);
    margin-bottom: 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.acordo-percentage-box {
    text-align: center;
    background: #eff6ff;
    padding: 20px 32px;
    border-radius: var(--radius-md);
    border: 1px solid #bfdbfe;
}

.acordo-percentage-num {
    font-size: 42px;
    font-weight: 800;
    color: var(--primary);
    line-height: 1;
}

.acordo-percentage-label {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-top: 4px;
}

.acordo-rules-list {
    background: #ffffff;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    padding: 28px;
    box-shadow: var(--shadow-sm);
}

.rule-item {
    display: flex;
    gap: 16px;
    margin-bottom: 20px;
}

.rule-icon {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: #eff6ff;
    color: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    flex-shrink: 0;
}

.rule-content h4 {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.rule-content p {
    font-size: 13.5px;
    color: var(--text-secondary);
    line-height: 1.6;
}

/* ========================================================
   RESPONSIVIDADE (MOBILE & TABLET)
   ======================================================== */
@media (max-width: 900px) {
    .app-container {
        flex-direction: column;
    }
    
    .sidebar {
        width: 100%;
        height: auto;
    }
    
    .sidebar-menu {
        flex-direction: row;
        flex-wrap: wrap;
        padding: 10px;
    }
    
    .menu-label {
        display: none;
    }
    
    .menu-item a {
        padding: 8px 12px;
        font-size: 12.5px;
    }
    
    .top-header {
        padding: 20px 20px 28px 20px;
    }
    
    .page-content {
        padding: 20px 16px;
    }
    
    .metrics-grid {
        grid-template-columns: 1fr;
    }
    
    .acordo-hero {
        flex-direction: column;
        gap: 20px;
        text-align: center;
    }
}
