/* =========================================================
   Pompeyo Agendamiento — CSS FULL (OPTIMIZADO + LIVIANO) ✅
   + ✅ Retiro y entrega a domicilio (Paso 3)
========================================================== */

/* ============ Tokens ============ */
:root{
  --p-blue:#0b6ef3;
  --p-bg:#f6f7fb;
  --p-card:#fff;
  --p-text:#0f172a;
  --p-muted:rgba(15,23,42,.65);
  --p-border:rgba(15,23,42,.10);
  --p-border-strong:rgba(15,23,42,.16);
  --p-shadow:0 12px 28px rgba(2,6,23,.08);
  --p-radius:18px;
}

/* ============ Layout general ============ */
.pompeyo-agend{
  max-width: 860px;
  margin: 0 auto;
  padding: 8px 16px;
  color: var(--p-text);
  position: relative;
}
.pompeyo-agend__title{
  margin: 0 0 10px;
  font-weight: 900;
  letter-spacing: -.02em;
  font-size: clamp(22px, 2.4vw, 28px);
}

/* ============ Stepper (desktop/tablet) ============ */
.pompeyo-steps{
  display:flex;
  flex-wrap:wrap;
  gap: 8px;
  align-items:center;
  justify-content: center;
  padding: 12px 16px;
  margin: 0 0 14px;
  border: 1px solid var(--p-border);
  border-radius: var(--p-radius);
  background: linear-gradient(180deg, #fff, #fbfcff);
  box-shadow: 0 8px 18px rgba(2,6,23,.04);
}
.pompeyo-steps .step{
  display:flex;
  align-items:center;
  gap: 10px;
  padding: 8px 12px;
  border-radius: 999px;
  border: 1px solid transparent;
  background: transparent;
  opacity: .65;
  user-select:none;
  transition: all .18s ease;
  flex: 0 0 auto;
}
.pompeyo-steps .step .num{
  width: 26px;
  height: 26px;
  display:grid;
  place-items:center;
  border-radius: 999px;
  font-weight: 900;
  font-size: 13px;
  border: 1px solid var(--p-border);
  background: #fff;
}
.pompeyo-steps .step .txt{
  font-weight: 800;
  font-size: 13px;
  letter-spacing: -.01em;
  color: var(--p-muted);
}
.pompeyo-steps .step.is-active{
  opacity: 1;
  border-color: rgba(11,110,243,.28);
  background: rgba(11,110,243,.08);
}
.pompeyo-steps .step.is-active .num{ border-color: rgba(11,110,243,.30); }
.pompeyo-steps .step.is-done{ opacity: 1; }
.pompeyo-steps .step.is-done .num{
  background: rgba(11,110,243,.12);
  border-color: rgba(11,110,243,.25);
}
.pompeyo-steps .step.is-done .txt{ color: rgba(15,23,42,.80); }

/* ============ Cards ============ */
.pompeyo-agend__card{
  background: var(--p-card);
  border: 1px solid var(--p-border);
  border-radius: var(--p-radius);
  padding: 18px 20px;
  margin: 0 0 12px;
  box-shadow: var(--p-shadow);
  overflow:hidden;
  position: relative;
  animation: pop .18s ease;
}
@keyframes pop{
  from { transform: translateY(4px); opacity: 0; }
  to   { transform: translateY(0); opacity: 1; }
}

/* ============ Form base ============ */
.pompeyo-agend label{
  display:block;
  font-size: 12px;
  margin: 12px 0 6px;
  color: var(--p-muted);
  font-weight: 800;
  letter-spacing: .01em;
}
.pompeyo-agend :where(input, select, textarea){
  width: 100%;
  border: 1px solid var(--p-border-strong);
  border-radius: 14px;
  padding: 11px 12px;
  font-size: 14px;
  outline: none;
  background: #fff;
  transition: border-color .15s ease, box-shadow .15s ease;
  min-width: 0;
  max-width: 100%;
  box-sizing: border-box;
}
.pompeyo-agend :where(input, select, textarea):focus{
  border-color: rgba(11,110,243,.55);
  box-shadow: 0 0 0 4px rgba(11,110,243,.12);
}
.pompeyo-agend textarea{
  min-height: 96px;
  resize: vertical;
}

/* ============ Buttons ============ */
.pompeyo-agend button{
  border: 0;
  border-radius: 14px;
  padding: 11px 14px;
  font-weight: 900;
  cursor: pointer;
  background: var(--p-blue);
  color: #fff;
  transition: transform .06s ease, filter .15s ease, opacity .15s ease;
  white-space: nowrap;
  box-sizing: border-box;
}
.pompeyo-agend button:hover{ filter: brightness(1.02); }
.pompeyo-agend button:active{ transform: translateY(1px); }
.pompeyo-agend button:disabled{
  opacity: .45;
  cursor:not-allowed;
  transform: none;
}

/* ============ Info boxes ============ */
.pompeyo-agend .info{
  margin-top: 10px;
  font-size: 13px;
  line-height: 1.35;
  color: rgba(15,23,42,.85);
  padding: 10px 12px;
  border-radius: 14px;
  background: rgba(15,23,42,.04);
  border: 1px dashed rgba(15,23,42,.16);
}
.pompeyo-agend .info:empty{ display:none; }
.pompeyo-agend .hint{
  margin: 0 0 10px;
  font-size: 13px;
  color: rgba(15,23,42,.70);
}
.is-hidden{ display: none; }
.subcard{
  margin-top: 12px;
  padding: 14px;
  border-radius: 16px;
  background: rgba(2,6,23,.03);
  border: 1px dashed rgba(15,23,42,.18);
}

/* ============ Header + Editar + Accordion ============ */
.p-card-head{
  display:flex;
  align-items:flex-start;
  justify-content: space-between;
  gap: 12px;
}
.p-head-title{ font-weight: 900; letter-spacing: -.01em; }
.p-head-summary{
  margin-top: 3px;
  font-size: 12px;
  color: rgba(15,23,42,.62);
  font-weight: 700;
}
.p-edit{
  display: none;
  background: rgba(15,23,42,.08);
  color: rgba(15,23,42,.90);
  border: 0;
  padding: 9px 12px;
  border-radius: 999px;
  font-weight: 900;
}
.p-edit:disabled{ opacity: .40; cursor: not-allowed; }
.p-step.is-done .p-edit,
.pompeyo-agend__card.is-done .p-edit{
  display: inline-flex;
  align-items:center;
  justify-content:center;
}
.p-step.is-collapsed .p-card-body{ display: none; }
.p-step.is-open .p-card-body{ display: block; }

/* ============ Confirmar ============ */
.p-confirm-row{ display:flex; margin-top: 12px; }
.pompeyo-agend button[id^="btn-confirmar-"]{ width: fit-content; }

/* ============ Accesibilidad ============ */
.sr-only{
  position:absolute !important;
  width:1px !important;
  height:1px !important;
  padding:0 !important;
  margin:-1px !important;
  overflow:hidden !important;
  clip:rect(0,0,0,0) !important;
  white-space:nowrap !important;
  border:0 !important;
}

/* Paso 1 rail */
#cliente-section .p-card-body,
#cliente-section .p-rail--cliente{ max-width: none !important; }

#cliente-section .p-rail--cliente{
  width: 100% !important;
  margin: 0 !important;
  display: block !important;
}
#cliente-section .p-rail--cliente .p-row--rut{
  display: grid !important;
  grid-template-columns: minmax(0, 1fr) max-content !important;
  align-items: stretch !important;
  gap: 10px !important;
  width: 100% !important;
}
#cliente-section .p-rail--cliente .p-row--rut #rut{
  width: 100% !important;
  min-width: 0 !important;
  max-width: none !important;
}
#cliente-section .p-rail--cliente .p-row--rut #btn-consultar-cliente{
  width: auto !important;
  margin: 0 !important;
  justify-self: end !important;
  align-self: stretch !important;
  padding: 11px 16px !important;
}
#cliente-section .p-confirm-row{
  width: 100% !important;
  justify-content: flex-start !important;
}
#cliente-section #btn-confirmar-cliente{ min-width: 240px; }

