/* Pixel Service — Panel de soporte
   Paleta pensada para el negocio (servicio técnico / electrónica):
   fondo carbón oscuro + acento teal ("pixel encendido"), tipografía
   IBM Plex (Sans para texto, Mono para números de teléfono y horas). */

:root {
  --bg: #14161a;
  --surface: #1b1e24;
  --surface-2: #232830;
  --surface-3: #2a2f38;
  --border: #2a2f38;
  --text: #edeff3;
  --text-dim: #9aa1b0;
  --text-faint: #5b6270;
  --accent: #2fd3b0;
  --accent-strong: #3fe8c4;
  --accent-dim: rgba(47, 211, 176, 0.14);
  --danger: #e5584f;
  --danger-dim: rgba(229, 88, 79, 0.14);
  --bubble-in: #232830;
  --bubble-out: #163a35;
  --font-ui: "IBM Plex Sans", system-ui, -apple-system, sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, "SF Mono", monospace;
  --radio: 10px;
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-ui);
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}

button, input, textarea {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
}

ul { list-style: none; margin: 0; padding: 0; }

::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: var(--surface-3); border-radius: 8px; }
::-webkit-scrollbar-track { background: transparent; }

.marca { display: flex; align-items: center; gap: 8px; }
.marca-icono {
  color: var(--accent);
  font-size: 18px;
  line-height: 1;
}
.marca-texto { font-weight: 600; letter-spacing: 0.01em; }

/* ---------- Login ---------- */

.pantalla-login {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(circle at 15% 15%, rgba(47, 211, 176, 0.08), transparent 45%),
    var(--bg);
  padding: 24px;
}

.tarjeta-login {
  width: 100%;
  max-width: 360px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 32px 28px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.tarjeta-login h1 {
  font-size: 20px;
  margin: 16px 0 2px;
}

.subtitulo {
  color: var(--text-dim);
  margin: 0 0 20px;
  font-size: 13px;
}

.campo {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 14px;
  font-size: 13px;
  color: var(--text-dim);
}

.campo input {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  color: var(--text);
  outline: none;
}

.campo input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-dim);
}

.boton-primario {
  margin-top: 8px;
  background: var(--accent);
  color: #0b1512;
  border: none;
  border-radius: 8px;
  padding: 11px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s ease;
}
.boton-primario:hover { background: var(--accent-strong); }
.boton-primario:disabled { opacity: 0.6; cursor: default; }

.mensaje-error {
  color: var(--danger);
  font-size: 12.5px;
  margin: 10px 0 0;
}

/* ---------- Layout general ---------- */

.app {
  height: 100vh;
  display: grid;
  grid-template-columns: 360px 1fr;
}

/* ---------- Bandeja ---------- */

.bandeja {
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.bandeja-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 16px 12px;
}

.boton-icono {
  background: transparent;
  border: none;
  color: var(--text-dim);
  width: 32px;
  height: 32px;
  border-radius: 8px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  transition: background 0.15s ease, color 0.15s ease;
}
.boton-icono:hover { background: var(--surface-3); color: var(--text); }

.bandeja-buscador { padding: 0 16px 12px; }
.bandeja-buscador input {
  width: 100%;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 9px 12px;
  outline: none;
}
.bandeja-buscador input:focus { border-color: var(--accent); }

.bandeja-filtros {
  display: flex;
  gap: 6px;
  padding: 0 16px 12px;
}
.filtro {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-dim);
  border-radius: 999px;
  padding: 5px 12px;
  font-size: 12.5px;
  cursor: pointer;
}
.filtro.activo {
  background: var(--accent-dim);
  border-color: var(--accent);
  color: var(--accent-strong);
}

.lista-conversaciones {
  flex: 1;
  overflow-y: auto;
  border-top: 1px solid var(--border);
}

.bandeja-vacia {
  text-align: center;
  color: var(--text-faint);
  padding: 32px 16px;
  font-size: 13px;
}

.conversacion-item {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background 0.12s ease;
}
.conversacion-item:hover { background: var(--surface-2); }
.conversacion-item.seleccionada {
  background: var(--accent-dim);
  box-shadow: inset 3px 0 0 var(--accent);
}

.avatar {
  flex: none;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--surface-3);
  color: var(--text-dim);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 13px;
}
.conversacion-item.seleccionada .avatar,
.conversacion-item.no-leida .avatar {
  background: var(--accent-dim);
  color: var(--accent-strong);
}

