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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: #f0f2f5;
  color: #1a1a1a;
  font-size: 15px;
}

.app {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: 220px;
  background: #075e54;
  color: white;
  display: flex;
  flex-direction: column;
  position: fixed;
  height: 100vh;
  z-index: 10;
}

.sidebar-header {
  padding: 20px 16px;
  border-bottom: 1px solid rgba(255,255,255,0.1);
}

.sidebar-header h2 {
  font-size: 18px;
  margin-bottom: 4px;
}

.user-badge {
  font-size: 12px;
  opacity: 0.7;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  color: rgba(255,255,255,0.8);
  text-decoration: none;
  font-size: 14px;
  transition: background 0.15s;
}

.nav-item:hover { background: rgba(255,255,255,0.1); }
.nav-item.active { background: rgba(255,255,255,0.15); color: white; font-weight: 600; }
.nav-icon { font-size: 18px; width: 24px; text-align: center; }
.nav-spacer { flex: 1; }
.nav-logout { border-top: 1px solid rgba(255,255,255,0.1); opacity: 0.6; font-size: 13px; }

.content {
  flex: 1;
  margin-left: 220px;
  padding: 24px;
  max-width: 1200px;
}

.page-header {
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.page-header h1 {
  font-size: 22px;
  font-weight: 600;
}

.back-link {
  color: #075e54;
  text-decoration: none;
  font-size: 13px;
  display: inline-block;
  margin-bottom: 8px;
}

.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 12px;
  font-size: 12px;
  background: #e0e0e0;
  color: #555;
}

