/* ============================================================
   Mileto CRM - Estilos das telas (Dashboard e placeholders)
   ============================================================ */

/* ---------- Filtros ---------- */
.filters {
    display: flex;
    align-items: flex-end;
    gap: var(--sp-3);
    flex-wrap: wrap;
}

/* ---------- KPI grid ---------- */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: var(--sp-4);
    margin-bottom: var(--sp-5);
}

.kpi {
    padding: var(--sp-4) var(--sp-5);
    display: flex;
    flex-direction: column;
    gap: var(--sp-2);
}
.kpi__head { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3); }
.kpi__label { color: var(--text-muted); font-size: 13px; font-weight: 600; }
.kpi__icon {
    width: 38px; height: 38px;
    display: grid; place-items: center;
    border-radius: var(--radius-sm);
}
.kpi__icon svg { width: 20px; height: 20px; }
.kpi__value { font-size: 28px; font-weight: 800; letter-spacing: -0.5px; line-height: 1.1; }
.kpi__hint { color: var(--text-soft); font-size: 12px; }

.kpi__icon--accent { background: var(--accent-50); color: var(--accent-600); }
.kpi__icon--success { background: var(--success-50); color: var(--success-500); }
.kpi__icon--warning { background: var(--warning-50); color: var(--warning-500); }
.kpi__icon--danger { background: var(--danger-50); color: var(--danger-500); }
.kpi__icon--info { background: var(--info-50); color: var(--info-500); }

/* ---------- Secoes ---------- */
.section-title {
    font-size: 13px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    color: var(--text-soft);
    margin: var(--sp-5) 0 var(--sp-3);
}

/* ---------- Paineis de distribuicao ---------- */
.panel-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: var(--sp-4);
}
.panel { padding: var(--sp-5); }
.panel__title { font-size: 15px; font-weight: 700; margin-bottom: var(--sp-4); }

