/** * Admin Dashboard Corporate - KPIs, Tendências e Detalhes * Filtros por período: Este Mês, Mês Anterior, Últimos 2 Meses, ou período customizado */ const { buildHeader, buildFooter, buildHead, getChartJsScript } = require('./ui-template'); function buildAdminDashboardHTML(user) { // Support both admin and corporate roles const role = user.role || 'corporate'; const pageScripts = getChartJsScript(); // Calculate default dates (current month) const now = new Date(); const firstDayOfMonth = new Date(now.getFullYear(), now.getMonth(), 1).toISOString().slice(0, 10); const today = now.toISOString().slice(0, 10); const pageCSS = ` /* Trading Terminal - Live Rates */ .trading-terminal { background: linear-gradient(135deg, #0F1923 0%, #1A2332 50%, #0D1B2A 100%); border-top: 1px solid rgba(0,255,136,0.15); border-bottom: 1px solid rgba(0,255,136,0.15); padding: 16px 40px; position: relative; overflow: hidden; } .trading-terminal::before { content: ''; position: absolute; top: 0; left: 0; right: 0; height: 1px; background: linear-gradient(90deg, transparent, rgba(0,255,136,0.3), transparent); } .trading-terminal::after { content: ''; position: absolute; bottom: 0; left: 0; right: 0; height: 1px; background: linear-gradient(90deg, transparent, rgba(0,255,136,0.3), transparent); } .live-rate-bar { display: flex; align-items: center; justify-content: center; gap: 20px; max-width: 1600px; margin: 0 auto; } .terminal-title { font-size: 10px; font-weight: 700; color: rgba(0,255,136,0.6); text-transform: uppercase; letter-spacing: 2px; margin-right: 8px; font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace; } .live-rate-dot { width: 7px; height: 7px; border-radius: 50%; background: #00FF88; display: inline-block; animation: blink 1.5s infinite; box-shadow: 0 0 6px rgba(0,255,136,0.6); } @keyframes blink { 0%, 100% { opacity: 1; } 50% { opacity: 0.2; } } .rate-pair-group { display: flex; align-items: center; gap: 8px; background: rgba(255,255,255,0.03); border: 1px solid rgba(255,255,255,0.06); border-radius: 8px; padding: 8px 14px; } .rate-pair-label { font-size: 11px; font-weight: 800; color: rgba(255,255,255,0.35); text-transform: uppercase; letter-spacing: 1px; writing-mode: vertical-rl; text-orientation: mixed; font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace; } .live-rate-btn { display: flex; flex-direction: column; align-items: center; gap: 1px; padding: 8px 18px; border-radius: 6px; border: 1px solid transparent; font-family: inherit; font-size: 14px; font-weight: 700; cursor: default; transition: all 0.25s; min-width: 150px; justify-content: center; position: relative; } .rate-flags { font-size: 9px; opacity: 0.5; letter-spacing: 1px; line-height: 1; } .live-rate-btn.compra { background: rgba(0,255,136,0.08); color: #00FF88; border-color: rgba(0,255,136,0.2); } .live-rate-btn.compra:hover { background: rgba(0,255,136,0.14); } .live-rate-btn.venda { background: rgba(255,68,68,0.08); color: #FF4444; border-color: rgba(255,68,68,0.2); } .live-rate-btn.venda:hover { background: rgba(255,68,68,0.14); } .live-rate-btn .rate-value { font-size: 22px; font-weight: 800; letter-spacing: -0.5px; font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace; font-variant-numeric: tabular-nums; text-shadow: 0 0 12px currentColor; } .live-rate-btn .rate-type { font-size: 9px; text-transform: uppercase; letter-spacing: 1.5px; opacity: 0.5; font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace; } .live-rate-btn.pulse .rate-value { animation: ratePulse 0.4s ease; } @keyframes ratePulse { 0% { transform: scale(1); text-shadow: 0 0 12px currentColor; } 50% { transform: scale(1.06); text-shadow: 0 0 24px currentColor, 0 0 48px currentColor; } 100% { transform: scale(1); text-shadow: 0 0 12px currentColor; } } .live-rate-time { font-size: 10px; color: rgba(255,255,255,0.25); font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace; letter-spacing: 0.5px; } @media (max-width: 768px) { .trading-terminal { padding: 12px 16px; } .live-rate-bar { flex-wrap: wrap; gap: 10px; justify-content: center; } .terminal-title { display: none; } .rate-pair-group { padding: 8px 12px; width: 100%; justify-content: center; } .live-rate-btn { min-width: 120px; padding: 8px 14px; flex: 1; } .live-rate-btn .rate-value { font-size: 18px; } .live-rate-time { width: 100%; text-align: center; } } @media (max-width: 480px) { .trading-terminal { padding: 10px 12px; } .live-rate-bar { gap: 8px; flex-direction: column; align-items: center; } .rate-pair-group { padding: 10px; gap: 6px; } .rate-pair-label { writing-mode: horizontal-tb; font-size: 10px; } .live-rate-btn { min-width: 110px; padding: 8px 12px; } .live-rate-btn .rate-value { font-size: 16px; } .live-rate-btn .rate-type { font-size: 8px; } .rate-flags { font-size: 9px; } .live-rate-time { font-size: 9px; } } /* Filter Bar */ .filter-bar { background: var(--card); border-radius: 16px; padding: 20px 24px; border: 1px solid var(--border); box-shadow: 0 2px 8px rgba(0,0,0,0.04); margin-bottom: 24px; display: flex; align-items: center; gap: 16px; flex-wrap: wrap; } .filter-bar-label { font-size: 13px; font-weight: 600; color: var(--text-secondary); } .filter-presets { display: flex; gap: 8px; } .preset-btn { padding: 8px 16px; border: 1px solid var(--border); border-radius: 8px; font-size: 13px; font-weight: 500; font-family: inherit; background: white; color: var(--text); cursor: pointer; transition: all 0.15s; } .preset-btn:hover { border-color: var(--primary); color: var(--primary); } .preset-btn.active { background: var(--primary); border-color: var(--primary); color: white; } .filter-divider { width: 1px; height: 32px; background: var(--border); margin: 0 8px; } .date-inputs { display: flex; align-items: center; gap: 8px; } .date-inputs label { font-size: 12px; font-weight: 600; color: var(--text-secondary); } .date-inputs input { padding: 8px 12px; border: 1px solid var(--border); border-radius: 8px; font-size: 13px; font-family: inherit; } .btn-apply { padding: 8px 20px; background: var(--primary); color: white; border: none; border-radius: 8px; font-size: 13px; font-weight: 600; font-family: inherit; cursor: pointer; transition: all 0.15s; } .btn-apply:hover { background: var(--primary-light); } .period-info { margin-left: auto; font-size: 12px; color: var(--text-muted); background: var(--bg); padding: 6px 12px; border-radius: 6px; } .dashboard-grid { display: grid; gap: 24px; } /* KPI Cards */ .kpi-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 20px; } .kpi-card { background: var(--card); border-radius: 16px; padding: 24px; border: 1px solid var(--border); box-shadow: 0 2px 8px rgba(0,0,0,0.04); position: relative; min-height: 140px; } .kpi-card.total { border-left: 4px solid var(--primary); } .kpi-card.brl-usd { border-left: 4px solid var(--blue); } .kpi-card.usd-brl { border-left: 4px solid var(--green); } .kpi-card.usd-usd { border-left: 4px solid var(--purple); } .kpi-label { font-size: 12px; font-weight: 600; color: var(--text-secondary); text-transform: uppercase; letter-spacing: 0.3px; margin-bottom: 12px; } .kpi-value { font-size: 32px; font-weight: 800; color: var(--text); margin-bottom: 4px; } .kpi-sub { font-size: 13px; color: var(--text-muted); } .kpi-detail { margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--border); font-size: 12px; color: var(--text-secondary); } .kpi-detail span { font-weight: 600; color: var(--text); } /* Chart Cards */ .charts-row { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; } .chart-card { background: var(--card); border-radius: 16px; padding: 24px; border: 1px solid var(--border); box-shadow: 0 2px 8px rgba(0,0,0,0.04); min-height: 380px; position: relative; } .chart-card.full-width { grid-column: span 2; } .chart-card h3 { font-size: 14px; font-weight: 700; margin-bottom: 20px; color: var(--text); } .chart-wrap { height: 300px; position: relative; } /* Details Table */ .details-card { background: var(--card); border-radius: 16px; padding: 24px; border: 1px solid var(--border); box-shadow: 0 2px 8px rgba(0,0,0,0.04); } .details-card h3 { font-size: 14px; font-weight: 700; margin-bottom: 16px; color: var(--text); } .details-table { width: 100%; border-collapse: collapse; } .details-table th { text-align: left; font-size: 11px; font-weight: 600; color: var(--text-secondary); text-transform: uppercase; padding: 12px 8px; border-bottom: 2px solid var(--border); } .details-table td { padding: 12px 8px; font-size: 13px; border-bottom: 1px solid #F3F4F6; } .details-table tr:hover { background: #FAFBFC; } .details-table .num { text-align: right; font-variant-numeric: tabular-nums; } /* Ranking Card */ .ranking-card { background: var(--card); border-radius: 16px; padding: 24px; border: 1px solid var(--border); box-shadow: 0 2px 8px rgba(0,0,0,0.04); min-height: 300px; } .ranking-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; } .ranking-header h3 { font-size: 14px; font-weight: 700; color: var(--text); } .ranking-table { width: 100%; border-collapse: collapse; } .ranking-table th { text-align: left; font-size: 11px; font-weight: 600; color: var(--text-secondary); text-transform: uppercase; padding: 12px 8px; border-bottom: 2px solid var(--border); } .ranking-table td { padding: 14px 8px; font-size: 14px; border-bottom: 1px solid #F3F4F6; } .ranking-table tr:last-child td { border-bottom: none; } .rank-num { width: 40px; font-weight: 800; color: var(--primary); } .rank-1 { color: #FFD700; } .rank-2 { color: #C0C0C0; } .rank-3 { color: #CD7F32; } /* Loading State */ .loading { display: flex; align-items: center; justify-content: center; height: 100%; min-height: 100px; } .spinner { width: 32px; height: 32px; border: 3px solid var(--border); border-top-color: var(--primary); border-radius: 50%; animation: spin 0.8s linear infinite; } @keyframes spin { to { transform: rotate(360deg); } } .loading-text { margin-left: 12px; font-size: 13px; color: var(--text-muted); } /* Responsive */ @media (max-width: 1200px) { .kpi-row { grid-template-columns: repeat(2, 1fr); } .charts-row { grid-template-columns: 1fr; } .chart-card.full-width { grid-column: span 1; } } @media (max-width: 768px) { .kpi-row { grid-template-columns: 1fr; } .filter-bar { flex-direction: column; align-items: stretch; padding: 16px; gap: 12px; } .filter-presets { flex-wrap: wrap; justify-content: center; } .preset-btn { flex: 1; min-width: 90px; text-align: center; } .filter-divider { display: none; } .date-inputs { flex-direction: column; align-items: stretch; gap: 8px; width: 100%; } .date-inputs input { width: 100%; } .btn-apply { width: 100%; } .period-info { margin-left: 0; text-align: center; } .kpi-card { padding: 16px; min-height: 120px; } .kpi-value { font-size: 24px; } .kpi-label { font-size: 11px; } .kpi-sub { font-size: 12px; } .kpi-detail { font-size: 11px; } .chart-card { padding: 16px; min-height: 300px; } .chart-card h3 { font-size: 13px; margin-bottom: 12px; } .chart-wrap { height: 240px; } .details-card, .ranking-card { padding: 16px; } .details-table th, .details-table td { padding: 8px 6px; font-size: 11px; } .ranking-table th, .ranking-table td { padding: 10px 6px; font-size: 12px; } } @media (max-width: 480px) { .filter-bar { padding: 12px; } .preset-btn { font-size: 11px; padding: 6px 10px; } .date-inputs input { font-size: 12px; padding: 8px 10px; } .kpi-value { font-size: 20px; } .chart-wrap { height: 200px; } .details-table th, .details-table td { padding: 6px 4px; font-size: 10px; } } /* Dark Mode overrides */ [data-theme="dark"] .preset-btn { background: var(--card); color: var(--text-secondary); border-color: var(--border); } [data-theme="dark"] .preset-btn:hover { border-color: var(--admin-accent); color: var(--green); } [data-theme="dark"] .date-inputs input { background: var(--card); color: var(--text); border-color: var(--border); } [data-theme="dark"] .details-table tr:hover { background: rgba(255,255,255,0.04); } [data-theme="dark"] .details-table thead th { background: var(--bg); } [data-theme="dark"] .details-table td { border-bottom-color: var(--border); } [data-theme="dark"] .loading-overlay { background: rgba(13,17,23,0.85); } `; return ` ${buildHead('Dashboard Corporate', pageCSS, pageScripts)} ${buildHeader({ role: role, userName: user.nome, activePage: 'dashboard', permissions: user.permissions || [] })}
Live Rates
USD
--
Periodo:
Carregando...
Carregando...

Volume Diario (USD)

Carregando grafico...

Quantidade de Ordens por Dia

Carregando grafico...

Volume por Fluxo (Comparativo)

Carregando grafico...

Resumo Diario do Periodo

Carregando detalhes...

Top 5 Agentes no Periodo

Carregando ranking...
${buildFooter()}