/* Lebawi public widgets — Command UI FAB dock, chat, modals */

:root {
    --lb-fab-offset: 0px;
}

@media (max-width: 768px) {
    :root {
        --lb-fab-offset: 5.35rem;
    }
}

/* —— FAB dock —— */
.lb-fab-dock {
    position: fixed;
    right: max(1rem, env(safe-area-inset-right));
    bottom: calc(max(1.15rem, env(safe-area-inset-bottom)) + var(--lb-fab-offset));
    z-index: 10040;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 0;
    font-family: Inter, system-ui, sans-serif;
    pointer-events: none;
}

.lb-fab-dock__stack {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 0.55rem;
    pointer-events: auto;
}

.lb-fab-dock__btn {
    display: inline-flex;
    align-items: center;
    gap: 0.55rem;
    min-height: 44px;
    padding: 0.35rem 0.9rem 0.35rem 0.35rem;
    border-radius: 999px;
    border: 1px solid rgba(0, 212, 255, 0.32);
    background:
        linear-gradient(145deg, rgba(12, 18, 30, 0.97), rgba(6, 8, 14, 0.98));
    color: #fff;
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.38), 0 0 18px rgba(0, 212, 255, 0.08);
    backdrop-filter: blur(14px);
    cursor: pointer;
    transition: transform 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease, opacity 0.2s ease, visibility 0.2s ease;
    text-decoration: none;
    font: inherit;
    font-size: 0.82rem;
    font-weight: 600;
    line-height: 1;
    white-space: nowrap;
}

.lb-fab-dock__btn:hover {
    transform: translateY(-2px);
    border-color: rgba(0, 212, 255, 0.55);
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.42), 0 0 24px rgba(0, 212, 255, 0.16);
}

.lb-fab-dock__btn-icon {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 0.95rem;
}

.lb-fab-dock__btn--scroll {
    width: 44px;
    height: 44px;
    min-height: 44px;
    padding: 0;
    justify-content: center;
    border-radius: 50%;
    opacity: 0;
    visibility: hidden;
    transform: translateY(10px) scale(0.92);
    pointer-events: none;
}

.lb-fab-dock__btn--scroll.visible {
    opacity: 1;
    visibility: visible;
    transform: none;
    pointer-events: auto;
}

#back-to-top.lb-fab-dock__btn--scroll {
    position: static;
    bottom: auto;
    right: auto;
    font-size: inherit;
}

.lb-fab-dock__btn--scroll .lb-fab-dock__btn-icon {
    background: linear-gradient(135deg, rgba(0, 212, 255, 0.28), rgba(0, 153, 204, 0.2));
    color: #fff;
}

.lb-fab-dock__btn--quote .lb-fab-dock__btn-icon {
    background: linear-gradient(135deg, #00d4ff, #0099cc);
    color: #041018;
}

.lb-fab-dock__btn--chat .lb-fab-dock__btn-icon {
    background: rgba(0, 212, 255, 0.14);
    color: #00d4ff;
    border: 1px solid rgba(0, 212, 255, 0.22);
}

.lb-fab-dock.is-chat-open .lb-fab-dock__btn--chat {
    border-color: rgba(0, 212, 255, 0.55);
    box-shadow: 0 0 0 1px rgba(0, 212, 255, 0.2), 0 16px 40px rgba(0, 0, 0, 0.42);
}

.lb-fab-dock.is-chat-open .lb-fab-dock__btn--chat .lb-fab-dock__btn-icon {
    background: rgba(0, 212, 255, 0.24);
}

/* —— Chat —— */
.lebawi-chat-root {
    position: relative;
    width: min(380px, calc(100vw - 2rem));
    pointer-events: auto;
    margin-bottom: 0.65rem;
}

.lebawi-chat-panel {
    display: none;
    flex-direction: column;
    width: 100%;
    height: min(520px, calc(100vh - 12rem));
    border-radius: 18px;
    overflow: hidden;
    border: 1px solid rgba(0, 212, 255, 0.22);
    background: linear-gradient(165deg, rgba(12, 18, 30, 0.98), rgba(6, 8, 14, 0.99));
    box-shadow: 0 24px 64px rgba(0, 0, 0, 0.5), 0 0 32px rgba(0, 212, 255, 0.08);
}

.lebawi-chat-root.is-open .lebawi-chat-panel {
    display: flex;
}

.lebawi-chat-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 0.75rem;
    padding: 0.95rem 1rem;
    background: linear-gradient(135deg, rgba(0, 212, 255, 0.08), rgba(15, 23, 42, 0.6));
    border-bottom: 1px solid rgba(0, 212, 255, 0.14);
    color: #fff;
}

.lebawi-chat-header__tag {
    display: block;
    font-size: 0.62rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: #00d4ff;
    margin-bottom: 0.2rem;
}

