/* ============================================================================
   RB Servicios Generales — Base: reset, tipografía, componentes compartidos
   ========================================================================= */

*, *::before, *::after { box-sizing: border-box; }

* { margin: 0; }

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--alto-barra) + var(--e-4));
}

body {
  font-family: var(--fuente-texto);
  font-size: var(--txt-base);
  line-height: 1.6;
  color: var(--txt-principal);
  background: var(--sup-fondo);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

img, svg, video, canvas { display: block; max-width: 100%; }
img, video { height: auto; }

input, button, textarea, select { font: inherit; color: inherit; }

h1, h2, h3, h4 {
  font-family: var(--fuente-titulo);
  font-weight: 800;
  line-height: 1.12;
  letter-spacing: -0.02em;
  text-wrap: balance;
}

h1 { font-size: clamp(2.1rem, 5.2vw, var(--txt-5xl)); }
h2 { font-size: clamp(1.7rem, 4vw, var(--txt-3xl)); }
h3 { font-size: var(--txt-lg); font-weight: 700; letter-spacing: -0.01em; }
h4 { font-size: var(--txt-base); font-weight: 700; letter-spacing: 0; }

p { text-wrap: pretty; }

a { color: var(--rb-azul-500); text-decoration-thickness: 1.5px; text-underline-offset: 2px; }
a:hover { color: var(--marca-hover); }

:focus-visible {
  outline: 3px solid var(--rb-azul-500);
  outline-offset: 2px;
  border-radius: var(--r-sm);
}

::selection { background: var(--rb-ambar-300); color: var(--rb-tinta); }

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
}

/* ---- Utilidades ---------------------------------------------------------- */
.contenedor {
  width: 100%;
  max-width: var(--ancho-max);
  margin-inline: auto;
  padding-inline: var(--e-5);
}

