/* ============================================================
   Centro de ayuda contextual · IUS Plataforma
   ============================================================ */

:root {
    --ius-navy: #263449;
    --ius-navy-deep: #1b2636;
    --ius-gold: #ce9d39;
    --ius-gold-soft: #f6edd8;
    --ius-ink: #1f2937;
    --ius-muted: #6b7280;
    --ius-line: #e5e7eb;
    --ius-surface: #ffffff;
    --ius-bg: #f7f8fa;
    --help-w: 432px;
    --help-ease: cubic-bezier(.22, .61, .36, 1);
}

/* ---------- Lanzador flotante ---------- */
#ius-help-launcher {
    position: fixed;
    right: 22px;
    bottom: 22px;
    z-index: 65;
    width: 54px;
    height: 54px;
    border: 0;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    background: linear-gradient(150deg, var(--ius-navy) 0%, var(--ius-navy-deep) 100%);
    box-shadow: 0 10px 28px rgba(27, 38, 54, .34), 0 0 0 3px rgba(206, 157, 57, .9);
    transition: transform .22s var(--help-ease), box-shadow .22s var(--help-ease);
}
#ius-help-launcher:hover { transform: translateY(-2px) scale(1.03); box-shadow: 0 14px 32px rgba(27, 38, 54, .4), 0 0 0 3px var(--ius-gold); }
#ius-help-launcher:active { transform: scale(.97); }
#ius-help-launcher svg { width: 25px; height: 25px; }
#ius-help-launcher .ihl-key {
    position: absolute; bottom: -2px; right: -2px;
    background: #fff; color: var(--ius-navy); font-size: 9px; font-weight: 800;
    border-radius: 7px; padding: 2px 4px; line-height: 1; border: 1px solid var(--ius-line);
}
#ius-help-launcher .ihl-dot {
    position: absolute; top: 2px; right: 2px; width: 11px; height: 11px; border-radius: 50%;
    background: var(--ius-gold); border: 2px solid #fff; display: none;
}
#ius-help-launcher.has-context .ihl-dot { display: block; animation: ihl-pulse 2.4s infinite; }
@keyframes ihl-pulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(206, 157, 57, .6); }
    50% { box-shadow: 0 0 0 7px rgba(206, 157, 57, 0); }
}

/* ---------- Backdrop ---------- */
#ius-help-backdrop {
    position: fixed; inset: 0; z-index: 66;
    background: rgba(15, 23, 42, .38);
    backdrop-filter: blur(2px);
    opacity: 0; pointer-events: none; transition: opacity .25s var(--help-ease);
}
#ius-help-backdrop.open { opacity: 1; pointer-events: auto; }

/* ---------- Panel ---------- */
#ius-help-panel {
    position: fixed; top: 0; right: 0; bottom: 0; z-index: 67;
    width: var(--help-w); max-width: 100vw;
    background: var(--ius-surface);
    display: flex; flex-direction: column;
    box-shadow: -18px 0 48px rgba(15, 23, 42, .22);
    transform: translateX(104%);
    transition: transform .3s var(--help-ease);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    color: var(--ius-ink);
}
#ius-help-panel.open { transform: translateX(0); }

.ihp-head {
    position: relative; padding: 18px 20px 16px;
    background: linear-gradient(150deg, var(--ius-navy) 0%, var(--ius-navy-deep) 100%);
    color: #fff; flex-shrink: 0;
}
.ihp-head::after {
    content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 3px;
    background: linear-gradient(90deg, var(--ius-gold), rgba(206, 157, 57, .25));
}
.ihp-head-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.ihp-eyebrow {
    font-size: 9.5px; letter-spacing: 2.2px; text-transform: uppercase;
    color: var(--ius-gold); font-weight: 800; margin-bottom: 4px;
}
.ihp-title { font-size: 17px; font-weight: 750; line-height: 1.2; margin: 0; }
.ihp-sub { font-size: 11.5px; color: #c3ccdb; margin-top: 3px; }
.ihp-close {
    flex-shrink: 0; width: 32px; height: 32px; border-radius: 9px; border: 0; cursor: pointer;
    background: rgba(255, 255, 255, .1); color: #fff; display: flex; align-items: center; justify-content: center;
    transition: background .18s;
}
.ihp-close:hover { background: rgba(255, 255, 255, .2); }
.ihp-close svg { width: 17px; height: 17px; }

.ihp-search-wrap { position: relative; margin-top: 14px; }
.ihp-search-wrap svg {
    position: absolute; left: 12px; top: 50%; transform: translateY(-50%);
    width: 15px; height: 15px; color: #93a0b4; pointer-events: none;
}
#ihp-search {
    width: 100%; border: 1px solid rgba(255, 255, 255, .14); border-radius: 11px;
    background: rgba(255, 255, 255, .1); color: #fff; font-size: 13px;
    padding: 10px 58px 10px 36px; outline: none; transition: background .2s, border-color .2s;
}
#ihp-search::placeholder { color: #a9b4c6; }
#ihp-search:focus { background: rgba(255, 255, 255, .16); border-color: rgba(206, 157, 57, .7); }
.ihp-kbd {
    position: absolute; right: 9px; top: 50%; transform: translateY(-50%);
    font-size: 10px; color: #cbd3df; border: 1px solid rgba(255, 255, 255, .22);
    border-radius: 6px; padding: 2px 5px; letter-spacing: .4px;
}