.bar-row { display: grid; grid-template-columns: 1fr auto; gap: 4px var(--sp-3); align-items: center; margin-bottom: var(--sp-3); }
.bar-row:last-child { margin-bottom: 0; }
.bar-row__label { font-size: 13px; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-row__value { font-size: 13px; font-weight: 700; color: var(--text-muted); }
.bar-track { grid-column: 1 / -1; height: 8px; background: var(--surface-2); border-radius: 999px; overflow: hidden; }
.bar-fill { height: 100%; border-radius: 999px; background: linear-gradient(90deg, var(--accent-400), var(--accent-600)); min-width: 4px; }

/* ---------- Conversao destaque ---------- */
.kpi--highlight {
    background: linear-gradient(135deg, var(--brand-800), var(--brand-600));
    color: #fff;
    border-color: transparent;
}
.kpi--highlight .kpi__label { color: #c7d6ee; }
.kpi--highlight .kpi__hint { color: #aebfdc; }
.kpi--highlight .kpi__icon { background: rgba(255, 255, 255, 0.16); color: #fff; }

/* ---------- Skeleton helpers ---------- */
.sk-kpi { height: 116px; }
.sk-panel { height: 240px; }

/* ---------- Placeholder ---------- */
.placeholder { max-width: 520px; margin: var(--sp-7) auto; }
.placeholder .state__icon { width: 64px; height: 64px; }
.placeholder ul { text-align: left; color: var(--text-muted); margin: var(--sp-3) 0 0; padding-left: var(--sp-5); }
.placeholder li { margin-bottom: 4px; }

/* ============================================================
   Leads - toolbar, tabela, detalhe, timeline, modal e form
   ============================================================ */

/* Toolbar de filtros */
.toolbar {
    display: flex;
    align-items: center;
    gap: var(--sp-3);
    padding: var(--sp-3) var(--sp-4);
    margin-bottom: var(--sp-4);
    flex-wrap: wrap;
}
.toolbar__search-wrap {
    display: flex;
    align-items: center;
    gap: var(--sp-2);
    flex: 1;
    min-width: 220px;
    padding: 0 12px;
    height: 38px;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--text-soft);
}
.toolbar__search-wrap svg { width: 16px; height: 16px; flex-shrink: 0; }
.toolbar__search { border: none; outline: none; flex: 1; height: 100%; padding: 0; font-size: 13px; background: transparent; }

/* Tabela */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th {
    text-align: left;
    padding: 12px var(--sp-4);
    color: var(--text-soft);
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}
.table td { padding: 12px var(--sp-4); border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: none; }
.row-click { cursor: pointer; transition: background 0.12s; }
.row-click:hover { background: var(--accent-50); }
.cell-strong { font-weight: 600; color: var(--text); }
.cell-actions { text-align: right; white-space: nowrap; }

.pill { display: inline-flex; align-items: center; gap: 6px; color: var(--text-muted); }
.pill svg { width: 14px; height: 14px; color: var(--text-soft); }

.btn--icon { padding: 7px; border-color: transparent; }
.btn--icon:hover { background: var(--surface-2); border-color: var(--border); }
.btn--icon svg { width: 16px; height: 16px; }

/* Detalhe */
.detail-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--sp-4);
    padding: var(--sp-5);
    margin-bottom: var(--sp-4);
    flex-wrap: wrap;
}
.detail-header__main { display: flex; align-items: center; gap: var(--sp-4); }
.detail-header__name { font-size: 20px; font-weight: 800; }
.detail-header__badges { display: flex; gap: var(--sp-2); margin-top: 6px; flex-wrap: wrap; }
.detail-header__actions { display: flex; gap: var(--sp-2); flex-wrap: wrap; }
.avatar--lg { width: 56px; height: 56px; font-size: 18px; }

.detail-grid { display: grid; grid-template-columns: minmax(280px, 360px) 1fr; gap: var(--sp-4); align-items: start; }
@media (max-width: 820px) { .detail-grid { grid-template-columns: 1fr; } }

.definition { display: grid; grid-template-columns: 130px 1fr; gap: 10px var(--sp-3); margin: 0; }
.definition dt { color: var(--text-soft); font-size: 12px; font-weight: 600; }
.definition dd { margin: 0; color: var(--text); word-break: break-word; }

/* Timeline */
.timeline { list-style: none; margin: 0; padding: 0; position: relative; }
.timeline::before { content: ""; position: absolute; left: 6px; top: 4px; bottom: 4px; width: 2px; background: var(--border); }
.timeline__item { position: relative; padding: 0 0 var(--sp-4) var(--sp-5); }
.timeline__item:last-child { padding-bottom: 0; }
.timeline__dot { position: absolute; left: 0; top: 4px; width: 14px; height: 14px; border-radius: 50%; background: var(--accent-500); border: 3px solid var(--surface); box-shadow: 0 0 0 1px var(--accent-100); }
.timeline__head { display: flex; align-items: baseline; justify-content: space-between; gap: var(--sp-3); flex-wrap: wrap; }
.timeline__time { display: inline-flex; align-items: center; gap: 4px; color: var(--text-soft); font-size: 12px; }
.timeline__time svg { width: 13px; height: 13px; }
.timeline__meta { display: flex; gap: 6px; margin: 6px 0; flex-wrap: wrap; }
.timeline__text { color: var(--text-muted); margin: 0; }

/* Modal */
.modal-overlay {
    position: fixed; inset: 0;
    background: rgba(11, 31, 58, 0.45);
    display: grid; place-items: center;
    padding: var(--sp-4);
    z-index: 200;
    animation: fade-in 0.15s ease;
}
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
.modal {
    background: var(--surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 560px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: toast-in 0.18s ease;
}
.modal__header { display: flex; align-items: center; justify-content: space-between; padding: var(--sp-4) var(--sp-5); border-bottom: 1px solid var(--border); }
.modal__title { font-size: 17px; font-weight: 700; }
.modal__close { padding: 6px; }
.modal__close svg { width: 18px; height: 18px; }
.modal__body { padding: var(--sp-5); overflow-y: auto; }

/* Formulario */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: var(--sp-4); }
.field--wide { grid-column: 1 / -1; }
@media (max-width: 560px) { .form-grid { grid-template-columns: 1fr; } }
.lead-form .field__label { margin-bottom: 2px; }
.form-error { color: var(--danger-500); background: var(--danger-50); border-radius: var(--radius-sm); padding: 10px 12px; margin: var(--sp-4) 0 0; font-size: 13px; font-weight: 600; }
.form-footer { display: flex; justify-content: flex-end; gap: var(--sp-2); margin-top: var(--sp-5); }

/* ============================================================
   Pipeline - quadro kanban
   ============================================================ */

.kanban {
    display: flex;
    gap: var(--sp-4);
    align-items: flex-start;
    overflow-x: auto;
    padding-bottom: var(--sp-3);
    min-height: 60vh;
}

.kanban-col {
    flex: 0 0 300px;
    width: 300px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    display: flex;
    flex-direction: column;
    max-height: calc(100vh - var(--topbar-h) - 80px);
}

.kanban-col__head {
    display: flex;
    align-items: center;
    gap: var(--sp-2);
    padding: var(--sp-3) var(--sp-4);
    border-top: 3px solid var(--accent-500);
    border-radius: var(--radius) var(--radius) 0 0;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
}
.kanban-col__name { font-weight: 700; font-size: 13px; }
.kanban-col__count {
    display: inline-grid; place-items: center;
    min-width: 22px; height: 22px; padding: 0 6px;
    background: var(--accent-50); color: var(--accent-600);
    border-radius: 999px; font-size: 12px; font-weight: 700;
}
.kanban-col__total { margin-left: auto; font-size: 12px; font-weight: 700; color: var(--success-500); }

.kanban-col__body {
    padding: var(--sp-3);
    display: flex;
    flex-direction: column;
    gap: var(--sp-3);
    overflow-y: auto;
    flex: 1;
    min-height: 80px;
    transition: background 0.15s;
}
.kanban-col__body.is-drop { background: var(--accent-50); outline: 2px dashed var(--accent-400); outline-offset: -6px; }

.kanban-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-sm);
    padding: var(--sp-3) var(--sp-4);
    cursor: grab;
    position: relative;
}
.kanban-card:hover { box-shadow: var(--shadow); border-color: var(--border-strong); }
.kanban-card.is-dragging { opacity: 0.5; }
.kanban-card__title { font-weight: 600; margin-bottom: 6px; }
.kanban-card__valor { color: var(--success-500); font-weight: 700; font-size: 13px; margin-bottom: 6px; }
.kanban-card__meta { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 6px; }
.tag { font-size: 11px; font-weight: 600; color: var(--text-muted); background: var(--surface-2); border: 1px solid var(--border); border-radius: 999px; padding: 2px 8px; }
.kanban-card__acao { display: flex; align-items: center; gap: 6px; color: var(--text-soft); font-size: 12px; }
.kanban-card__acao svg { width: 13px; height: 13px; flex-shrink: 0; }
.kanban-card__acao span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.kanban-card__actions { display: none; gap: 4px; position: absolute; top: 8px; right: 8px; }
.kanban-card:hover .kanban-card__actions { display: flex; }
.kanban-card__actions .btn--icon { padding: 5px; background: var(--surface); border: 1px solid var(--border); }
.kanban-card__actions .btn--icon:hover { background: var(--surface-2); }
.kanban-card__actions svg { width: 14px; height: 14px; }