.badge-info { background: #075e54; color: white; }

/* ─── STATUS BAR ─── */
.status-bar {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 20px;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
  transition: opacity 0.15s;
}

.status-pill:hover { opacity: 0.85; }
.pill-green { background: #d4edda; color: #155724; }
.pill-yellow { background: #fff3cd; color: #856404; }
.pill-red { background: #f8d7da; color: #721c24; }
.pill-empty { font-size: 13px; color: #999; }

/* ─── STATS GRID ─── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  background: white;
  border-radius: 12px;
  padding: 16px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.stat-phone {
  font-weight: 600;
  font-size: 15px;
  margin-bottom: 12px;
  color: #075e54;
}

.stat-numbers {
  display: flex;
  gap: 16px;
}

.stat-item { text-align: center; flex: 1; }

.stat-value {
  display: block;
  font-size: 24px;
  font-weight: 700;
}

.stat-label {
  font-size: 11px;
  color: #888;
  text-transform: uppercase;
}

.stat-out { color: #25d366; }
.stat-in { color: #34b7f1; }
.stat-alert { color: #e74c3c; }

.stat-time {
  margin-top: 10px;
  font-size: 12px;
  color: #999;
}

/* ─── SECTION HEADER ─── */
.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.section-header h2 { font-size: 16px; font-weight: 600; }

.link-more {
  color: #075e54;
  text-decoration: none;
  font-size: 13px;
}

/* ─── FILTER ROW + CHIPS ─── */
.filter-row {
  display: flex;
  gap: 10px;
  margin-bottom: 20px;
  flex-wrap: wrap;
  align-items: center;
}

.chips-group {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.chip {
  display: inline-block;
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 13px;
  background: white;
  border: 1px solid #ddd;
  color: #555;
  text-decoration: none;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}

.chip:hover { border-color: #075e54; color: #075e54; }
.chip-active { background: #075e54; color: white; border-color: #075e54; }
.chip-red.chip-active { background: #e74c3c; border-color: #e74c3c; }

/* ─── LEGACY FILTERS (search page) ─── */
.filters {
  display: flex;
  gap: 10px;
  margin-bottom: 20px;
  flex-wrap: wrap;
  align-items: center;
}

.filters select, .filters input[type="date"], .filters input[type="text"] {
  padding: 8px 12px;
  border: 1px solid #ddd;
  border-radius: 6px;
  font-size: 13px;
  background: white;
}

.filters .search-input { flex: 1; min-width: 200px; }

.filters button {
  padding: 8px 20px;
  background: #075e54;
  color: white;
  border: none;
  border-radius: 6px;
  font-size: 13px;
  cursor: pointer;
}

.filters button:hover { background: #064e46; }

/* ─── CHAT LIST ─── */
.chat-list { display: flex; flex-direction: column; gap: 2px; }

.chat-item {
  display: flex;
  gap: 12px;
  padding: 12px 16px;
  background: white;
  text-decoration: none;
  color: inherit;
  border-radius: 12px;
  transition: background 0.15s;
  align-items: center;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}

.chat-item:hover { background: #f5f5f5; }
.chat-item.chat-has-alert { border-left: 4px solid #e74c3c; }

.chat-avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: #075e54;
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  font-weight: 600;
  flex-shrink: 0;
}

.avatar-alert { background: #e74c3c; }

.chat-info { flex: 1; min-width: 0; }

.chat-top {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
}

.chat-name { font-weight: 600; font-size: 14px; }
.chat-phone-tag {
  font-size: 11px;
  background: #e8f5e9;
  color: #2e7d32;
  padding: 1px 6px;
  border-radius: 4px;
}

.chat-time { margin-left: auto; font-size: 12px; color: #999; }

.chat-preview {
  font-size: 13px;
  color: #666;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat-meta {
  display: flex;
  gap: 10px;
  font-size: 11px;
  color: #999;
  margin-top: 2px;
}

.chat-alert-badge {
  color: #e74c3c;
  font-weight: 600;
}

/* ─── CHAT DETAIL ─── */
.chat-container {
  max-width: 700px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 16px;
  background: #e5ddd5;
  border-radius: 10px;
  min-height: 300px;
  background-image: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23c9c3b8' fill-opacity='0.15'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
}

.bubble {
  max-width: 75%;
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 14px;
  line-height: 1.4;
  position: relative;
}

.bubble-out {
  align-self: flex-end;
  background: #dcf8c6;
  border-bottom-right-radius: 2px;
}

.bubble-in {
  align-self: flex-start;
  background: white;
  border-bottom-left-radius: 2px;
}

.bubble-alert { border: 2px solid #e74c3c; }
.bubble-text { word-wrap: break-word; }

.bubble-media {
  font-size: 12px;
  color: #075e54;
  font-style: italic;
  margin-bottom: 4px;
}

.bubble-alert-tag {
  font-size: 11px;
  color: #e74c3c;
  font-weight: 600;
  margin-top: 4px;
}

.bubble-time {
  font-size: 11px;
  color: #999;
  text-align: right;
  margin-top: 2px;
}

/* ─── ALERT LIST ─── */
.alert-list { display: flex; flex-direction: column; gap: 10px; }

.alert-card {
  background: white;
  border-radius: 12px;
  padding: 14px 16px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.08);
  border-left: 4px solid #e74c3c;
}

.alert-card.alert-reviewed {
  border-left-color: #aaa;
  opacity: 0.7;
}

.alert-top {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-bottom: 6px;
  flex-wrap: wrap;
}

.alert-phone { font-weight: 600; font-size: 13px; }

.alert-dir {
  font-size: 11px;
  padding: 1px 6px;
  border-radius: 4px;
  font-weight: 600;
}

.dir-out { background: #fff3cd; color: #856404; }
.dir-in { background: #d1ecf1; color: #0c5460; }

.alert-priority {
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 4px;
  font-weight: 700;
}

.priority-high { background: #f8d7da; color: #721c24; }
.priority-med { background: #fff3cd; color: #856404; }

.alert-time { margin-left: auto; font-size: 12px; color: #999; }

.btn-review {
  padding: 4px 12px;
  background: #075e54;
  color: white;
  border: none;
  border-radius: 6px;
  font-size: 12px;
  cursor: pointer;
  font-weight: 600;
  white-space: nowrap;
  min-height: 30px;
  min-width: 90px;
}

.btn-review:hover { background: #064e46; }

.reviewed-tag {
  font-size: 12px;
  color: #27ae60;
  font-weight: 600;
}

.alert-contact {
  font-size: 13px;
  color: #555;
  margin-bottom: 6px;
}

.alert-contact a { color: #075e54; text-decoration: none; }

.alert-body {
  font-size: 14px;
  line-height: 1.4;
  margin-bottom: 6px;
  padding: 8px;
  background: #fafafa;
  border-radius: 4px;
}

.alert-words {
  font-size: 12px;
  color: #e74c3c;
}

/* ─── EMPTY ALERTS STATE ─── */
.empty-alerts {
  text-align: center;
  padding: 48px 24px;
  color: #888;
}

.empty-check {
  display: block;
  font-size: 48px;
  color: #27ae60;
  margin-bottom: 8px;
}

.empty-sub {
  font-size: 13px;
  margin-top: 4px;
  color: #aaa;
}

/* ─── TIMELINE ─── */
.timeline {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.timeline-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  background: white;
  border-radius: 8px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

.timeline-item.timeline-alert {
  border-left: 3px solid #e74c3c;
}

.timeline-icon { font-size: 16px; flex-shrink: 0; width: 24px; text-align: center; }

.timeline-content {
  flex: 1;
  min-width: 0;
  display: flex;
  gap: 8px;
  align-items: baseline;
  flex-wrap: wrap;
}

.timeline-phone {
  font-weight: 600;
  font-size: 13px;
  white-space: nowrap;
  color: #075e54;
}

.timeline-preview {
  font-size: 13px;
  color: #666;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 400px;
}

.timeline-time { font-size: 12px; color: #999; flex-shrink: 0; }

/* ─── SEARCH ─── */
.search-results { display: flex; flex-direction: column; gap: 8px; }

.result-card {
  background: white;
  border-radius: 12px;
  padding: 12px 16px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}

.result-card.result-alert { border-left: 3px solid #e74c3c; }

.result-top {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-bottom: 6px;
  flex-wrap: wrap;
}

.result-phone { font-weight: 600; font-size: 12px; color: #075e54; }
.result-contact { color: #075e54; text-decoration: none; font-size: 13px; }
.result-time { margin-left: auto; font-size: 12px; color: #999; }
.result-body { font-size: 14px; line-height: 1.4; }
.result-count { font-size: 13px; color: #666; margin-bottom: 12px; }

/* ─── VER IMAGEN / COMPROBANTE ─── */
.btn-ver-imagen {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  background: #e8f5e9;
  color: #2e7d32;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  text-decoration: none;
  transition: background 0.15s;
}

.btn-ver-imagen:hover { background: #c8e6c9; }

.comprobante-badge {
  display: inline-block;
  margin-top: 4px;
  padding: 3px 8px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 600;
}

.comprobante-pendiente { background: #fff3cd; color: #856404; }
.comprobante-verificado_ok { background: #d4edda; color: #155724; }
.comprobante-sospechoso { background: #f8d7da; color: #721c24; }
.comprobante-no_subio_bancos { background: #f8d7da; color: #721c24; }
.comprobante-bancos_ok_erp_pendiente { background: #d1ecf1; color: #0c5460; }

.media-tag {
  color: #075e54;
  font-style: italic;
  font-size: 13px;
}

.chat-comprobante-badge {
  color: #856404;
  font-weight: 600;
  font-size: 11px;
}

/* ─── EMPTY STATE ─── */
.empty-state {
  text-align: center;
  padding: 40px;
  color: #999;
  font-size: 14px;
}

/* ─── LOGIN ─── */
.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: #075e54;
}

.login-box {
  background: white;
  padding: 40px;
  border-radius: 12px;
  width: 340px;
  text-align: center;
  box-shadow: 0 4px 20px rgba(0,0,0,0.2);
}

.login-box h1 {
  color: #075e54;
  font-size: 24px;
  margin-bottom: 4px;
}

.login-subtitle {
  color: #999;
  font-size: 13px;
  margin-bottom: 24px;
}

.login-box input {
  display: block;
  width: 100%;
  padding: 10px 14px;
  border: 1px solid #ddd;
  border-radius: 6px;
  font-size: 14px;
  margin-bottom: 12px;
}

.login-box button {
  width: 100%;
  padding: 10px;
  background: #075e54;
  color: white;
  border: none;
  border-radius: 6px;
  font-size: 14px;
  cursor: pointer;
  font-weight: 600;
}

.login-box button:hover { background: #064e46; }

.error-msg {
  background: #f8d7da;
  color: #721c24;
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 13px;
  margin-bottom: 16px;
}

/* ─── BOTTOM NAV (mobile) ─── */
.bottom-nav { display: none; }

@media (max-width: 768px) {
  .sidebar { display: none; }
  .content { margin-left: 0; padding: 16px; padding-bottom: 80px; }
  .stats-grid { grid-template-columns: 1fr; }
  .bubble { max-width: 90%; }
  .timeline-preview { max-width: 160px; }
  .filter-row { gap: 8px; }

  .bottom-nav {
    display: flex;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 60px;
    background: #075e54;
    z-index: 100;
    border-top: 1px solid rgba(255,255,255,0.1);
  }

  .bottom-nav-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: rgba(255,255,255,0.7);
    text-decoration: none;
    gap: 2px;
    min-height: 48px;
  }

  .bottom-nav-item.active { color: white; }
  .bottom-nav-icon { font-size: 20px; }
  .bottom-nav-label { font-size: 10px; }
}
