/* TratativasIA — Dashboard Styles */
:root {
  --bg: #f0f2f5;
  --card: #fff;
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --danger: #dc2626;
  --warning: #f59e0b;
  --success: #16a34a;
  --text: #1e293b;
  --text-muted: #64748b;
  --border: #e2e8f0;
  --radius: 8px;
  --shadow: 0 1px 3px rgba(0,0,0,.08);
}

* { margin: 0; padding: 0; box-sizing: border-box; }
body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; background: var(--bg); color: var(--text); font-size: 14px; }

/* Navbar */
.navbar { display: flex; align-items: center; justify-content: space-between; background: #0f172a; color: #fff; padding: 0 24px; height: 56px; position: sticky; top: 0; z-index: 100; }
.nav-brand { display: flex; align-items: center; gap: 8px; }
.brand-icon { font-size: 24px; }
.brand-icon.large { font-size: 48px; }
.brand-text { font-size: 18px; font-weight: 700; }
.nav-links { display: flex; gap: 4px; }
.nav-link { color: #94a3b8; text-decoration: none; padding: 8px 16px; border-radius: var(--radius); transition: all .2s; }
.nav-link:hover, .nav-link.active { color: #fff; background: rgba(255,255,255,.1); }
.nav-link.logout { color: #f87171; }
.nav-user { display: flex; align-items: center; gap: 8px; }
.user-name { color: #cbd5e1; font-size: 13px; }

/* Content */
.content { max-width: 1400px; margin: 0 auto; padding: 24px; }
.page-header { display: flex; align-items: center; gap: 16px; margin-bottom: 24px; }
.page-header h2 { font-size: 22px; font-weight: 700; }

/* KPI Cards */
.kpi-row { display: grid; grid-template-columns: repeat(5, 1fr); gap: 16px; margin-bottom: 24px; }
.kpi-card { background: var(--card); border-radius: var(--radius); padding: 20px; text-align: center; box-shadow: var(--shadow); border-top: 3px solid var(--primary); }
.kpi-card.kpi-warning { border-top-color: var(--warning); }
.kpi-card.kpi-danger { border-top-color: var(--danger); }
.kpi-card.kpi-alert { border-top-color: #dc2626; }
.kpi-card.kpi-success { border-top-color: var(--success); }
.kpi-value { font-size: 32px; font-weight: 800; color: var(--text); }
.kpi-label { font-size: 12px; color: var(--text-muted); margin-top: 4px; text-transform: uppercase; letter-spacing: .5px; }

/* Cards */
.card, .section { background: var(--card); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); margin-bottom: 20px; }
.section h3 { font-size: 16px; font-weight: 700; margin-bottom: 16px; }

/* Charts */
.charts-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin-bottom: 24px; }
.chart-card { background: var(--card); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); }
.chart-card.wide { grid-column: span 3; }
.chart-card h4 { font-size: 14px; color: var(--text-muted); margin-bottom: 12px; }

/* Tables */
.table-container { overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.data-table th { background: #f8fafc; padding: 10px 12px; text-align: left; font-weight: 600; color: var(--text-muted); border-bottom: 2px solid var(--border); white-space: nowrap; }
.data-table td { padding: 10px 12px; border-bottom: 1px solid var(--border); }
.data-table tr:hover { background: #f8fafc; }
.data-table .mono { font-family: monospace; font-size: 12px; }
.data-table .num { text-align: right; font-variant-numeric: tabular-nums; }
.data-table .small { font-size: 12px; color: var(--text-muted); }
.data-table a { color: var(--primary); text-decoration: none; }
.data-table a:hover { text-decoration: underline; }
.text-muted { color: var(--text-muted); }
.sortable { cursor: pointer; }
.sortable:hover { color: var(--primary); }
.handled-row { opacity: .5; }

/* Badges */
.badge { display: inline-block; padding: 2px 8px; border-radius: 12px; font-size: 11px; font-weight: 600; white-space: nowrap; }
.badge-plat-ml { background: #FFE600; color: #333; }
.badge-plat-amazon { background: #FF9900; color: #fff; }
.badge-plat-shopee { background: #EE4D2D; color: #fff; }
.badge-plat-shein { background: #222; color: #fff; }
.badge-status-aberta { background: #dbeafe; color: #1e40af; }
.badge-status-em_andamento { background: #fef3c7; color: #92400e; }
.badge-status-respondida { background: #ede9fe; color: #5b21b6; }
.badge-status-escalada { background: #fee2e2; color: #991b1b; }
.badge-status-resolvida { background: #dcfce7; color: #166534; }
.badge-status-encerrada { background: #f1f5f9; color: #475569; }
.badge-sev-critica { background: #dc2626; color: #fff; }
.badge-sev-alta { background: #ea580c; color: #fff; }
.badge-sev-media { background: #eab308; color: #422006; }
.badge-sev-baixa { background: #22c55e; color: #fff; }
.badge-pend-empresa { background: #fee2e2; color: #991b1b; }
.badge-pend-cliente { background: #dbeafe; color: #1e40af; }
.badge-pend-plataforma { background: #ede9fe; color: #5b21b6; }
.badge-admin { background: #7c3aed; color: #fff; }
.badge-supervisor { background: #2563eb; color: #fff; }
.badge-operador { background: #64748b; color: #fff; }
.badge-handled { background: #f1f5f9; color: #475569; }

/* Deadline */
.deadline { font-size: 12px; font-weight: 600; }
.deadline.expired { color: #dc2626; }
.deadline.critical { color: #ea580c; }
.deadline.warning { color: #d97706; }
.deadline.ok { color: #16a34a; }
.deadline.neutral { color: #94a3b8; }

/* Buttons */
.btn { display: inline-block; padding: 8px 16px; border-radius: var(--radius); border: 1px solid var(--border); background: #fff; color: var(--text); font-size: 13px; cursor: pointer; text-decoration: none; transition: all .2s; }
.btn:hover { background: #f8fafc; }
.btn-primary { background: var(--primary); color: #fff; border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-dark); }
.btn-danger { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn-success { background: var(--success); color: #fff; border-color: var(--success); }
.btn-sm { padding: 4px 10px; font-size: 12px; }
.btn-full { width: 100%; }

/* Forms */
input, select, textarea { padding: 8px 12px; border: 1px solid var(--border); border-radius: var(--radius); font-size: 13px; font-family: inherit; background: #fff; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37,99,235,.1); }
textarea { width: 100%; resize: vertical; }

/* Filters */
.filters-row { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 20px; align-items: center; }
.filters-row select, .filters-row input[type="text"] { min-width: 140px; }
.checkbox-label { display: flex; align-items: center; gap: 4px; font-size: 13px; color: var(--text-muted); }

/* Form rows */
.form-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: end; }

/* Detail grid */
.detail-grid { display: grid; grid-template-columns: 2fr 1fr; gap: 20px; margin-bottom: 20px; }
.info-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.info-item { display: flex; flex-direction: column; gap: 2px; }
.info-item.full { grid-column: span 2; }
.info-label { font-size: 11px; color: var(--text-muted); text-transform: uppercase; letter-spacing: .5px; }

/* Actions */
.action-group { margin-bottom: 16px; padding-bottom: 16px; border-bottom: 1px solid var(--border); }
.action-group:last-child { border-bottom: none; margin-bottom: 0; }
.action-group h4 { font-size: 13px; font-weight: 600; margin-bottom: 8px; }
.action-group select, .action-group input, .action-group textarea { width: 100%; margin-bottom: 8px; }
.action-group .btn { width: 100%; }

/* Timeline */
.timeline { position: relative; padding-left: 36px; }
.timeline::before { content: ''; position: absolute; left: 16px; top: 0; bottom: 0; width: 2px; background: var(--border); }
.timeline-item { position: relative; margin-bottom: 16px; }
.tl-icon { position: absolute; left: -36px; width: 28px; height: 28px; display: flex; align-items: center; justify-content: center; background: var(--card); border: 2px solid var(--border); border-radius: 50%; font-size: 14px; z-index: 1; }
.tl-content { background: #f8fafc; border-radius: var(--radius); padding: 12px; }
.tl-header { display: flex; gap: 8px; align-items: center; margin-bottom: 4px; }
.tl-type { font-weight: 600; font-size: 12px; text-transform: uppercase; color: var(--primary); }
.tl-actor { font-size: 12px; color: var(--text-muted); }
.tl-time { font-size: 11px; color: var(--text-muted); margin-left: auto; }
.tl-desc { font-size: 13px; color: var(--text); }

/* Pagination */
.pagination { display: flex; gap: 4px; justify-content: center; margin-top: 16px; }
.table-footer { text-align: center; color: var(--text-muted); font-size: 12px; margin-top: 8px; }

/* Period selector */
.period-selector { display: flex; gap: 4px; margin-left: auto; }

/* Flash messages */
.flash-messages { margin-bottom: 16px; }
.flash { padding: 12px 16px; border-radius: var(--radius); font-size: 13px; margin-bottom: 8px; }
.flash-error { background: #fee2e2; color: #991b1b; }
.flash-warning { background: #fef3c7; color: #92400e; }
.flash-success { background: #dcfce7; color: #166534; }

/* Login */
.login-body { display: flex; align-items: center; justify-content: center; min-height: 100vh; background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%); }
.login-container { background: var(--card); border-radius: 12px; padding: 40px; width: 100%; max-width: 400px; box-shadow: 0 20px 60px rgba(0,0,0,.3); }
.login-header { text-align: center; margin-bottom: 32px; }
.login-header h1 { font-size: 24px; margin-top: 8px; }
.login-header p { color: var(--text-muted); font-size: 14px; }
.login-form .form-group { margin-bottom: 16px; }
.login-form label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 4px; color: var(--text-muted); }
.login-form input { width: 100%; padding: 10px 14px; font-size: 14px; }
.login-form .btn { padding: 12px; font-size: 15px; margin-top: 8px; }

/* Chat — Timeline (mesma estrutura do timeline de eventos) */
.chat-timeline { position: relative; padding-left: 36px; }
.chat-timeline::before { content: ''; position: absolute; left: 16px; top: 0; bottom: 0; width: 2px; background: var(--border); }
.chat-tl-item { position: relative; margin-bottom: 16px; }
.chat-tl-icon { position: absolute; left: -36px; width: 28px; height: 28px; display: flex; align-items: center; justify-content: center; background: var(--card); border: 2px solid var(--border); border-radius: 50%; font-size: 14px; z-index: 1; }
.chat-tl-icon.icon-buyer { border-color: #93c5fd; }
.chat-tl-icon.icon-seller { border-color: #6ee7b7; }
.chat-tl-icon.icon-mediator { border-color: #c4b5fd; }
.chat-tl-icon.icon-system { border-color: #e2e8f0; }
.chat-tl-content { background: #f8fafc; border-radius: var(--radius); padding: 12px; }
.chat-tl-content.bg-buyer { background: #eff6ff; }
.chat-tl-content.bg-seller { background: #ecfdf5; }
.chat-tl-content.bg-mediator { background: #f8fafc; }
.chat-tl-content.bg-system { background: #f8fafc; }
.chat-tl-header { display: flex; gap: 8px; align-items: center; margin-bottom: 4px; }
.chat-tl-sender { font-weight: 600; font-size: 12px; text-transform: uppercase; }
.chat-tl-sender.clr-buyer { color: #2563eb; }
.chat-tl-sender.clr-seller { color: #059669; }
.chat-tl-sender.clr-mediator { color: #7c3aed; }
.chat-tl-sender.clr-system { color: #64748b; }
.chat-tl-time { font-size: 11px; color: var(--text-muted); margin-left: auto; }
.chat-tl-text { font-size: 13px; line-height: 1.6; color: var(--text); }
.chat-empty, .chat-loading { text-align: center; color: var(--text-muted); padding: 32px; font-size: 13px; line-height: 2; }

/* Responsive */
@media (max-width: 1024px) {
  .kpi-row { grid-template-columns: repeat(3, 1fr); }
  .charts-row { grid-template-columns: 1fr; }
  .chart-card.wide { grid-column: span 1; }
  .detail-grid { grid-template-columns: 1fr; }
}
@media (max-width: 768px) {
  .kpi-row { grid-template-columns: repeat(2, 1fr); }
  .navbar { flex-wrap: wrap; height: auto; padding: 12px; gap: 8px; }
  .nav-links { order: 3; width: 100%; }
  .content { padding: 16px; }
  .filters-row { flex-direction: column; }
  .info-grid { grid-template-columns: 1fr; }
}
