/* Premium rule-based chat widget — positioned left of conversion widget (bottom-right stack) */

.hospital-chat {
    position: fixed;
    z-index: 9015;
    bottom: max(20px, env(safe-area-inset-bottom));
    right: calc(max(18px, env(safe-area-inset-right)) + min(320px, calc(100vw - 28px)) + 16px);
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 12px;
    font-family: inherit;
    max-width: calc(100vw - 24px);
}

.hospital-chat__fab {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    border: none;
    background: transparent;
    color: inherit;
    cursor: pointer;
    box-shadow: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.22s ease, box-shadow 0.22s ease, opacity 0.2s ease;
}

.hospital-chat__fab:hover {
    transform: translateY(-1px) scale(1.02);
    box-shadow: none;
}

.hospital-chat__fab:focus-visible {
    outline: 3px solid #0f8a35;
    outline-offset: 3px;
}

.hospital-chat__fab-icon {
    width: 30px;
    height: 30px;
    object-fit: contain;
    display: block;
}

.hospital-chat__panel {
    width: min(360px, calc(100vw - 24px));
    max-height: min(520px, calc(100vh - 120px));
    display: flex;
    flex-direction: column;
    box-sizing: border-box;
    border-radius: 18px;
    border: 1px solid rgba(0, 128, 1, 0.18);
    background: rgba(255, 255, 255, 0.98);
    backdrop-filter: blur(10px);
    box-shadow: 0 18px 48px rgba(15, 23, 42, 0.18), 0 0 0 1px rgba(255, 255, 255, 0.6) inset;
    overflow: hidden;
    opacity: 0;
    transform: translateY(10px) scale(0.98);
    pointer-events: none;
    transition: opacity 0.28s ease, transform 0.28s ease;
}

.hospital-chat.is-open .hospital-chat__panel {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: auto;
}

.hospital-chat__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 14px 16px;
    background: linear-gradient(135deg, rgba(0, 128, 1, 0.1) 0%, rgba(0, 128, 1, 0.02) 100%);
    border-bottom: 1px solid rgba(0, 128, 1, 0.12);
}

.hospital-chat__title-wrap {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}

.hospital-chat__badge {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #22c55e;
    box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.25);
    flex-shrink: 0;
}

.hospital-chat__title {
    margin: 0;
    font-size: 1rem;
    font-weight: 700;
    color: #0f172a;
    letter-spacing: -0.02em;
}

.hospital-chat__close {
    width: 36px;
    height: 36px;
    border: none;
    border-radius: 10px;
    background: rgba(15, 23, 42, 0.06);
    color: #334155;
    font-size: 1.35rem;
    line-height: 1;
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease;
}

.hospital-chat__close:hover {
    background: rgba(0, 128, 1, 0.12);
    color: #008001;
}

.hospital-chat__body {
    flex: 1;
    min-height: 140px;
    max-height: 280px;
    overflow-y: auto;
    padding: 12px 14px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    -webkit-overflow-scrolling: touch;
}

.hospital-chat__msg {
    max-width: 92%;
    padding: 10px 12px;
    border-radius: 14px;
    font-size: 0.9rem;
    line-height: 1.45;
    color: #1e293b;
}

.hospital-chat__msg--bot {
    align-self: flex-start;
    background: #f1f5f9;
    border: 1px solid #e2e8f0;
    border-bottom-left-radius: 4px;
}

.hospital-chat__msg--user {
    align-self: flex-end;
    background: linear-gradient(145deg, #008001 0%, #0a6b2e 100%);
    color: #fff;
    border-bottom-right-radius: 4px;
}

.hospital-chat__quick {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 8px 12px 4px;
    border-top: 1px solid #e2e8f0;
    background: #fafbfc;
}

.hospital-chat__chip {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 6px 10px;
    font-size: 0.72rem;
    font-weight: 600;
    border-radius: 999px;
    border: 1px solid rgba(0, 128, 1, 0.25);
    background: #fff;
    color: #0f172a;
    cursor: pointer;
    text-decoration: none;
    transition: border-color 0.15s ease, background 0.15s ease, color 0.15s ease;
}

.hospital-chat__chip:hover {
    border-color: #008001;
    background: rgba(0, 128, 1, 0.08);
    color: #008001;
}

.hospital-chat__chip--link {
    color: #0f172a;
}

.hospital-chat__form {
    display: flex;
    gap: 8px;
    padding: 10px 12px 12px;
    border-top: 1px solid #e2e8f0;
    background: #fff;
}

.hospital-chat__input {
    flex: 1;
    min-width: 0;
    padding: 10px 12px;
    border-radius: 12px;
    border: 1px solid #cbd5e1;
    font-size: 0.9rem;
    outline: none;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.hospital-chat__input:focus {
    border-color: #008001;
    box-shadow: 0 0 0 3px rgba(0, 128, 1, 0.15);
}

.hospital-chat__send {
    width: 44px;
    height: 44px;
    flex-shrink: 0;
    border: none;
    border-radius: 12px;
    background: #008001;
    color: #fff;
    font-size: 1rem;
    cursor: pointer;
    transition: background 0.15s ease, transform 0.15s ease;
}

.hospital-chat__send:hover {
    background: #006902;
    transform: translateY(-1px);
}

.hospital-chat__send:disabled {
    opacity: 0.55;
    cursor: not-allowed;
    transform: none;
}

.hospital-chat--busy .hospital-chat__quick {
    pointer-events: none;
    opacity: 0.62;
}

.hospital-chat--busy .hospital-chat__send {
    position: relative;
    color: transparent;
}

.hospital-chat--busy .hospital-chat__send::after {
    content: "";
    position: absolute;
    inset: 0;
    margin: auto;
    width: 18px;
    height: 18px;
    border: 2px solid rgba(255, 255, 255, 0.35);
    border-top-color: #fff;
    border-radius: 50%;
    animation: hospital-chat-spin 0.65s linear infinite;
}

@keyframes hospital-chat-spin {
    to {
        transform: rotate(360deg);
    }
}

@media (max-width: 768px) {
    .hospital-chat {
        right: calc(max(12px, env(safe-area-inset-right)) + 52px + 10px);
        bottom: max(12px, env(safe-area-inset-bottom));
    }

    .hospital-chat__panel {
        width: min(340px, calc(100vw - 88px));
    }

    .hospital-chat__body {
        max-height: 42vh;
    }
}

@media (prefers-reduced-motion: reduce) {
    .hospital-chat__panel,
    .hospital-chat__fab,
    .hospital-chat__send {
        transition: none;
    }

    .hospital-chat.is-open .hospital-chat__panel {
        transform: none;
    }

    .hospital-chat--busy .hospital-chat__send::after {
        animation: none;
        border: 2px solid rgba(255, 255, 255, 0.6);
    }
}