.lebawi-chat-header strong {
    display: block;
    font-size: 1rem;
}

.lebawi-chat-sub {
    display: block;
    font-size: 0.72rem;
    opacity: 0.72;
    margin-top: 0.2rem;
    font-weight: 400;
}

.lebawi-chat-close {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    border: 1px solid rgba(0, 212, 255, 0.22);
    background: rgba(8, 12, 20, 0.85);
    color: #fff;
    font-size: 0.95rem;
    cursor: pointer;
    flex-shrink: 0;
    transition: border-color 0.2s ease, background 0.2s ease;
}

.lebawi-chat-close:hover {
    border-color: rgba(0, 212, 255, 0.45);
    background: rgba(0, 212, 255, 0.12);
}

.lebawi-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
    background: rgba(2, 6, 14, 0.55);
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
    scrollbar-width: thin;
    scrollbar-color: rgba(0, 212, 255, 0.35) transparent;
}

.lebawi-chat-msg {
    max-width: 88%;
    padding: 0.7rem 0.9rem;
    border-radius: 14px;
    font-size: 0.88rem;
    line-height: 1.5;
}

.lebawi-chat-msg--bot {
    align-self: flex-start;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(0, 212, 255, 0.14);
    color: rgba(255, 255, 255, 0.88);
}

.lebawi-chat-msg--user {
    align-self: flex-end;
    background: linear-gradient(135deg, rgba(0, 212, 255, 0.22), rgba(0, 153, 204, 0.18));
    border: 1px solid rgba(0, 212, 255, 0.28);
    color: #fff;
}

.lebawi-chat-msg--typing {
    opacity: 0.65;
    font-style: italic;
}

.lebawi-chat-footer {
    padding: 0.85rem;
    border-top: 1px solid rgba(0, 212, 255, 0.12);
    background: rgba(8, 12, 20, 0.92);
}

.lebawi-chat-form {
    display: flex;
    gap: 0.5rem;
}

.lebawi-chat-form input {
    flex: 1;
    min-width: 0;
    border: 1px solid rgba(0, 212, 255, 0.18);
    border-radius: 10px;
    padding: 0.6rem 0.8rem;
    font-size: 0.88rem;
    background: rgba(2, 6, 14, 0.75);
    color: #fff;
}

.lebawi-chat-form input::placeholder {
    color: rgba(255, 255, 255, 0.42);
}

.lebawi-chat-form input:focus {
    outline: none;
    border-color: rgba(0, 212, 255, 0.45);
    box-shadow: 0 0 0 2px rgba(0, 212, 255, 0.12);
}

.lebawi-chat-form button {
    width: 42px;
    height: 42px;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    color: #041018;
    background: linear-gradient(135deg, #00d4ff, #0099cc);
    flex-shrink: 0;
    transition: filter 0.2s ease, transform 0.2s ease;
}

.lebawi-chat-form button:hover {
    filter: brightness(1.08);
    transform: translateY(-1px);
}

.lebawi-chat-quote-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    width: 100%;
    margin-top: 0.6rem;
    padding: 0.55rem 0.75rem;
    border-radius: 10px;
    border: 1px solid rgba(0, 212, 255, 0.2);
    background: rgba(0, 212, 255, 0.06);
    color: #7ee8ff;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s ease, border-color 0.2s ease;
}

.lebawi-chat-quote-link:hover {
    background: rgba(0, 212, 255, 0.12);
    border-color: rgba(0, 212, 255, 0.35);
}

/* —— Modals —— */
.lebawi-modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 10070;
    background: rgba(2, 6, 14, 0.82);
    backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.lebawi-modal-overlay[hidden] {
    display: none !important;
}

.lebawi-modal {
    position: relative;
    width: min(520px, 100%);
    max-height: min(92vh, 720px);
    overflow-y: auto;
    border-radius: 20px;
    padding: 1.75rem;
    border: 1px solid rgba(0, 212, 255, 0.22);
    background: linear-gradient(165deg, rgba(12, 18, 30, 0.98), rgba(6, 8, 14, 0.99));
    box-shadow: 0 28px 72px rgba(0, 0, 0, 0.55), 0 0 36px rgba(0, 212, 255, 0.08);
    color: rgba(255, 255, 255, 0.88);
    scrollbar-width: thin;
    scrollbar-color: rgba(0, 212, 255, 0.35) transparent;
}

.lebawi-modal-close {
    position: absolute;
    top: 0.85rem;
    right: 0.9rem;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    border: 1px solid rgba(0, 212, 255, 0.22);
    background: rgba(8, 12, 20, 0.9);
    font-size: 1.25rem;
    line-height: 1;
    cursor: pointer;
    color: rgba(255, 255, 255, 0.8);
    transition: border-color 0.2s ease, background 0.2s ease;
}