/* Mobile stepper */
.pompeyo-steps .steps-mobile{ display: none; }

@media (max-width: 768px){
  .pompeyo-agend__card{ padding: 16px; }
}

@media (max-width: 540px){
  .pompeyo-agend{ padding: 8px 14px; }
  .pompeyo-agend__card{ padding: 14px; }

  .pompeyo-agend button{ width: 100%; }
  .p-confirm-row{ width: 100%; }
  .pompeyo-agend button[id^="btn-confirmar-"]{ width: 100%; min-width: 0; }

  #cliente-section .p-rail--cliente .p-row--rut{ grid-template-columns: 1fr !important; }
  #cliente-section .p-rail--cliente .p-row--rut #btn-consultar-cliente{
    width: 100% !important;
    justify-self: stretch !important;
  }
  #cliente-section #btn-confirmar-cliente{ width: 100% !important; min-width: 0 !important; }

  .p-card-head{
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 10px !important;
  }
  .p-card-head .p-head-left{ width: 100% !important; min-width: 0 !important; text-align: center !important; }
  .p-card-head .p-head-text{ width: 100% !important; text-align: center !important; }
  .p-card-head .p-head-title,
  .p-card-head .p-head-summary{ text-align: center !important; }
  .p-card-head .p-edit{
    width: 100% !important;
    border-radius: 14px !important;
    padding: 12px 14px !important;
    justify-content: center !important;
  }

  .pompeyo-steps .step{ display: none !important; }
  .pompeyo-steps .steps-mobile{ display: block !important; width: 100%; }
  .pompeyo-steps .steps-mobile__top{
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 6px;
  }
  .pompeyo-steps .steps-mobile__label{
    font-weight: 900;
    font-size: 13px;
    color: rgba(15,23,42,.75);
    letter-spacing: -.01em;
  }
  .pompeyo-steps .steps-mobile__name{
    font-weight: 900;
    font-size: 14px;
    color: rgba(15,23,42,.95);
  }
  .pompeyo-steps .steps-mobile__bar{
    margin-top: 10px;
    width: 100%;
    height: 10px;
    border-radius: 999px;
    background: rgba(15,23,42,.08);
    overflow: hidden;
  }
  .pompeyo-steps .steps-mobile__bar .fill{
    display: block;
    height: 100%;
    width: 0%;
    border-radius: 999px;
    background: rgba(11,110,243,.90);
    transition: width .18s ease;
  }
}

