/* ================================================================
   REGENT DENTAL — Floating Chat Widget
   ================================================================ */

/* ================================================================
   FLOATING WIDGET (.rdb-widget)
   ================================================================ */

.rdb-widget {
    --chat-green:       #006d70;
    --chat-green-dark:  #005558;
    --chat-green-dim:   rgba(0, 109, 112, 0.15);
    --chat-dark:        #1a1a2e;
    --chat-white:       #ffffff;
    --chat-text:        #111827;
    --chat-text-muted:  #6b7280;
    --chat-border:      #e5e7eb;
    --chat-radius:      16px;
    --chat-radius-pill: 28px;
    --chat-font-body:   'Poppins', -apple-system, sans-serif;
    --chat-font-head:   'Montserrat', 'Poppins', sans-serif;
}
.rdb-widget,
.rdb-widget *,
.rdb-widget *::before,
.rdb-widget *::after {
    box-sizing: border-box;
    font-family: var(--chat-font-body);
    margin: 0;
    padding: 0;
}

.rdb-widget {
    position: fixed;
    bottom: 28px;
    right: 28px;
    z-index: 99999;
    font-size: 14px;
    line-height: 1.5;
}

/* Toggle FAB */
.rdb-widget__toggle {
    width: 58px;
    height: 58px;
    border-radius: 50%;
    background: var(--chat-green);
    color: #fff;
    border: none;
    cursor: pointer;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 20px rgba(0, 109, 112, 0.4);
    transition: background 0.2s, transform 0.2s, box-shadow 0.2s;
    margin-left: auto;
}

.rdb-widget__toggle:hover {
    background: var(--chat-green-dark);
    transform: scale(1.07);
    box-shadow: 0 6px 28px rgba(0, 109, 112, 0.5);
}

.rdb-widget__toggle:focus-visible { outline: 3px solid var(--chat-green); outline-offset: 4px; }

/* Icon swap */
.rdb-wicon--close { display: none; }
.rdb-widget.is-open .rdb-wicon--chat  { display: none; }
.rdb-widget.is-open .rdb-wicon--close { display: block; }

/* Popup window */
.rdb-widget__popup {
    position: absolute;
    bottom: 70px;
    right: 0;
    width: min(370px, calc(100vw - 32px));
    max-height: min(560px, 80vh);
    background: #fff;
    border-radius: var(--chat-radius);
    box-shadow: 0 8px 40px rgba(0,0,0,0.18), 0 2px 8px rgba(0,0,0,0.06);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: rdb-popup-in 0.24s cubic-bezier(0.34, 1.28, 0.64, 1) both;
    transform-origin: bottom right;
}

.rdb-widget__popup[hidden] { display: none; }

@keyframes rdb-popup-in {
    from { opacity: 0; transform: scale(0.88) translateY(14px); }
    to   { opacity: 1; transform: scale(1)    translateY(0); }
}

/* Popup head */
.rdb-widget__head {
    background: var(--chat-dark);
    color: #fff;
    padding: 14px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}

.rdb-widget__head-info {
    display: flex;
    align-items: center;
    gap: 9px;
}

.rdb-widget__dot {
    width: 9px;
    height: 9px;
    background: var(--chat-green);
    border-radius: 50%;
    flex-shrink: 0;
    box-shadow: 0 0 0 2px rgba(0, 109, 112, 0.3);
    animation: rdb-hchat-pulse 2.5s ease-in-out infinite;
}

.rdb-widget__title {
    font-family: var(--chat-font-head);
    font-weight: 700;
    font-size: 0.9375rem;
    letter-spacing: 0.01em;
}

.rdb-widget__close {
    background: none;
    border: none;
    color: rgba(255,255,255,0.6);
    cursor: pointer;
    padding: 4px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    transition: color 0.15s, background 0.15s;
}

.rdb-widget__close:hover { color: #fff; background: rgba(255,255,255,0.12); }

/* Popup messages */
.rdb-widget__messages {
    flex: 1;
    overflow-y: auto;
    padding: 18px 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    scroll-behavior: smooth;
    overscroll-behavior: contain;
    background: #fff;
}

.rdb-widget__messages::-webkit-scrollbar { width: 4px; }
.rdb-widget__messages::-webkit-scrollbar-thumb { background: var(--chat-green-dim); border-radius: 4px; }

/* Bubbles in popup — reuse hchat bubble logic with light theme */
.rdb-widget__messages .rdb-hchat__bubble--user {
    background: var(--chat-green);
    color: #fff;
}

.rdb-widget__messages .rdb-hchat__bubble--assistant {
    background: rgba(0, 109, 112, 0.1);
    color: var(--chat-text);
    border: 1px solid rgba(0, 109, 112, 0.2);
}

.rdb-widget__messages .rdb-hchat__bubble--error {
    background: #fef2f2;
    color: #b91c1c;
    border: 1px solid #fecaca;
}

/* Popup foot */
.rdb-widget__foot {
    border-top: 1px solid var(--chat-border);
    padding: 12px 14px 14px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    gap: 10px;
    background: #fff;
}

.rdb-widget__input-row {
    display: flex;
    gap: 8px;
    align-items: flex-end;
}

.rdb-widget__input {
    flex: 1;
    resize: none;
    border: 1.5px solid var(--chat-border);
    border-radius: 12px;
    padding: 10px 13px;
    font-size: 0.875rem;
    font-family: var(--chat-font-body);
    line-height: 1.45;
    max-height: 110px;
    overflow-y: auto;
    color: var(--chat-text);
    background: #fff;
    transition: border-color 0.15s, box-shadow 0.15s;
}

.rdb-widget__input::placeholder { color: var(--chat-text-muted); }

.rdb-widget__input:focus {
    outline: none;
    border-color: var(--chat-green);
    box-shadow: 0 0 0 3px rgba(0, 109, 112, 0.12);
}

.rdb-widget__send {
    width: 40px;
    height: 40px;
    flex-shrink: 0;
    background: var(--chat-green);
    color: #fff;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s, transform 0.15s;
}

.rdb-widget__send:hover:not(:disabled) { background: var(--chat-green-dark); transform: scale(1.05); }
.rdb-widget__send:disabled { opacity: 0.4; cursor: not-allowed; transform: none; }

.rdb-widget__book {
    display: block;
    text-align: center;
    padding: 10px 20px;
    background: var(--chat-green);
    color: #fff;
    border-radius: var(--chat-radius-pill);
    font-size: 0.8125rem;
    font-family: var(--chat-font-head);
    font-weight: 700;
    text-decoration: none;
    letter-spacing: 0.02em;
    transition: background 0.2s, transform 0.15s, box-shadow 0.2s;
    box-shadow: 0 2px 10px rgba(0, 109, 112, 0.25);
}

.rdb-widget__book:hover {
    background: var(--chat-green-dark);
    text-decoration: none;
    transform: translateY(-1px);
    box-shadow: 0 4px 16px rgba(0, 109, 112, 0.35);
    color: #fff;
}

/* ================================================================
   RESPONSIVE
   ================================================================ */

@media (max-width: 900px) {
    .rdb-header-inner {
        flex-direction: column;
        align-items: stretch;
    }

    .rdb-header-right {
        flex: unset;
        width: 100%;
    }
}

@media (max-width: 480px) {
    .rdb-widget {
        bottom: 16px;
        right: 16px;
    }

    .rdb-widget__popup {
        width: calc(100vw - 32px);
        right: 0;
        bottom: 68px;
        max-height: 72vh;
    }
}

/* iOS Safari zooms any input with font-size < 16px — prevent that */
@media (hover: none) {
    .rdb-widget__input { font-size: 1rem; }
}
