/* ServiHogar V18 — coordinación privada dentro de la plataforma. */
.is-chat-page .site-main{padding-bottom:0}
.chat-page{max-width:920px;padding-top:clamp(1rem,3vw,2rem);padding-bottom:calc(6rem + env(safe-area-inset-bottom))}
.chat-header{display:flex;align-items:center;gap:1rem;margin-bottom:1rem}
.chat-header h1{margin:.15rem 0;font-size:clamp(1.35rem,4vw,2rem)}
.chat-header p{margin:0;color:var(--muted,#60708a)}
.chat-back{display:grid;place-items:center;flex:0 0 44px;width:44px;height:44px;border:1px solid #c8d5e5;border-radius:999px;background:#fff;color:#102747}
.chat-security-note{display:flex;align-items:flex-start;gap:.65rem;margin:0 0 1rem;padding:.85rem 1rem;border:1px solid #c9e4dc;border-radius:16px;background:#eef9f5;color:#234c43;font-size:.92rem}
.chat-security-note .icon{flex:0 0 20px;width:20px;height:20px;margin-top:.05rem}
.chat-thread{display:flex;flex-direction:column;gap:.55rem;min-height:min(52vh,520px);max-height:62vh;overflow-y:auto;overscroll-behavior:contain;padding:1rem;border:1px solid #d7e1ee;border-radius:24px;background:linear-gradient(180deg,#f5f8fc 0%,#edf3f9 100%);scrollbar-gutter:stable}
.chat-empty{margin:auto;max-width:350px;text-align:center;color:#586b83}
.chat-empty>span{display:grid;place-items:center;width:54px;height:54px;margin:0 auto .75rem;border-radius:18px;background:#fff;color:#1459b8;box-shadow:0 8px 24px rgba(18,52,91,.08)}
.chat-empty h2{margin:0 0 .35rem;color:#102747;font-size:1.2rem}
.chat-empty p{margin:0}
.chat-message{display:flex;width:100%}
.chat-message.is-mine{justify-content:flex-end}
.chat-message.is-theirs{justify-content:flex-start}
.chat-bubble{max-width:min(78%,620px);padding:.72rem .85rem .4rem;border-radius:18px;box-shadow:0 2px 8px rgba(22,48,81,.07)}
.chat-message.is-mine .chat-bubble{border-bottom-right-radius:5px;background:#155ebc;color:#fff}
.chat-message.is-theirs .chat-bubble{border:1px solid #d8e0ea;border-bottom-left-radius:5px;background:#fff;color:#152b49}
body.servihogar-app:not(.is-admin-route) .chat-bubble p{margin:0;white-space:normal;overflow-wrap:anywhere;color:inherit;line-height:1.45}
body.servihogar-app:not(.is-admin-route) .chat-message.is-mine .chat-bubble p{color:#fff;-webkit-text-fill-color:#fff}
body.servihogar-app:not(.is-admin-route) .chat-message.is-theirs .chat-bubble p{color:#152b49;-webkit-text-fill-color:#152b49}
.chat-bubble time{display:block;margin-top:.25rem;text-align:right;font-size:.75rem;font-weight:650;line-height:1.25;opacity:1}
.chat-message.is-mine .chat-bubble time{color:#eaf3ff;-webkit-text-fill-color:#eaf3ff}
.chat-message.is-theirs .chat-bubble time{color:#52647b;-webkit-text-fill-color:#52647b}
.chat-composer{position:sticky;z-index:20;bottom:calc(4.6rem + env(safe-area-inset-bottom));display:grid;grid-template-columns:minmax(0,1fr) auto;gap:.65rem;margin-top:.8rem;padding:.65rem;border:1px solid #cdd9e7;border-radius:20px;background:rgba(255,255,255,.97);box-shadow:0 -8px 30px rgba(15,46,82,.1);backdrop-filter:blur(12px)}
.chat-composer textarea{width:100%;min-height:46px;max-height:140px;resize:none;margin:0;padding:.72rem .85rem;border:1px solid #9fb3ca;border-radius:14px;background:#fff;color:#142b47;caret-color:#155ebc;font:inherit;line-height:1.35;-webkit-text-fill-color:#142b47}
.chat-composer textarea::placeholder{color:#64748b;opacity:1;-webkit-text-fill-color:#64748b}
.chat-composer textarea:focus-visible{border-color:#155ebc;outline:3px solid #155ebc;outline-offset:2px}
.chat-send{align-self:end;min-height:46px;border-radius:14px}
.chat-send:disabled{background:#426a64;border-color:#426a64;color:#fff;opacity:1}
.chat-composer small{grid-column:1/-1;min-height:0;color:#9b2835}
.chat-readonly{display:flex;align-items:center;gap:.75rem;margin-top:.8rem;padding:1rem;border:1px solid #d8e0ea;border-radius:18px;background:#f5f7fa;color:#586b83}
.chat-readonly p{margin:0}
.chat-unread-badge{display:inline-grid;place-items:center;min-width:1.45rem;height:1.45rem;padding:0 .38rem;margin-left:.35rem;border-radius:999px;background:#c62f45;color:#fff;font-size:.75rem;font-weight:800;vertical-align:middle}

/* Administración — reseteo protegido en dos pasos. */
.admin-danger-zone{border:1px solid #e6b8bf;background:linear-gradient(135deg,#fff 0%,#fff7f8 100%)}
.admin-danger-zone>p{max-width:900px;color:#59434a}
.button-danger{border-color:#a91f34;background:#a91f34;color:#fff}
.button-danger:hover{border-color:#851729;background:#851729;color:#fff;box-shadow:0 8px 22px rgba(169,31,52,.2)}
.reset-blocker{margin:1rem 0;padding:.85rem 1rem;border:1px solid #e2c27a;border-radius:12px;background:#fff7df;color:#775510}
.reset-blocker p{margin:0}
.reset-blocker p+p{margin-top:.4rem}
.admin-reset-review{max-width:980px;margin-inline:auto;border-color:#e2b2ba}
.reset-summary{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:.65rem;margin:1.2rem 0}
.reset-summary>div{display:flex;flex-direction:column;padding:.9rem;border:1px solid #dbe3ed;border-radius:14px;background:#f7f9fc}
.reset-summary strong{font-size:1.55rem;line-height:1;color:#102747}
.reset-summary span{margin-top:.3rem;color:#60708a;font-size:.82rem}
.reset-scope-grid{display:grid;gap:.8rem;margin:1rem 0 1.25rem}
.reset-scope-grid>div{padding:1rem;border:1px solid #dbe3ed;border-radius:16px;background:#fff}
.reset-scope-grid>div:first-child{border-color:#e8c2c8;background:#fff8f9}
.reset-scope-grid h3{margin:0 0 .55rem;font-size:1rem}
.reset-scope-grid ul{margin:0;padding-left:1.15rem;color:#42546d}
.reset-scope-grid li+li{margin-top:.35rem}
.reset-final-form{margin-top:1rem;padding-top:1.1rem;border-top:1px solid #e5d7da}
.reset-final-form .field{max-width:560px}
.reset-final-form input[type="text"],.reset-final-form input[type="password"]{width:100%}
.reset-final-form[aria-busy="true"]{opacity:.72;pointer-events:none}

@media (min-width:760px){
  .chat-page{padding-bottom:3rem}
  .chat-thread{min-height:520px}
  .chat-composer{bottom:1rem}
  .reset-summary{grid-template-columns:repeat(3,minmax(0,1fr))}
  .reset-scope-grid{grid-template-columns:repeat(2,minmax(0,1fr))}
}

@media (max-width:480px){
  .chat-page{padding-left:.65rem;padding-right:.65rem}
  .chat-security-note{font-size:.84rem}
  .chat-thread{min-height:54vh;max-height:61vh;padding:.65rem;border-radius:18px}
  .chat-bubble{max-width:88%}
  .chat-composer{grid-template-columns:minmax(0,1fr) auto;padding:.5rem;border-radius:16px}
  .chat-send{padding-inline:.85rem}
}
