
/* ==========================================
   LEMON STORE
   AI CUSTOMER SUPPORT - CLEAN CSS V5
   ========================================== */

.lemon-ai {
    --ai-yellow: #facc15;
    --ai-ink: #101010;
    --ai-panel: #171717;
    --ai-border: #343434;

    position: fixed;
    bottom: max(20px, env(safe-area-inset-bottom));
    right: 20px;

    z-index: 9990;

    font-family: system-ui, -apple-system,
        "Segoe UI", sans-serif;

    color: #ffffff;
    max-width: calc(100vw - 24px);
}

.lemon-ai,
.lemon-ai *,
.lemon-ai *::before,
.lemon-ai *::after {
    box-sizing: border-box;
}

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

/* ==========================================
   AI DESTEK AÇMA BUTONU
   ========================================== */

.lemon-ai-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;

    padding: 13px 18px;
    min-height: 52px;

    border: 1px solid #e0ac00;
    border-radius: 999px;

    background: var(--ai-yellow);
    color: var(--ai-ink);

    font-size: 14px;
    font-weight: 800;

    cursor: pointer;

    box-shadow:
        0 10px 30px rgba(0, 0, 0, .25);

    transition:
        transform .2s ease,
        box-shadow .2s ease;

    touch-action: manipulation;
}

.lemon-ai-toggle:hover {
    transform: translateY(-2px);

    box-shadow:
        0 14px 38px rgba(0, 0, 0, .3);
}

.lemon-ai-toggle:active {
    transform: scale(.97);
}

.lemon-ai-spark {
    display: grid;
    place-items: center;

    width: 28px;
    height: 28px;

    border-radius: 50%;

    background: #171717;
    color: var(--ai-yellow);

    font-size: 19px;
}

/* ==========================================
   SOHBET PENCERESİ
   ========================================== */

.lemon-ai-panel {
    position: absolute;

    bottom: calc(100% + 14px);
    right: 0;

    width: min(390px, calc(100vw - 32px));
    height: min(550px, calc(100dvh - 122px));

    max-width: calc(100vw - 24px);
    max-height: calc(100dvh - 110px);

    display: none;
    flex-direction: column;

    border: 1px solid var(--ai-border);
    border-radius: 20px;

    overflow: hidden;

    background: var(--ai-panel);

    box-shadow:
        0 24px 70px rgba(0, 0, 0, .45);
}

.lemon-ai.is-open .lemon-ai-panel {
    display: flex;
}

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

/* ==========================================
   SOHBET BAŞLIĞI
   ========================================== */

.lemon-ai-head {
    display: flex;
    align-items: center;

    gap: 12px;
    padding: 16px;

    flex-shrink: 0;
    min-width: 0;

    background: #0e0e0e;

    border-bottom:
        1px solid var(--ai-border);
}

.lemon-ai-avatar {
    display: grid;
    place-items: center;

    width: 42px;
    height: 42px;
    flex-shrink: 0;

    border-radius: 14px;

    background: var(--ai-yellow);
    color: #171717;

    font-weight: 900;
    font-size: 23px;
}

.lemon-ai-title,
.lemon-ai-head > div {
    flex: 1;
    min-width: 0;
}

.lemon-ai-head strong,
.lemon-ai-head small {
    display: block;
}

