*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --bg:        #f5f5f5;
    --surface:   #ffffff;
    --sidebar:   #000000;
    --brand:     #15A319;
    --brand-dk:  #15A379;
    --text:      #000000;
    --muted:     #666666;
    --border:    #e0e0e0;
    --danger:    #dc2626;
    --success:   #16a34a;
    --warn:      #15A379;
    --radius:    8px;
    --sidebar-w: 220px;
}

body {
    background: var(--bg);
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    color: var(--text);
    display: flex;
    min-height: 100vh;
    font-size: 14px;
}

/* ── Sidebar ── */
.sidebar {
    width: var(--sidebar-w);
    background: var(--sidebar);
    display: flex;
    flex-direction: column;
    padding: 24px 0;
    position: fixed;
    top: 0; left: 0; bottom: 0;
}

.sidebar-logo{
  display: flex;
  align-items: center;
  justify-content: center;
}
.sidebar-logo img{
  width: 120px;  
}

.sidebar nav { margin-top: 16px; }

.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 20px;
    color: rgba(255,255,255,.55);
    cursor: pointer;
    border-left: 3px solid transparent;
    transition: all .15s;
    font-size: 13px;
    font-weight: 500;
}

.nav-item:hover  { color: #fff; background: rgba(255,255,255,.05); }
.nav-item.active { color: #fff; border-left-color: var(--brand); background: rgba(49, 253, 34, 0.12); }

.nav-icon { font-size: 16px; width: 20px; text-align: center; }

/* ── Main ── */
.main {
    margin-left: var(--sidebar-w);
    flex: 1;
    display: flex;
    flex-direction: column;
}

.topbar {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: 14px 28px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 10;
}

.topbar h1 { font-size: 16px; font-weight: 700; }

.badge-internal {
    background: #fef3c7;
    color: #20920e;
    font-size: 11px;
    font-weight: 600;
    padding: 3px 10px;
    border-radius: 99px;
}

.content { padding: 28px; }

/* ── Pages ── */
.page { display: none; }
.page.active { display: block; }

/* ── Cards ── */
.card {
    background: var(--surface);
    border-radius: 12px;
    box-shadow: 0 1px 4px rgba(0,0,0,.06);
    padding: 24px;
}

.card-title {
    font-size: 15px;
    font-weight: 700;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 8px;
}

/* ── Form ── */
.field { margin-bottom: 16px; }

.phone-row{
  display: flex;
  gap: 8px;
  align-items: center;
}
.phone-row select{
  width: 100px;
}

label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    margin-bottom: 5px;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: .04em;
}

input, select, textarea {
    width: 100%;
    padding: 9px 12px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius);
    font-size: 14px;
    color: var(--text);
    background: var(--surface);
    transition: border-color .15s;
    outline: none;
    font-family: inherit;
}

input:focus, select:focus, textarea:focus {
    border-color: var(--brand);
    box-shadow: 0 0 0 3px rgba(100, 253, 34, 0.12);
}

textarea { resize: vertical; min-height: 80px; }

.hint { font-size: 11px; color: var(--muted); margin-top: 4px; }

.row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

/* ── Preview ── */
.preview-box {
    background: #e5ddd5;
    border-radius: 12px;
    padding: 16px;
    min-height: 80px;
    position: relative;
}

.preview-bubble {
    background: #fff;
    border-radius: 0 8px 8px 8px;
    padding: 10px 14px;
    max-width: 80%;
    font-size: 13px;
    line-height: 1.6;
    box-shadow: 0 1px 2px rgba(0,0,0,.12);
    white-space: pre-wrap;
}

.preview-bubble .cta-btn {
    margin-top: 10px;
    padding: 7px 12px;
    background: #f0f2f5;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 600;
    color: #075e54;
    text-align: center;
}

.preview-empty {
    color: var(--muted);
    font-size: 13px;
    font-style: italic;
}

/* ── Buttons ── */
.btn {
    padding: 10px 20px;
    border: none;
    border-radius: var(--radius);
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
    transition: background .15s, opacity .15s;
}