/* Stepper apilado */
@media (min-width: 541px) and (max-width: 860px){
  .pompeyo-steps .steps-mobile{ display: none !important; }
  .pompeyo-steps .step{ display: inline-flex !important; }

  .pompeyo-steps{
    display: grid !important;
    grid-template-columns: repeat(6, minmax(0, 1fr)) !important;
    gap: 8px !important;
    justify-content: stretch !important;
    align-items: center !important;
  }
  .pompeyo-steps .step{
    grid-column: span 2 !important;
    width: 100% !important;
    justify-content: center !important;
    padding: 8px 10px !important;
  }
  .pompeyo-steps .step:nth-child(4){ grid-column: 2 / span 2 !important; }
  .pompeyo-steps .step:nth-child(5){ grid-column: 4 / span 2 !important; }
  .pompeyo-steps .step .txt{ font-size: 12px !important; }
}

/* Desktop grande vuelve a flex */
@media (min-width: 861px){
  .pompeyo-steps{
    display:flex !important;
    flex-wrap: wrap !important;
    justify-content: center !important;
  }
  .pompeyo-steps .step{
    width: auto !important;
    justify-content: flex-start !important;
    padding: 8px 12px !important;
  }
  .pompeyo-steps .step .txt{ font-size: 13px !important; }
}

/* Fix observación */
#observacion{
  resize: none !important;
  min-height: 110px !important;
}
#confirmacion-section #observacion{ margin-bottom: 12px !important; }
#confirmacion-section #agendar-btn{ margin-top: 8px !important; }
@media (max-width: 540px){
  #confirmacion-section #observacion{ margin-bottom: 14px !important; }
  #confirmacion-section #agendar-btn{ margin-top: 10px !important; }
}

