/* ==========================================================================
   Clinic Helper widget — adapted from Parkway Pharmacy AI widget.
   Uses site theme tokens (--primary, --accent) with safe fallbacks.
   ========================================================================== */

.aih {
    --aih-primary:  var(--primary,      #1d5b7c);
    --aih-deep:     var(--primary-dark, #154759);
    --aih-accent:   var(--accent,       #c8872e);
    --aih-ink:      var(--ink,          #1f2a30);
    position: fixed;
    right: 22px;
    bottom: 88px; /* above accessibility widget */
    z-index: 1200;
    font-family: inherit;
}

/* ---- Mobile: round icon under accessibility button ---- */
@media (max-width: 1024px) {
    .aih { right: 16px; bottom: 16px; z-index: 100001; }

    body.cr-ai-open #accessibilityWidget,
    body.cr-ai-open .acc-toggle-btn { display: none !important; }

    .aih__launch {
        padding: 0;
        width: 50px; height: 50px;
        border-radius: 50%;
        justify-content: center;
        background: var(--aih-primary);
        box-shadow:
            inset 0 0 0 4px var(--aih-primary),
            inset 0 0 0 6px #fff,
            0 2px 5px rgba(0,0,0,.2);
    }
    .aih__launch-text { display: none; }
    .aih__launch-icon svg { width: 26px; height: 26px; }

    .aih__panel {
        position: fixed !important;
        left: 10px !important; right: 10px !important;
        bottom: 10px !important; top: auto !important;
        width: auto !important; max-width: none !important;
        max-height: 72vh !important;
        border-radius: 16px;
    }
}

/* ---- Launcher pill ---- */
.aih__launch {
    display: inline-flex;
    align-items: center;
    gap: 9px;
    padding: 12px 18px 12px 14px;
    border: 0;
    cursor: pointer;
    color: #fff;
    font-size: 15px;
    font-weight: 600;
    border-radius: 999px;
    background: var(--aih-primary);
    box-shadow: 0 10px 30px rgba(20,40,75,.35), 0 0 0 1px rgba(255,255,255,.06) inset;
    transition: transform .18s ease, box-shadow .18s ease;
}
.aih__launch:hover {
    transform: translateY(-2px);
    box-shadow: 0 16px 40px rgba(20,40,75,.45), 0 0 22px rgba(200,135,46,.3);
}
.aih__launch-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px; height: 24px;
    border-radius: 50%;
    background: rgba(255,255,255,.18);
    animation: aih-pulse 2.6s ease-in-out infinite;
}
@keyframes aih-pulse {
    0%,100% { box-shadow: 0 0 0 0 rgba(200,135,46,.55); }
    50%      { box-shadow: 0 0 0 8px rgba(200,135,46,0); }
}

/* ---- Panel ---- */
.aih__panel {
    position: absolute;
    right: 0; bottom: 0;
    width: 360px;
    max-height: min(560px, 80vh);
    display: none;
    flex-direction: column;
    overflow: hidden;
    border-radius: 18px;
    background: rgba(255,255,255,.93);
    backdrop-filter: blur(14px) saturate(1.1);
    -webkit-backdrop-filter: blur(14px) saturate(1.1);
    border: 1px solid rgba(20,40,75,.12);
    box-shadow: 0 24px 60px rgba(15,30,55,.35);
    color: var(--aih-ink);
}
.aih.is-open .aih__panel  { display: flex; animation: aih-rise .22s ease both; }
.aih.is-open .aih__launch { display: none; }
@keyframes aih-rise {
    from { opacity:0; transform: translateY(10px) scale(.98); }
    to   { opacity:1; transform: translateY(0)    scale(1); }
}

/* ---- Header ---- */
.aih__head {
    display: flex; align-items: center; gap: 10px;
    padding: 14px 14px 12px;
    color: #fff;
    background: linear-gradient(135deg, var(--aih-primary), var(--aih-deep));
    flex-shrink: 0;
}
.aih__avatar {
    width: 36px; height: 36px;
    border-radius: 50%;
    display: inline-grid; place-items: center;
    background: rgba(255,255,255,.22);
    border: 1.5px solid rgba(255,255,255,.5);
    flex: 0 0 auto;
    color: #fff;
}
.aih__head-text { display: flex; flex-direction: column; line-height: 1.2; flex: 1 1 auto; }
.aih__title    { font-size: 15px; font-weight: 700; }
.aih__subtitle { font-size: 11.5px; opacity: .82; }
.aih__min {
    border: 0; background: rgba(255,255,255,.14); color: #fff;
    width: 28px; height: 28px; border-radius: 8px; cursor: pointer;
    font-size: 18px; line-height: 1; flex: 0 0 auto;
}
.aih__min:hover { background: rgba(255,255,255,.26); }

/* ---- Message log ---- */
.aih__log {
    flex: 1 1 auto;
    overflow-y: auto;
    padding: 14px;
    display: flex; flex-direction: column; gap: 10px;
    background:
        radial-gradient(120% 80% at 100% 0%, rgba(200,135,46,.06), transparent 60%),
        radial-gradient(120% 80% at 0% 100%, rgba(29,91,124,.06), transparent 60%),
        #fff;
}
.aih__msg { display: flex; }
.aih__msg--bot  { justify-content: flex-start; }
.aih__msg--user { justify-content: flex-end; }

.aih__bubble {
    margin: 0; padding: 10px 13px;
    border-radius: 14px;
    font-size: 14px; line-height: 1.5;
    max-width: 86%;
    box-shadow: 0 2px 8px rgba(15,30,55,.08);
}
.aih__msg--bot  .aih__bubble {
    background: #fff;
    border: 1px solid rgba(20,40,75,.08);
    border-bottom-left-radius: 5px;
}
.aih__msg--user .aih__bubble {
    background: linear-gradient(135deg, var(--aih-primary), var(--aih-deep));
    color: #fff;
    border-bottom-right-radius: 5px;
}
.aih__bubble a.aih__link {
    display: inline-flex; align-items: center; gap: 6px;
    margin-top: 8px; padding: 7px 12px;
    border-radius: 999px;
    font-weight: 600; font-size: 13px;
    text-decoration: none;
    color: var(--aih-deep);
    background: rgba(200,135,46,.16);
    border: 1px solid rgba(200,135,46,.45);
}
.aih__bubble a.aih__link:hover { background: rgba(200,135,46,.28); }

/* Secondary "Find out more" link (WebMD) */
.aih__more {
    margin-top: 6px; font-size: 12px; line-height: 1.35;
}
.aih__more a { color: var(--aih-deep); text-decoration: underline; opacity: .85; }
.aih__more a:hover { opacity: 1; }

/* ---- Typing indicator ---- */
.aih__typing {
    display: inline-flex; gap: 4px; align-items: center;
    padding: 12px 14px;
}
.aih__typing span {
    width: 9px; height: 9px; border-radius: 50%;
    background: rgba(29,91,124,.5);
    animation: aih-blink 1.2s infinite ease-in-out both;
}
.aih__typing span:nth-child(2) { animation-delay: .18s; }
.aih__typing span:nth-child(3) { animation-delay: .36s; }
.aih__typing-label { font-size: 12px; opacity: .7; margin-left: 4px; color: var(--aih-ink); }
@keyframes aih-blink {
    0%,80%,100% { transform: translateY(0) scale(1); opacity: .45; }
    40%         { transform: translateY(-9px) scale(1.3); opacity: 1; }
}

/* ---- Suggested question chips ---- */
.aih__chips {
    display: flex; flex-wrap: wrap; gap: 7px;
    padding: 0 14px 10px;
    flex-shrink: 0;
}
.aih__chip {
    border: 1px solid rgba(29,91,124,.25);
    background: rgba(29,91,124,.06);
    color: var(--aih-deep);
    border-radius: 999px;
    padding: 7px 12px;
    font-size: 12.5px;
    cursor: pointer;
    transition: background .15s;
}
.aih__chip:hover { background: rgba(29,91,124,.14); }

/* ---- Input form ---- */
.aih__form {
    display: flex; gap: 8px;
    padding: 10px 12px;
    border-top: 1px solid rgba(20,40,75,.1);
    background: #fff;
    flex-shrink: 0;
}
.aih__input {
    flex: 1 1 auto;
    border: 1px solid rgba(20,40,75,.2);
    border-radius: 999px;
    padding: 10px 14px;
    font-size: 14px;
    outline: none;
    font-family: inherit;
}
.aih__input:focus {
    border-color: var(--aih-primary);
    box-shadow: 0 0 0 3px rgba(29,91,124,.12);
}
.aih__send {
    flex: 0 0 auto;
    width: 42px; height: 42px;
    border: 0; border-radius: 50%;
    cursor: pointer;
    color: #fff;
    font-size: 16px;
    background: linear-gradient(135deg, var(--aih-primary), var(--aih-deep));
    display: inline-flex; align-items: center; justify-content: center;
    transition: filter .15s;
}
.aih__send:hover { filter: brightness(1.1); }

/* ---- Footer ---- */
.aih__foot {
    background: #0f2c44;
    padding: 7px 12px 8px;
    text-align: center;
    flex-shrink: 0;
}
.aih__fine {
    margin: 0;
    font-size: 10.5px;
    font-weight: 700;
    color: #fff;
    line-height: 1.3;
}
.aih__fine--sub {
    font-weight: 400;
    opacity: .78;
    margin-top: 2px;
}

/* Locked state */
.aih.is-locked .aih__input { background: #f5f5f5; color: #999; cursor: not-allowed; }

@media (prefers-reduced-motion: reduce) {
    .aih__launch-icon,
    .aih__typing span { animation: none; }
    .aih.is-open .aih__panel { animation: none; }
}
