/* ==================== CUSTOM: Sistema Clínica ==================== */

.nav-inner {
  max-width: 1100px;
  margin: 0 auto;
  padding: 8px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
  width: 100%;
}

.nav-logo {
  height: 44px;
}

.nav-tabs {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  flex: 1 1 auto;
  min-width: 0;
  order: 2;
}

/* Nombre y foto del usuario arriba a la izquierda, Salir arriba a la derecha */
.nav-user {
  order: 1;
  flex: 1 1 auto;
  min-width: 0;
  text-align: left;
}

.nav-salir {
  order: 3;
  flex: 0 0 auto;
  display: flex;
  align-items: center;
}

.nav-tabs .tab {
  background: transparent;
  color: rgba(255, 255, 255, 0.85);
  border: none;
  cursor: pointer;
  padding: 6px 12px;
  border-radius: 20px;
  font-size: 0.88rem;
  white-space: nowrap;
}

.nav-tabs .tab:hover {
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
}

.nav-tabs .tab.active {
  background: #fff;
  color: var(--primario);
  font-weight: 700;
}

.nav-nombre {
  font-weight: 700;
}

.nav-especialidad {
  font-size: 0.75rem;
  opacity: 0.85;
}

.contenido {
  max-width: 1100px;
  margin: 0 auto;
  padding: 18px 16px 60px;
}

