/* ==========================================================================
   Shree Specialty Clinics — Global Responsive Chatbot Widget
   ========================================================================== */

/* 3rd Sticky Floating Button (Chatbot) */
.fab-chatbot {
    background: linear-gradient(135deg, #731436 0%, #5e102c 100%);
    border: none;
    padding: 0;
}

.fab-chatbot .fab-pulse-ring {
    border: 2px solid rgba(115, 20, 54, 0.55);
    animation: fab-ripple-chat 3s cubic-bezier(0.25, 0.8, 0.25, 1) 0.75s infinite;
}

.fab-chatbot.is-open .fab-pulse-ring {
    animation: none;
    opacity: 0;
}

.fab-chatbot svg.fab-chatbot-icon {
    width: 25px;
    height: 25px;
    fill: currentColor;
    stroke: none;
}

@keyframes fab-ripple-chat {
    0% { transform: scale(1); opacity: 0.8; }
    50% { transform: scale(1.4); opacity: 0; }
    100% { transform: scale(1.4); opacity: 0; }
}

@media (max-width: 575px) {
    .fab-chatbot svg.fab-chatbot-icon {
        width: 23px;
        height: 23px;
    }
}

/* Chatbot Widget Container (Scoped) */
#shree-chatbot-root {
    --cb-pink-dark: #5E102C;
    --cb-pink: #731436;
    --cb-pink-mid: #A86D82;
    --cb-pink-light: #E3D0D7;
    --cb-pink-pale: #F5EFF1;
    --cb-ink: #221019;
    --cb-ink-soft: #5B4650;
    --cb-white: #FFFFFF;
    --cb-line: #F3D3E0;
    --cb-shadow: 0 10px 30px rgba(115, 20, 54, 0.18);

    position: fixed;
    right: clamp(0.75rem, 2.2vw, 1.75rem);
    bottom: clamp(0.75rem, 2.2vw, 1.75rem);
    z-index: 1250;
    pointer-events: none;
    font-family: 'Poppins', 'Noto Sans Tamil', Montserrat, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    color: var(--cb-ink);
    line-height: 1.45;
}

#shree-chatbot-root *,
#shree-chatbot-root *::before,
#shree-chatbot-root *::after {
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

#shree-chatbot-root.is-open {
    pointer-events: auto;
}

body.chatbot-open .floating-contact {
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.18s ease;
}

/* Floating Panel (Reference Screenshot Style) */
#shree-chatbot-panel {
    position: relative;
    width: min(390px, calc(100vw - 24px));
    height: min(650px, calc(100vh - 36px));
    height: min(650px, calc(100dvh - 36px));
    background: var(--cb-white);
    border-radius: 22px;
    box-shadow: 0 22px 55px rgba(55, 8, 26, 0.34), 0 0 0 1px rgba(115, 20, 54, 0.12);
    display: flex;
    flex-direction: column;
    overflow: visible;
    opacity: 0;
    visibility: hidden;
    transform: translateY(20px) scale(0.95);
    transform-origin: bottom right;
    transition: opacity 0.24s ease, transform 0.26s cubic-bezier(0.22, 1, 0.36, 1), visibility 0.24s;
}

#shree-chatbot-root.is-open #shree-chatbot-panel {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
}

/* Circular Close Button (Top-right like reference screenshot) */
#cb-close-btn {
    position: absolute;
    top: -12px;
    right: -10px;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    border: 2px solid #ffffff;
    background: #5b4650;
    color: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 30;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.28);
    font-size: 18px;
    line-height: 1;
    padding: 0;
    transition: background 0.2s ease, transform 0.2s ease;
}

#cb-close-btn:hover {
    background: var(--cb-pink-dark);
    transform: scale(1.08);
}

#cb-close-btn:active {
    transform: scale(0.94);
}

#cb-inner-shell {
    width: 100%;
    height: 100%;
    border-radius: 22px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    background: var(--cb-white);
    position: relative;
}

/* Header */
#cb-header {
    background: linear-gradient(135deg, var(--cb-pink-dark) 0%, var(--cb-pink) 55%, var(--cb-pink-mid) 100%);
    padding: 14px 16px 12px;
    flex-shrink: 0;
    z-index: 5;
    overflow: hidden;
}

#cb-brand-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    min-width: 0;
}

#shree-chatbot-root .cb-logo {
    height: 42px;
    max-width: 170px;
    padding: 5px 10px;
    border-radius: 10px;
    background: #ffffff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    overflow: hidden;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.22);
}

#shree-chatbot-root .cb-logo picture {
    height: 100%;
    display: flex;
    align-items: center;
}

