* { margin: 0; padding: 0; box-sizing: border-box; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: #0f0f0f; color: #e9edef; height: 100vh; overflow: hidden;
}
.app { display: flex; flex-direction: column; height: 100vh; }

.topbar {
  background: #128C7E; padding: 12px 20px;
  display: flex; align-items: center; gap: 16px;
  border-bottom: 1px solid #0d6b60;
}
.topbar h1 { font-size: 18px; font-weight: 600; color: white; }
.cliente-selector {
  background: #0d6b60; color: white; border: none;
  padding: 8px 14px; border-radius: 6px; font-size: 14px;
  cursor: pointer; font-family: inherit; outline: none;
}
.cliente-selector option { background: #0d6b60; }
.topbar-info { margin-left: auto; display: flex; gap: 12px; align-items: center; color: white; font-size: 13px; }
.estado-pill { background: rgba(255,255,255,0.15); padding: 4px 10px; border-radius: 12px; font-size: 12px; }
.estado-pill.conectado { background: #25D366; }
.estado-pill.desconectado { background: #d32f2f; }

.main-layout { display: flex; flex: 1; overflow: hidden; }

.sidebar {
  width: 380px; background: #1a1a1a;
  border-right: 1px solid #2a2a2a;
  display: flex; flex-direction: column;
}
.tabs { display: flex; background: #1a1a1a; border-bottom: 1px solid #2a2a2a; flex-wrap: wrap; }
.tab {
  flex: 1; padding: 10px 6px; text-align: center; cursor: pointer;
  color: #8696a0; font-size: 11px; font-weight: 500;
  border-bottom: 2px solid transparent; transition: all 0.2s;
  min-width: 60px;
}
.tab.active { color: #25D366; border-bottom-color: #25D366; }
.tab:hover:not(.active) { color: #d1d7db; }

.search-bar { padding: 10px 16px; background: #1a1a1a; border-bottom: 1px solid #2a2a2a; }
.search-bar input {
  width: 100%; padding: 9px 14px; background: #2a2a2a;
  border: none; border-radius: 8px; color: #e9edef; font-size: 14px; outline: none;
}
.search-bar input::placeholder { color: #8696a0; }

.list-area { flex: 1; overflow-y: auto; }
.contacto-item, .cliente-item {
  display: flex; align-items: center; padding: 12px 16px;
  cursor: pointer; border-bottom: 1px solid #1f1f1f;
  transition: background 0.15s; position: relative;
}
.contacto-item:hover, .cliente-item:hover { background: #222; }
.contacto-item.active, .cliente-item.active { background: #2a2a2a; }
.contacto-item.pausada::before {
  content: '⏸'; position: absolute; right: 12px; bottom: 8px;
  background: #ff9800; color: white; width: 18px; height: 18px;
  border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 9px;
}

.avatar {
  width: 48px; height: 48px; border-radius: 50%; background: #128C7E;
  color: white; display: flex; align-items: center; justify-content: center;
  font-weight: 600; font-size: 18px; margin-right: 12px; flex-shrink: 0;
}

.contacto-info, .cliente-info { flex: 1; min-width: 0; }
.contacto-nombre, .cliente-nombre {
  font-weight: 500; font-size: 15px; margin-bottom: 4px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.contacto-ultimo, .cliente-desc {
  font-size: 13px; color: #8696a0;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.contacto-meta { text-align: right; font-size: 11px; color: #8696a0; margin-left: 8px; }

.btn-add {
  margin: 12px 16px; padding: 10px;
  background: #25D366; color: white; border: none;
  border-radius: 8px; font-size: 14px; font-weight: 500; cursor: pointer;
  font-family: inherit;
}
.btn-add:hover { background: #1ba34d; }

.main { flex: 1; display: flex; flex-direction: column; background: #0a0a0a; overflow-y: auto; }
.empty-state {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  color: #8696a0; text-align: center; padding: 40px;
}
.empty-state h2 { font-size: 28px; font-weight: 300; margin-bottom: 12px; color: #d1d7db; }
.empty-state p { font-size: 14px; max-width: 400px; line-height: 1.5; }

.chat-header {
  background: #1a1a1a; padding: 14px 20px;
  border-bottom: 1px solid #2a2a2a;
  display: flex; align-items: center; gap: 14px;
}
.chat-header .info { flex: 1; }
.chat-header .info h2 { font-size: 16px; font-weight: 500; margin-bottom: 2px; }
.chat-header .info .telefono { font-size: 13px; color: #8696a0; }

.btn {
  padding: 8px 16px; border-radius: 8px; border: none;
  cursor: pointer; font-size: 13px; font-weight: 500;
  transition: all 0.2s; font-family: inherit;
}
.btn-pausar { background: #ff9800; color: white; }
.btn-pausar:hover { background: #f57c00; }
.btn-reanudar { background: #25D366; color: white; }
.btn-reanudar:hover { background: #1ba34d; }
.btn-secundario { background: #2a2a2a; color: #e9edef; }
.btn-secundario:hover { background: #3a3a3a; }
.btn-secundario.btn-warn { background: #5a4a1a; color: #ffcc80; }
.btn-secundario.btn-warn:hover { background: #6a5a2a; }
.btn-primario { background: #25D366; color: white; }
.btn-primario:hover { background: #1ba34d; }
.btn-peligro { background: #b71c1c; color: white; }
.btn-peligro:hover { background: #8a0e0e; }

.banner-pausa {
  background: #ff9800; color: white;
  padding: 8px 20px; text-align: center;
  font-size: 13px; font-weight: 500;
}

.messages {
  flex: 1; overflow-y: auto; padding: 20px;
  background: #0a0a0a; display: flex; flex-direction: column; gap: 8px;
}
.mensaje {
  max-width: 65%; padding: 8px 12px; border-radius: 8px;
  font-size: 14.5px; line-height: 1.4; word-wrap: break-word; white-space: pre-wrap;
}
.mensaje.entrada { background: #1a1a1a; align-self: flex-start; border-bottom-left-radius: 2px; }
.mensaje.salida { background: #128C7E; color: white; align-self: flex-end; border-bottom-right-radius: 2px; }
.mensaje .fecha { display: block; font-size: 11px; opacity: 0.7; margin-top: 4px; text-align: right; }

.input-area {
  background: #1a1a1a; padding: 12px 16px;
  border-top: 1px solid #2a2a2a;
  display: flex; gap: 10px; align-items: center;
}
.input-area textarea {
  flex: 1; background: #2a2a2a; border: none; border-radius: 8px;
  padding: 10px 14px; color: #e9edef; font-size: 14px;
  font-family: inherit; outline: none; resize: none; min-height: 40px;
}
.input-area .btn-enviar { background: #25D366; color: white; padding: 10px 20px; }
.input-area .btn-enviar:hover { background: #1ba34d; }
.input-area .btn-enviar:disabled { background: #444; cursor: not-allowed; }

.content-view { flex: 1; overflow-y: auto; padding: 30px; }
.content-view h2 { margin-bottom: 24px; color: #d1d7db; font-weight: 500; }

.stats-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px; margin-bottom: 30px;
}
.stat-card { background: #1a1a1a; border-radius: 12px; padding: 20px; border: 1px solid #2a2a2a; }
.stat-card .label { color: #8696a0; font-size: 12px; text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 8px; }
.stat-card .value { font-size: 32px; font-weight: 600; color: #25D366; }
.stat-card .sublabel { color: #8696a0; font-size: 12px; margin-top: 4px; }

.form-card {
  background: #1a1a1a; border-radius: 12px; padding: 24px;
  border: 1px solid #2a2a2a; max-width: 700px;
}
.form-group { margin-bottom: 18px; }
.form-group label {
  display: block; font-size: 13px; color: #d1d7db;
  margin-bottom: 6px; font-weight: 500;
}
.form-group input, .form-group textarea, .form-group select {
  width: 100%; background: #2a2a2a; border: 1px solid #3a3a3a;
  border-radius: 6px; padding: 10px 14px; color: #e9edef;
  font-size: 14px; font-family: inherit; outline: none;
}
.form-group input:focus, .form-group textarea:focus, .form-group select:focus { border-color: #25D366; }
.form-group input:disabled { opacity: 0.5; cursor: not-allowed; }
.form-group textarea { resize: vertical; min-height: 200px; line-height: 1.5; }
.form-group .hint { font-size: 12px; color: #8696a0; margin-top: 4px; }

.form-actions {
  display: flex; flex-wrap: wrap; gap: 10px; margin-top: 20px;
  padding-top: 20px; border-top: 1px solid #2a2a2a;
}

.qr-container {
  background: white; padding: 20px;
  border-radius: 12px; display: inline-block; margin: 20px auto;
}
.qr-instructions {
  background: #1a1a1a; padding: 16px 20px;
  border-radius: 8px; margin-top: 20px; border-left: 3px solid #25D366;
}
.qr-instructions ol { padding-left: 20px; line-height: 1.8; color: #d1d7db; }

.top-list .top-item {
  display: flex; align-items: center; padding: 10px 0;
  border-bottom: 1px solid #2a2a2a;
}
.top-list .top-item:last-child { border-bottom: none; }
.top-list .top-item .pos {
  width: 28px; height: 28px; background: #128C7E;
  border-radius: 50%; display: flex; align-items: center; justify-content: center;
  margin-right: 12px; font-size: 13px; font-weight: 600;
}
.top-list .top-item .nombre { flex: 1; font-size: 14px; }
.top-list .top-item .count { color: #8696a0; font-size: 13px; }

.stats-section { background: #1a1a1a; border-radius: 12px; padding: 20px; border: 1px solid #2a2a2a; }
.stats-section h3 { font-size: 16px; margin-bottom: 16px; color: #d1d7db; }

::-webkit-scrollbar { width: 8px; }
::-webkit-scrollbar-track { background: #1a1a1a; }
::-webkit-scrollbar-thumb { background: #444; border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: #555; }