/* Modal */
.p-modal{
  position: fixed;
  inset: 0;
  z-index: 99999;
  display: none;
}
.p-modal.is-open{
  display: grid;
  place-items: center;
}
.p-modal__overlay{
  position: absolute;
  inset: 0;
  background: rgba(2,6,23,.38);
  backdrop-filter: blur(2px);
}
.p-modal__card{
  position: relative;
  width: min(500px, calc(100% - 28px));
  background: #fff;
  border: 1px solid rgba(15,23,42,.10);
  border-radius: 16px;
  box-shadow: 0 16px 44px rgba(2,6,23,.18);
  padding: 16px 16px 14px;
  animation: pModalPop .14s ease;
}
@keyframes pModalPop{
  from { transform: translateY(8px) scale(.98); opacity: 0; }
  to   { transform: translateY(0) scale(1); opacity: 1; }
}
.pompeyo-agend .p-modal__close{
  position: absolute;
  top: 10px;
  right: 10px;
  width: 36px;
  height: 36px;
  border-radius: 12px;
  background: transparent;
  border: 0;
  color: rgba(15,23,42,.55);
  font-weight: 700;
  box-shadow: none;
  outline: none;
  padding: 0;
  display: grid;
  place-items: center;
  line-height: 1;
}
.pompeyo-agend .p-modal__close:hover{
  color: rgba(15,23,42,.75);
  background: transparent;
}
.p-modal__icon{
  width: 44px;
  height: 44px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  background: rgba(11,110,243,.08);
  margin-bottom: 8px;
  color: rgba(15,23,42,.80);
}
.p-modal__icon-svg{
  width: 20px;
  height: 20px;
  fill: currentColor;
}
.p-modal__title{
  margin: 0;
  font-weight: 850;
  letter-spacing: -.02em;
  font-size: 17px;
  color: rgba(15,23,42,.96);
}
.p-modal__subtitle{
  margin: 6px 0 0;
  font-size: 13px;
  color: rgba(15,23,42,.62);
  font-weight: 600;
}
.p-modal__body{
  margin-top: 10px;
  background: rgba(2,6,23,.02);
  border: 1px solid rgba(15,23,42,.08);
  border-radius: 14px;
  padding: 16px 18px;
  font-size: 13px;
  line-height: 1.35;
  color: rgba(15,23,42,.90);
}
.p-modal__body .row{
  display: flex;
  gap: 14px;
  align-items: flex-start;
  justify-content: space-between;
  padding: 6px 0;
  border-bottom: 1px solid rgba(15,23,42,.06);
}
.p-modal__body .row:last-child{ border-bottom: 0; }
.p-modal__body .k{
  min-width: 110px;
  color: rgba(15,23,42,.55);
  font-weight: 700;
}
.p-modal__body .v{
  flex: 1;
  text-align: right;
  font-weight: 800;
  color: rgba(15,23,42,.90);
  overflow-wrap: anywhere;
  word-break: break-word;
}
.p-modal__actions{
  display: flex;
  gap: 10px;
  margin-top: 10px;
}
.p-modal__actions button{
  width: 100%;
  padding: 10px 12px;
  border-radius: 999px;
  font-weight: 700;
  background: rgba(15,23,42,.06);
  color: rgba(15,23,42,.85);
  border: 1px solid rgba(15,23,42,.12);
}
@media (max-width: 540px){
  .p-modal__card{ padding: 14px 14px 12px; }
  .p-modal__actions{ flex-direction: column; }
  .p-modal__body{ padding: 14px 16px; }
  .p-modal__body .k{ min-width: 96px; }
}

/* Patente missing separación */
#patente-missing-card #btn-usar-patente{ margin-top: 14px; }
#patente-missing-card #patente-missing-msg{ margin-top: 10px; }

/* Link-like button */
.p-linklike{
  background: transparent !important;
  border: 0 !important;
  padding: 0 !important;
  margin: 6px 0 0 !important;
  display: inline-block !important;
  width: auto !important;
  color: var(--p-blue) !important;
  font-weight: 900 !important;
  text-decoration: underline !important;
  cursor: pointer !important;
  border-radius: 0 !important;
  box-shadow: none !important;
}
.p-linklike:hover{ filter: brightness(0.95); }
.p-linklike:disabled{
  opacity: .5 !important;
  cursor: not-allowed !important;
}

/* Botón + agregar vehículo */
.p-add-vehiculo{
  background: rgba(15,23,42,.06) !important;
  color: rgba(15,23,42,.90) !important;
  border: 1px solid rgba(15,23,42,.12) !important;
  border-radius: 14px !important;
  padding: 10px 12px !important;
  font-weight: 900 !important;
  width: auto !important;
}
.p-add-vehiculo:hover{ filter: brightness(0.98); }

/* Botón cerrar form */
.p-form-top{
  display:flex;
  align-items:flex-start;
  justify-content:space-between;
  gap:12px;
  margin-bottom:10px;
}
.p-form-top .hint{
  margin:0;
  flex:1;
  min-width:0;
}
.p-form-close{
  flex:0 0 auto;
  width:34px;
  height:34px;
  padding:0 !important;
  border-radius:12px !important;
  background:rgba(15,23,42,.08) !important;
  color:rgba(15,23,42,.85) !important;
  border:1px solid rgba(15,23,42,.12) !important;
  display:grid;
  place-items:center;
  font-weight:900 !important;
  line-height:1;
  cursor:pointer;
}
.p-form-close:hover{ background:rgba(15,23,42,.12) !important; }
@media (max-width: 540px){
  .p-form-top{
    flex-direction:column;
    align-items:center;
    gap:8px;
  }
  .p-form-close{
    width:40px;
    height:40px;
    order:0;
    border-radius:999px !important;
  }
  .p-form-top .hint{
    order:1;
    text-align:center;
    width:100%;
  }
}
#vehiculo-form #btn-grabar-vehiculo{ margin-top: 16px; }