#shree-chatbot-root .cb-logo img {
    height: 32px;
    width: auto;
    max-height: 100%;
    max-width: 100%;
    object-fit: contain;
    display: block;
}

#cb-lang-toggle {
    margin-left: auto;
    display: flex;
    background: rgba(255, 255, 255, 0.22);
    border-radius: 20px;
    padding: 3px;
    gap: 3px;
}

#cb-lang-toggle button {
    border: none;
    outline: none;
    cursor: pointer;
    padding: 5px 11px;
    border-radius: 16px;
    font-family: inherit;
    font-weight: 600;
    font-size: 12px;
    color: #ffffff;
    background: transparent;
    transition: all 0.2s;
}

#cb-lang-toggle button.active {
    background: #ffffff;
    color: var(--cb-pink-dark);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
}

#cb-status-row {
    margin-top: 10px;
    display: flex;
    align-items: center;
    gap: 6px;
}

#cb-status-row .cb-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #5CFFB1;
    box-shadow: 0 0 0 3px rgba(92, 255, 177, 0.25);
    flex-shrink: 0;
}

#cb-status-row span {
    color: #FFE3EF;
    font-size: 11px;
    font-weight: 500;
}

/* Scrollable Body */
#cb-scrollArea {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    scroll-behavior: smooth;
    background: var(--cb-pink-pale);
    position: relative;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
}

#cb-scrollArea::-webkit-scrollbar {
    width: 0;
    display: none;
}

#shree-chatbot-root [lang-ta] {
    font-family: 'Noto Sans Tamil', 'Poppins', sans-serif;
}

#cb-welcome {
    padding: 18px 18px 16px;
    text-align: center;
    background: radial-gradient(circle at 15% 10%, rgba(115, 20, 54, 0.07), transparent 45%),
                radial-gradient(circle at 90% 0%, rgba(115, 20, 54, 0.08), transparent 40%),
                var(--cb-pink-pale);
    border-bottom: 1px solid var(--cb-line);
}

#cb-welcome-badge {
    height: 58px;
    max-width: 220px;
    padding: 7px 14px;
    border-radius: 14px;
    background: #ffffff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 10px;
    overflow: hidden;
    box-shadow: var(--cb-shadow);
    border: 2px solid var(--cb-pink-light);
}

#cb-welcome-badge picture {
    height: 100%;
    display: flex;
    align-items: center;
}

#cb-welcome-badge img {
    height: 40px;
    width: auto;
    max-height: 100%;
    max-width: 100%;
    object-fit: contain;
    display: block;
}

#cb-welcome h1 {
    font-family: inherit;
    font-size: 18px;
    font-weight: 800;
    color: var(--cb-pink-dark);
    margin: 0 0 6px;
    line-height: 1.25;
}

#cb-welcome p {
    font-size: 12px;
    color: var(--cb-ink-soft);
    line-height: 1.55;
    margin: 0 auto;
    max-width: 310px;
    font-weight: 500;
}

/* Hero Card */
#cb-hero-wrap {
    padding: 14px 16px 4px;
}

#cb-hero-card {
    width: 100%;
    aspect-ratio: 16 / 11;
    min-height: 195px;
    border-radius: 18px;
    overflow: hidden;
    position: relative;
    box-shadow: var(--cb-shadow);
    border: 1px solid var(--cb-line);
    background: linear-gradient(160deg, var(--cb-pink-mid) 0%, var(--cb-pink) 55%, var(--cb-pink-dark) 100%);
}

#cb-hero-card picture {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    display: block;
}

#cb-hero-card img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: 70% 45%;
    display: block;
    position: absolute;
    inset: 0;
}

#cb-hero-card::after {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(to top, rgba(40, 5, 20, 0.86) 0%, rgba(40, 5, 20, 0.2) 55%, rgba(40, 5, 20, 0) 100%);
}

#cb-hero-text {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    padding: 14px 14px 12px;
    color: #ffffff;
    z-index: 2;
}

#cb-hero-text .cb-kicker {
    font-size: 10.5px;
    font-weight: 700;
    color: #FFD3E7;
    margin: 0 0 4px;
    letter-spacing: 0.04em;
}

#cb-hero-text h2 {
    font-family: inherit;
    font-size: 15.5px;
    font-weight: 800;
    margin: 0 0 4px;
    text-shadow: 0 2px 10px rgba(0, 0, 0, 0.45);
    line-height: 1.25;
    color: #ffffff;
}

#cb-hero-text p {
    font-size: 11px;
    font-weight: 500;
    margin: 0;
    color: #FFEAF3;
}