.lebawi-modal-close:hover {
    border-color: rgba(0, 212, 255, 0.45);
    background: rgba(0, 212, 255, 0.1);
}

.lebawi-modal-tag {
    display: inline-block;
    font-size: 0.68rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: #00d4ff;
    font-weight: 600;
    margin-bottom: 0.4rem;
}

.lebawi-modal h2 {
    font-size: clamp(1.2rem, 2.5vw, 1.45rem);
    margin: 0 0 0.45rem;
    color: #fff;
    line-height: 1.25;
}

.lebawi-modal-lead,
.lebawi-modal > p {
    color: rgba(255, 255, 255, 0.62);
    font-size: 0.92rem;
    margin: 0 0 1.1rem;
    line-height: 1.55;
}

.lebawi-modal-fine {
    font-size: 0.8rem;
    margin-top: 0.75rem;
    min-height: 1.2em;
    color: rgba(255, 255, 255, 0.55);
}

.lebawi-modal-fine.is-error {
    color: #f87171;
}

.lebawi-modal-fine.is-success {
    color: #4ade80;
}

.lebawi-newsletter-form {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.lebawi-newsletter-form input {
    flex: 1;
    min-width: 180px;
    border: 1px solid rgba(0, 212, 255, 0.18);
    border-radius: 10px;
    padding: 0.65rem 0.85rem;
    background: rgba(2, 6, 14, 0.75);
    color: #fff;
}

.lebawi-newsletter-form input:focus {
    outline: none;
    border-color: rgba(0, 212, 255, 0.45);
    box-shadow: 0 0 0 2px rgba(0, 212, 255, 0.12);
}

.lebawi-btn-primary {
    background: linear-gradient(135deg, #00d4ff, #0099cc);
    color: #041018;
    border: none;
    border-radius: 10px;
    padding: 0.7rem 1.25rem;
    font-weight: 700;
    cursor: pointer;
    transition: filter 0.2s ease, transform 0.2s ease;
}

.lebawi-btn-primary:hover {
    filter: brightness(1.06);
    transform: translateY(-1px);
}

.lebawi-btn-block {
    width: 100%;
    margin-top: 0.35rem;
}

.lebawi-quote-form label {
    display: block;
    font-size: 0.78rem;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.72);
    margin-bottom: 0.7rem;
}

.lebawi-quote-form input,
.lebawi-quote-form select,
.lebawi-quote-form textarea {
    width: 100%;
    margin-top: 0.3rem;
    border: 1px solid rgba(0, 212, 255, 0.18);
    border-radius: 10px;
    padding: 0.58rem 0.72rem;
    font-size: 0.9rem;
    font-weight: 400;
    background: rgba(2, 6, 14, 0.75);
    color: #fff;
}

.lebawi-quote-form input:focus,
.lebawi-quote-form select:focus,
.lebawi-quote-form textarea:focus {
    outline: none;
    border-color: rgba(0, 212, 255, 0.45);
    box-shadow: 0 0 0 2px rgba(0, 212, 255, 0.12);
}

.lebawi-quote-form select option {
    background: #0c1220;
    color: #fff;
}

.lebawi-form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
}

.lebawi-hp {
    position: absolute;
    left: -9999px;
    height: 0;
    width: 0;
    overflow: hidden;
}

/* Hide legacy floating buttons if still present */
.floating-cta {
    display: none !important;
}

/* Side menu open — tuck dock away */
body.side-menu-open .lb-fab-dock {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transform: translateY(110%);
    transition: opacity 0.25s ease, transform 0.25s ease, visibility 0.25s;
}

/* Contact page — hide duplicate quote FAB */
body:has(main.lb-contact-page) .lb-fab-dock__btn--quote {
    display: none;
}

@media (max-width: 768px) {
    .lb-fab-dock {
        right: max(0.75rem, env(safe-area-inset-right));
    }

    .lb-fab-dock__btn {
        padding: 0;
        width: 44px;
        min-height: 44px;
        justify-content: center;
        border-radius: 50%;
    }

    .lb-fab-dock__btn-label {
        display: none;
    }

    .lebawi-chat-root {
        width: min(360px, calc(100vw - 1.5rem));
    }

    .lebawi-chat-panel {
        height: min(480px, calc(100vh - 10rem));
    }

    .lebawi-modal {
        padding: 1.35rem;
        border-radius: 16px;
    }
}

@media (max-width: 540px) {
    .lebawi-form-row {
        grid-template-columns: 1fr;
    }

    .lebawi-modal-overlay {
        padding: 0.5rem;
        align-items: flex-end;
    }

    .lebawi-modal {
        width: 100%;
        max-height: 92vh;
        border-bottom-left-radius: 0;
        border-bottom-right-radius: 0;
    }
}