.conversacion-texto { flex: 1; min-width: 0; }
.conversacion-fila-superior {
  display: flex;
  justify-content: space-between;
  gap: 8px;
}
.conversacion-nombre {
  font-weight: 600;
  font-size: 13.5px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.conversacion-hora {
  flex: none;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-faint);
}
.conversacion-preview {
  color: var(--text-dim);
  font-size: 12.5px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 2px;
  display: flex;
  justify-content: space-between;
  gap: 8px;
  align-items: center;
}
.conversacion-item.no-leida .conversacion-preview { color: var(--text); }
.conversacion-item.no-leida .conversacion-nombre { color: var(--accent-strong); }

.badge-no-leidos {
  flex: none;
  background: var(--accent);
  color: #0b1512;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  min-width: 18px;
  height: 18px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 5px;
}

.etiqueta-estado-cerrada {
  font-size: 11px;
  color: var(--text-faint);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 1px 7px;
}

/* ---------- Chat ---------- */

.chat {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
}

.chat-vacio {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: var(--text-faint);
  gap: 10px;
}
.chat-vacio-icono { font-size: 26px; color: var(--surface-3); }

.chat-activo {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.chat-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
}
.chat-header-info { flex: 1; min-width: 0; }
.chat-header-info h2 {
  margin: 0;
  font-size: 15px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.chat-telefono {
  margin: 1px 0 0;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-dim);
}
.chat-header-acciones { display: flex; align-items: center; gap: 10px; }

.etiqueta-estado {
  font-size: 11.5px;
  padding: 3px 10px;
  border-radius: 999px;
  border: 1px solid var(--accent);
  color: var(--accent-strong);
  background: var(--accent-dim);
  text-transform: capitalize;
}
.etiqueta-estado.cerrada {
  border-color: var(--border);
  color: var(--text-dim);
  background: transparent;
}

.boton-secundario {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-dim);
  border-radius: 8px;
  padding: 6px 12px;
  font-size: 12.5px;
  cursor: pointer;
}
.boton-secundario:hover { border-color: var(--accent); color: var(--accent-strong); }

.boton-volver { display: none; }

.chat-mensajes {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.burbuja {
  max-width: 68%;
  padding: 9px 12px;
  border-radius: var(--radio);
  font-size: 13.5px;
  line-height: 1.4;
  word-wrap: break-word;
}
.burbuja.entrante {
  align-self: flex-start;
  background: var(--bubble-in);
  border-bottom-left-radius: 3px;
}
.burbuja.saliente {
  align-self: flex-end;
  background: var(--bubble-out);
  border-bottom-right-radius: 3px;
}
.burbuja p { margin: 0; white-space: pre-wrap; }
.burbuja-hora {
  display: block;
  margin-top: 4px;
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--text-faint);
  text-align: right;
}
.burbuja-media {
  max-width: 100%;
  border-radius: 8px;
  display: block;
  margin-bottom: 6px;
}
.burbuja-media-cargando {
  width: 220px;
  height: 140px;
  border-radius: 8px;
  background: var(--surface-3);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-faint);
  font-size: 12px;
  margin-bottom: 6px;
}
.burbuja-doc {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-dim);
  font-size: 12.5px;
  margin-bottom: 4px;
}

.separador-fecha {
  align-self: center;
  color: var(--text-faint);
  font-size: 11px;
  background: var(--surface-2);
  border-radius: 999px;
  padding: 3px 12px;
  margin: 6px 0;
}

.previsualizacion-archivo {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 20px;
  background: var(--surface-2);
  border-top: 1px solid var(--border);
  font-size: 12.5px;
  color: var(--text-dim);
}

.chat-composer {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 14px 20px;
  border-top: 1px solid var(--border);
}

.chat-composer textarea {
  flex: 1;
  resize: none;
  max-height: 120px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  outline: none;
  line-height: 1.4;
}
.chat-composer textarea:focus { border-color: var(--accent); }

.boton-enviar {
  background: var(--accent);
  color: #0b1512;
  border: none;
  border-radius: 8px;
  padding: 10px 16px;
  font-weight: 600;
  cursor: pointer;
}
.boton-enviar:hover { background: var(--accent-strong); }
.boton-enviar:disabled { opacity: 0.5; cursor: default; }

#envio-error { padding: 0 20px 12px; }

/* ---------- Responsive (una sola columna en pantallas chicas) ---------- */

@media (max-width: 760px) {
  .app { grid-template-columns: 1fr; }
  .bandeja { display: flex; }
  .chat { display: none; }
  .app.mostrando-chat .bandeja { display: none; }
  .app.mostrando-chat .chat { display: flex; }
  .boton-volver { display: inline-flex; }
}