/* Specialities */
#cb-specialities {
    padding: 18px 16px 6px;
}

#cb-specialities h3,
#cb-doctors h3,
#cb-chat-heading h3 {
    font-family: inherit;
    font-size: 14.5px;
    font-weight: 700;
    margin: 0 0 3px;
    color: var(--cb-ink);
    line-height: 1.3;
}

#cb-specialities .cb-sub,
#cb-doctors .cb-sub,
#cb-chat-heading .cb-sub {
    font-size: 11px;
    color: var(--cb-ink-soft);
    margin: 0 0 11px;
    font-weight: 500;
}

#cb-spec-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 9px;
}

#shree-chatbot-root .cb-spec-pill {
    border: none;
    cursor: pointer;
    background: linear-gradient(135deg, var(--cb-pink) 0%, var(--cb-pink-dark) 100%);
    color: #ffffff;
    font-family: inherit;
    font-weight: 600;
    font-size: 11.5px;
    padding: 11px 10px;
    border-radius: 999px;
    text-align: center;
    box-shadow: 0 5px 12px rgba(115, 20, 54, 0.25);
    transition: transform 0.15s;
    line-height: 1.3;
}

#shree-chatbot-root .cb-spec-pill:active {
    transform: scale(0.96);
}

#shree-chatbot-root .cb-spec-pill:last-child:nth-child(odd) {
    grid-column: span 2;
}

/* Doctors */
#cb-doctors {
    padding: 16px 16px 4px;
}

#shree-chatbot-root .cb-doc-card {
    display: flex;
    align-items: center;
    gap: 11px;
    background: #ffffff;
    border: 1px solid var(--cb-line);
    border-radius: 16px;
    padding: 11px;
    box-shadow: 0 4px 12px rgba(115, 20, 54, 0.08);
}

#shree-chatbot-root .cb-doc-avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--cb-pink-mid), var(--cb-pink-dark));
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

#shree-chatbot-root .cb-doc-avatar svg {
    width: 28px;
    height: 28px;
    fill: #ffffff;
    stroke: none;
}

#shree-chatbot-root .cb-doc-info {
    flex: 1;
    min-width: 0;
}

#shree-chatbot-root .cb-doc-name {
    font-size: 13px;
    font-weight: 700;
    color: var(--cb-ink);
    line-height: 1.3;
}

#shree-chatbot-root .cb-doc-role {
    font-size: 11px;
    font-weight: 600;
    color: var(--cb-pink);
    margin-top: 2px;
    line-height: 1.35;
}

#shree-chatbot-root .cb-doc-btn {
    border: none;
    cursor: pointer;
    background: var(--cb-pink);
    color: #ffffff;
    font-family: inherit;
    font-weight: 600;
    font-size: 11px;
    padding: 7px 11px;
    border-radius: 999px;
    flex-shrink: 0;
}

/* Chat Area */
#cb-chat-heading {
    padding: 18px 16px 4px;
}

#cb-chat-heading .cb-sub {
    margin: 0;
}

#cb-chatLog {
    padding: 12px 14px 8px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

#shree-chatbot-root .cb-msg {
    max-width: 82%;
    padding: 10px 13px;
    border-radius: 16px;
    font-size: 12.5px;
    line-height: 1.55;
    font-weight: 500;
    animation: cb-pop 0.25s ease;
    word-wrap: break-word;
    overflow-wrap: anywhere;
}

@keyframes cb-pop {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: none; }
}

#shree-chatbot-root .cb-msg.bot {
    background: #ffffff;
    border: 1px solid var(--cb-line);
    border-bottom-left-radius: 4px;
    align-self: flex-start;
    box-shadow: 0 3px 10px rgba(115, 20, 54, 0.06);
    color: var(--cb-ink);
}

#shree-chatbot-root .cb-msg.user {
    background: linear-gradient(135deg, var(--cb-pink) 0%, var(--cb-pink-dark) 100%);
    color: #ffffff;
    border-bottom-right-radius: 4px;
    align-self: flex-end;
}

#shree-chatbot-root .cb-bot-row {
    display: flex;
    gap: 8px;
    align-items: flex-end;
}

#shree-chatbot-root .cb-bot-avatar {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: var(--cb-pink-light);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 13px;
}

#shree-chatbot-root .cb-typing {
    display: flex;
    gap: 4px;
    padding: 12px 14px;
    background: #ffffff;
    border: 1px solid var(--cb-line);
    border-radius: 16px;
}

