/* =========================================================
   DISCOUNT TILES AI CHAT — iOS GLASS STYLE (CLEANED)
   ========================================================= */

#dt-ai-chat,
#dt-ai-chat * {
    box-sizing: border-box;
    font-family: "Inter", "SF Pro Display", "Segoe UI", Arial, sans-serif;
}

#dt-ai-chat {
    position: fixed !important;
    right: 22px !important;
    bottom: 22px !important;
    left: auto !important;
    z-index: 999999999 !important;
}

/* ── FLOATING BUTTON ───────────────────────────────────── */

#dt-chat-bubble {
    width: 74px;
    height: 74px;
    border: none;
    border-radius: 50%;
    overflow: hidden;
    background: rgba(255, 255, 255, .72);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    padding: 4px;
    cursor: pointer;
    box-shadow: 0 18px 45px rgba(0, 0, 0, .22);
    transition: transform .28s cubic-bezier(.22, .8, .36, 1),
                box-shadow .28s ease;
}

#dt-chat-bubble:hover {
    transform: translateY(-3px) scale(1.04);
    box-shadow: 0 24px 60px rgba(0, 0, 0, .28);
}

#dt-chat-bubble:active {
    transform: scale(.96);
}

#dt-chat-bubble img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
    display: block;
}

/* ── PANEL ─────────────────────────────────────────────── */

#dt-chat-panel {
    position: relative;
    width: 400px;
    max-width: calc(100vw - 24px);
    height: 650px;
    max-height: calc(100vh - 44px);
    display: none;
    flex-direction: column;
    overflow: hidden;

    background: rgba(255, 255, 255, .72);
    backdrop-filter: blur(26px) saturate(180%);
    -webkit-backdrop-filter: blur(26px) saturate(180%);

    border: 1px solid rgba(255, 255, 255, .55);
    border-radius: 30px;

    box-shadow:
        0 30px 90px rgba(0, 0, 0, .22),
        inset 0 1px 0 rgba(255, 255, 255, .75);

    transform-origin: bottom right;

    /* FIX: will-change improves GPU compositing for the open animation */
    will-change: transform, opacity;
}

#dt-ai-chat.dt-chat-open #dt-chat-panel {
    display: flex !important;
    animation: dtPanelIn .36s cubic-bezier(.22, .8, .36, 1) both;
}

#dt-ai-chat.dt-chat-open #dt-chat-bubble {
    display: none !important;
}

/* FIX: single unified panel-open keyframe (duplicate removed) */
@keyframes dtPanelIn {
    from {
        opacity: 0;
        transform: translateY(26px) scale(.94);
        filter: blur(8px);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
        filter: blur(0);
    }
}

/* ── HEADER ────────────────────────────────────────────── */

.dt-chat-head {
    min-height: 86px;
    padding: 16px 18px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;

    background: rgba(10, 10, 10, .86);
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);

    color: #fff;
    border-bottom: 1px solid rgba(255, 255, 255, .12);
}

.dt-chat-head-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.dt-chat-head-left img {
    width: 46px;
    height: 46px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
    box-shadow: 0 8px 24px rgba(0, 0, 0, .28);
}

.dt-chat-head strong {
    display: block;
    font-size: 20px;
    line-height: 1.1;
    margin-bottom: 4px;
    letter-spacing: -.03em;
}

.dt-chat-head small {
    display: block;
    font-size: 12px;
    opacity: .78;
}

/* ── CLOSE BUTTON ──────────────────────────────────────── */

/* FIX: duplicate #dt-chat-close block removed — single definition below */
#dt-chat-close {
    width: 38px;
    height: 38px;
    border: 0;
    outline: none;
    background: rgba(255, 255, 255, .08);
    border-radius: 50%;
    position: relative;
    cursor: pointer;
    flex-shrink: 0;
    padding: 0;
    min-width: 38px;
    min-height: 38px;
    overflow: hidden;

    display: flex;
    align-items: center;
    justify-content: center;

    transition: background .22s ease, transform .16s ease;
}

#dt-chat-close:hover {
    background: rgba(255, 255, 255, .14);
}

#dt-chat-close:active {
    transform: scale(.92);
}

/* CSS ✕ icon — no span needed */
#dt-chat-close::before,
#dt-chat-close::after {
    content: "";
    position: absolute;
    width: 16px;
    height: 2px;
    background: #fff;
    border-radius: 999px;
    top: 50%;
    left: 50%;
}

#dt-chat-close::before {
    transform: translate(-50%, -50%) rotate(45deg);
}

#dt-chat-close::after {
    transform: translate(-50%, -50%) rotate(-45deg);
}

/* Hide any legacy span inside close button */
#dt-chat-close span {
    display: none !important;
}

/* ── BODY ──────────────────────────────────────────────── */