#cliente-edit-card #cli-edit-celular,
#cliente-edit-card #cli-edit-email{
  background: #fff !important;
  border-color: rgba(15,23,42,.16) !important;
}

/* Cliente form: inputs blancos + separación botón */
#cliente-form :where(input, select, textarea){
  background: #fff !important;
}
#cliente-form #btn-grabar-cliente{
  margin-top: 16px !important;
}

/* =========================
   ✅ LOADERS (SAFE)
========================= */
.p-spinner{
  width: 18px;
  height: 18px;
  border-radius: 999px;
  border: 2px solid rgba(15,23,42,.18);
  border-top-color: rgba(11,110,243,.95);
  display: inline-block;
  animation: pSpin .75s linear infinite;
}
@keyframes pSpin{ to { transform: rotate(360deg); } }

.pompeyo-agend button.p-btn-loading{
  position: relative;
  pointer-events: none;
  filter: saturate(.95);
}
.pompeyo-agend button.p-btn-loading::after{
  content:"";
  position: absolute;
  right: 12px;
  top: 50%;
  width: 16px;
  height: 16px;
  margin-top: -8px;
  border-radius: 999px;
  border: 2px solid rgba(255,255,255,.35);
  border-top-color: rgba(255,255,255,.98);
  animation: pSpin .75s linear infinite;
}
@media (max-width: 540px){
  .pompeyo-agend button.p-btn-loading::after{ right: 14px; }
}

.p-global-loader{
  position: absolute;
  inset: 0;
  z-index: 9999;
  display: none;
  border-radius: var(--p-radius);
}
.p-global-loader.is-on{
  display: grid;
  place-items: center;
}
.p-global-loader__overlay{
  position: absolute;
  inset: 0;
  background: rgba(246,247,251,.72);
  backdrop-filter: blur(2px);
  border-radius: var(--p-radius);
}
.p-global-loader__card{
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  background: #fff;
  border: 1px solid rgba(15,23,42,.10);
  border-radius: 16px;
  box-shadow: 0 14px 40px rgba(2,6,23,.10);
  color: rgba(15,23,42,.92);
  font-weight: 800;
}
.p-global-loader__text{
  font-size: 13px;
  color: rgba(15,23,42,.72);
  font-weight: 800;
}

/* Ocultar SI o SI: Región */
#pompeyo-agendamiento label[for="region"],
#pompeyo-agendamiento #region{
  display: none !important;
  visibility: hidden !important;
  height: 0 !important;
  margin: 0 !important;
  padding: 0 !important;
  border: 0 !important;
}

/* ✅ Tipo de servicio: SOLO el select (no toques el label) */
#pompeyo-agendamiento #tipoServicio{
  display: block !important;
  visibility: visible !important;
  height: auto !important;
}

/* Fade Mantenciones */
#mantenciones-card{
  transition: opacity .18s ease, transform .18s ease;
  opacity: 0;
  transform: translateY(6px);
  pointer-events: none;
}
#mantenciones-card.is-visible{
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

/* =========================================================
   ✅ NUEVO: Retiro y entrega (Paso 3)
========================================================== */
#retiro-card{
  /* hereda look de subcard, pero lo dejamos un pelo más “importante” */
  background: rgba(11,110,243,.06);
  border-style: solid;
  border-color: rgba(11,110,243,.18);
}

#retiro-card label[for="retiro-servicio"]{
  margin-top: 0;
  font-size: 13px;
  color: rgba(15,23,42,.78);
}

#retiro-precio-label{
  color: rgba(15,23,42,.92);
}

#retiro-details{
  border-top: 1px solid rgba(15,23,42,.10);
  padding-top: 12px;
}

#retiro-details .p-retiro-title{
  font-size: 13px;
  color: rgba(15,23,42,.92);
}

#retiro-details :where(input, select){
  background: #fff;
}

@media (max-width: 540px){
  #retiro-card{
    padding: 14px;
  }
}