#shree-chatbot-root .cb-typing span {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--cb-pink);
    opacity: 0.5;
    animation: cb-blink 1.1s infinite;
}

#shree-chatbot-root .cb-typing span:nth-child(2) { animation-delay: 0.15s; }
#shree-chatbot-root .cb-typing span:nth-child(3) { animation-delay: 0.3s; }

@keyframes cb-blink {
    0%, 80%, 100% { opacity: 0.3; }
    40% { opacity: 1; }
}

#cb-chips-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 2px 14px 16px;
}

#shree-chatbot-root .cb-chip {
    border: 1.5px solid var(--cb-pink);
    background: #ffffff;
    color: var(--cb-pink-dark);
    font-family: inherit;
    font-weight: 600;
    font-size: 11.5px;
    padding: 7px 12px;
    border-radius: 999px;
    cursor: pointer;
    transition: all 0.15s;
}

#shree-chatbot-root .cb-chip:active {
    background: var(--cb-pink-light);
}

#shree-chatbot-root .cb-chip.solid {
    background: var(--cb-pink);
    color: #ffffff;
}

#cb-bottom-spacer {
    height: 12px;
}

/* Scroll Rail */
#cb-scroll-rail {
    position: absolute;
    right: 6px;
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    flex-direction: column;
    gap: 6px;
    z-index: 20;
}

#shree-chatbot-root .cb-rail-btn {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: none;
    background: rgba(255, 255, 255, 0.92);
    color: var(--cb-pink-dark);
    box-shadow: 0 4px 12px rgba(115, 20, 54, 0.24);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 12px;
    padding: 0;
}

#shree-chatbot-root .cb-rail-track {
    width: 3px;
    flex: 1;
    min-height: 54px;
    background: rgba(115, 20, 54, 0.18);
    border-radius: 3px;
    margin: 2px auto;
    position: relative;
}

#cb-railThumb {
    position: absolute;
    left: -2.5px;
    width: 8px;
    height: 24px;
    border-radius: 5px;
    background: var(--cb-pink);
    top: 0;
    transition: top 0.1s linear;
}

/* Input Bar */
#cb-inputBar {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    background: #ffffff;
    border-top: 1px solid var(--cb-line);
}

#cb-userInput {
    flex: 1;
    min-width: 0;
    border: 1.5px solid var(--cb-line);
    background: var(--cb-pink-pale);
    border-radius: 22px;
    padding: 10px 14px;
    font-family: inherit;
    font-size: 16px; /* Prevents iOS Safari zoom on focus */
    color: var(--cb-ink);
    outline: none;
}

#cb-userInput:focus {
    border-color: var(--cb-pink);
}

#cb-sendBtn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: none;
    background: linear-gradient(135deg, var(--cb-pink) 0%, var(--cb-pink-dark) 100%);
    color: #ffffff;
    font-size: 16px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 10px rgba(115, 20, 54, 0.35);
    flex-shrink: 0;
    padding: 0;
}

#cb-sendBtn:active {
    transform: scale(0.94);
}

/* Mobile Full-Screen Mode (All Android/iOS Phones) */
@media (max-width: 575px) {
    body.chatbot-open {
        overflow: hidden;
    }

    #shree-chatbot-root {
        right: 0;
        bottom: 0;
        left: 0;
        top: 0;
    }

    #shree-chatbot-panel {
        width: 100vw;
        height: 100vh;
        height: 100dvh;
        max-height: none;
        border-radius: 0;
        box-shadow: none;
    }

    #cb-inner-shell {
        border-radius: 0;
    }

    #cb-header {
        padding-top: max(14px, env(safe-area-inset-top));
        padding-right: 54px;
    }

    #cb-close-btn {
        top: max(14px, env(safe-area-inset-top));
        right: max(12px, env(safe-area-inset-right));
        width: 34px;
        height: 34px;
        background: rgba(255, 255, 255, 0.22);
        border: 1.5px solid rgba(255, 255, 255, 0.65);
    }

    #cb-inputBar {
        padding-bottom: max(10px, env(safe-area-inset-bottom));
        padding-left: max(12px, env(safe-area-inset-left));
        padding-right: max(12px, env(safe-area-inset-right));
    }
}

/* Short / Landscape Mobile Screens */
@media (max-height: 540px) and (min-width: 576px) {
    #shree-chatbot-panel {
        height: calc(100vh - 20px);
        height: calc(100dvh - 20px);
    }
}

@media (prefers-reduced-motion: reduce) {
    #shree-chatbot-panel,
    #shree-chatbot-root .cb-msg {
        transition: none !important;
        animation: none !important;
    }
}