.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary  { background: var(--brand); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--brand-dk); }
.btn-ghost    { background: #f3f4f6; color: var(--text); }
.btn-ghost:hover:not(:disabled) { background: #e5e7eb; }
.btn-danger   { background: var(--danger); color: #fff; }

.btn-row { display: flex; gap: 10px; margin-top: 20px; }

/* ── Feedback ── */
.feedback {
    display: none;
    padding: 12px 14px;
    border-radius: var(--radius);
    font-size: 13px;
    font-weight: 500;
    margin-bottom: 16px;
}
.feedback.success { background: #f0fdf4; color: var(--success); border: 1px solid #bbf7d0; display: block; }
.feedback.error   { background: #fef2f2; color: var(--danger);  border: 1px solid #fecaca; display: block; }
.feedback.loading { background: #eff6ff; color: #1d4ed8; border: 1px solid #bfdbfe; display: block; }

/* ── Loading overlay ── */
.spinner {
    display: inline-block;
    width: 14px; height: 14px;
    border: 2px solid rgba(255,255,255,.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin .6s linear infinite;
    vertical-align: middle;
    margin-right: 6px;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Layout envio ── */
.send-layout {
    display: grid;
    grid-template-columns: 1fr 340px;
    gap: 20px;
    align-items: start;
}

/* ── Tabela histórico ── */
.table-wrap { 
    overflow-x: auto; 
    margin-top: 0; 
}

table { 
    width: 100%; 
    border-collapse: collapse; 
    font-size: 13px; 
}
th { 
    text-align: left; 
    padding: 8px 12px; 
    font-size: 11px; 
    font-weight: 700; 
    text-transform: uppercase; 
    color: var(--muted); 
    letter-spacing: .04em; 
    border-bottom: 2px solid var(--border); 
}
td { 
    padding: 10px 12px; 
    border-bottom: 1px solid var(--border); 
    vertical-align: middle; 
}
tr:last-child td { border-bottom: none; }
tr:hover td { background: #f9fafb; }

.status-badge {
    display: inline-block;
    padding: 2px 9px;
    border-radius: 99px;
    font-size: 11px;
    font-weight: 600;
}
.status-sent        { background: #dbeafe; color: #1d4ed8; }
.status-delivered   { background: #d1fae5; color: #065f46; }
.status-read        { background: #ede9fe; color: #5b21b6; }
.status-failed,
.status-undelivered { background: #fee2e2; color: #991b1b; }
.status-pending,
.status-queued      { background: #fef3c7; color: #0e921d; }

.test-tag {
    background: #fef9c3;
    color: #10850e;
    font-size: 10px;
    font-weight: 700;
    padding: 1px 7px;
    border-radius: 99px;
    margin-left: 4px;
}

.empty-state {
    text-align: center;
    padding: 48px 24px;
    color: var(--muted);
}

.empty-state .icon { font-size: 36px; margin-bottom: 8px; }
.empty-state p { font-size: 13px; }

.refresh-btn {
    font-size: 12px;
    color: var(--brand);
    cursor: pointer;
    font-weight: 600;
    background: none;
    border: none;
    padding: 0;
}
.refresh-btn:hover { text-decoration: underline; }

/* ── Variables section ── */
#variablesSection { display: none; }

#variableFields .var-field {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
}

#variableFields .var-label {
    font-size: 12px;
    font-weight: 700;
    color: var(--muted);
    min-width: 32px;
}

/* ── Template selector ── */
#templateLoading { color: var(--muted); font-size: 13px; font-style: italic; }

/* ── Tabs avulso / em massa ── */
.send-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 20px;
  background: #f3f4f6;
  border-radius: var(--radius);
  padding: 4px;
}

.send-tab {
  flex: 1;
  padding: 8px;
  text-align: center;
  font-size: 13px;
  font-weight: 600;
  border-radius: 6px;
  cursor: pointer;
  color: var(--muted);
  transition: all .15s;
  border: none;
  background: none;
}

.send-tab.active {
  background: var(--surface);
  color: var(--brand);
  box-shadow: 0 1px 3px rgba(0,0,0,.1);
}

.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ── Upload CSV ── */
.csv-dropzone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 32px;
  text-align: center;
  cursor: pointer;
  transition: border-color .15s, background .15s;
}

.csv-dropzone:hover,
.csv-dropzone.dragover {
  border-color: var(--brand);
  background: rgba(49, 253, 34, 0.04);
}

.csv-dropzone .dz-icon { font-size: 32px; margin-bottom: 8px; }
.csv-dropzone .dz-text { font-size: 13px; color: var(--muted); }
.csv-dropzone .dz-text strong { color: var(--brand); cursor: pointer; }
.csv-dropzone input[type="file"] { display: none; }

/* ── Prévia do CSV ── */
#csvPreviewSection { display: none; margin-top: 20px; }

.preview-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.preview-meta .meta-info { font-size: 13px; color: var(--muted); }
.preview-meta .meta-info strong { color: var(--text); }

.csv-table-wrap {
  max-height: 260px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.csv-table-wrap table { margin: 0; }
.csv-table-wrap th { position: sticky; top: 0; background: #f9fafb; z-index: 1; }

.row-valid   td:first-child { color: var(--success); }
.row-invalid td:first-child { color: var(--danger); }
.row-invalid { background: #fff5f5; }

.preview-warning {
  font-size: 12px;
  color: var(--warn);
  margin-top: 8px;
}

/* ── Barra de progresso ── */
#bulkProgressSection { display: none; margin-top: 20px; }

.progress-bar-wrap {
  background: #e5e7eb;
  border-radius: 99px;
  height: 8px;
  overflow: hidden;
  margin: 10px 0;
}

.progress-bar-fill {
  height: 100%;
  background: var(--brand);
  border-radius: 99px;
  transition: width .3s;
  width: 0%;
}

.progress-label {
  font-size: 12px;
  color: var(--muted);
  text-align: right;
}
/* ══════════════════════════════════════════
   CONVERSAS
══════════════════════════════════════════ */
.conv-layout {
  display: grid;
  grid-template-columns: 300px 1fr;
  gap: 16px;
  height: calc(100vh - 120px);
}

/* ── Sidebar de contatos ── */
.conv-sidebar {
  display: flex;
  flex-direction: column;
  padding: 0;
  overflow: hidden;
}

.conv-sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 16px 12px;
  font-size: 14px;
  font-weight: 700;
  border-bottom: 1px solid var(--border);
}

.conv-update-label {
  font-size: 10px;
  font-weight: 400;
  color: var(--muted);
}

.conv-contact-list {
  overflow-y: auto;
  flex: 1;
}

.conv-contact-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
  transition: background .12s;
}

.conv-contact-item:hover  { background: #f9fafb; }
.conv-contact-item.active { background: rgba(38, 253, 34, 0.07); border-left: 3px solid var(--brand); }

.conv-contact-avatar {
  width: 40px; height: 40px;
  border-radius: 50%;
  background: var(--brand);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.conv-contact-info { flex: 1; min-width: 0; }
.conv-contact-name    { font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.conv-contact-preview { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 2px; }

.conv-contact-meta { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; flex-shrink: 0; }
.conv-contact-date { font-size: 10px; color: var(--muted); }

.conv-unread-badge {
  background: var(--brand);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  border-radius: 99px;
  padding: 1px 6px;
  min-width: 18px;
  text-align: center;
}

/* ── Área do chat ── */
.conv-chat {
  display: flex;
  flex-direction: column;
  padding: 0;
  overflow: hidden;
}

.conv-chat-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.conv-chat-avatar {
  width: 38px; height: 38px;
  border-radius: 50%;
  background: var(--brand);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}

.conv-chat-title    { font-size: 14px; font-weight: 700; }
.conv-chat-subtitle { font-size: 12px; color: var(--muted); }

.conv-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px 20px;
  background: #f0ede8;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

/* ── Separador de dia ── */
.conv-day-separator {
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 12px 0 8px;
}

.conv-day-separator span {
  background: rgba(0,0,0,.12);
  color: #555;
  font-size: 11px;
  font-weight: 600;
  padding: 3px 12px;
  border-radius: 99px;
}

/* ── Bolhas ── */
.conv-bubble-wrap {
  display: flex;
  margin-bottom: 4px;
}

.conv-bubble-wrap.outbound { justify-content: flex-end; }
.conv-bubble-wrap.inbound  { justify-content: flex-start; }

.conv-bubble {
  max-width: 65%;
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 13px;
  line-height: 1.5;
  box-shadow: 0 1px 2px rgba(0,0,0,.1);
  word-break: break-word;
}

.conv-bubble.outbound { background: #dcf8c6; border-bottom-right-radius: 2px; }
.conv-bubble.inbound  { background: #ffffff; border-bottom-left-radius: 2px; }

.conv-bubble-body { white-space: pre-wrap; }

.conv-bubble-meta {
  font-size: 10px;
  color: #999;
  text-align: right;
  margin-top: 4px;
}

/* ══════════════════════════════════════════
   AUTH — topbar user + logout
══════════════════════════════════════════ */
.topbar-user {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 13px;
  color: var(--muted);
}

.btn-logout {
  padding: 6px 14px;
  background: #f3f4f6;
  border: none;
  border-radius: var(--radius);
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
  cursor: pointer;
  transition: background .15s;
}

.btn-logout:hover { background: #e5e7eb; }

/* ══════════════════════════════════════════
   MODAL — usuários
══════════════════════════════════════════ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}

.modal-box {
  background: #fff;
  border-radius: 14px;
  padding: 28px 32px;
  width: 100%;
  max-width: 420px;
  box-shadow: 0 8px 40px rgba(0,0,0,.16);
}

.modal-title {
  font-size: 16px;
  font-weight: 700;
  margin-bottom: 20px;
}
