html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, Arial, sans-serif;
  background: #f4f6f8;
}

body {
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
  box-sizing: border-box;
}

/* ── Chrome (en flujo normal, arriba del contenedor) ── */
#appChrome {
  position: relative;
  z-index: 2147483000;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.12);
}

#installBanner {
  display: none;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: #00c389;
  color: #fff;
  font-size: 14px;
  font-weight: 600;
}

#installBanner button {
  margin-left: auto;
  border: none;
  border-radius: 6px;
  background: #fff;
  color: #00c389;
  font-weight: 700;
  padding: 6px 14px;
  cursor: pointer;
}

#installBanner button#dismissInstall {
  background: transparent;
  color: #fff;
  padding: 6px 8px;
}

/* ── Cabecera institucional ───────────────────────── */
#appHeader {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  background: #00c389;
  color: #fff;
  flex-shrink: 0;
}

#appHeader h1 {
  margin: 0;
  font-size: 20px;
}

.header-logo {
  width: 34px;
  height: 34px;
  border-radius: 8px;
}

/* ── Menú hamburguesa (header) ────────────────────── */
#menuWrap {
  position: relative;
}

#hamburgerBtn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  margin-left: -6px;
  padding: 0;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: #fff;
  cursor: pointer;
}

#hamburgerBtn:active {
  background: rgba(255, 255, 255, 0.18);
}

#hamburgerBtn .material-symbols-outlined {
  font-size: 28px;
  line-height: 1;
}

#menuDropdown {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  z-index: 2147483100;
  display: flex;
  flex-direction: column;
  min-width: 210px;
  background: #fff;
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.22);
  overflow: hidden;
}

#menuDropdown[hidden] {
  display: none;
}

#menuDropdown button {
  padding: 13px 16px;
  border: none;
  background: transparent;
  color: #333;
  font-family: inherit;
  font-size: 15px;
  font-weight: 600;
  text-align: left;
  cursor: pointer;
}

#menuDropdown button:hover {
  background: #f1f5f7;
}

/* ── Toggle (Chatea con Alma / Mi Perfil) ─────────── */
#toggleNav {
  display: flex;
  gap: 4px;
  padding: 8px;
  background: #e8eded;
  border-bottom: 1px solid #d9e0e4;
  flex-shrink: 0;
}

.tab {
  flex: 1;
  padding: 10px;
  border: none;
  border-radius: 8px;
  background: transparent;
  font-weight: 600;
  font-size: 14px;
  color: #555;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}

.tab.active {
  background: #fff;
  color: #00c389;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.14);
}

.tab:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

/* ── Vistas ───────────────────────────────────────── */
.view {
  flex: 1;
  overflow: hidden;
  display: none;
}

.view.active {
  display: block;
}

#chatView {
  position: relative;
  z-index: 1;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

#botmaker-webchat-container {
  position: relative;
  z-index: 1;
  overflow: hidden;
  height: 100%;
  width: 100%;
}

#botmaker-webchat-container > div {
  position: absolute !important;
  top: 0 !important;
  left: 0 !important;
  right: 0 !important;
  bottom: 0 !important;
  width: 100% !important;
  height: 100% !important;
  box-sizing: border-box !important;
}

#botmaker-webchat-container iframe {
  width: 100% !important;
  height: 100% !important;
}

#perfilView {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 16px;
  box-sizing: border-box;
}

/* ── Formulario DNI ───────────────────────────────── */
#dniForm {
  background: #fff;
  border-radius: 12px;
  padding: 20px;
  margin: 8px 0;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
}

#dniForm p {
  margin: 0 0 12px;
  color: #444;
  font-size: 14px;
}

#dniForm input {
  width: 100%;
  box-sizing: border-box;
  padding: 12px;
  border: 1px solid #ccc;
  border-radius: 8px;
  font-size: 16px;
  margin-bottom: 12px;
}

#dniForm button {
  width: 100%;
  padding: 12px;
  border: none;
  border-radius: 8px;
  background: #00c389;
  color: #fff;
  font-weight: 700;
  font-size: 15px;
  cursor: pointer;
}

#dniError {
  color: #d32f2f;
  font-size: 13px;
  margin: 8px 0 0;
}