/* ============================================================
   Agenda - lista por dia
   ============================================================ */
.agenda-list { display: flex; flex-direction: column; gap: var(--sp-3); margin-bottom: var(--sp-4); }
.agenda-item { display: grid; grid-template-columns: 72px 1fr auto; gap: var(--sp-4); align-items: center; padding: var(--sp-3) var(--sp-4); }
.agenda-item__time { display: flex; flex-direction: column; align-items: flex-start; border-right: 1px solid var(--border); padding-right: var(--sp-3); }
.agenda-item__time strong { font-size: 16px; }
.agenda-item__time span { color: var(--text-soft); font-size: 12px; }
.agenda-item__title { font-weight: 600; margin-bottom: 6px; }
.agenda-item__actions { display: flex; align-items: center; gap: var(--sp-2); }

.select--sm { height: 32px; font-size: 12px; padding: 0 8px; }
.status-warning { border-color: var(--warning-500); color: var(--warning-500); }
.status-info { border-color: var(--info-500); color: var(--info-500); }
.status-success { border-color: var(--success-500); color: var(--success-500); }
.status-danger { border-color: var(--danger-500); color: var(--danger-500); }
.status-muted { color: var(--text-muted); }

@media (max-width: 640px) {
    .agenda-item { grid-template-columns: 1fr; }
    .agenda-item__time { flex-direction: row; gap: 8px; border-right: none; border-bottom: 1px solid var(--border); padding: 0 0 6px; }
    .agenda-item__actions { justify-content: flex-start; flex-wrap: wrap; }
}

