/* OMC Medical guided chat assistant (view/partials/chatbot.php) */
:root {
    --omc-chat-primary: #252775;
    --omc-chat-primary-hover: #2f3fa0;
    --omc-chat-accent: #2584b7;
    --omc-chat-bg: #f4f5f8;
    --omc-chat-surface: #ffffff;
    --omc-chat-border: #e1e4ec;
    --omc-chat-text: #14162e;
    --omc-chat-muted: #5b5f73;
}

/* Launcher sits directly above #backToTop (bottom 24px, 44px tall, centred on the same axis) */
.omc-chat-launcher {
    position: fixed;
    right: 20px;
    bottom: 80px;
    width: 52px;
    height: 52px;
    border-radius: 50%;
    border: none;
    background: var(--omc-chat-primary);
    color: #fff;
    font-size: 22px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 8px 24px rgba(37, 39, 117, 0.35);
    z-index: 10000;
    transition: background 0.2s ease, transform 0.2s ease;
}

.omc-chat-launcher:hover {
    background: var(--omc-chat-primary-hover);
    transform: translateY(-2px);
}

.omc-chat-launcher:focus-visible {
    outline: 3px solid var(--omc-chat-accent);
    outline-offset: 3px;
}

.omc-chat-launcher.is-active .bi-chat-dots-fill::before {
    content: "\F659"; /* bi-x-lg */
}

.omc-chat-launcher__badge {
    position: absolute;
    top: 3px;
    right: 3px;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: #22c55e;
    border: 2px solid #fff;
}

.omc-chat-launcher.is-active .omc-chat-launcher__badge {
    display: none;
}

/* Panel */
.omc-chat {
    position: fixed;
    right: 20px;
    bottom: 144px;
    width: 380px;
    max-width: calc(100vw - 40px);
    height: min(600px, calc(100vh - 170px));
    display: flex;
    flex-direction: column;
    background: var(--omc-chat-bg);
    border-radius: 24px;
    box-shadow: 0 24px 60px rgba(15, 18, 50, 0.28);
    overflow: hidden;
    z-index: 10001;
    color: var(--omc-chat-text);
    opacity: 0;
    transform: translateY(12px) scale(0.98);
    transform-origin: bottom right;
    transition: opacity 0.2s ease, transform 0.2s ease;
}

.omc-chat[hidden] {
    display: none;
}

.omc-chat.is-open {
    opacity: 1;
    transform: none;
}

.omc-chat__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 14px 16px 14px 18px;
    background: var(--omc-chat-primary);
    color: #fff;
}

