/* Suite Match: MatchStatus, MatchWallet, MatchFamily, MatchEmpresa, Match360, MatchScan, MatchBot y MatchAlert.
   Se carga en el sitio y en la aplicación; los colores usan variables con respaldo para servir en ambos. */

/* ---------- MatchStatus ---------- */
.match-status { padding: 18px 20px; }
.ms-steps { list-style: none; display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 4px; margin: 0; padding: 0; counter-reset: s; }
.ms-steps li { position: relative; display: flex; flex-direction: column; align-items: center; gap: 6px; text-align: center; font-size: .8rem; color: #6c757d; }
.ms-steps li::before { content: ''; position: absolute; top: 15px; left: calc(-50% + 16px); right: calc(50% + 16px); height: 3px; background: #e3e7eb; border-radius: 2px; }
.ms-steps li:first-child::before { display: none; }
.ms-steps li.done::before, .ms-steps li.current::before, .ms-steps li.stopped::before { background: var(--green, #a9d52f); }
.ms-dot { position: relative; z-index: 1; width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; font-size: .85rem;
    background: #fff; border: 2px solid #ced4da; color: #6c757d; }
.ms-steps li.done .ms-dot { background: var(--green, #a9d52f); border-color: var(--green, #a9d52f); color: #fff; }
.ms-steps li.current .ms-dot { border-color: var(--blue, #4b9fdd); color: var(--blue-dark, #3a87c4); box-shadow: 0 0 0 4px rgba(75, 159, 221, .18); }
.ms-steps li.current .ms-label { color: #212529; font-weight: 600; }
.ms-steps li.stopped .ms-dot { border-color: #c22a22; color: #c22a22; }
.ms-note { margin: 12px 0 0; text-align: center; }
.ms-mini { display: inline-flex; gap: 3px; margin-left: 6px; vertical-align: middle; }
.ms-mini i { width: 12px; height: 5px; border-radius: 3px; background: #e3e7eb; }
.ms-mini i.on { background: var(--green, #a9d52f); }
.ms-mini.is-ended i.on { background: #adb5bd; }
@media (max-width: 560px) {
    .ms-steps li .ms-label { font-size: .7rem; }
    .ms-steps li::before { left: calc(-50% + 13px); right: calc(50% + 13px); top: 13px; }
    .ms-dot { width: 26px; height: 26px; font-size: .75rem; }
}

/* ---------- MatchAlert ---------- */
.match-alert { display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap; border-left: 4px solid #e8a33d; background: #fff8ec; }
.match-alert p { margin: 4px 0 0; }

/* ---------- MatchWallet ---------- */
.wallet-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr)); gap: 18px; margin-bottom: 20px; }
.wallet-card { position: relative; display: flex; flex-direction: column; gap: 10px; padding: 18px; border-radius: 16px; color: #fff; overflow: hidden;
    background: linear-gradient(135deg, #1a2b4a 0%, #27466f 60%, #2f6a8f 100%); box-shadow: 0 10px 24px rgba(26, 43, 74, .18); }
.wallet-card::after { content: ''; position: absolute; right: -40px; top: -40px; width: 140px; height: 140px; border-radius: 50%; background: rgba(169, 213, 47, .15); }
.wallet-card.is-soon { background: linear-gradient(135deg, #3b2f12 0%, #6f5420 60%, #94702a 100%); }
.wallet-card.is-urgent { background: linear-gradient(135deg, #4a1a1a 0%, #7a2a24 60%, #a5342a 100%); }
.wallet-card header { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; position: relative; z-index: 1; }
.wallet-ramo { font-weight: 600; }
.wallet-insurer { font-size: .8rem; opacity: .85; text-align: right; }
.wallet-number { font-family: ui-monospace, Consolas, monospace; letter-spacing: .06em; font-size: 1.05rem; position: relative; z-index: 1; }
.wallet-data { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 0; font-size: .82rem; position: relative; z-index: 1; }
.wallet-data dt { opacity: .7; font-size: .75rem; }
.wallet-data dd { margin: 0; }
.wallet-due { margin: 0; font-weight: 600; font-size: .88rem; position: relative; z-index: 1; }
.wallet-card footer { display: flex; flex-wrap: wrap; gap: 8px; position: relative; z-index: 1; }
.wallet-card .btn-outline { background: rgba(255, 255, 255, .1); color: #fff; border-color: rgba(255, 255, 255, .5); }
.wallet-card .btn-primary { color: #15201a; }
.wallet-docs { list-style: none; margin: 0; padding: 8px 0 0; border-top: 1px solid rgba(255, 255, 255, .2); font-size: .82rem; position: relative; z-index: 1; }
.wallet-docs a { color: #fff; }

/* ---------- MatchFamily / MatchEmpresa ---------- */
.family-list { display: grid; gap: 4px; }
.family-row { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid #eef0f2; }
.family-row:last-child { border-bottom: 0; }
.family-row > div:nth-child(2) { flex: 1; min-width: 0; }
.family-row .actions { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.family-row .avatar { flex: none; width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; background: rgba(169, 213, 47, .18); color: #4d6a0c; }
.renewal-calendar { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 150px), 1fr)); gap: 10px; }
.rc-month { border: 1px solid #e3e7eb; border-radius: 10px; padding: 10px; display: grid; gap: 6px; align-content: start; min-height: 80px; }
.rc-month.has { border-color: var(--green, #a9d52f); background: rgba(169, 213, 47, .07); }
.rc-month strong { font-size: .85rem; }
.rc-item { display: block; font-size: .82rem; font-weight: 600; color: inherit; }
.rc-item span { display: block; font-weight: 400; color: #6c757d; font-size: .75rem; }

/* ---------- Match360 ---------- */
.map-summary p { margin: 6px 0 0; }
.map-meter { display: flex; gap: 6px; }
.map-meter span { flex: 1; height: 10px; border-radius: 5px; background: #e3e7eb; }
.map-meter .mm-protegido { background: var(--green, #a9d52f); }
.map-meter .mm-por_vencer, .map-meter .mm-para_revisar { background: #e8a33d; }
.map-meter .mm-en_proceso { background: var(--blue, #4b9fdd); }
.map-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 260px), 1fr)); gap: 16px; margin-bottom: 20px; }
.map-area { background: #fff; border: 1px solid #e3e7eb; border-top: 4px solid #ced4da; border-radius: 14px; padding: 16px; display: flex; flex-direction: column; gap: 8px; }
.map-area header { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.map-area h3, .map-area h2 { margin: 0; font-size: 1rem; flex: 1; min-width: 0; }
.map-area p { margin: 0; }
.map-area footer { margin-top: auto; display: flex; flex-wrap: wrap; gap: 8px; padding-top: 6px; }
.map-icon { width: 38px; height: 38px; border-radius: 10px; display: grid; place-items: center; background: #f1f3f5; color: #495057; flex: none; }
.map-protegido { border-top-color: var(--green, #a9d52f); }
.map-protegido .map-icon { background: rgba(169, 213, 47, .18); color: #4d6a0c; }
.map-por_vencer, .map-para_revisar { border-top-color: #e8a33d; }
.map-por_vencer .map-icon, .map-para_revisar .map-icon { background: #fff3dc; color: #9a5f08; }
.map-en_proceso { border-top-color: var(--blue, #4b9fdd); }
.map-en_proceso .map-icon { background: rgba(75, 159, 221, .14); color: #3a87c4; }
.badge-gray { background: #eef0f2; color: #495057; }

/* ---------- MatchScan ---------- */
.scan-banner { display: flex; align-items: center; gap: 16px; padding: 18px 20px; margin-bottom: 28px; border-radius: 16px; color: inherit; text-decoration: none;
    background: linear-gradient(90deg, rgba(75, 159, 221, .1), rgba(169, 213, 47, .14)); border: 1px solid rgba(75, 159, 221, .25); transition: transform .2s, box-shadow .2s; }
.scan-banner:hover { transform: translateY(-2px); box-shadow: 0 8px 24px rgba(0, 0, 0, .08); }
.scan-banner > span:nth-child(2) { flex: 1; min-width: 0; }
.scan-banner-icon { flex: none; width: 48px; height: 48px; border-radius: 12px; display: grid; place-items: center; background: #fff; color: var(--blue-dark, #3a87c4); font-size: 1.3rem; }
.scan-steps { list-style: none; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; padding: 0; margin: 0 0 20px; }
.scan-steps li { display: flex; flex-direction: column; align-items: center; gap: 6px; text-align: center; font-size: .85rem; padding: 12px 6px; border-radius: 12px; background: #f8f9fa; }
.scan-steps i { font-size: 1.3rem; color: var(--green-dark, #8fb825); }
@media (max-width: 560px) { .scan-steps { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.express-more summary { cursor: pointer; font-weight: 600; padding: 4px 0; }
.express-more[open] summary { margin-bottom: 14px; }
.consent-actions { display: flex; flex-wrap: wrap; gap: 10px; margin: 18px 0; }

/* ---------- MatchBot ---------- */
.matchbot { position: fixed; right: 20px; bottom: 20px; z-index: 1900; font-family: inherit; }
.matchbot-toggle { display: inline-flex; align-items: center; gap: 8px; min-height: 48px; padding: 0 18px; border: 0; border-radius: 999px; cursor: pointer;
    background: #1a2b4a; color: #fff; font-family: inherit; font-weight: 600; font-size: .9rem; box-shadow: 0 8px 24px rgba(26, 43, 74, .3); }
.matchbot-toggle i { font-size: 1.1rem; color: var(--green, #a9d52f); }
.matchbot.is-open .matchbot-toggle { display: none; }
.matchbot-panel { width: min(370px, calc(100vw - 24px)); max-height: min(560px, calc(100vh - 40px)); display: flex; flex-direction: column; background: #fff; color: #212529;
    border-radius: 18px; box-shadow: 0 18px 50px rgba(0, 0, 0, .22); overflow: hidden; }
.matchbot-panel[hidden] { display: none; }
.matchbot-panel header { display: flex; align-items: center; gap: 10px; padding: 12px 14px; background: #1a2b4a; color: #fff; }
.matchbot-panel header div { flex: 1; display: flex; flex-direction: column; line-height: 1.2; }
.matchbot-panel header span { font-size: .75rem; opacity: .8; }
.matchbot-avatar { width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; background: var(--green, #a9d52f); color: #1a2b4a; }
.matchbot-close { background: none; border: 0; color: #fff; font-size: 1.1rem; cursor: pointer; min-width: 44px; min-height: 44px; }
.matchbot-log { flex: 1; overflow-y: auto; padding: 14px; display: flex; flex-direction: column; gap: 8px; background: #f6f8fa; }
.mb-msg { max-width: 88%; padding: 9px 12px; border-radius: 14px; font-size: .88rem; line-height: 1.45; white-space: pre-line; }
.mb-bot { align-self: flex-start; background: #fff; border: 1px solid #e3e7eb; border-bottom-left-radius: 4px; }
.mb-user { align-self: flex-end; background: #1a2b4a; color: #fff; border-bottom-right-radius: 4px; }
.mb-link { display: block; margin-top: 6px; font-weight: 600; color: var(--blue-dark, #3a87c4); }
.mb-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.mb-chip { align-self: flex-start; border: 1px solid #ced4da; background: #fff; border-radius: 999px; padding: 6px 12px; min-height: 36px; font: inherit; font-size: .8rem; cursor: pointer; }
.mb-chip:hover { border-color: var(--blue, #4b9fdd); color: var(--blue-dark, #3a87c4); }
.matchbot-input { display: flex; gap: 6px; padding: 10px; border-top: 1px solid #e3e7eb; }
.matchbot-input[hidden], .matchbot-handoff[hidden] { display: none; }
.matchbot-input input { flex: 1; min-width: 0; border: 1px solid #ced4da; border-radius: 999px; padding: 10px 14px; font: inherit; font-size: 16px; }
.matchbot-input button { flex: none; width: 44px; height: 44px; border-radius: 50%; border: 0; background: var(--green, #a9d52f); color: #fff; cursor: pointer; }
.matchbot-handoff { display: grid; gap: 8px; padding: 12px; border-top: 1px solid #e3e7eb; }
.matchbot-handoff p { margin: 0; }
.matchbot-handoff input, .matchbot-handoff textarea { width: 100%; border: 1px solid #ced4da; border-radius: 10px; padding: 9px 11px; font: inherit; font-size: 16px; }
.mb-consent { display: flex; gap: 6px; align-items: flex-start; font-size: .78rem; }
.mb-error { color: #c22a22; font-size: .8rem; }
.mb-actions { display: flex; justify-content: flex-end; gap: 8px; }
.matchbot-disclaimer { margin: 0; padding: 6px 12px 10px; font-size: .75rem; color: #6c757d; text-align: center; }
/* El botón «volver arriba» del sitio se desplaza para no quedar bajo el asistente */
body:has(.matchbot) .back-to-top { bottom: 84px; }
@media (max-width: 560px) {
    .matchbot { right: 12px; bottom: 12px; }
    .matchbot-toggle span { display: none; }
    .matchbot-toggle { width: 52px; padding: 0; justify-content: center; }
}
@media print { .matchbot { display: none !important; } }