.solo-lectores {
  position: absolute; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

.saltar-al-contenido {
  position: absolute; top: -100px; left: var(--e-4); z-index: 200;
  background: var(--rb-ambar-500); color: var(--rb-tinta);
  padding: var(--e-3) var(--e-5); border-radius: var(--r-md); font-weight: 700;
}
.saltar-al-contenido:focus { top: var(--e-4); }

[hidden] { display: none !important; }

/* ---- Botones ------------------------------------------------------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--e-2);
  padding: var(--e-3) var(--e-5);
  min-height: 46px;
  font-family: var(--fuente-texto);
  font-size: var(--txt-sm);
  font-weight: 650;
  line-height: 1.2;
  text-decoration: none;
  border: 1.5px solid transparent;
  border-radius: var(--r-md);
  cursor: pointer;
  transition: background var(--trans-rapida), border-color var(--trans-rapida),
              color var(--trans-rapida), transform var(--trans-rapida),
              box-shadow var(--trans-rapida);
  white-space: nowrap;
}
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn svg { flex: none; width: 18px; height: 18px; }

.btn--acento {
  background: var(--rb-ambar-500); color: var(--rb-tinta);
  box-shadow: var(--sombra-sm);
}
.btn--acento:hover:not(:disabled) { background: var(--rb-ambar-600); color: var(--rb-tinta); }

.btn--marca { background: var(--rb-azul-700); color: #fff; }
.btn--marca:hover:not(:disabled) { background: var(--rb-azul-600); color: #fff; }

.btn--contorno {
  background: transparent; color: var(--txt-principal); border-color: var(--borde);
}
.btn--contorno:hover:not(:disabled) {
  border-color: var(--marca); color: var(--marca); background: var(--rb-azul-50);
}

.btn--fantasma { background: transparent; color: var(--txt-secundario); }
.btn--fantasma:hover:not(:disabled) { background: var(--sup-suave); color: var(--txt-principal); }

.btn--claro { background: #fff; color: var(--rb-azul-700); }
.btn--claro:hover:not(:disabled) { background: var(--rb-azul-50); color: var(--rb-azul-700); }

.btn--whatsapp { background: var(--rb-whatsapp); color: #06251A; }
.btn--whatsapp:hover:not(:disabled) { background: #1FBE5B; color: #06251A; }

.btn--peligro { background: var(--rb-error); color: #fff; }
.btn--peligro:hover:not(:disabled) { background: #93190F; color: #fff; }

.btn--sm { min-height: 36px; padding: var(--e-2) var(--e-3); font-size: var(--txt-xs); }
.btn--sm svg { width: 15px; height: 15px; }
.btn--lg { min-height: 56px; padding: var(--e-4) var(--e-8); font-size: var(--txt-base); }
.btn--bloque { width: 100%; }
.btn--icono { padding: var(--e-2); min-height: 38px; min-width: 38px; }
.btn--icono svg { width: 17px; height: 17px; }

/* ---- Etiquetas de estado ------------------------------------------------- */
.chip {
  display: inline-flex; align-items: center; gap: var(--e-1);
  padding: 3px var(--e-2);
  font-size: var(--txt-xs); font-weight: 650; line-height: 1.5;
  border-radius: var(--r-full);
  white-space: nowrap;
}
.chip::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.chip--borrador  { background: var(--rb-gris-100); color: var(--rb-gris-700); }
.chip--enviada   { background: var(--rb-aviso-bg); color: var(--rb-aviso); }
.chip--aprobada  { background: var(--rb-exito-bg); color: var(--rb-exito); }
.chip--ejecucion { background: var(--rb-info-bg);  color: var(--rb-info); }
.chip--rechazada { background: var(--rb-error-bg); color: var(--rb-error); }
.chip--vencida   { background: var(--rb-error-bg); color: var(--rb-error); }

/* ---- Campos de formulario ------------------------------------------------ */
.campo { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.campo > label, .etiqueta {
  font-size: var(--txt-xs); font-weight: 650;
  color: var(--txt-secundario);
  text-transform: uppercase; letter-spacing: .04em;
}
.campo .ayuda { font-size: var(--txt-xs); color: var(--txt-secundario); }
.campo .error { font-size: var(--txt-xs); color: var(--rb-error); font-weight: 600; }

.entrada, .selector, .area {
  width: 100%;
  padding: var(--e-3);
  font-size: var(--txt-sm);
  color: var(--txt-principal);
  background: var(--sup-panel);
  border: 1.5px solid var(--borde);
  border-radius: var(--r-md);
  transition: border-color var(--trans-rapida), box-shadow var(--trans-rapida);
}
.entrada:hover, .selector:hover, .area:hover { border-color: var(--rb-gris-400); }
.entrada:focus, .selector:focus, .area:focus {
  outline: none; border-color: var(--rb-azul-500); box-shadow: var(--anillo);
}
.entrada::placeholder, .area::placeholder { color: var(--rb-gris-400); }
.entrada[aria-invalid="true"], .area[aria-invalid="true"] { border-color: var(--rb-error); }
.area { min-height: 90px; resize: vertical; line-height: 1.55; }
.selector {
  appearance: none;
  padding-right: var(--e-8);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%23667085' stroke-width='2' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right var(--e-3) center;
}
.entrada--num { text-align: right; font-variant-numeric: tabular-nums; }

.fila { display: grid; gap: var(--e-4); }
.fila--auto { grid-template-columns: repeat(auto-fit, minmax(148px, 1fr)); }
@media (min-width: 640px) {
  .fila--2 { grid-template-columns: repeat(2, 1fr); }
  .fila--3 { grid-template-columns: repeat(3, 1fr); }
  .fila--4 { grid-template-columns: repeat(4, 1fr); }
}

/* ---- Avisos flotantes ---------------------------------------------------- */
.avisos {
  position: fixed; z-index: 300;
  bottom: var(--e-5); left: 50%; transform: translateX(-50%);
  display: flex; flex-direction: column; gap: var(--e-2);
  width: min(440px, calc(100vw - 2 * var(--e-4)));
  pointer-events: none;
}
.aviso {
  display: flex; align-items: flex-start; gap: var(--e-3);
  padding: var(--e-3) var(--e-4);
  background: var(--rb-tinta); color: #fff;
  border-radius: var(--r-md); box-shadow: var(--sombra-xl);
  font-size: var(--txt-sm); font-weight: 550;
  animation: aviso-entra 220ms cubic-bezier(.2, .9, .3, 1.2);
  pointer-events: auto;
}
.aviso--exito { background: var(--rb-exito); }
.aviso--error { background: var(--rb-error); }
.aviso--aviso { background: var(--rb-aviso); }
.aviso svg { flex: none; width: 18px; height: 18px; margin-top: 1px; }
@keyframes aviso-entra { from { opacity: 0; transform: translateY(14px) scale(.97); } }

/* ---- Ventanas modales ---------------------------------------------------- */
dialog.modal {
  /* margin:auto es lo que centra un <dialog> modal; el reset `* { margin: 0 }`
     de más arriba lo pisaba y los modales quedaban pegados arriba a la izquierda. */
  margin: auto;
  width: min(620px, calc(100vw - 2 * var(--e-4)));
  max-height: min(86vh, 900px);
  padding: 0;
  border: none;
  border-radius: var(--r-lg);
  background: var(--sup-panel);
  color: var(--txt-principal);
  box-shadow: var(--sombra-xl);
  overflow: hidden;
}
dialog.modal::backdrop { background: rgba(10, 21, 51, .55); backdrop-filter: blur(3px); }
dialog.modal .modal__cab {
  display: flex; align-items: center; justify-content: space-between; gap: var(--e-4);
  padding: var(--e-5); border-bottom: 1px solid var(--borde-suave);
}
dialog.modal .modal__cuerpo { padding: var(--e-5); overflow-y: auto; max-height: 60vh; }
dialog.modal .modal__pie {
  display: flex; gap: var(--e-3); justify-content: flex-end;
  padding: var(--e-4) var(--e-5); border-top: 1px solid var(--borde-suave);
  background: var(--sup-suave); flex-wrap: wrap;
}

/* ---- Impresión ----------------------------------------------------------- */
@media print {
  .no-imprimir, .barra, .pie, .flotante { display: none !important; }
  body { background: #fff; }
}