.lemon-ai-head strong {
    font-size: 14px;
    font-weight: 700;

    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.lemon-ai-head small {
    margin-top: 4px;

    font-size: 11px;
    color: #a9a9a9;
}

.lemon-ai-close {
    display: grid;
    place-items: center;

    width: 34px;
    height: 34px;
    flex-shrink: 0;

    border: 0;
    border-radius: 9px;

    background: transparent;
    color: #ffffff;

    font-size: 27px;
    cursor: pointer;
}

.lemon-ai-close:hover {
    background: #292929;
}

/* ==========================================
   MESAJ ALANI
   ========================================== */

.lemon-ai-feed {
    display: flex;
    flex: 1 1 auto;
    flex-direction: column;

    gap: 12px;
    padding: 18px;

    min-height: 0;

    overflow-x: hidden;
    overflow-y: auto;

    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;

    background:
        radial-gradient(
            circle at 10% 0%,
            #28240f 0%,
            #171717 55%
        );
}

.lemon-ai-msg {
    max-width: 88%;
    align-self: flex-start;

    border: 1px solid #3b3b3b;
    border-radius: 16px 16px 16px 4px;

    background: #2a2a2a;
    color: #eeeeee;

    padding: 12px 14px;

    font-size: 13px;
    line-height: 1.55;

    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

.lemon-ai-msg.user {
    align-self: flex-end;

    background: var(--ai-yellow);
    border-color: var(--ai-yellow);

    color: #191919;

    border-radius: 16px 16px 4px 16px;
}

/* ==========================================
   MESAJ GÖNDERME ALANI
   ========================================== */

.lemon-ai-form {
    display: flex;
    align-items: center;

    gap: 8px;
    padding: 12px;

    min-width: 0;
    flex-shrink: 0;

    background: #141414;

    border-top:
        1px solid var(--ai-border);
}

.lemon-ai-form input,
#lemonAiMessage {
    flex: 1 1 0%;
    min-width: 0;
    width: 100%;
    max-width: 100%;

    padding: 12px;

    background: #242424;
    border: 1px solid #3b3b3b;
    border-radius: 13px;

    color: #ffffff;

    /* iOS otomatik zoom önleme */
    font-size: 16px !important;
    line-height: 1.5 !important;

    outline: none;
}

.lemon-ai-form input:focus {
    border-color: var(--ai-yellow);
}

.lemon-ai-form button {
    display: grid;
    place-items: center;

    min-width: 44px;
    min-height: 44px;

    flex: 0 0 auto;

    border: none;
    border-radius: 13px;

    background: var(--ai-yellow);
    color: #171717;

    font-size: 20px;
    cursor: pointer;

    touch-action: manipulation;
}

.lemon-ai-form button:disabled {
    opacity: .45;
    cursor: wait;
}

.lemon-ai-disclaimer {
    flex-shrink: 0;

    margin: 0;
    padding: 0 8px 12px;

    text-align: center;
    font-size: 10px;

    color: #aaaaaa;
    background: #141414;
}

.lemon-ai-sr {
    position: absolute;

    width: 1px;
    height: 1px;

    padding: 0;
    margin: -1px;

    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* ==========================================
   MOBILE DESIGN
   ========================================== */

@media screen and (max-width: 768px) {

    .lemon-ai {
        position: fixed;

        right: 12px;
        left: auto;

        bottom: calc(
            12px + env(safe-area-inset-bottom, 0px)
        );

        max-width: calc(100vw - 24px);
        z-index: 9990;
    }

    .lemon-ai[data-position="left"] {
        left: 12px;
        right: auto;
    }

    .lemon-ai-toggle {
        min-height: 48px;

        padding: 10px 14px;

        font-size: 13px;
    }

    .lemon-ai-panel {
        position: absolute;

        right: 0;
        left: auto;
        bottom: calc(100% + 12px);

        width: min(
            340px,
            calc(100vw - 24px)
        );

        height: min(
            420px,
            calc(100dvh - 105px)
        );

        max-height: calc(100dvh - 105px);

        border-radius: 18px;
        overflow: hidden;
    }

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

    .lemon-ai-head {
        padding: 12px;
        gap: 9px;
    }

    .lemon-ai-avatar {
        width: 36px;
        height: 36px;

        font-size: 20px;
    }

    .lemon-ai-feed {
        min-height: 0;

        padding: 12px;
        gap: 10px;
    }

    .lemon-ai-msg {
        font-size: 13px;
        padding: 10px 12px;
    }

    .lemon-ai-form {
        padding: 9px;
        gap: 7px;
    }

    .lemon-ai-form input {
        font-size: 16px !important;
        min-width: 0;
    }
}

/* ==========================================
   SMALL MOBILE DEVICES
   ========================================== */

@media screen and (max-width: 380px) {

    .lemon-ai {
        right: 10px;
    }

    .lemon-ai[data-position="left"] {
        left: 10px;
        right: auto;
    }

    .lemon-ai-panel {
        width: calc(100vw - 20px);

        height: min(
            390px,
            calc(100dvh - 100px)
        );
    }
}

/* ==========================================
   CART / DRAWER VISIBILITY FIX
   ========================================== */

/*
   Lemon Store sepeti:
   [data-drawer="cart"]

   data-open aktif olduğunda
   AI Destek gizlenir.
*/

/* data-open özelliğiyle açılan sepet */
body:has(
    [data-drawer="cart"][data-open]:not([data-open="false"])
) .lemon-ai {
    display: none !important;
}

/* aria-hidden üzerinden yönetilen sepet */
body:has(
    [data-drawer="cart"][aria-hidden="false"]
) .lemon-ai {
    display: none !important;
}

/* data-state üzerinden açılan sepet */
body:has(
    [data-drawer="cart"][data-state="open"]
) .lemon-ai {
    display: none !important;
}

/* Mobil menü açılırsa */
body:has(
    [data-drawer="menu"][data-open]:not([data-open="false"])
) .lemon-ai {
    display: none !important;
}

/* Favoriler paneli açılırsa */
body:has(
    [data-drawer="favorites"][data-open]:not([data-open="false"])
) .lemon-ai {
    display: none !important;
}

/* HTML dialog açılırsa */
body:has(dialog[open]) .lemon-ai {
    display: none !important;
}

/* Erişilebilirlik */
@media (prefers-reduced-motion: reduce) {
    .lemon-ai-toggle {
        transition: none;
    }
}
