/* ===========================================================================
   Dhaka Hybrid chat widget
   ---------------------------------------------------------------------------
   Built on the same design tokens as the rest of the site (front/theme.blade),
   so recolouring the site from Theme Settings recolours the chat too. The two
   overridable knobs are --dhc-accent and --dhc-head, which the super admin can
   set on the Chatbot Settings screen; both fall back to the site palette.
   ========================================================================= */

.dhc{
    --dhc-accent: var(--dh-primary, #f9bf29);
    --dhc-accent-rgb: var(--dh-primary-rgb, 249, 191, 41);
    --dhc-on-accent: var(--dh-on-primary, #1f2937);
    --dhc-head: var(--dh-dark, #0b1220);
    --dhc-radius: 18px;

    position: fixed;
    bottom: 20px;
    z-index: 10000;
    font-family: var(--dh-font-body, 'Segoe UI', system-ui, sans-serif);
}

.dhc[data-position="right"]{ right: 20px; }
.dhc[data-position="left"]{ left: 20px; }

/* The Quick Booking pill owns the bottom-right corner by default, so it steps
   aside for the chat launcher rather than sitting under it. */
body.dhc-active .floating-book-btn{ bottom: 92px; }

/* ---------- launcher ---------- */

.dhc-launcher{
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 13px 20px;
    border: 0;
    border-radius: 999px;
    background: var(--dhc-accent);
    color: var(--dhc-on-accent);
    font-size: .92rem;
    font-weight: 700;
    line-height: 1;
    cursor: pointer;
    box-shadow: 0 14px 34px rgba(var(--dhc-accent-rgb), .42);
    transition: transform .22s cubic-bezier(.2, .9, .3, 1.3), box-shadow .22s ease;
}

.dhc-launcher:hover{ transform: translateY(-3px); box-shadow: 0 18px 40px rgba(var(--dhc-accent-rgb), .5); }
.dhc-launcher:active{ transform: translateY(0); }
.dhc-launcher i{ font-size: 1.15rem; }

/* A quiet pulse the first time only — enough to be noticed, not a nag. */
.dhc-launcher::after{
    content: '';
    position: absolute;
    inset: 0;
    border-radius: inherit;
    box-shadow: 0 0 0 0 rgba(var(--dhc-accent-rgb), .6);
    animation: dhc-pulse 2.6s ease-out 3;
    pointer-events: none;
}

.dhc-launcher{ position: relative; }

@keyframes dhc-pulse{
    to{ box-shadow: 0 0 0 22px rgba(var(--dhc-accent-rgb), 0); }
}

@media (prefers-reduced-motion: reduce){
    .dhc-launcher::after{ animation: none; }
    .dhc-launcher{ transition: none; }
}

/* Unread dot for a reply that arrived while the panel was shut. */
.dhc-dot{
    position: absolute;
    top: -3px;
    right: -3px;
    width: 13px;
    height: 13px;
    border-radius: 50%;
    background: #ef4444;
    border: 2px solid #fff;
    display: none;
}

.dhc-launcher.has-unread .dhc-dot{ display: block; }

/* ---------- teaser bubble ---------- */

.dhc-teaser{
    position: absolute;
    bottom: 64px;
    width: 246px;
    padding: 13px 34px 13px 15px;
    border-radius: 16px;
    background: #fff;
    color: #1f2937;
    font-size: .84rem;
    line-height: 1.55;
    box-shadow: 0 18px 44px rgba(15, 23, 42, .18);
    border: 1px solid rgba(15, 23, 42, .07);
    opacity: 0;
    transform: translateY(10px) scale(.96);
    transition: opacity .3s ease, transform .3s cubic-bezier(.2, .9, .3, 1.3);
    pointer-events: none;
}

/* The bubble sits beside the launcher, not above it: straight above is where
   the Quick Booking pill lives, and the two used to stack on top of each other. */
.dhc[data-position="right"] .dhc-teaser{ right: calc(100% + 12px); }
.dhc[data-position="left"] .dhc-teaser{ left: calc(100% + 12px); }
.dhc-teaser{ bottom: 0; }

.dhc-teaser.is-on{ opacity: 1; transform: none; pointer-events: auto; }

.dhc-teaser-close{
    position: absolute;
    top: 7px;
    right: 9px;
    border: 0;
    background: none;
    color: #94a3b8;
    font-size: 1.1rem;
    line-height: 1;
    cursor: pointer;
    padding: 2px 4px;
}

.dhc-teaser-close:hover{ color: #ef4444; }

/* ---------- panel ---------- */

.dhc-panel{
    position: absolute;
    bottom: 0;
    width: 384px;
    max-width: calc(100vw - 32px);
    height: min(628px, calc(100vh - 110px));
    display: none;
    flex-direction: column;
    overflow: hidden;
    border-radius: var(--dhc-radius);
    background: #fff;
    box-shadow: 0 40px 90px -18px rgba(15, 23, 42, .45);
    border: 1px solid rgba(15, 23, 42, .08);
}

.dhc[data-position="right"] .dhc-panel{ right: 0; }
.dhc[data-position="left"] .dhc-panel{ left: 0; }

.dhc.is-open .dhc-panel{
    display: flex;
    animation: dhc-in .3s cubic-bezier(.2, .9, .3, 1.25);
}

.dhc.is-open .dhc-launcher,
.dhc.is-open .dhc-teaser{ display: none; }

@keyframes dhc-in{
    from{ opacity: 0; transform: translateY(24px) scale(.97); }
    to{ opacity: 1; transform: none; }
}

/* ---------- header ---------- */

.dhc-head{
    position: relative;
    flex: none;
    padding: 17px 18px 15px;
    color: #fff;
    background:
        radial-gradient(520px 190px at 92% 120%, rgba(var(--dhc-accent-rgb), .38), transparent 66%),
        var(--dhc-head);
}

.dhc-head-top{ display: flex; align-items: center; gap: 12px; }

.dhc-avatar{
    width: 42px;
    height: 42px;
    flex: none;
    display: grid;
    place-items: center;
    border-radius: 50%;
    background: var(--dhc-accent);
    color: var(--dhc-on-accent);
    font-size: 1.15rem;
}

.dhc-title{ min-width: 0; flex: 1; }
.dhc-title h4{ margin: 0; font-size: 1rem; font-weight: 800; color: #fff; letter-spacing: -.01em; }

.dhc-title p{
    margin: 2px 0 0;
    font-size: .74rem;
    color: rgba(255, 255, 255, .68);
    display: flex;
    align-items: center;
    gap: 6px;
}

.dhc-live{
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #22c55e;
    box-shadow: 0 0 0 3px rgba(34, 197, 94, .25);
    flex: none;
}

.dhc-live.is-off{ background: #f59e0b; box-shadow: 0 0 0 3px rgba(245, 158, 11, .22); }

.dhc-close{
    width: 30px;
    height: 30px;
    flex: none;
    display: grid;
    place-items: center;
    border: 1px solid rgba(255, 255, 255, .2);
    border-radius: 50%;
    background: rgba(255, 255, 255, .1);
    color: #fff;
    font-size: 1.2rem;
    line-height: 1;
    cursor: pointer;
    transition: background .2s ease, transform .2s ease;
}

.dhc-close:hover{ background: rgba(239, 68, 68, .85); transform: rotate(90deg); }

/* Contact strip — the details a visitor most often opens a chat to ask for. */
.dhc-facts{ display: flex; flex-wrap: wrap; gap: 6px; margin-top: 13px; }

.dhc-facts a,
.dhc-facts span{
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 10px;
    border-radius: 999px;
    background: rgba(255, 255, 255, .1);
    border: 1px solid rgba(255, 255, 255, .16);
    color: rgba(255, 255, 255, .9);
    font-size: .71rem;
    font-weight: 600;
    text-decoration: none;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.dhc-facts a:hover{ background: var(--dhc-accent); color: var(--dhc-on-accent); border-color: transparent; }
.dhc-facts i{ font-size: .68rem; opacity: .85; }

/* ---------- body ---------- */

.dhc-body{
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: 18px 16px 6px;
    background: #f6f8fc;
    scrollbar-width: thin;
}

.dhc-body::-webkit-scrollbar{ width: 6px; }
.dhc-body::-webkit-scrollbar-thumb{ background: #cbd5e1; border-radius: 999px; }

/* ---------- pre-chat lead form ---------- */

.dhc-lead{ padding: 4px 2px 14px; }

.dhc-lead h5{
    margin: 0 0 5px;
    font-size: .98rem;
    font-weight: 800;
    color: #0f172a;
}

.dhc-lead > p{ margin: 0 0 15px; font-size: .81rem; line-height: 1.6; color: #64748b; }

.dhc-field{ display: block; margin-bottom: 11px; }

.dhc-field span{
    display: block;
    margin-bottom: 5px;
    font-size: .76rem;
    font-weight: 700;
    color: #334155;
}

.dhc-field span b{ color: #ef4444; font-weight: 700; }

.dhc-field input,
.dhc-field select,
.dhc-field textarea{
    width: 100%;
    padding: 10px 13px;
    border: 1px solid #dbe3ee;
    border-radius: 11px;
    background: #fff;
    font-size: .86rem;
    font-family: inherit;
    color: #0f172a;
    outline: none;
    transition: border-color .18s ease, box-shadow .18s ease;
}

.dhc-field input:focus,
.dhc-field select:focus,
.dhc-field textarea:focus{
    border-color: var(--dhc-accent);
    box-shadow: 0 0 0 3px rgba(var(--dhc-accent-rgb), .18);
}

.dhc-field textarea{ resize: vertical; min-height: 68px; }

.dhc-error{
    display: none;
    margin: -5px 0 10px;
    font-size: .74rem;
    font-weight: 600;
    color: #dc2626;
}

.dhc-error.is-on{ display: block; }

.dhc-consent{ margin: 4px 0 13px; font-size: .71rem; line-height: 1.55; color: #94a3b8; }

.dhc-submit{
    width: 100%;
    padding: 12px 18px;
    border: 0;
    border-radius: 11px;
    background: var(--dhc-accent);
    color: var(--dhc-on-accent);
    font-size: .89rem;
    font-weight: 800;
    font-family: inherit;
    cursor: pointer;
    transition: filter .18s ease, transform .18s ease;
}

.dhc-submit:hover{ filter: brightness(1.06); transform: translateY(-1px); }
.dhc-submit:disabled{ opacity: .6; cursor: progress; transform: none; }

/* ---------- messages ---------- */

.dhc-thread{ display: none; flex-direction: column; gap: 12px; padding-bottom: 8px; }
.dhc.is-chatting .dhc-thread{ display: flex; }
.dhc.is-chatting .dhc-lead{ display: none; }

.dhc-msg{ display: flex; gap: 9px; max-width: 100%; animation: dhc-msg-in .26s ease; }

@keyframes dhc-msg-in{
    from{ opacity: 0; transform: translateY(8px); }
    to{ opacity: 1; transform: none; }
}

.dhc-msg-ico{
    width: 28px;
    height: 28px;
    flex: none;
    display: grid;
    place-items: center;
    border-radius: 50%;
    background: var(--dhc-head);
    color: var(--dhc-accent);
    font-size: .74rem;
}

.dhc-bubble{
    padding: 10px 14px;
    border-radius: 14px 14px 14px 4px;
    background: #fff;
    color: #1e293b;
    font-size: .855rem;
    line-height: 1.62;
    box-shadow: 0 2px 10px rgba(15, 23, 42, .07);
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

.dhc-msg--user{ flex-direction: row-reverse; }

.dhc-msg--user .dhc-bubble{
    border-radius: 14px 14px 4px 14px;
    background: var(--dhc-accent);
    color: var(--dhc-on-accent);
    box-shadow: 0 4px 14px rgba(var(--dhc-accent-rgb), .3);
}

.dhc-msg--user .dhc-msg-ico{ background: rgba(15, 23, 42, .08); color: #475569; }

.dhc-time{
    margin-top: 4px;
    font-size: .65rem;
    color: #b0bccd;
    padding-left: 37px;
}

.dhc-msg--user + .dhc-time{ text-align: right; padding: 0 37px 0 0; }

/* Answer link the admin attached to a knowledge row. */
.dhc-link{
    display: inline-flex;
    align-items: center;
    gap: 7px;
    margin-top: 9px;
    padding: 7px 13px;
    border-radius: 999px;
    background: var(--dhc-head);
    color: #fff;
    font-size: .77rem;
    font-weight: 700;
    text-decoration: none;
}

.dhc-link:hover{ background: var(--dhc-accent); color: var(--dhc-on-accent); }

/* ---------- suggestion chips ---------- */

.dhc-chips{ display: flex; flex-wrap: wrap; gap: 7px; padding: 2px 0 4px 37px; }
.dhc-chips--foot{ padding: 0 0 10px; }

.dhc-chip{
    padding: 7px 13px;
    border: 1px solid rgba(var(--dhc-accent-rgb), .45);
    border-radius: 999px;
    background: rgba(var(--dhc-accent-rgb), .1);
    color: #1e293b;
    font-size: .755rem;
    font-weight: 600;
    font-family: inherit;
    line-height: 1.3;
    cursor: pointer;
    text-align: left;
    transition: background .18s ease, transform .18s ease;
}

.dhc-chip:hover{ background: var(--dhc-accent); color: var(--dhc-on-accent); transform: translateY(-1px); }

/* ---------- typing indicator ---------- */

.dhc-typing{ display: flex; gap: 4px; padding: 13px 15px; }

.dhc-typing i{
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #94a3b8;
    animation: dhc-bounce 1.3s infinite ease-in-out;
}

.dhc-typing i:nth-child(2){ animation-delay: .18s; }
.dhc-typing i:nth-child(3){ animation-delay: .36s; }

@keyframes dhc-bounce{
    0%, 60%, 100%{ transform: translateY(0); opacity: .45; }
    30%{ transform: translateY(-5px); opacity: 1; }
}

/* ---------- composer ---------- */

.dhc-foot{
    flex: none;
    padding: 11px 14px 13px;
    background: #fff;
    border-top: 1px solid #eef2f7;
}

.dhc-form{ display: flex; align-items: flex-end; gap: 9px; }

.dhc-input{
    flex: 1;
    min-height: 42px;
    max-height: 108px;
    padding: 11px 15px;
    border: 1px solid #dbe3ee;
    border-radius: 22px;
    background: #f8fafc;
    font-size: .86rem;
    font-family: inherit;
    line-height: 1.45;
    color: #0f172a;
    outline: none;
    resize: none;
    transition: border-color .18s ease, box-shadow .18s ease;
}

.dhc-input:focus{
    border-color: var(--dhc-accent);
    background: #fff;
    box-shadow: 0 0 0 3px rgba(var(--dhc-accent-rgb), .16);
}

.dhc-send{
    width: 42px;
    height: 42px;
    flex: none;
    display: grid;
    place-items: center;
    border: 0;
    border-radius: 50%;
    background: var(--dhc-accent);
    color: var(--dhc-on-accent);
    font-size: .95rem;
    cursor: pointer;
    transition: filter .18s ease, transform .18s ease;
}

.dhc-send:hover{ filter: brightness(1.07); transform: scale(1.05); }
.dhc-send:disabled{ opacity: .5; cursor: not-allowed; transform: none; }

.dhc-note{
    margin: 8px 0 0;
    text-align: center;
    font-size: .66rem;
    color: #b4bfce;
}

.dhc-note a{ color: #94a3b8; text-decoration: none; }
.dhc-note a:hover{ color: var(--dhc-accent); }

/* ---------- phone-sized screens ---------- */

@media (max-width: 480px){
    .dhc{ bottom: 14px; }
    .dhc[data-position="right"]{ right: 14px; }
    .dhc[data-position="left"]{ left: 14px; }

    .dhc-launcher span{ display: none; }
    .dhc-launcher{ padding: 15px; }
    .dhc-launcher i{ font-size: 1.3rem; }

    .dhc-panel{
        position: fixed;
        inset: 0;
        width: 100%;
        max-width: none;
        height: 100%;
        border-radius: 0;
        border: 0;
    }

    .dhc-teaser{ width: min(240px, calc(100vw - 100px)); font-size: .8rem; }
}