.ihp-body { flex: 1; overflow-y: auto; overscroll-behavior: contain; background: var(--ius-bg); }
.ihp-body::-webkit-scrollbar { width: 9px; }
.ihp-body::-webkit-scrollbar-thumb { background: #cfd6e0; border-radius: 9px; border: 2px solid var(--ius-bg); }

/* ---------- Vista: inicio ---------- */
.ihp-section { padding: 16px 18px; }
.ihp-section + .ihp-section { padding-top: 0; }
.ihp-label {
    font-size: 9.5px; font-weight: 800; letter-spacing: 1.6px; text-transform: uppercase;
    color: #8b97a8; margin: 0 0 8px 2px;
}

.ihp-context {
    position: relative; border-radius: 14px; overflow: hidden; cursor: pointer; border: 1px solid #dbe3ee;
    background: linear-gradient(160deg, #ffffff 0%, #f3f6fb 100%);
    padding: 14px 15px 14px 16px; transition: transform .18s var(--help-ease), box-shadow .18s;
}
.ihp-context::before {
    content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px;
    background: linear-gradient(180deg, var(--ius-gold), #a97c22);
}
.ihp-context:hover { transform: translateY(-1px); box-shadow: 0 8px 20px rgba(38, 52, 73, .1); }
.ihp-context-tag {
    display: inline-flex; align-items: center; gap: 4px; font-size: 9.5px; font-weight: 800;
    letter-spacing: 1.1px; text-transform: uppercase; color: #8a6a1e; background: var(--ius-gold-soft);
    padding: 2px 7px; border-radius: 20px; margin-bottom: 6px;
}
.ihp-context h3 { margin: 0; font-size: 13.8px; font-weight: 750; color: var(--ius-navy); line-height: 1.28; }
.ihp-context p { margin: 3px 0 0; font-size: 11.8px; color: var(--ius-muted); line-height: 1.45; }
.ihp-context .ihp-go { margin-top: 8px; font-size: 11.5px; font-weight: 700; color: var(--ius-navy); display: inline-flex; align-items: center; gap: 4px; }
.ihp-context .ihp-go svg { width: 13px; height: 13px; }

.ihp-empty-context {
    border: 1px dashed #d6dde8; border-radius: 14px; padding: 16px;
    background: #fff; font-size: 12px; color: var(--ius-muted); text-align: center;
}

.ihp-cats { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.ihp-cat {
    display: flex; align-items: center; gap: 9px; text-align: left;
    border: 1px solid #e2e8f1; background: #fff; border-radius: 11px; padding: 10px 11px;
    cursor: pointer; font-size: 12px; font-weight: 650; color: var(--ius-navy);
    transition: border-color .16s, transform .16s, box-shadow .16s;
}
.ihp-cat:hover { border-color: var(--ius-gold); transform: translateY(-1px); box-shadow: 0 5px 14px rgba(38,52,73,.08); }
.ihp-cat i, .ihp-cat svg { width: 15px; height: 15px; color: var(--ius-gold); flex-shrink: 0; }
.ihp-cat span { line-height: 1.2; }
.ihp-cat small { display: block; font-size: 9.5px; color: #94a1b3; font-weight: 600; margin-top: 1px; }

.ihp-list { display: flex; flex-direction: column; gap: 2px; }
.ihp-item {
    display: flex; align-items: flex-start; gap: 9px; padding: 9px 10px; border-radius: 9px;
    cursor: pointer; border: 0; background: transparent; text-align: left; width: 100%;
    transition: background .14s;
}
.ihp-item:hover { background: #fff; box-shadow: 0 1px 3px rgba(38, 52, 73, .07); }
.ihp-item-ico {
    width: 27px; height: 27px; border-radius: 8px; background: #eef2f8; color: var(--ius-navy);
    display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.ihp-item-ico svg { width: 14px; height: 14px; }
.ihp-item-t { font-size: 12.4px; font-weight: 650; color: var(--ius-ink); line-height: 1.3; }
.ihp-item-s { font-size: 10.8px; color: #8b97a8; margin-top: 2px; line-height: 1.35; }

/* ---------- Vista: artículo ---------- */
.ihp-article { background: #fff; min-height: 100%; }
.ihp-art-head { padding: 14px 18px 0; }
.ihp-back {
    display: inline-flex; align-items: center; gap: 5px; border: 0; background: transparent;
    color: #7b8798; font-size: 11.5px; font-weight: 700; cursor: pointer; padding: 4px 0;
}
.ihp-back:hover { color: var(--ius-navy); }
.ihp-back svg { width: 14px; height: 14px; }
.ihp-chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0 8px; }
.ihp-chip {
    font-size: 9.5px; font-weight: 800; letter-spacing: .8px; text-transform: uppercase;
    padding: 3px 8px; border-radius: 20px; background: #eef2f8; color: #55657c;
}
.ihp-chip.gold { background: var(--ius-gold-soft); color: #8a6a1e; }
.ihp-art-head h2 { margin: 0; font-size: 18px; line-height: 1.25; color: var(--ius-navy); font-weight: 780; }
.ihp-art-sum { margin: 6px 0 0; font-size: 12.5px; color: var(--ius-muted); line-height: 1.5; }
.ihp-art-body { padding: 14px 18px 22px; }
.ihp-steps { list-style: none; margin: 0 0 14px; padding: 0; counter-reset: s; }
.ihp-steps li {
    position: relative; padding: 0 0 12px 30px; font-size: 12.4px; line-height: 1.5; color: #374151;
    counter-increment: s;
}
.ihp-steps li::before {
    content: counter(s); position: absolute; left: 0; top: -1px;
    width: 20px; height: 20px; border-radius: 50%; background: var(--ius-navy); color: #fff;
    font-size: 10px; font-weight: 800; display: flex; align-items: center; justify-content: center;
}
.ihp-steps li::after {
    content: ""; position: absolute; left: 10px; top: 21px; bottom: 0; width: 1px; background: #e3e9f1;
}
.ihp-steps li:last-child::after { display: none; }
.ihp-steps b { color: var(--ius-navy); }

.ihp-note {
    border-radius: 10px; padding: 9px 11px; font-size: 11.6px; line-height: 1.5;
    background: #f4f6fa; border-left: 3px solid var(--ius-navy); color: #4b5563; margin: 0 0 12px;
}
.ihp-note.warn { background: #fdf7ea; border-left-color: var(--ius-gold); }
.ihp-note b { color: var(--ius-navy); }

.ihp-figure { margin: 0 0 14px; border-radius: 10px; overflow: hidden; border: 1px solid var(--ius-line); background: #fafbfc; }
.ihp-figure img { display: block; width: 100%; height: auto; cursor: zoom-in; }
.ihp-figure figcaption { font-size: 10px; color: #8b97a8; padding: 6px 9px; border-top: 1px solid var(--ius-line); background: #fff; }

.ihp-action {
    display: flex; align-items: center; justify-content: space-between; gap: 10px;
    width: 100%; border: 0; cursor: pointer; border-radius: 11px; padding: 12px 14px;
    background: linear-gradient(150deg, var(--ius-navy), var(--ius-navy-deep)); color: #fff;
    font-size: 12.8px; font-weight: 700; text-align: left;
    box-shadow: 0 6px 16px rgba(27, 38, 54, .22); transition: transform .16s, box-shadow .16s;
}
.ihp-action:hover { transform: translateY(-1px); box-shadow: 0 9px 20px rgba(27, 38, 54, .28); }
.ihp-action svg { width: 16px; height: 16px; color: var(--ius-gold); }
.ihp-action .ihp-action-sub { display: block; font-size: 10.5px; font-weight: 500; color: #c3ccdb; margin-top: 2px; }
.ihp-action[disabled] { background: #eef1f6; color: #8b97a8; box-shadow: none; cursor: not-allowed; }
.ihp-action[disabled] svg { color: #a9b4c6; }
.ihp-action[disabled] .ihp-action-sub { color: #a0aab8; }

.ihp-feedback { margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--ius-line); display: flex; align-items: center; gap: 8px; font-size: 11.5px; color: #7b8798; }
.ihp-feedback button { border: 1px solid #dbe3ee; background: #fff; border-radius: 8px; padding: 5px 9px; cursor: pointer; font-size: 13px; transition: border-color .15s, background .15s; }
.ihp-feedback button:hover { border-color: var(--ius-gold); background: #fffdf7; }
.ihp-feedback .thanks { color: #1f7a4d; font-weight: 700; }

/* ---------- Resultados de búsqueda ---------- */
.ihp-results { padding: 12px 12px 20px; }
.ihp-result {
    display: block; width: 100%; text-align: left; border: 0; background: #fff; cursor: pointer;
    border-radius: 10px; padding: 10px 12px; margin-bottom: 6px; transition: box-shadow .15s, transform .15s;
    box-shadow: 0 1px 2px rgba(38, 52, 73, .06);
}
.ihp-result:hover, .ihp-result.active { transform: translateY(-1px); box-shadow: 0 6px 16px rgba(38, 52, 73, .1); }
.ihp-result .cats { font-size: 9.5px; font-weight: 800; letter-spacing: .8px; text-transform: uppercase; color: #a68a45; margin-bottom: 2px; }
.ihp-result .t { font-size: 12.8px; font-weight: 700; color: var(--ius-navy); }
.ihp-result .s { font-size: 11px; color: #8b97a8; margin-top: 2px; line-height: 1.4; }
.ihp-result mark { background: #fdf1cf; color: #6b5213; padding: 0 1px; border-radius: 2px; }
.ihp-noresults { text-align: center; padding: 34px 16px; color: #8b97a8; font-size: 12.5px; }
.ihp-noresults svg { width: 32px; height: 32px; margin: 0 auto 8px; color: #cbd3df; display: block; }

.ihp-foot {
    flex-shrink: 0; display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
    padding: 10px 18px; border-top: 1px solid var(--ius-line);
    background: #fff; font-size: 11px; color: #7b8798;
}
.ihp-foot a { color: var(--ius-navy); font-weight: 700; text-decoration: none; }
.ihp-foot a:hover { text-decoration: underline; }
.ihp-foot-tel { color: #9aa6b6; }

/* ---------- Zoom de imagen ---------- */
#ihp-zoom {
    position: fixed; inset: 0; z-index: 80; background: rgba(10, 16, 26, .88);
    display: none; align-items: center; justify-content: center; padding: 24px; cursor: zoom-out;
}
#ihp-zoom.open { display: flex; }
#ihp-zoom img { max-width: 100%; max-height: 92vh; border-radius: 8px; box-shadow: 0 20px 60px rgba(0,0,0,.5); }

/* ---------- Toast contextual ---------- */
#ihp-toast {
    position: fixed; right: 22px; bottom: 88px; z-index: 64; width: 300px;
    background: #fff; border-radius: 13px; border: 1px solid #e2e8f1;
    box-shadow: 0 16px 40px rgba(15, 23, 42, .18); padding: 12px 14px;
    transform: translateY(12px); opacity: 0; pointer-events: none;
    transition: opacity .28s var(--help-ease), transform .28s var(--help-ease);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}
#ihp-toast.show { opacity: 1; transform: translateY(0); pointer-events: auto; }
#ihp-toast .ihp-toast-top { display: flex; align-items: flex-start; gap: 9px; }
#ihp-toast .ihp-toast-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ius-gold); margin-top: 5px; flex-shrink: 0; }
#ihp-toast p { margin: 0; font-size: 11.8px; color: #374151; line-height: 1.45; }
#ihp-toast b { color: var(--ius-navy); }
#ihp-toast button { margin-top: 8px; border: 0; background: var(--ius-navy); color: #fff; border-radius: 8px; padding: 6px 10px; font-size: 11.5px; font-weight: 700; cursor: pointer; }
#ihp-toast .ihp-toast-close { position: absolute; top: 6px; right: 8px; background: transparent; color: #9aa6b6; font-size: 15px; padding: 2px 5px; }

/* ---------- Utilidades ---------- */
.ihp-hidden { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }

@media (max-width: 640px) {
    :root { --help-w: 100vw; }
    #ius-help-launcher { right: 16px; bottom: 16px; width: 50px; height: 50px; }
    .ihp-cats { grid-template-columns: 1fr; }
    #ihp-toast { right: 16px; left: 16px; width: auto; bottom: 78px; }
}

@media (prefers-reduced-motion: reduce) {
    #ius-help-panel, #ius-help-backdrop, #ius-help-launcher, #ihp-toast { transition: none !important; }
    #ius-help-launcher.has-context .ihl-dot { animation: none; }
}
