/* ==========================================================================
   Proposta360 — Analytics e painel administrativo
   É a tela que sustenta o valor do produto: precisa apresentar o dado com
   hierarquia clara e transformar número em decisão de venda.
   ========================================================================== */

/* --- Cabeçalho de detalhe -------------------------------------------------- */
.detail-header {
    position: sticky;
    top: 0;
    z-index: var(--z-sticky);
    display: flex;
    align-items: center;
    gap: var(--space-4);
    min-height: var(--topbar-height);
    padding: var(--space-3) var(--space-6);
    padding-top: calc(var(--space-3) + var(--safe-top));
    background: var(--surface);
    border-bottom: 1px solid var(--border);
}

.detail-header__info { flex: 1; min-width: 0; }

.detail-header__info h1 {
    font-size: var(--text-lg);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.detail-header__info p {
    font-size: var(--text-sm);
    color: var(--text-muted);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.detail-content {
    padding: var(--space-6);
    padding-bottom: calc(var(--space-12) + var(--safe-bottom));
    max-width: var(--content-max);
    margin-inline: auto;
}

/* --- Score de interesse ---------------------------------------------------- */
.score-card {
    display: flex;
    align-items: center;
    gap: var(--space-8);
    padding: var(--space-8);
    margin-bottom: var(--space-6);
    border-radius: var(--radius-md);
    background: var(--surface);
    border: 1px solid var(--border);
    color: var(--text);
    position: relative;
}

/* Anel de progresso: dá contexto imediato ao número. */
.score-ring {
    position: relative;
    display: grid;
    place-items: center;
    width: 132px;
    height: 132px;
    flex-shrink: 0;
    border-radius: 50%;
    /* Anel de dado (não decoração): preenchido na proporção do score. */
    background: conic-gradient(var(--brand) calc(var(--score, 0) * 1%), var(--border) 0);
}

.score-ring::before {
    content: '';
    position: absolute;
    inset: 10px;
    border-radius: 50%;
    background: var(--surface);
}

.score-ring__value {
    position: relative;
    font-family: var(--font-mono);
    font-size: var(--text-3xl);
    font-weight: var(--weight-bold);
    line-height: 1;
}

.score-ring__max {
    position: relative;
    font-size: var(--text-2xs);
    font-family: var(--font-mono);
    letter-spacing: var(--tracking-label);
    text-transform: uppercase;
    opacity: 0.75;
}

.score-info h2 {
    font-family: var(--font-display);
    font-weight: var(--weight-regular);
    font-size: var(--text-2xl);
    color: var(--text);
    margin-bottom: var(--space-2);
}

.score-info > p {
    color: var(--text-muted);
    max-width: 52ch;
}

.score-info .score-note {
    margin-top: var(--space-3);
    font-size: var(--text-xs);
    color: var(--text-muted);
}

.score-badges {
    display: flex;
    gap: var(--space-2);
    flex-wrap: wrap;
    margin-top: var(--space-5);
}

.score-badge {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-2) var(--space-3);
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--bg-subtle);
    font-size: var(--text-xs);
    font-weight: var(--weight-medium);
}

/* --- Colunas --------------------------------------------------------------- */
.columns {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-5);
    margin-bottom: var(--space-6);
}

/* --- Tempo por página ------------------------------------------------------ */
.page-time {
    padding: var(--space-4) 0;
    border-bottom: 1px solid var(--border-subtle);
}

.page-time:last-child { border-bottom: none; }

.page-time__head {
    display: flex;
    justify-content: space-between;
    gap: var(--space-3);
    margin-bottom: var(--space-2);
    font-size: var(--text-sm);
}

.page-time__name { font-weight: var(--weight-medium); }
.page-time__value { font-family: var(--font-mono); color: var(--text-muted); }

/* --- Linha do tempo -------------------------------------------------------- */
.timeline {
    position: relative;
    padding-left: var(--space-6);
}

.timeline::before {
    content: '';
    position: absolute;
    left: 7px;
    top: 6px;
    bottom: 6px;
    width: 2px;
    background: var(--border);
}

.timeline-item {
    position: relative;
    padding-bottom: var(--space-5);
}

.timeline-item:last-child { padding-bottom: 0; }

.timeline-dot {
    position: absolute;
    left: calc(var(--space-6) * -1 + 2px);
    top: 4px;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--surface);
    border: 2px solid var(--border-strong);
}

