/* ============================================================
   DASHBOARD DO LOJISTA
   Carregado só na página com o template "Dashboard". Usa os mesmos
   tokens de cor do tema (--dvt-primary / --dvt-secondary), definidos
   em Personalizar > Configurações da Loja > Cores.
============================================================ */

:root {
    --dv-dash-bg: #F1F5F9;
    --dv-dash-surface: #FFFFFF;
    --dv-dash-text: #0F172A;
    --dv-dash-muted: #64748B;
    --dv-dash-border: #E2E8F0;
    --dv-dash-sombra: 0 4px 15px rgba(15, 23, 42, .06);
}

body.dv-dark {
    --dv-dash-bg: #0B1220;
    --dv-dash-surface: #16213A;
    --dv-dash-text: #F1F5F9;
    --dv-dash-muted: #94A3B8;
    --dv-dash-border: #263352;
    --dv-dash-sombra: 0 8px 24px rgba(0, 0, 0, .35);
    background: var(--dv-dash-bg);
}

.dv-dash-wrap {
    max-width: 1280px;
    margin: 0 auto;
    padding: 32px 24px 64px;
    background: var(--dv-dash-bg);
    color: var(--dv-dash-text);
}

body.dv-dark .dv-dash-wrap { background: var(--dv-dash-bg); }

/* ---- Topo ---- */
.dv-dash-topo {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 16px;
    margin-bottom: 28px;
}

.dv-dash-topo h1 {
    font-size: 28px;
    margin-bottom: 4px;
    color: var(--dv-dash-text);
}

.dv-dash-atualizado {
    font-size: 13px;
    color: var(--dv-dash-muted);
    margin: 0;
}

.dv-dash-acoes {
    display: flex;
    gap: 10px;
}

.dv-dash-btn-icone {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: 1px solid var(--dv-dash-border);
    background: var(--dv-dash-surface);
    color: var(--dv-dash-text);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    text-decoration: none;
    transition: .2s;
}

