/* Reset & base */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --primary:    #1B3A5C;
  --secondary:  #2E6DA4;
  --bg:         #F5F7FA;
  --surface:    #FFFFFF;
  --border:     #DDE3EC;
  --text:       #1A1A2E;
  --muted:      #6C757D;
  --human:      #E67E22;
  --bot:        #6C757D;
  --success:    #27AE60;
  --danger:     #E74C3C;
  --radius:     8px;
  --shadow:     0 1px 4px rgba(0,0,0,.08);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
}

a { color: var(--secondary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* Navbar */
.navbar {
  background: var(--primary);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  height: 52px;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 6px rgba(0,0,0,.2);
}
.navbar-brand { display: flex; align-items: center; gap: 10px; }
.navbar-logo {
  background: var(--secondary);
  color: #fff;
  font-weight: 700;
  font-size: 13px;
  padding: 4px 8px;
  border-radius: 4px;
  letter-spacing: .5px;
}
.navbar-title { font-weight: 600; font-size: 15px; }
.btn-logout {
  color: rgba(255,255,255,.8);
  font-size: 13px;
  border: 1px solid rgba(255,255,255,.3);
  padding: 4px 12px;
  border-radius: 4px;
  transition: all .15s;
}
.btn-logout:hover { color: #fff; border-color: #fff; text-decoration: none; }

/* Container */
.container { max-width: 1100px; margin: 0 auto; padding: 24px 16px; }

/* Login */
.login-wrapper {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
}
.login-card {
  background: var(--surface);
  border-radius: 12px;
  box-shadow: 0 4px 24px rgba(0,0,0,.10);
  padding: 40px 36px;
  width: 100%;
  max-width: 380px;
}
.login-header { text-align: center; margin-bottom: 28px; }
.login-logo {
  display: inline-block;
  background: var(--primary);
  color: #fff;
  font-weight: 700;
  font-size: 22px;
  width: 56px; height: 56px;
  line-height: 56px;
  border-radius: 12px;
  margin-bottom: 12px;
}
.login-header h1 { font-size: 18px; color: var(--primary); }
.login-header p  { color: var(--muted); font-size: 13px; margin-top: 4px; }

.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-weight: 500; margin-bottom: 6px; font-size: 13px; }
.form-group input {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 9px 12px;
  font-size: 14px;
  transition: border-color .15s;
}
.form-group input:focus { outline: none; border-color: var(--secondary); }

.btn-primary {
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  padding: 10px 20px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s;
}
.btn-primary:hover { background: var(--secondary); }
.btn-full { width: 100%; }
.btn-secondary {
  background: var(--surface);
  color: var(--primary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 7px 14px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all .15s;
}
.btn-secondary:hover { border-color: var(--secondary); color: var(--secondary); }
.btn-link { color: var(--muted); font-size: 13px; padding: 7px 8px; cursor: pointer; }
.btn-link:hover { color: var(--danger); text-decoration: none; }

.alert { padding: 10px 14px; border-radius: var(--radius); margin-bottom: 16px; font-size: 13px; }
.alert-error { background: #FDECEA; color: var(--danger); border: 1px solid #FBCAC7; }

/* Metrics */
.metrics-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}
.metric-card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
}
.metric-card.metric-alert { border-left: 3px solid var(--human); }
.metric-icon { font-size: 20px; margin-bottom: 4px; }
.metric-value { font-size: 28px; font-weight: 700; color: var(--primary); line-height: 1; }
.metric-label { font-size: 12px; color: var(--muted); }

/* Filter bar */
.filter-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: var(--surface);
  border-radius: var(--radius);
  padding: 12px 16px;
  margin-bottom: 16px;
  box-shadow: var(--shadow);
}
.filter-group { display: flex; align-items: center; gap: 8px; }
.filter-select {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 7px 10px;
  font-size: 13px;
  background: var(--bg);
  cursor: pointer;
}
.filter-search {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 7px 12px;
  font-size: 13px;
  width: 220px;
}
.filter-search:focus { outline: none; border-color: var(--secondary); }

/* Table */
.table-wrapper {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.conv-table {
  width: 100%;
  border-collapse: collapse;
}
.conv-table th {
  text-align: left;
  padding: 12px 16px;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .4px;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
}
.conv-table td {
  padding: 13px 16px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.conv-row { cursor: pointer; transition: background .1s; }
.conv-row:hover { background: #EEF3FA; }
.conv-row:last-child td { border-bottom: none; }
.td-nome  { font-weight: 600; color: var(--primary); min-width: 140px; }
.td-phone { color: var(--muted); font-size: 13px; white-space: nowrap; }
.td-preview { color: var(--muted); font-size: 13px; max-width: 320px; }

/* Badges */
.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}
.badge-humano { background: #FEF0E4; color: var(--human); }
.badge-bot    { background: #F0F1F2; color: var(--bot); }

.btn-ver {
  color: var(--secondary);
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
}

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

.refresh-info {
  text-align: right;
  font-size: 12px;
  color: var(--muted);
  margin-top: 10px;
}

/* Conversation page */
.conv-header {
  display: flex;
  align-items: center;
  gap: 16px;
  background: var(--surface);
  border-radius: var(--radius);
  padding: 16px 20px;
  margin-bottom: 20px;
  box-shadow: var(--shadow);
}
.conv-header-info { flex: 1; }
.conv-header-info h2 { font-size: 17px; color: var(--primary); }
.conv-phone { font-size: 13px; color: var(--muted); }
.btn-back {
  color: var(--primary);
  font-weight: 600;
  font-size: 14px;
  white-space: nowrap;
}
.btn-back:hover { color: var(--secondary); text-decoration: none; }

/* Chat */
.chat-box {
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: var(--surface);
  border-radius: var(--radius);
  padding: 20px;
  min-height: 300px;
  box-shadow: var(--shadow);
}

.bubble-wrap { display: flex; }
.bubble-left  { justify-content: flex-start; }
.bubble-right { justify-content: flex-end; }

.bubble {
  max-width: 68%;
  padding: 10px 14px;
  border-radius: 12px;
  font-size: 14px;
  line-height: 1.5;
  word-break: break-word;
}
.bubble-human {
  background: #DCF0FF;
  color: #1A1A2E;
  border-bottom-right-radius: 3px;
}
.bubble-bot {
  background: #F0F1F2;
  color: #1A1A2E;
  border-bottom-left-radius: 3px;
}
.bubble-system {
  background: #EEF3FA;
  color: var(--muted);
  font-style: italic;
  border-radius: var(--radius);
}
.bubble-meta {
  font-size: 10px;
  color: var(--muted);
  margin-top: 4px;
  text-align: right;
}
.bubble-left .bubble-meta { text-align: left; }

.transfer-divider {
  text-align: center;
  margin: 12px 0;
  position: relative;
}
.transfer-divider::before,
.transfer-divider::after {
  content: "";
  position: absolute;
  top: 50%;
  width: 38%;
  height: 1px;
  background: var(--border);
}
.transfer-divider::before { left: 0; }
.transfer-divider::after  { right: 0; }
.transfer-divider span {
  background: var(--surface);
  padding: 0 12px;
  font-size: 12px;
  color: var(--human);
  font-weight: 600;
  position: relative;
  z-index: 1;
}

/* Responsive */
@media (max-width: 680px) {
  .metrics-grid { grid-template-columns: 1fr; }
  .filter-group { flex-wrap: wrap; }
  .filter-search { width: 100%; }
  .bubble { max-width: 88%; }
}