.timeline-dot.copy { border-color: var(--accent); background: var(--accent); }
.timeline-dot.approve { border-color: var(--success); background: var(--success); }
.timeline-dot.reject { border-color: var(--danger); background: var(--danger); }
.timeline-dot.select { border-color: var(--info); }

.timeline-time {
    font-family: var(--font-mono);
    font-size: var(--text-2xs);
    color: var(--text-subtle);
    text-transform: uppercase;
    letter-spacing: var(--tracking-label);
}

.timeline-content {
    font-size: var(--text-sm);
    margin-top: 2px;
    word-break: break-word;
}

/* --- Insights -------------------------------------------------------------- */
.insights-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: var(--space-4);
}

.insight {
    display: flex;
    gap: var(--space-4);
    padding: var(--space-4);
    border-radius: var(--radius-md);
    background: var(--bg-subtle);
    border-left: 3px solid var(--border-strong);
}

.insight__icon {
    display: grid;
    place-items: center;
    width: 36px;
    height: 36px;
    flex-shrink: 0;
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--text-muted);
}

.insight h4 { font-size: var(--text-sm); margin-bottom: 2px; }

.insight p {
    font-size: var(--text-sm);
    color: var(--text-muted);
    line-height: var(--leading-snug);
}

.insight.success { border-left-color: var(--success); }
.insight.success .insight__icon { color: var(--success); }
.insight.warning { border-left-color: var(--warning); }
.insight.warning .insight__icon { color: var(--warning); }
.insight.highlight { border-left-color: var(--accent); }
.insight.highlight .insight__icon { color: var(--accent); }
.insight.action { border-left-color: var(--info); }
.insight.action .insight__icon { color: var(--info); }
.insight.info { border-left-color: var(--brand); }
.insight.info .insight__icon { color: var(--brand); }

/* --- Dispositivos ---------------------------------------------------------- */
.device-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: var(--space-4);
    text-align: center;
}

.device-item {
    padding: var(--space-4);
    border-radius: var(--radius-md);
    background: var(--bg-subtle);
}

.device-item .icon {
    color: var(--text-muted);
    margin-inline: auto;
    margin-bottom: var(--space-2);
}

.device-item__count {
    font-family: var(--font-mono);
    font-size: var(--text-xl);
    font-weight: var(--weight-bold);
}

.device-item__name { font-size: var(--text-xs); color: var(--text-muted); }

/* --- Comentários ----------------------------------------------------------- */
.comment-item {
    padding: var(--space-4);
    border-radius: var(--radius-md);
    background: var(--bg-subtle);
    margin-bottom: var(--space-3);
}

.comment-item:last-child { margin-bottom: 0; }

.comment-item__head {
    display: flex;
    justify-content: space-between;
    gap: var(--space-3);
    margin-bottom: var(--space-2);
    font-size: var(--text-sm);
}

.comment-item p {
    color: var(--text-muted);
    white-space: pre-wrap;
    word-break: break-word;
}

/* --- Bloqueio por plano ---------------------------------------------------- */
.upgrade-card {
    display: flex;
    align-items: center;
    gap: var(--space-5);
    padding: var(--space-6);
    margin-bottom: var(--space-6);
    border-radius: var(--radius-lg);
    background: var(--brand-soft);
    border: 1px dashed var(--brand);
}

.upgrade-card__body { flex: 1; }
.upgrade-card h3 { font-size: var(--text-md); margin-bottom: var(--space-1); }
.upgrade-card p { font-size: var(--text-sm); color: var(--text-muted); }

/* --- Ranking (admin) ------------------------------------------------------- */
.ranking-table th {
    padding: var(--space-3) var(--space-4);
    text-align: left;
    font-family: var(--font-mono);
    font-size: var(--text-2xs);
    text-transform: uppercase;
    letter-spacing: var(--tracking-label);
    color: var(--text-muted);
    font-weight: var(--weight-medium);
    border-bottom: 1px solid var(--border);
}

.ranking-table td {
    padding: var(--space-4);
    border-bottom: 1px solid var(--border-subtle);
    vertical-align: middle;
}

.ranking-table tr:last-child td { border-bottom: none; }

.rank-badge {
    display: grid;
    place-items: center;
    width: 30px;
    height: 30px;
    border-radius: var(--radius-sm);
    font-family: var(--font-mono);
    font-size: var(--text-sm);
    font-weight: var(--weight-bold);
    background: var(--bg-subtle);
    color: var(--text-muted);
}