.dv-dash-btn-icone:hover {
    background: var(--dvt-primary, #1D4ED8);
    border-color: var(--dvt-primary, #1D4ED8);
    color: #fff;
}

.dv-icone-lua { display: none; }
body.dv-dark .dv-icone-sol { display: none; }
body.dv-dark .dv-icone-lua { display: block; }

/* ---- Seções ---- */
.dv-dash-secao-titulo {
    font-size: 18px;
    margin: 32px 0 14px;
    color: var(--dv-dash-text);
}

.dv-dash-secao-titulo:first-of-type { margin-top: 0; }

/* ---- Cartões de indicador ---- */
.dv-dash-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
    gap: 14px;
}

.dv-dash-cartao {
    display: flex;
    align-items: stretch;
    gap: 12px;
    background: var(--dv-dash-surface);
    border: 1px solid var(--dv-dash-border);
    border-radius: 14px;
    padding: 16px;
    box-shadow: var(--dv-dash-sombra);
    min-width: 0; /* permite que o texto encolha dentro do grid em vez de estourar a coluna */
    min-height: 104px;
}

.dv-dash-cartao-icone {
    flex-shrink: 0;
    align-self: center; /* ícone: esquerda (ordem natural no flex) + centralizado verticalmente */
    width: 36px;
    height: 36px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: color-mix(in srgb, var(--dvt-primary, #1D4ED8) 12%, transparent);
    color: var(--dvt-primary, #1D4ED8);
}

.dv-dash-cartao-corpo {
    display: grid;
    grid-template-rows: 1fr auto; /* linha de cima flexível (valor centralizado nela), rótulo sempre embaixo */
    justify-items: center;
    text-align: center;
    flex: 1;
    min-width: 0; /* para o texto poder quebrar/encolher em vez de empurrar o card */
}

.dv-dash-cartao-valor {
    align-self: center; /* centralizado no meio da área disponível acima do rótulo */
    font-family: var(--dvt-font-display, 'Manrope', sans-serif);
    font-size: 16px;
    font-weight: 800;
    line-height: 1.25;
    color: var(--dv-dash-text);
    word-break: break-word;
}

.dv-dash-cartao-rotulo {
    align-self: end; /* sempre encostado embaixo do card */
    font-size: 12px;
    line-height: 1.35;
    color: var(--dv-dash-muted);
    margin-top: 6px;
}

.dv-dash-positivo .dv-dash-cartao-valor { color: #16A34A; }
.dv-dash-positivo .dv-dash-cartao-icone { background: color-mix(in srgb, #16A34A 14%, transparent); color: #16A34A; }
.dv-dash-negativo .dv-dash-cartao-valor { color: #DC2626; }
.dv-dash-negativo .dv-dash-cartao-icone { background: color-mix(in srgb, #DC2626 14%, transparent); color: #DC2626; }

/* ---- Gráficos ----
   Empilhados em 1 coluna só: são gráficos de linha do tempo (12 meses),
   ficam mais legíveis "widescreen" (largos e não muito altos). */
.dv-dash-graficos {
    display: grid;
    grid-template-columns: 1fr;
    gap: 16px;
}

.dv-dash-grafico-card {
    background: var(--dv-dash-surface);
    border: 1px solid var(--dv-dash-border);
    border-radius: 14px;
    padding: 20px;
    box-shadow: var(--dv-dash-sombra);
}

.dv-dash-grafico-card h3 {
    font-size: 15px;
    margin-bottom: 14px;
    color: var(--dv-dash-text);
}

.dv-dash-grafico-card .dv-dash-grafico-canvas-wrap {
    position: relative;
    width: 100%;
    height: 260px;
}

.dv-dash-grafico-card canvas {
    width: 100% !important;
    height: 100% !important;
}

/* ---- Vendedores: pódio + gráfico de colunas ----
   Duas colunas em telas largas (pódio ganha mais espaço), empilha em 1
   coluna em telas estreitas. */
.dv-dash-graficos-vendedores {
    display: grid;
    grid-template-columns: 1.3fr 1fr;
    gap: 16px;
}

.dv-dash-sem-dados {
    color: var(--dv-dash-muted);
    font-size: 13px;
    text-align: center;
    padding: 40px 0;
    margin: 0;
}

/* ---- Pódio ---- */
.dv-podio-card {
    display: flex;
    flex-direction: column;
}

.dv-podio-scroll {
    overflow-x: auto;
    overflow-y: hidden;
    padding-bottom: 2px;
}

.dv-podio-wrap {
    display: flex;
    align-items: flex-end;
    justify-content: center;
    gap: 10px;
    min-height: 250px;
    padding: 44px 6px 0;
}

.dv-podio-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 104px;
    flex: 0 0 auto;
}

/* Ordem visual: 5º | 3º | 1º | 2º | 4º — o melhor sempre no centro. */
.dv-podio-rank-1 { order: 3; }
.dv-podio-rank-2 { order: 4; }
.dv-podio-rank-3 { order: 2; }
.dv-podio-rank-4 { order: 5; }
.dv-podio-rank-5 { order: 1; }

.dv-podio-pessoa {
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative;
    z-index: 2;
}

.dv-podio-avatar-wrap {
    position: relative;
    margin-bottom: 10px;
}

.dv-podio-rank-1 .dv-podio-avatar-wrap::before {
    content: '🏆';
    position: absolute;
    top: -26px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 18px;
    line-height: 1;
}

.dv-podio-avatar {
    width: 72px;
    height: 72px;
    border-radius: 50%;
    overflow: hidden;
    border: 3px solid var(--dv-dash-surface);
    box-shadow: 0 3px 10px rgba(15, 23, 42, .18);
    background: linear-gradient(135deg, var(--dvt-primary, #1D4ED8), color-mix(in srgb, var(--dvt-primary, #1D4ED8) 55%, #0F172A));
}

.dv-podio-rank-1 .dv-podio-avatar { width: 92px; height: 92px; border-width: 4px; box-shadow: 0 6px 16px rgba(245, 158, 11, .35); }
.dv-podio-rank-2 .dv-podio-avatar,
.dv-podio-rank-3 .dv-podio-avatar { width: 78px; height: 78px; }

.dv-podio-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.dv-podio-avatar-fallback {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-weight: 800;
    font-size: 20px;
    font-family: var(--dvt-font-display, 'Manrope', sans-serif);
}

.dv-podio-medalha {
    position: absolute;
    bottom: -3px;
    right: -3px;
    width: 27px;
    height: 27px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 800;
    color: #fff;
    border: 2px solid var(--dv-dash-surface);
    box-shadow: 0 2px 6px rgba(15, 23, 42, .25);
}

.dv-podio-medalha-1 { background: linear-gradient(135deg, #FDE68A, #F59E0B); color: #7C4A03; }
.dv-podio-medalha-2 { background: linear-gradient(135deg, #F1F5F9, #94A3B8); color: #334155; }
.dv-podio-medalha-3 { background: linear-gradient(135deg, #E9B98A, #B5651D); color: #4A2A0A; }

.dv-podio-posicao {
    position: absolute;
    bottom: -3px;
    right: -3px;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    font-weight: 700;
    color: var(--dv-dash-muted);
    background: var(--dv-dash-bg);
    border: 2px solid var(--dv-dash-surface);
}

.dv-podio-nome {
    font-size: 12.5px;
    font-weight: 700;
    color: var(--dv-dash-text);
    max-width: 100px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    text-align: center;
}

.dv-podio-stats {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    margin-top: 5px;
}

.dv-podio-stat-vendas {
    font-size: 13px;
    font-weight: 800;
    color: var(--dvt-primary, #1D4ED8);
}

.dv-podio-stat-faturamento {
    font-size: 11px;
    color: var(--dv-dash-muted);
}

.dv-podio-pedestal {
    width: 100%;
    margin-top: 12px;
    border-radius: 10px 10px 0 0;
    display: flex;
    justify-content: center;
    padding-top: 8px;
    box-shadow: inset 0 2px 4px rgba(255, 255, 255, .25);
}

.dv-podio-pedestal-numero {
    font-family: var(--dvt-font-display, 'Manrope', sans-serif);
    font-size: 19px;
    font-weight: 800;
    color: rgba(255, 255, 255, .92);
    text-shadow: 0 1px 3px rgba(0, 0, 0, .25);
}

.dv-podio-rank-1 .dv-podio-pedestal { height: 138px; background: linear-gradient(180deg, #FDE68A, #F59E0B); }
.dv-podio-rank-2 .dv-podio-pedestal { height: 106px; background: linear-gradient(180deg, #F1F5F9, #94A3B8); }
.dv-podio-rank-3 .dv-podio-pedestal { height: 88px; background: linear-gradient(180deg, #E9B98A, #B5651D); }
.dv-podio-rank-4 .dv-podio-pedestal,
.dv-podio-rank-5 .dv-podio-pedestal { height: 66px; background: linear-gradient(180deg, var(--dv-dash-border), var(--dv-dash-muted)); }

body.dv-dark .dv-podio-rank-1 .dv-podio-pedestal { background: linear-gradient(180deg, #F5B301, #B45309); }
body.dv-dark .dv-podio-rank-2 .dv-podio-pedestal { background: linear-gradient(180deg, #94A3B8, #475569); }
body.dv-dark .dv-podio-rank-3 .dv-podio-pedestal { background: linear-gradient(180deg, #B5651D, #7C3F0F); }

/* ---- Acesso negado ---- */
.dv-dash-negado {
    max-width: 640px;
    margin: 60px auto;
    text-align: center;
    padding: 0 24px;
}

/* ---- Responsivo ---- */
@media (max-width: 900px) {
    .dv-dash-graficos-vendedores { grid-template-columns: 1fr; }
}

@media (max-width: 640px) {
    .dv-dash-wrap { padding: 20px 16px 48px; }
    .dv-dash-topo h1 { font-size: 24px; }
    .dv-dash-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
    .dv-dash-grafico-card .dv-dash-grafico-canvas-wrap { height: 200px; }
    .dv-podio-wrap { justify-content: flex-start; }
}
