/* ==========================================================================
   Floating chat widget (Artemis)

   A launcher pinned bottom-left that expands into the direct-chat channels
   (WhatsApp, Messenger). Bottom-LEFT because the Facebook customer-chat plugin
   and Zoho SalesIQ both take the bottom-right corner on dev and production.

   z-index sits below Bootstrap's modal layer (1050) so the delete/confirm/message
   modals in the shop layout still cover it.

   Paired with:
     resources/views/project/layouts/shop/includes/sections/chat-widget.blade.php
   ========================================================================== */

.am-chat {
    --am-chat-size: 56px;
    --am-chat-gap: 20px;

    position: fixed;
    left: var(--am-chat-gap);
    bottom: var(--am-chat-gap);
    z-index: 1030;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
}

/* ----------------------------------------------------------- Launcher ---- */

.am-chat__launcher {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    width: var(--am-chat-size);
    height: var(--am-chat-size);
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: var(--artemis-red, #ff325a);
    color: #fff;
    font-size: 24px;
    line-height: 1;
    cursor: pointer;
    box-shadow: 0 6px 20px rgba(0, 0, 0, .22);
    transition: transform .18s ease, background-color .18s ease;
}

.am-chat__launcher:hover,
.am-chat__launcher:focus {
    background: #e02a4d;
    color: #fff;
    transform: scale(1.05);
}

.am-chat__launcher:focus-visible {
    outline: 3px solid #111113;
    outline-offset: 3px;
}

/* Swap the bubble for a cross while the panel is open */
.am-chat__launcher-close {
    display: none;
    font-size: 30px;
    font-weight: 300;
}

.am-chat.is-open .am-chat__launcher-open {
    display: none;
}

.am-chat.is-open .am-chat__launcher-close {
    display: block;
}

.am-chat.is-open .am-chat__launcher {
    background: #111113;
}

/* -------------------------------------------------------- Channels ------- */

.am-chat__list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;

    /* Collapsed. `visibility` rather than `display` so the entry can animate, and
       so the links are not reachable by keyboard while hidden. */
    visibility: hidden;
    opacity: 0;
    transform: translateY(8px);
    transition: opacity .18s ease, transform .18s ease, visibility .18s;
}

.am-chat.is-open .am-chat__list {
    visibility: visible;
    opacity: 1;
    transform: none;
}

.am-chat__link,
.am-chat__link:visited {
    display: flex;
    flex-direction: row-reverse;   /* icon nearest the launcher edge, label beside it */
    align-items: center;
    gap: 10px;
    padding: 6px 14px 6px 6px;
    border-radius: 999px;
    background: #fff;
    color: #111113;
    font-size: 13.5px;
    font-weight: 600;
    text-decoration: none;
    white-space: nowrap;
    box-shadow: 0 4px 16px rgba(0, 0, 0, .18);
    transition: transform .18s ease, box-shadow .18s ease;
}

.am-chat__link:hover,
.am-chat__link:focus {
    color: #111113;
    transform: translateX(3px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, .24);
}

.am-chat__link:focus-visible {
    outline: 3px solid var(--artemis-red, #ff325a);
    outline-offset: 2px;
}

.am-chat__icon {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
}

.am-chat__icon img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.am-chat__label {
    display: block;
}

/* ------------------------------------------------------- Breakpoints ----- */

@media (max-width: 767px) {
    .am-chat {
        --am-chat-size: 52px;
        --am-chat-gap: 14px;
    }

    .am-chat__link {
        font-size: 13px;
        padding: 5px 12px 5px 5px;
    }

    .am-chat__icon {
        width: 30px;
        height: 30px;
    }
}

/* Very narrow phones: the labels would run past the viewport, so the channels
   become plain icon buttons. Their accessible name comes from the label text,
   which is moved off-screen rather than removed. */
@media (max-width: 400px) {
    .am-chat__link {
        padding: 6px;
    }

    .am-chat__label {
        position: absolute;
        width: 1px;
        height: 1px;
        margin: -1px;
        padding: 0;
        border: 0;
        overflow: hidden;
        clip: rect(0 0 0 0);
        clip-path: inset(50%);
        white-space: nowrap;
    }
}

@media (prefers-reduced-motion: reduce) {
    .am-chat__list,
    .am-chat__link,
    .am-chat__launcher {
        transition: none;
    }

    .am-chat__link:hover,
    .am-chat__link:focus,
    .am-chat__launcher:hover,
    .am-chat__launcher:focus {
        transform: none;
    }
}