#dt-chat-body {
    flex: 1;
    overflow-y: auto;
    padding: 15px;
    background: linear-gradient(180deg, rgba(246, 246, 248, .78), rgba(235, 235, 238, .72));
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
}

#dt-chat-body::-webkit-scrollbar {
    width: 5px;
}

#dt-chat-body::-webkit-scrollbar-track {
    background: transparent;
}

#dt-chat-body::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, .18);
    border-radius: 10px;
}

/* ── MESSAGES ──────────────────────────────────────────── */

.dt-msg {
    margin-bottom: 14px;
    /* FIX: will-change helps GPU composite message animations */
    will-change: transform, opacity;
}

.dt-msg.user {
    text-align: right;
}

.dt-msg-bubble {
    display: inline-block;
    max-width: 90%;
    padding: 12px 15px;
    border-radius: 20px;
    line-height: 1.5;
    font-size: 14px;

    background: rgba(255, 255, 255, .82);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);

    color: #111;
    border: 1px solid rgba(255, 255, 255, .55);
    box-shadow: 0 6px 18px rgba(0, 0, 0, .06);
}

.dt-msg.user .dt-msg-bubble {
    background: #111;
    color: #fff;
    border-color: #111;
    box-shadow: 0 8px 22px rgba(0, 0, 0, .16);
}

/* FIX: single unified message animation block (duplicate removed) */
.dt-msg-enter {
    opacity: 0;
    transform: translateY(12px) scale(.98);
    transition: opacity .34s ease,
                transform .34s cubic-bezier(.22, .8, .36, 1);
}

.dt-msg-visible {
    opacity: 1;
    transform: translateY(0) scale(1);
}

.dt-msg-exit {
    opacity: 0;
    transform: translateY(-4px);
    transition: opacity .18s ease, transform .18s ease;
    pointer-events: none;
}

.dt-msg.user.dt-msg-enter {
    transform: translateX(12px) scale(.98);
}

.dt-msg.user.dt-msg-visible {
    transform: translateX(0) scale(1);
}

/* ── SUGGESTION BUTTONS ────────────────────────────────── */

.dt-suggest-wrap {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: 10px 0 16px;
}

.dt-suggest-wrap.dt-msg-enter {
    opacity: 0;
    transform: translateY(8px);
    transition: opacity .22s ease .06s, transform .22s ease .06s;
}

.dt-suggest-wrap.dt-msg-visible {
    opacity: 1;
    transform: translateY(0);
}

.dt-suggest-btn {
    border: 1px solid rgba(0, 0, 0, .08);
    background: rgba(255, 255, 255, .76);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);

    color: #111;
    padding: 10px 15px;
    border-radius: 999px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;

    box-shadow: 0 5px 14px rgba(0, 0, 0, .05);

    /* FIX: unified transition — includes opacity & color for smooth hover */
    transition: background .22s ease,
                color .22s ease,
                box-shadow .22s ease,
                transform .14s ease;
}

.dt-suggest-btn:hover {
    background: #111;
    color: #fff;
    box-shadow: 0 10px 24px rgba(0, 0, 0, .14);
}

.dt-suggest-btn:active {
    transform: scale(.96);
}

/* ── INPUT ─────────────────────────────────────────────── */

#dt-chat-form {
    display: flex;
    gap: 10px;
    padding: 12px;
    background: rgba(255, 255, 255, .82);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    border-top: 1px solid rgba(0, 0, 0, .08);
}

#dt-chat-input {
    flex: 1;
    height: 52px;
    border: 1px solid rgba(0, 0, 0, .1);
    border-radius: 18px;
    padding: 0 16px;
    font-size: 15px;
    outline: none;
    background: rgba(255, 255, 255, .82);
    transition: border-color .2s ease, box-shadow .2s ease, background .2s ease;
}

/* FIX: placeholder styling to match glassmorphism aesthetic */
#dt-chat-input::placeholder {
    color: rgba(0, 0, 0, .35);
}

#dt-chat-input:focus {
    border-color: #111;
    background: #fff;
    box-shadow: 0 0 0 4px rgba(0, 0, 0, .06);
}

#dt-chat-form button {
    height: 52px;
    border: none;
    background: #111;
    color: #fff;
    border-radius: 18px;
    padding: 0 22px;
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 8px 22px rgba(0, 0, 0, .16);

    /* FIX: unified transition — includes opacity & color */
    transition: opacity .2s ease,
                background .22s ease,
                box-shadow .22s ease,
                transform .14s ease;
}

#dt-chat-form button:hover {
    opacity: .9;
    box-shadow: 0 12px 28px rgba(0, 0, 0, .2);
}

#dt-chat-form button:active {
    transform: scale(.96);
}

/* ── ACTION BUTTON ─────────────────────────────────────── */