/* Tarefas - prazo atrasado */
.is-overdue { color: var(--danger-500); font-weight: 600; }

/* Truncamento de celula */
.cell-truncate { display: block; max-width: 320px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ============================================================
   Configuracoes - abas
   ============================================================ */
.tabs { display: flex; gap: var(--sp-1); border-bottom: 1px solid var(--border); margin-bottom: var(--sp-4); }
.tab {
    border: none; background: transparent; cursor: pointer;
    padding: 10px var(--sp-4); font-size: 13px; font-weight: 600; color: var(--text-muted);
    border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.tab:hover { color: var(--text); }
.tab.is-active { color: var(--accent-600); border-bottom-color: var(--accent-600); }

.config-bar { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3); margin-bottom: var(--sp-4); flex-wrap: wrap; }
.config-note { margin-bottom: var(--sp-4); }
.swatch { display: inline-block; width: 12px; height: 12px; border-radius: 3px; margin-right: 8px; vertical-align: middle; border: 1px solid rgba(0,0,0,0.1); }

/* ============================================================
   Login (tela cheia) e botao sair
   ============================================================ */
.login {
    position: fixed; inset: 0; z-index: 300;
    display: grid; place-items: center; padding: var(--sp-5);
    background: linear-gradient(135deg, var(--brand-900), var(--brand-700));
}
.login__card {
    background: var(--surface); width: 100%; max-width: 384px;
    border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); padding: var(--sp-6);
}
.login__brand { display: flex; align-items: center; gap: var(--sp-3); justify-content: center; }
.login__logo {
    display: grid; place-items: center; width: 44px; height: 44px; border-radius: var(--radius);
    background: linear-gradient(135deg, var(--accent-500), var(--accent-700)); color: #fff;
}
.login__title { font-size: 20px; font-weight: 500; }
.login__title strong { font-weight: 800; }
.login__subtitle { text-align: center; color: var(--text-muted); margin: var(--sp-2) 0 var(--sp-5); }
.login__form { display: flex; flex-direction: column; gap: var(--sp-4); }
.login__submit { width: 100%; justify-content: center; height: 42px; margin-top: var(--sp-1); }

.sidebar__logout { width: 100%; justify-content: center; color: #aebdd4; margin-top: var(--sp-3); }
.sidebar__logout:hover { background: rgba(255, 255, 255, 0.06); color: #fff; }
.sidebar__logout svg { width: 16px; height: 16px; }

/* ============================================================
   Perfis - grade de permissoes
   ============================================================ */
.perm-grid { display: flex; flex-direction: column; gap: 2px; border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; }
.perm-row { display: flex; align-items: center; gap: var(--sp-4); padding: 8px var(--sp-4); }
.perm-row:nth-child(odd) { background: var(--surface-2); }
.perm-modulo { flex: 1; font-weight: 600; font-size: 13px; }
.perm-check { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--text-muted); cursor: pointer; }
.perm-check input { width: 15px; height: 15px; }
