* { box-sizing: border-box; margin: 0; padding: 0; }
body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    color: #222;
    background: #f7f7f9;
    line-height: 1.4;
}
header {
    background: #1a1a2e;
    color: white;
    padding: 12px 20px;
    display: flex;
    align-items: center;
    gap: 20px;
}
header h1 { font-size: 18px; font-weight: 600; }
header h1 a { color: white; text-decoration: none; }
#breadcrumb { font-size: 14px; opacity: 0.8; }
#breadcrumb a { color: white; text-decoration: none; }
#breadcrumb a:hover { text-decoration: underline; }

main { padding: 20px; max-width: 1400px; margin: 0 auto; }
.loading { color: #888; padding: 40px; text-align: center; }
.error { color: #c0392b; padding: 20px; background: #fdecea; border-radius: 4px; }

/* === Home: cards de snapshots === */
.snapshots-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 16px;
}
.snapshot-card {
    background: white;
    border: 1px solid #e0e0e6;
    border-radius: 6px;
    padding: 16px;
    cursor: pointer;
    transition: transform 0.1s, box-shadow 0.1s;
}
.snapshot-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}
.snapshot-card h2 { font-size: 16px; margin-bottom: 8px; }
.snapshot-card .stats { font-size: 14px; color: #555; }
.snapshot-card .stats div { margin: 4px 0; }

/* === Snapshot: header com TL;DR === */
.snapshot-header {
    background: white;
    border: 1px solid #e0e0e6;
    border-radius: 6px;
    padding: 16px 20px;
    margin-bottom: 16px;
}
.snapshot-header h2 { margin-bottom: 8px; font-size: 18px; }
.snapshot-header .summary { color: #444; font-size: 14px; }
.snapshot-header .summary span { margin-right: 12px; }

/* === Snapshot: filtros === */
.filters {
    display: flex;
    gap: 12px;
    margin-bottom: 16px;
    align-items: center;
}
.filters select, .filters input {
    padding: 6px 10px;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-size: 14px;
}
.filters input { flex: 1; min-width: 200px; }
.filters .status { color: #888; font-size: 12px; }

/* === Snapshot: dois painéis === */
.split-view {
    display: grid;
    grid-template-columns: 280px 1fr;
    gap: 16px;
}
.panel {
    background: white;
    border: 1px solid #e0e0e6;
    border-radius: 6px;
    overflow: hidden;
}
.panel h3 {
    padding: 10px 16px;
    border-bottom: 1px solid #e0e0e6;
    font-size: 14px;
    color: #555;
    background: #fafafa;
}
.panel-list { max-height: 70vh; overflow-y: auto; }
.panel-item {
    padding: 10px 16px;
    border-bottom: 1px solid #f0f0f0;
    cursor: pointer;
}
.panel-item:hover { background: #f4f7ff; }
.panel-item.selected { background: #e8efff; border-left: 3px solid #4a6fff; padding-left: 13px; }
.panel-item .label { font-weight: 500; }
.panel-item .meta { font-size: 12px; color: #888; margin-top: 4px; }
.panel-item .badge {
    display: inline-block;
    font-size: 11px;
    padding: 2px 6px;
    border-radius: 3px;
    background: #eef;
    color: #336;
    margin-right: 6px;
}
.panel-item .snippet {
    font-size: 12px;
    color: #666;
    margin-top: 4px;
    font-style: italic;
}

/* === Conversation view === */
.conv-view {
    display: grid;
    grid-template-columns: 1fr 360px;
    gap: 16px;
}
.transcript {
    background: white;
    border: 1px solid #e0e0e6;
    border-radius: 6px;
    padding: 20px;
    max-height: calc(100vh - 180px);
    overflow-y: auto;
}
.transcript h1 { font-size: 16px; margin-bottom: 8px; }
.transcript p { margin: 4px 0; }
.transcript ul { margin: 8px 0 16px 24px; }
.transcript strong { color: #1a1a2e; }

/* === Chat (bolhas estilo WhatsApp) === */
.chat {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 12px;
    background: #ece5dd;  /* fundo bege clássico WhatsApp */
    border-radius: 6px;
    margin-top: 12px;
}
.bubble {
    max-width: 78%;
    padding: 8px 10px 6px 10px;
    border-radius: 8px;
    box-shadow: 0 1px 0.5px rgba(0, 0, 0, 0.08);
    font-size: 14px;
    line-height: 1.4;
    word-wrap: break-word;
}
.bubble.client {
    align-self: flex-start;
    background: #ffffff;
    color: #1a1a2e;
}
.bubble.agent {
    align-self: flex-end;
    background: #dcf8c6;  /* verde WhatsApp do remetente */
    color: #1a1a2e;
}
.bubble-header {
    font-size: 11px;
    color: #777;
    margin-bottom: 3px;
}
.bubble-header .who {
    font-weight: 600;
    color: #555;
}
.bubble.agent .bubble-header .who { color: #2c7a3f; }
.bubble-text { white-space: pre-wrap; }
.bubble audio {
    display: block;
    height: 32px;
    width: 100%;
    margin-top: 6px;
}
.analysis {
    background: white;
    border: 1px solid #e0e0e6;
    border-radius: 6px;
    padding: 16px;
}
.analysis h4 { font-size: 12px; color: #888; text-transform: uppercase; margin-top: 12px; margin-bottom: 4px; }
.analysis h4:first-child { margin-top: 0; }
.analysis .value { font-size: 14px; }
.analysis .motivo {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 4px;
    background: #fff3cd;
    color: #856404;
    font-weight: 600;
}
.analysis .trecho {
    background: #f4f4f8;
    padding: 8px;
    border-left: 3px solid #4a6fff;
    font-size: 13px;
    white-space: pre-wrap;
}
.back-link {
    display: inline-block;
    margin-bottom: 12px;
    color: #4a6fff;
    text-decoration: none;
}
.back-link:hover { text-decoration: underline; }

/* === Toggle / Filtros (Perdidas / Ganhas / Todas) === */
.mode-toggle {
    display: inline-flex;
    background: white;
    border: 1px solid #e0e0e6;
    border-radius: 6px;
    overflow: hidden;
    margin-bottom: 16px;
}
.mode-btn {
    border: none;
    background: transparent;
    padding: 8px 16px;
    font-size: 14px;
    font-weight: 500;
    color: #555;
    cursor: pointer;
    border-right: 1px solid #e0e0e6;
}
.mode-btn:last-child { border-right: none; }
.mode-btn:hover:not(.disabled):not(.active) { background: #f4f7ff; }
.mode-btn.active {
    background: #4a6fff;
    color: white;
    cursor: default;
}
.mode-btn.disabled {
    color: #bbb;
    cursor: not-allowed;
}

/* === Stats coloridas === */
.stat-won { color: #1e8449; font-weight: 600; margin-right: 6px; }
.stat-lost { color: #c0392b; font-weight: 600; margin-right: 6px; }

.snapshot-header .summary.actions { margin-top: 8px; }
.snapshot-header .summary.actions a {
    display: inline-block;
    margin-right: 12px;
    color: #4a6fff;
    text-decoration: none;
    font-size: 13px;
}
.snapshot-header .summary.actions a:hover { text-decoration: underline; }

/* === Sort bar === */
.sort-bar {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 12px;
    color: #555;
    font-size: 13px;
}
.sort-btn {
    border: 1px solid #e0e0e6;
    background: white;
    padding: 4px 10px;
    font-size: 12px;
    color: #555;
    cursor: pointer;
    border-radius: 4px;
}
.sort-btn:hover:not(.active) { background: #f4f7ff; }
.sort-btn.active {
    background: #4a6fff;
    color: white;
    border-color: #4a6fff;
}

/* === Grid de agentes na tela de snapshot === */
.agents-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 12px;
}
.agent-card {
    background: white;
    border: 1px solid #e0e0e6;
    border-radius: 6px;
    padding: 14px;
    cursor: pointer;
    transition: transform 0.1s, box-shadow 0.1s;
}
.agent-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}
.agent-card h3 {
    font-size: 14px;
    margin-bottom: 8px;
    color: #1a1a2e;
}
.agent-stats {
    font-size: 13px;
    color: #555;
    margin-bottom: 8px;
}
.agent-stats .sep { color: #ccc; margin: 0 4px; }
.agent-bar {
    height: 6px;
    background: #fadbd8;  /* perdas (vermelho claro) */
    border-radius: 3px;
    overflow: hidden;
}
.agent-bar-fill.won {
    height: 100%;
    background: #58d68d;  /* ganhas (verde) */
}

/* === Conv list dentro da tela do agente === */
.conv-list {
    background: white;
    border: 1px solid #e0e0e6;
    border-radius: 6px;
    overflow: hidden;
    margin-top: 12px;
}
.conv-list .panel-item { padding: 12px 16px; border-bottom: 1px solid #f0f0f0; cursor: pointer; }
.conv-list .panel-item:hover { background: #f4f7ff; }
.conv-list .panel-item:last-child { border-bottom: none; }
.conv-list .panel-item.won { border-left: 3px solid #1e8449; padding-left: 13px; }
.conv-list .panel-item.lost { border-left: 3px solid #c0392b; padding-left: 13px; }

.badge.won {
    background: #d5f5e3;
    color: #1e8449;
    font-weight: 600;
}
.badge.lost {
    background: #fadbd8;
    color: #c0392b;
    font-weight: 600;
}

/* === Modal do Glossário === */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}
.modal {
    background: white;
    border-radius: 8px;
    max-width: 900px;
    width: 100%;
    max-height: 85vh;
    overflow-y: auto;
    padding: 24px 28px;
    position: relative;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
}
.modal h2 { font-size: 18px; margin-bottom: 8px; color: #1a1a2e; }
.modal h3 { font-size: 14px; color: #555; margin: 18px 0 8px 0; text-transform: uppercase; letter-spacing: 0.5px; }
.modal .muted { color: #888; font-size: 13px; margin-bottom: 12px; }
.modal-close {
    position: absolute;
    top: 12px; right: 16px;
    background: none;
    border: none;
    font-size: 28px;
    cursor: pointer;
    color: #888;
    line-height: 1;
}
.modal-close:hover { color: #222; }

.glossary-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}
.glossary-table th, .glossary-table td {
    text-align: left;
    vertical-align: top;
    padding: 8px 10px;
    border-bottom: 1px solid #eee;
}
.glossary-table th {
    background: #f7f7f9;
    font-size: 12px;
    color: #555;
    font-weight: 600;
}
.glossary-table code {
    background: #f4f4f8;
    padding: 1px 5px;
    border-radius: 3px;
    font-size: 12px;
    color: #336;
}
.glossary-table .muted {
    color: #888;
    font-size: 11px;
    margin-top: 2px;
}
.glossary-table .example {
    color: #555;
    font-style: italic;
    font-size: 12px;
    max-width: 280px;
}