/* Pódio identificado por cor E posição numérica. */
.rank-badge.gold { background: var(--warning-soft); color: var(--warning-soft-text); }
.rank-badge.silver { background: var(--bg-subtle); color: var(--text-muted); }
.rank-badge.bronze { background: var(--accent-soft); color: var(--accent-soft-text); }

.seller-name { font-weight: var(--weight-semibold); }
.seller-email { font-size: var(--text-xs); color: var(--text-muted); }

.table-scroll { overflow-x: auto; }

/* --- Gaveta de detalhe ----------------------------------------------------- */
.drawer {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    z-index: var(--z-modal);
    width: min(460px, 92vw);
    padding: var(--space-8) var(--space-6);
    padding-top: calc(var(--space-8) + var(--safe-top));
    background: var(--surface);
    border-left: 1px solid var(--border);
    box-shadow: var(--shadow-xl);
    overflow-y: auto;
    transform: translateX(100%);
    transition: transform var(--duration-base) var(--ease-out);
}

.drawer.is-open { transform: none; }

.drawer__close {
    position: absolute;
    top: calc(var(--safe-top) + var(--space-4));
    right: var(--space-4);
}

.drawer-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-3) 0;
    border-bottom: 1px solid var(--border-subtle);
}

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

@media (max-width: 640px) {
    .score-card {
        flex-direction: column;
        text-align: center;
        gap: var(--space-5);
        padding: var(--space-6);
    }

    .score-badges { justify-content: center; }
    .upgrade-card { flex-direction: column; text-align: center; }
    .detail-header { padding-inline: var(--space-4); }
    .detail-content { padding: var(--space-4); }
    .ranking-table { min-width: 640px; }
}

/* --- Direitos de dados (LGPD) na página de assinatura ---------------------- */
.privacy-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-4);
    padding: var(--space-4) 0;
    border-top: 1px solid var(--border);
}

.privacy-row__text {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

/* No celular o botão vai para baixo em vez de espremer o texto. */
@media (max-width: 560px) {
    .privacy-row {
        flex-direction: column;
        align-items: stretch;
    }

    .privacy-row .btn { width: 100%; }
}

/* --- Pedidos de reunião ---------------------------------------------------- */
.meeting-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.meeting-item {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    justify-content: space-between;
    gap: var(--space-3) var(--space-5);
    padding: var(--space-4) 0;
    border-bottom: 1px solid var(--border-subtle);
}

.meeting-item:first-child { padding-top: 0; }
.meeting-item:last-child { border-bottom: none; padding-bottom: 0; }

.meeting-item__main { flex: 1 1 260px; min-width: 0; }

.meeting-item__main p {
    margin-top: var(--space-1);
    font-size: var(--text-sm);
    color: var(--text-muted);
    overflow-wrap: anywhere;
}

.meeting-item__actions {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-2);
}

.meeting-state {
    display: inline-flex;
    align-items: center;
    gap: var(--space-1);
    margin-left: var(--space-2);
    padding: 1px var(--space-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: var(--text-xs);
    font-weight: var(--weight-semibold);
    vertical-align: middle;
}

.meeting-state.is-requested { color: var(--warning-soft-text); background: var(--warning-soft); border-color: var(--warning); }
.meeting-state.is-confirmed { color: var(--success-soft-text); background: var(--success-soft); border-color: var(--success); }
.meeting-state.is-declined { color: var(--text-muted); background: var(--bg-subtle); }

/* Aviso de proposta expirada no analytics. */
.expired-note {
    display: flex;
    align-items: flex-start;
    gap: var(--space-3);
    padding: var(--space-4);
    margin-bottom: var(--space-6);
    border: 1px solid var(--warning);
    border-radius: var(--radius-md);
    background: var(--warning-soft);
    color: var(--warning-soft-text);
    font-size: var(--text-sm);
}

.expired-note .icon { flex-shrink: 0; margin-top: 2px; }

.expired-note a { color: inherit; font-weight: var(--weight-semibold); text-decoration: underline; }

/* --- Visitas (eliminação de dados de um visitante) --------------------------- */
.visit-list { list-style: none; margin: 0; padding: 0; }
.visit-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-3);
    padding: var(--space-3) 0;
    border-bottom: 1px solid var(--border-subtle);
}
.visit-item:last-child { border-bottom: 0; }
.visit-item__who { display: flex; flex-direction: column; gap: 2px; min-width: 0; overflow-wrap: anywhere; }
@media (max-width: 560px) {
    .visit-item { flex-direction: column; align-items: stretch; }
}