.omc-chat .omc-chat__eyebrow {
    margin: 0 0 2px;
    font-size: 10px;
    line-height: 1.2;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    opacity: 0.75;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.omc-chat .omc-chat__title {
    margin: 0;
    font-size: 15px;
    font-weight: 700;
    line-height: 1.3;
    color: #fff;
}

.omc-chat__actions {
    display: flex;
    gap: 6px;
}

/* Header avatar (placeholder: img/chat-avatar.svg) */
.omc-chat__avatar {
    position: relative;
    flex-shrink: 0;
    width: 44px;
    height: 44px;
}

.omc-chat__avatar img {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid rgba(255, 255, 255, 0.85);
    background: #fff;
}

.omc-chat__status {
    position: absolute;
    right: 0;
    bottom: 1px;
    width: 11px;
    height: 11px;
    border-radius: 50%;
    background: #22c55e;
    border: 2px solid var(--omc-chat-primary);
}

.omc-chat__heading {
    flex: 1;
    min-width: 0;
}

.omc-chat__icon-btn {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: none;
    background: rgba(255, 255, 255, 0.14);
    color: #fff;
    font-size: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.2s ease;
}

.omc-chat__icon-btn:hover {
    background: rgba(255, 255, 255, 0.26);
}

.omc-chat__body {
    flex: 1;
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: 18px 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

/* Bot message row: mini avatar + content. Only the first row of a bot group shows the avatar. */
.omc-chat__row {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    max-width: 100%;
}

.omc-chat__row > .omc-chat__card {
    flex: 1;
    min-width: 0;
}

.omc-chat__mini-avatar {
    width: 28px;
    height: 28px;
    flex-shrink: 0;
    border-radius: 50%;
    object-fit: cover;
    background: #fff;
    border: 1px solid var(--omc-chat-border);
}

.omc-chat__row + .omc-chat__row .omc-chat__mini-avatar {
    visibility: hidden;
}

.omc-chat__bubble {
    max-width: 88%;
    padding: 12px 16px;
    border-radius: 18px;
    font-size: 14.5px;
    line-height: 1.5;
    word-wrap: break-word;
    animation: omcChatIn 0.2s ease;
}

.omc-chat__bubble--bot {
    align-self: flex-start;
    background: var(--omc-chat-surface);
    border: 1px solid var(--omc-chat-border);
    border-bottom-left-radius: 6px;
}

.omc-chat__bubble--bot.is-strong {
    font-weight: 700;
}

.omc-chat__bubble--user {
    align-self: flex-end;
    background: var(--omc-chat-primary);
    color: #fff;
    border-bottom-right-radius: 6px;
}

.omc-chat__options {
    margin-left: 36px; /* line up with bot bubbles (avatar 28px + 8px gap) */
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 4px;
    animation: omcChatIn 0.2s ease;
}

.omc-chat__options--inline {
    flex-direction: row;
}

.omc-chat__option {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    width: 100%;
    padding: 13px 16px;
    background: var(--omc-chat-surface);
    border: 1px solid var(--omc-chat-border);
    border-radius: 14px;
    font-size: 14.5px;
    font-weight: 600;
    color: var(--omc-chat-text);
    text-align: left;
    cursor: pointer;
    transition: border-color 0.15s ease, box-shadow 0.15s ease, transform 0.15s ease;
}

.omc-chat__option:hover,
.omc-chat__option:focus-visible {
    border-color: var(--omc-chat-primary);
    box-shadow: 0 4px 14px rgba(37, 39, 117, 0.12);
    transform: translateY(-1px);
    outline: none;
}

.omc-chat__arrow {
    color: var(--omc-chat-accent);
    font-size: 18px;
    flex-shrink: 0;
}

.omc-chat__chip {
    padding: 6px 14px;
    border-radius: 50rem;
    border: 1px solid var(--omc-chat-border);
    background: var(--omc-chat-surface);
    font-size: 13px;
    font-weight: 600;
    color: var(--omc-chat-muted);
    cursor: pointer;
}

.omc-chat__chip:hover {
    border-color: var(--omc-chat-primary);
    color: var(--omc-chat-primary);
}

/* Service info card */
.omc-chat__card {
    background: var(--omc-chat-surface);
    border: 1px solid var(--omc-chat-border);
    border-radius: 16px;
    padding: 14px 16px;
    font-size: 13.5px;
    animation: omcChatIn 0.2s ease;
}

.omc-chat__card-title {
    margin: 0 0 6px;
    font-size: 15px;
    font-weight: 700;
    color: var(--omc-chat-primary);
}

.omc-chat__card-text {
    margin: 0 0 10px;
    color: var(--omc-chat-muted);
    line-height: 1.5;
}

.omc-chat__service-list {
    list-style: none;
    margin: 0 0 10px;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.omc-chat__service-list li {
    padding: 0 0 0 12px;
    border-left: 3px solid var(--omc-chat-accent);
}

.omc-chat__service-list a {
    display: block;
    font-weight: 700;
    color: var(--omc-chat-text);
    text-decoration: none;
}

.omc-chat__service-list a:hover {
    color: var(--omc-chat-accent);
    text-decoration: underline;
}

.omc-chat__service-list small {
    display: block;
    color: var(--omc-chat-muted);
    line-height: 1.4;
}

.omc-chat__card-link {
    font-weight: 700;
    color: var(--omc-chat-accent);
    text-decoration: none;
}

.omc-chat__card-link:hover {
    text-decoration: underline;
}

/* Typing indicator */
.omc-chat__typing {
    align-self: flex-start;
    display: flex;
    gap: 4px;
    padding: 14px 16px;
    background: var(--omc-chat-surface);
    border: 1px solid var(--omc-chat-border);
    border-radius: 18px;
    border-bottom-left-radius: 6px;
}

.omc-chat__typing span {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #a3a7b8;
    animation: omcChatDot 1s infinite ease-in-out;
}

.omc-chat__typing span:nth-child(2) {
    animation-delay: 0.15s;
}

.omc-chat__typing span:nth-child(3) {
    animation-delay: 0.3s;
}

/* Composer */
.omc-chat__composer {
    display: flex;
    gap: 8px;
    padding: 12px 14px;
    background: var(--omc-chat-surface);
    border-top: 1px solid var(--omc-chat-border);
}

.omc-chat__composer[hidden] {
    display: none;
}

.omc-chat__input {
    flex: 1;
    min-width: 0;
    height: 44px;
    padding: 0 16px;
    border: 1px solid var(--omc-chat-border);
    border-radius: 50rem;
    font-size: 15px;
    color: var(--omc-chat-text);
    background: var(--omc-chat-bg);
}

.omc-chat__input:focus {
    outline: none;
    border-color: var(--omc-chat-primary);
    background: #fff;
}

.omc-chat__send {
    width: 44px;
    height: 44px;
    flex-shrink: 0;
    border-radius: 50%;
    border: none;
    background: var(--omc-chat-primary);
    color: #fff;
    cursor: pointer;
}

.omc-chat__send:hover {
    background: var(--omc-chat-primary-hover);
}

.omc-chat__hp {
    position: absolute;
    left: -9999px;
    width: 1px;
    height: 1px;
}

@keyframes omcChatIn {
    from {
        opacity: 0;
        transform: translateY(6px);
    }

    to {
        opacity: 1;
        transform: none;
    }
}

@keyframes omcChatDot {

    0%,
    80%,
    100% {
        transform: scale(0.6);
        opacity: 0.5;
    }

    40% {
        transform: scale(1);
        opacity: 1;
    }
}

@media (prefers-reduced-motion: reduce) {

    .omc-chat,
    .omc-chat__bubble,
    .omc-chat__options,
    .omc-chat__card,
    .omc-chat__typing span {
        animation: none;
        transition: none;
    }
}

/* Mobile: #backToTop is 40px at bottom/right 16px, so the launcher moves down with it
   and the panel goes near full-screen */
@media (max-width: 575.98px) {
    .omc-chat-launcher {
        right: 12px;
        bottom: 68px;
        width: 48px;
        height: 48px;
        font-size: 20px;
    }

    .omc-chat {
        left: 8px;
        right: 8px;
        bottom: 8px;
        top: 8px;
        width: auto;
        max-width: none;
        height: auto;
        border-radius: 20px;
    }

    body.omc-chat-open .omc-chat-launcher,
    body.omc-chat-open #backToTop {
        display: none;
    }

    .omc-chat__input {
        font-size: 16px; /* prevents iOS zoom on focus */
    }
}