.dt-action-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 42px;
    padding: 0 16px;
    border-radius: 999px;
    border: 1px solid rgba(0, 0, 0, .1);
    background: rgba(255, 255, 255, .78);
    color: #111;
    font-size: 13px;
    font-weight: 700;
    text-decoration: none;
    cursor: pointer;

    /* FIX: unified transition — includes opacity & color */
    transition: background .22s ease,
                color .22s ease,
                box-shadow .22s ease,
                transform .14s ease;
}

.dt-action-btn:hover {
    background: #111;
    color: #fff;
    box-shadow: 0 8px 20px rgba(0, 0, 0, .15);
}

.dt-action-btn:active {
    transform: scale(.96);
}

/* ── PRODUCTS ───────────────────────────────────────────── */

.dt-products {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.dt-product-card {
    background: rgba(255, 255, 255, .82);
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
    border: 1px solid rgba(255, 255, 255, .55);
    border-radius: 24px;
    overflow: hidden;
    box-shadow: 0 10px 28px rgba(0, 0, 0, .08);
    transition: transform .24s cubic-bezier(.22, .8, .36, 1),
                box-shadow .24s ease;
}

.dt-product-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 18px 42px rgba(0, 0, 0, .13);
}

.dt-product-card a {
    display: block;
}

.dt-product-card img {
    width: 100%;
    height: 180px;
    object-fit: contain;
    object-position: center;
    background: rgba(250, 250, 250, .88);
    padding: 12px;
}

.dt-product-info {
    padding: 14px;
}

.dt-product-title {
    font-size: 17px;
    font-weight: 800;
    line-height: 1.35;
    margin-bottom: 10px;
    letter-spacing: -.02em;
}

.dt-product-price {
    font-size: 26px;
    font-weight: 900;
    margin-bottom: 14px;
    letter-spacing: -.04em;
}

.dt-product-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

/* ── TYPING INDICATOR ──────────────────────────────────── */

.dt-typing {
    display: inline-flex;
    gap: 5px;
    align-items: center;
    padding: 13px 15px;
}

.dt-typing span {
    width: 7px;
    height: 7px;
    background: #999;
    border-radius: 50%;
    animation: dtBounce 1.2s infinite ease-in-out;
}

.dt-typing span:nth-child(1) { animation-delay: 0s; }
.dt-typing span:nth-child(2) { animation-delay: .18s; }
.dt-typing span:nth-child(3) { animation-delay: .36s; }

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

/* ── LOADING ────────────────────────────────────────────── */

.dt-loading {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: #777;
    font-size: 13px;
}

.dt-loading::before {
    content: "";
    display: inline-block;
    width: 14px;
    height: 14px;
    border: 2px solid #ddd;
    border-top-color: #555;
    border-radius: 50%;
    animation: dtSpin .7s linear infinite;
    flex-shrink: 0;
}

@keyframes dtSpin {
    to { transform: rotate(360deg); }
}

/* ── MOBILE ─────────────────────────────────────────────── */

@media (max-width: 640px) {

    #dt-ai-chat {
        right: 8px !important;
        left: 8px !important;
        bottom: 8px !important;
    }

    #dt-chat-panel {
        width: 100% !important;
        max-width: 100% !important;
        height: 85vh !important;
        max-height: 85vh !important;
        border-radius: 26px !important;
    }

    .dt-chat-head {
        padding: 14px;
        min-height: 76px;
    }

    .dt-chat-head strong {
        font-size: 17px;
    }

    .dt-chat-head small {
        font-size: 11px;
    }

    .dt-chat-head-left img {
        width: 40px;
        height: 40px;
    }

    #dt-chat-body {
        padding: 12px;
    }

    .dt-msg-bubble {
        max-width: 94%;
        font-size: 14px;
        line-height: 1.45;
    }

    .dt-suggest-wrap {
        gap: 7px;
    }

    .dt-suggest-btn {
        font-size: 13px;
        padding: 10px 12px;
    }

    .dt-product-card {
        border-radius: 20px;
    }

    .dt-product-card img {
        width: 100%;
        height: 150px !important;
        object-fit: contain;
        padding: 8px;
    }

    .dt-product-info {
        padding: 12px;
    }

    .dt-product-title {
        font-size: 15px;
        line-height: 1.4;
    }

    .dt-product-price {
        font-size: 22px;
        margin-bottom: 12px;
    }

    .dt-product-actions {
        gap: 8px;
    }

    .dt-action-btn {
        min-height: 40px;
        font-size: 12px;
        padding: 0 12px;
    }

    #dt-chat-form {
        position: sticky;
        bottom: 0;
        padding: 10px;
        gap: 8px;
        z-index: 20;
    }

    #dt-chat-input {
        height: 48px;
        min-width: 0;
        font-size: 15px;
        border-radius: 16px;
    }

    #dt-chat-form button {
        height: 48px;
        min-width: 78px;
        padding: 0 14px;
        font-size: 14px;
        border-radius: 16px;
        flex-shrink: 0;
    }

    body.dt-chat-mobile-open {
        overflow: hidden;
    }
}