.cargando {
  color: var(--texto-suave, #666);
  padding: 24px 8px;
  text-align: center;
}

.gris {
  color: var(--texto-suave, #666);
  font-size: 0.9rem;
}

.aviso-turno {
  background: #fff7e0;
  border: 1px solid #f0d98a;
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 0.9rem;
  margin-top: 8px;
}

.link {
  color: var(--primario, #2f6f9f);
  text-decoration: underline;
  cursor: pointer;
  background: none;
  border: none;
  font-size: 0.9rem;
  padding: 0;
}

.breadcrumb {
  margin: 6px 0 12px;
}

.form-error {
  color: #b3261e;
}

.form-success {
  background: #e9f7ee;
  border: 1px solid #bfe6cd;
  color: #226b3c;
  border-radius: 10px;
  padding: 10px 12px;
  margin-bottom: 12px;
  font-size: 0.9rem;
  line-height: 1.45;
}

.nota-wa {
  margin: 2px 0 8px;
}

/* ---------- FILAS ---------- */
.fila-turno {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 16px;
  padding: 10px 0;
  border-bottom: 1px dashed var(--borde, #dbe3ea);
  justify-content: space-between;
}

.fila-turno > div {
  min-width: 140px;
}

.fila-turno .acciones {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

/* ---------- SOLICITUD DE TURNO (paciente) ---------- */
.pk-dia {
  margin-top: 12px;
  padding: 10px;
  border: 1px solid var(--borde, #dbe3ea);
  border-radius: 10px;
}

.pk-fecha {
  font-weight: 700;
  margin-bottom: 8px;
}

.pk-slot {
  margin: 0 6px 6px 0;
}

.pk-resumen {
  margin-top: 14px;
}

.pk-resumen-inner {
  padding: 12px;
  background: var(--fondo-suave, #f4f8fb);
  border: 1px solid var(--borde, #dbe3ea);
  border-radius: 10px;
}

.pill-hora {
  display: inline-block;
  background: #eef4f9;
  border: 1px solid #cfddea;
  border-radius: 12px;
  padding: 3px 9px;
  font-size: 0.82rem;
  margin: 0 6px 6px 0;
}

.pill-hora-asignar {
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s, color 0.15s;
  border-color: #b8d4ea;
}

.pill-hora-asignar:hover {
  background: #e0f0fa;
  border-color: #159a9a;
  color: #159a9a;
}

/* ---------- HISTORIA CLÍNICA ---------- */
.consulta-card {
  border: 1px solid var(--borde, #dbe3ea);
  border-radius: 10px;
  padding: 12px;
  margin: 12px 0;
  background: #fff;
}

.consulta-cab {
  font-weight: 700;
  margin-bottom: 8px;
  padding-bottom: 6px;
  border-bottom: 1px dashed var(--borde, #dbe3ea);
}

.consulta-card p {
  margin: 4px 0;
  font-size: 0.93rem;
  white-space: pre-wrap;
}

/* ---------- MODAL GENÉRICO ---------- */
.modal-capa {
  position: fixed;
  inset: 0;
  background: rgba(15, 30, 45, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 100;
}

.modal-caja {
  background: #fff;
  border-radius: 14px;
  max-width: 620px;
  width: 100%;
  max-height: 88vh;
  overflow-y: auto;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.3);
}

.modal-cab {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-weight: 800;
  font-size: 1.02rem;
  padding: 14px 18px;
  border-bottom: 1px solid var(--borde, #dbe3ea);
  position: sticky;
  top: 0;
  background: #fff;
}

.modal-x {
  border: none;
  background: none;
  font-size: 1.3rem;
  line-height: 1;
  cursor: pointer;
  color: #888;
}

.modal-cuerpo {
  padding: 16px 18px;
}

.modal-pie {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 12px 18px;
  border-top: 1px solid var(--borde, #dbe3ea);
}

/* ---------- REPORTES ---------- */
.rep-totales {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 10px;
  margin-bottom: 16px;
}

.rep-tile {
  background: #f4f8fb;
  border: 1px solid var(--borde, #dbe3ea);
  border-radius: 12px;
  padding: 12px;
  text-align: center;
}

.rep-tile b {
  display: block;
  font-size: 1.6rem;
  color: var(--primario, #2f6f9f);
}

.rep-tile span {
  font-size: 0.82rem;
  color: #666;
}

.dispo-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 12px;
}

.usr-estado {
  width: auto;
  display: inline-block;
  font-size: 0.85rem;
}

/* ---------- RESPONSIVE ---------- */
@media (max-width: 700px) {
  .nav-inner {
    justify-content: space-between;
  }
  .nav-user {
    order: 1;
    flex: 1 1 auto;
    min-width: 0;
  }
  .nav-salir {
    order: 2;
  }
  .nav-tabs {
    order: 3;
    width: 100%;
    justify-content: center;
  }
  .fila-turno .acciones {
    justify-content: flex-start;
  }
  input.input, select.input, textarea.input {
    font-size: 16px;
  }
}

/* ==================== CHAT ==================== */
.nav-tabs .tab {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.tab-badge {
  background: #e11d48;
  color: #fff;
  border-radius: 999px;
  font-size: 0.68rem;
  font-weight: 700;
  line-height: 1;
  padding: 3px 6px;
  min-width: 18px;
  text-align: center;
}

.tab-badge[hidden] {
  display: none;
}

.chat-card {
  display: flex;
  flex-direction: column;
  padding: 0;
  overflow: hidden;
}

.chat-msgs {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 16px;
  max-height: 58vh;
  min-height: 320px;
  overflow-y: auto;
  background: #f7f8fa;
}

.chat-msg {
  max-width: 78%;
  border-radius: 12px;
  padding: 8px 12px;
  background: #fff;
  border: 1px solid #e2e5ea;
  align-self: flex-start;
}

.chat-msg.mio {
  align-self: flex-end;
  background: #0f766e;
  border-color: #0f766e;
  color: #fff;
}

.chat-meta {
  font-size: 0.72rem;
  opacity: 0.72;
  margin-bottom: 4px;
}

.chat-texto {
  white-space: pre-wrap;
  word-break: break-word;
  line-height: 1.35;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translate(-50%, 20px);
  max-width: min(92vw, 460px);
  padding: 12px 18px;
  border-radius: 10px;
  background: #0f172a;
  color: #fff;
  font-size: 0.92rem;
  line-height: 1.35;
  box-shadow: 0 10px 30px rgba(15, 23, 42, 0.3);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
  z-index: 1200;
  text-align: center;
}

.toast.visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

.toast.err { background: var(--rojo, #dc2626); }
.toast.ok { background: #0f766e; }

.usr-filtros { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }

.pill-filtro {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 12px;
  border-radius: 999px;
  border: 1px solid #e2e8f0;
  background: #fff;
  color: #0f172a;
  font-size: 0.85rem;
  font-family: inherit;
  cursor: pointer;
}

.pill-filtro:hover { border-color: #159a9a; }

.pill-filtro.activo {
  background: #159a9a;
  border-color: #159a9a;
  color: #fff;
  font-weight: 600;
}

.pill-cuenta {
  background: rgba(15, 23, 42, 0.1);
  border-radius: 999px;
  padding: 0 7px;
  font-size: 0.75rem;
  line-height: 1.5;
}

.pill-filtro.activo .pill-cuenta { background: rgba(255, 255, 255, 0.25); }

/* ---------- FILA DE USUARIOS (grilla fija: controles siempre alineados) ---------- */
.usr-fila {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px 16px;
  padding: 12px 0;
  border-bottom: 1px dashed var(--borde, #dbe3ea);
}

.usr-info { min-width: 0; }

.usr-info > div + div { margin-top: 3px; }

.usr-ctrl {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
  flex-wrap: nowrap;
}

.usr-ctrl .usr-estado { width: 128px; flex: 0 0 128px; }

.usr-fila:last-child { border-bottom: 0; }

@media (max-width: 700px) {
  .usr-fila { grid-template-columns: 1fr; }
  .usr-ctrl { justify-content: flex-start; flex-wrap: wrap; }
  .usr-ctrl .usr-estado { width: auto; flex: 1 1 150px; }
}

/* ---------- AVATAR ---------- */
.avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  object-fit: cover;
  background: #e2e8f0;
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.avatar.ini {
  background: #159a9a;
  color: #fff;
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.3px;
}

.avatar-grande {
  width: 96px;
  height: 96px;
  font-size: 1.7rem;
}

.nav-ident {
  display: inline-flex;
  flex-direction: column;
  align-items: flex-start;
  background: none;
  border: 0;
  padding: 0;
  font-family: inherit;
  cursor: pointer;
  text-align: left;
}

.nav-ident:hover .nav-nombre { text-decoration: underline; }

.nav-user { flex-wrap: nowrap; }

.nav-user .avatar { width: 34px; height: 34px; }

.nav-ident .nav-roles,
.nav-ident .nav-nombre,
.nav-ident .nav-especialidad { line-height: 1.2; }

.nav-inner > .nav-user:only-child { margin-right: auto; }

.perfil-top {
  display: flex;
  gap: 18px;
  align-items: flex-start;
  margin-bottom: 16px;
}

.perfil-foto { text-align: center; }

.perfil-foto-botones {
  margin-top: 10px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: center;
}

.perfil-foto .mini-ayuda { max-width: 190px; margin-top: 6px; }

.perfil-campos { flex: 1 1 auto; min-width: 0; }

@media (max-width: 700px) {
  .perfil-top { flex-direction: column; align-items: center; }
  .perfil-campos { width: 100%; }
}

/* ---------- ACCESO DEL PACIENTE ---------- */
.acceso-box {
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  padding: 14px;
  background: #f8fafc;
}

.acceso-margin { margin-top: 4px; }

.acceso-ok {
  background: #ecfdf5;
  border: 1px solid #a7f3d0;
  color: #065f46;
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 0.88rem;
  margin-bottom: 12px;
}

.acceso-err {
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: #991b1b;
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 0.88rem;
  margin-bottom: 12px;
}

.acceso-datos { display: grid; gap: 8px; margin-bottom: 12px; }

.acceso-datos > div { display: flex; gap: 10px; align-items: baseline; font-size: 0.9rem; }

.acceso-datos span { color: #64748b; min-width: 96px; }

.acceso-datos b { word-break: break-all; }

.acceso-link { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 0.82rem; }

/* ---------- ALERTA DE PACIENTES NUEVOS ---------- */
.alerta-nuevos {
  border-left: 4px solid #d97706;
  background: #fffbeb;
}

.alerta-nuevos-titulo {
  font-weight: 700;
  color: #92400e;
  margin-bottom: 4px;
}

.alerta-nuevos .acciones { margin-top: 10px; }

.fila-nueva {
  background: #fffbeb;
  border-left: 3px solid #d97706;
  border-radius: 6px;
  padding-left: 8px;
}

.badge-nuevo {
  background: #d97706;
  color: #fff;
  font-size: 0.68rem;
  padding: 2px 7px;
  border-radius: 999px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  vertical-align: middle;
}

/* ---------- ADJUNTOS ---------- */
.adj-subir {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  padding: 12px;
  border: 1px dashed #cbd5e1;
  border-radius: 12px;
  background: #f8fafc;
  margin-bottom: 12px;
}

.adj-subir .mini-ayuda { flex: 1 1 100%; }

.adj-fila {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
  padding: 9px 0;
  border-bottom: 1px dashed var(--borde, #dbe3ea);
}

.adj-fila:last-child { border-bottom: 0; }

.adj-nombre {
  font-weight: 600;
  color: #0e7490;
  word-break: break-all;
  flex: 1 1 220px;
}

.adj-fila .gris { font-size: 0.8rem; flex: 0 1 auto; }

.mini-ayuda { font-size: 0.76rem; color: #64748b; margin-top: 4px; }

.mini-ayuda.ok { color: #15803d; }

.mini-ayuda.err { color: #b91c1c; }

.cp-hecho {
  margin-top: 12px;
  padding: 10px 12px;
  border-radius: 8px;
  background: #ecfdf5;
  border: 1px solid #6ee7b7;
  color: #065f46;
  font-size: 0.88rem;
}

.cp-hecho.err {
  background: #fef2f2;
  border-color: #fca5a5;
  color: #991b1b;
}

.wa-panel { text-align: left; }

.wa-titulo { font-weight: 600; color: #111827; margin-bottom: 6px; }

.wa-alerta {
  background: #fff7ed;
  border: 1px solid #fdba74;
  border-radius: 8px;
  padding: 10px;
  font-size: 0.85rem;
  color: #9a3412;
}

.wa-cel-falla {
  background: #fef2f2;
  border: 1px solid #fca5a5;
  border-radius: 8px;
  padding: 10px;
  font-size: 0.85rem;
  color: #991b1b;
  margin-bottom: 8px;
}

.wa-alerta-chica {
  display: inline-block;
  background: #fff7ed;
  border: 1px solid #fdba74;
  border-radius: 8px;
  padding: 6px 8px;
  font-size: 0.78rem;
  color: #9a3412;
}

.wa-numero { font-size: 0.78rem; margin-top: 8px; }

.wa-ver { margin-top: 10px; font-size: 0.8rem; color: #4b5563; }

.wa-ver pre {
  white-space: pre-wrap;
  word-break: break-word;
  background: #f3f4f6;
  border-radius: 8px;
  padding: 10px;
  font-size: 0.78rem;
  color: #374151;
  margin: 6px 0 0;
}

.busca-nota { font-size: 0.8rem; margin-top: 4px; }

.busca-res { margin-top: 8px; }

.busca-vacio { font-size: 0.85rem; color: #6b7280; padding: 8px 0; }

.busca-item {
  display: block;
  width: 100%;
  text-align: left;
  padding: 8px 10px;
  border: 1px solid #e2e5ea;
  border-radius: 8px;
  background: #fff;
  cursor: pointer;
  margin-bottom: 6px;
  font: inherit;
}

.busca-item:hover { border-color: #2563eb; background: #f5f8ff; }

.busca-nom { display: block; font-weight: 600; color: #111827; }

.busca-det { display: block; font-size: 0.8rem; color: #6b7280; }

.busca-elegido {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 10px;
  padding: 10px;
  border: 1px solid #2563eb;
  border-radius: 8px;
  background: #f5f8ff;
}

.busca-nuevo { border: 1px dashed #cbd5e1; border-radius: 8px; padding: 10px; }

.chat-avisos {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  padding: 10px 12px;
  border-bottom: 1px solid #e2e5ea;
  background: #fbfcfd;
}

.chat-avisos-txt {
  font-size: 0.82rem;
  color: #4b5563;
}

.chat-form {
  display: flex;
  gap: 8px;
  padding: 12px;
  border-top: 1px solid #e2e5ea;
  background: #fff;
}

.chat-form .input {
  flex: 1 1 auto;
}

.chat-wrap {
  display: grid;
  grid-template-columns: 260px 1fr;
  gap: 12px;
  align-items: start;
}

.chat-contactos {
  padding: 10px;
  max-height: 68vh;
  overflow-y: auto;
}

.chat-contactos-titulo {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #6b7280;
  margin-bottom: 8px;
  padding: 0 4px;
}

.chat-contacto {
  display: flex;
  flex-direction: column;
  gap: 2px;
  width: 100%;
  text-align: left;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 8px 10px;
  cursor: pointer;
  margin-bottom: 4px;
}

.chat-contacto:hover {
  background: #f1f5f9;
}

.chat-contacto.activo {
  background: #e0f2f1;
  border-color: #0f766e;
}

.chat-contacto-nom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  font-weight: 600;
  font-size: 0.9rem;
}

.chat-contacto-rol {
  font-size: 0.72rem;
  color: #6b7280;
}

.chat-contacto-prev {
  font-size: 0.78rem;
  color: #4b5563;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chat-mini-badge {
  background: #e11d48;
  color: #fff;
  border-radius: 999px;
  font-size: 0.65rem;
  font-weight: 700;
  padding: 2px 6px;
}

@media (max-width: 700px) {
  .chat-wrap {
    grid-template-columns: 1fr;
  }
  .chat-contactos {
    max-height: 34vh;
  }
}

@media (max-width: 700px) {
  .chat-msgs {
    max-height: 66vh;
  }
  .chat-msg {
    max-width: 88%;
  }
}

/* ==================== TURNOS DE HOY / LISTA DE ESPERA ==================== */
.hoy-resumen {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.hoy-chip {
  background: #eef1f5;
  border-radius: 999px;
  padding: 5px 12px;
  font-size: 0.85rem;
}

.hoy-chip b {
  font-size: 0.95rem;
}

.hoy-chip.ok {
  background: #dcfce7;
  color: #166534;
}

.hoy-chip.pend {
  background: #fef3c7;
  color: #92400e;
}

.hoy-lista {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 18px;
}

.hoy-fila {
  align-items: center;
}

.hoy-fila.en-atencion {
  background: #f0fdf4;
  border-left: 3px solid #16a34a;
}
/* ============ Historia clinica integral (v57) ============ */
.hc-consulta {
  border: 1px solid var(--borde, #e2e2e2);
  border-radius: 10px;
  padding: 12px 14px;
  margin-bottom: 12px;
  background: #fff;
}
.hc-consulta.hc-ajena {
  background: #fafafa;
  border-left: 3px solid #bbb;
}
.hc-consulta-head {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 4px;
}
.badge-lectura {
  display: inline-block;
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 10px;
  background: #ececec;
  color: #555;
  border: 1px solid #d5d5d5;
}
.hc-adjuntos {
  margin-top: 6px;
  font-size: 13px;
}
.hc-filtros {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 10px;
  align-items: end;
}
.hc-resumen {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 10px;
}
.hc-resumen-item {
  border: 1px solid var(--borde, #e2e2e2);
  border-radius: 10px;
  padding: 10px 12px;
  background: #fff;
}
.hc-resumen-item b {
  font-size: 20px;
  display: block;
}

/* ============ Tabla de permisos (v57) ============ */
.tabla-wrap { overflow-x: auto; }
.tabla {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}
.tabla th, .tabla td {
  border: 1px solid #e2e2e2;
  padding: 8px 10px;
  text-align: left;
  vertical-align: middle;
}
.tabla th { background: #f4f4f4; font-weight: 600; }
.tabla tr:nth-child(even) td { background: #fcfcfc; }

/* ============ Movimientos de turnos ============ */
.mov-linea { font-size: 0.8rem; color: #6b7280; margin-top: 2px; }
.hist-lista { display: grid; gap: 8px; max-height: 60vh; overflow-y: auto; }
.hist-fila {
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  padding: 8px 10px;
  background: #fff;
}