/* ── Tarjeta de Credencial ────────────────────────── */
.card_C {
  background-image: linear-gradient(to right, #985398, #872f79);
  color: #fff;
}

#credencialCard {
  position: relative;
  border-radius: 16px;
  padding: 18px 20px 20px;
  margin: 8px 0;
  box-shadow: 0 4px 12px rgba(135, 47, 121, 0.3);
  overflow: hidden;
}

.ocultar {
  float: right;
  margin: 15px 20px 0 0;
}

.credencial-tag {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.9);
}

.card_logo {
  margin: 10px 12px;
  background-repeat: no-repeat;
  height: 20px;
  background-size: 60px auto;
}

.card_logo_C {
  background-image: url(logos/osep.png);
}

#credencialNumeroRow {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin: 40px 25px 10px;
}

#credencialNumero {
  font-family: 'Courier New', monospace;
  font-size: 22px;
  font-weight: 700;
  letter-spacing: 1.5px;
  line-height: 1.3;
  text-align: center;
  color: #fff;
}

#toggleCredencialBtn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  padding: 0;
  border: none;
  background: transparent;
  color: #fff;
  opacity: 0.9;
  cursor: pointer;
  flex-shrink: 0;
}

#toggleCredencialBtn svg {
  width: 20px;
  height: 20px;
}

#toggleCredencialBtn:disabled {
  opacity: 0.35;
  cursor: default;
}

#toggleCredencialBtn:not(:disabled):active {
  transform: scale(0.9);
}

#credencialError {
  min-height: 14px;
  margin-top: 6px;
  font-size: 12px;
  text-align: center;
  color: #ffe1e1;
}

#credencialAfiliado {
  font-size: 12px;
  font-family: 'Courier New', monospace;
  text-align: center;
  color: rgba(255, 255, 255, 0.85);
}

#credencialNombre {
  margin: 10px 25px;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.5px;
  font-family: 'Courier New', monospace;
  text-transform: uppercase;
  text-align: center;
}

/* ── Token de Atención ────────────────────────────── */
#tokenBlock {
  margin-top: 12px;
  background: #fff;
  color: #333;
  border-radius: 12px;
  padding: 14px;
  text-align: center;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
}

#tokenBlock h4 {
  margin: 0 0 8px;
  font-size: 11px;
  letter-spacing: 1.5px;
  color: #888;
}

#tokenRow {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

#tokenCode {
  font-size: 34px;
  font-weight: 800;
  letter-spacing: 8px;
  font-family: 'Courier New', monospace;
  color: #00c389;
}

#copyTokenBtn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border: none;
  border-radius: 8px;
  background: #00c389;
  color: #fff;
  cursor: pointer;
  transition: background 0.15s ease, transform 0.1s ease;
}

#copyTokenBtn svg {
  width: 18px;
  height: 18px;
}

#copyTokenBtn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

#copyTokenBtn:not(:disabled):active {
  transform: scale(0.92);
}

#copyTokenBtn.copied {
  background: #872f79;
}

#tokenCountdown {
  font-size: 13px;
  color: #666;
  margin: 6px 0;
}

#generarTokenBtn {
  margin-top: 8px;
  padding: 10px 18px;
  border: none;
  border-radius: 8px;
  background: #00c389;
  color: #fff;
  font-weight: 700;
  cursor: pointer;
}

/* ── Grupo Familiar ───────────────────────────────── */
#grupoFamiliarSection {
  background: #fff;
  border-radius: 12px;
  padding: 16px;
  margin-top: 12px;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
}

#grupoFamiliarSection h3 {
  margin: 0 0 12px;
  font-size: 15px;
  color: #333;
}

#familiaList {
  list-style: none;
  margin: 0;
  padding: 0;
}

#familiaList li {
  padding: 12px;
  border-radius: 8px;
  border: 1px solid #eee;
  margin-bottom: 8px;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
}

#familiaList li:hover {
  border-color: #00c389;
  background: #f0fbf7;
}

#familiaList li.selected {
  border-color: #00c389;
  background: #e6f7f0;
}

#familiaList .fam-nombre {
  font-weight: 700;
  color: #222;
}

#familiaList .fam-afiliado {
  font-size: 12px;
  color: #777;
}

