/* AI Page Layout */
.ai-page-shell {
    height: 100vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.ai-layout {
    flex: 1;
    display: flex;
    overflow: hidden;
    background: #fff;
}

/* Sidebar */
.ai-sidebar {
    width: 260px;
    background: #f7f8fa;
    border-right: 1px solid #e2e8f0;
    display: flex;
    flex-direction: column;
    padding: 16px;
}

.new-chat-btn {
    width: 100%;
    background: #fff;
    border: 1px solid #e2e8f0;
    padding: 12px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    color: #0f1724;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.2s;
    margin-bottom: 24px;
}

.new-chat-btn:hover {
    border-color: var(--yellow);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
}

.new-chat-btn span {
    font-size: 18px;
    color: var(--yellow);
}

.chat-history-list {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.chat-history-item {
    padding: 10px 12px;
    border-radius: 6px;
    font-size: 13.5px;
    color: #4a5568;
    cursor: pointer;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    transition: background 0.2s, color 0.2s;
    user-select: none;
}

.chat-history-item:hover {
    background: #eef1f8;
}

.chat-history-item.active {
    background: #e2e8f0;
    color: #0f1724;
    font-weight: 600;
}

/* Main Area */
.ai-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    position: relative;
    background: #fff;
}

.chat-window {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 24px;
    scroll-behavior: smooth;
}

.welcome-screen {
    margin: auto;
    text-align: center;
    color: #0f1724;
    max-width: 400px;
}

.welcome-screen h2 {
    font-size: 24px;
    font-weight: 800;
}

.message-row {
    display: flex;
    gap: 16px;
    max-width: 800px;
    margin: 0 auto;
    width: 100%;
}

.message-row.user-msg {
    justify-content: flex-end;
}

.message-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    flex-shrink: 0;
}

.message-avatar.ai {
    background: rgba(169, 71, 71, 0.15);
}

.message-avatar.user {
    background: var(--navy);
    color: #fff;
    font-size: 14px;
    font-weight: 700;
}

.message-bubble {
    padding: 12px 18px;
    border-radius: 12px;
    font-size: 15px;
    line-height: 1.6;
    color: #0f1724;
    max-width: 85%;
}

.user-msg .message-bubble {
    background: #f0f2f7;
    border-bottom-right-radius: 4px;
}

.ai-msg .message-bubble {
    background: #fff;
    border-bottom-left-radius: 4px;
    border: 1px solid #e2e8f0;
}

/* Product Card inside AI Message */
.ai-product-card {
    display: flex;
    align-items: center;
    gap: 12px;
    border: 1px solid #e2e8f0;
    padding: 10px;
    border-radius: 8px;
    margin-top: 12px;
    background: #f8f9fa;
    text-decoration: none;
    color: inherit;
    transition: border-color 0.2s;
}

.ai-product-card:hover {
    border-color: var(--yellow);
}

.ai-product-img {
    width: 50px;
    height: 50px;
    background: #fff;
    border-radius: 6px;
    display: grid;
    place-items: center;
    font-size: 24px;
}

.ai-product-info h4 {
    font-size: 14px;
    font-weight: 600;
    margin: 0 0 2px;
}

.ai-product-info p {
    font-size: 13px;
    font-weight: 700;
    color: #b12704;
    margin: 0;
}

/* Input Area */
.chat-input-area {
    padding: 24px;
    background: linear-gradient(0deg, #fff 50%, rgba(255, 255, 255, 0) 100%);
    display: flex;
    flex-direction: column;
    align-items: center;
}

.chat-form {
    width: 100%;
    max-width: 800px;
    position: relative;
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 16px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.06);
    display: flex;
    align-items: center;
    padding: 8px 12px;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.chat-form:focus-within {
    border-color: #cbd5e0;
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.1);
}

.chat-form input {
    flex: 1;
    border: none;
    outline: none;
    padding: 10px 8px;
    font-size: 15px;
    font-family: inherit;
    color: #0f1724;
}

.chat-form button {
    background: var(--yellow);
    color: var(--navy);
    width: 36px;
    height: 36px;
    border-radius: 10px;
    display: grid;
    place-items: center;
    transition: transform 0.15s, background 0.15s;
    border: none;
    cursor: pointer;
}

.chat-form button:hover {
    background: var(--yellow-dark);
    transform: scale(1.05);
}

.chat-form button:active {
    transform: scale(0.95);
}

.chat-disclaimer {
    font-size: 11px;
    color: #a0aec0;
    margin-top: 10px;
    text-align: center;
}

@keyframes pulse {
    0% {
        transform: scale(0.8);
        opacity: 0.5;
    }

    100% {
        transform: scale(1.2);
        opacity: 1;
    }
}

/* ─── AI Sidebar Toggle (mobile) ─── */
.ai-sidebar-toggle {
    display: none;
    position: absolute;
    top: 12px;
    left: 12px;
    z-index: 10;
    width: 40px;
    height: 40px;
    background: #f7f8fa;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    font-size: 18px;
    cursor: pointer;
    transition: background 0.2s;
}

.ai-sidebar-toggle:hover {
    background: #eef1f8;
}

/* ─── AI Mobile Responsive ─── */
@media (max-width: 768px) {
    .ai-sidebar {
        position: fixed;
        top: 0;
        left: 0;
        z-index: 1800;
        width: 260px;
        max-width: 85vw;
        height: 100vh;
        height: 100dvh;
        transform: translateX(-100%);
        transition: transform 0.3s cubic-bezier(.4, 0, .2, 1);
        box-shadow: 4px 0 24px rgba(0, 0, 0, 0.15);
    }

    .ai-sidebar.mobile-open {
        transform: translateX(0);
    }

    .ai-sidebar-backdrop {
        position: fixed;
        inset: 0;
        background: rgba(0, 0, 0, 0.5);
        z-index: 1799;
        opacity: 0;
        pointer-events: none;
        transition: opacity 0.3s;
    }

    .ai-sidebar-backdrop.open {
        opacity: 1;
        pointer-events: all;
    }

    .ai-sidebar-toggle {
        display: grid;
        place-items: center;
    }

    .chat-window {
        padding: 16px;
        padding-top: 60px;
    }

    .message-row {
        gap: 10px;
    }

    .message-bubble {
        max-width: 92%;
        font-size: 14px;
    }

    .chat-input-area {
        padding: 12px;
    }

    .chat-form {
        padding: 6px 10px;
    }

    .chat-form input {
        font-size: 14px;
    }

    .welcome-screen {
        padding-top: 20px;
    }

    .welcome-screen h2 {
        font-size: 20px;
    }
}

@media (max-width: 480px) {
    .message-avatar {
        width: 28px;
        height: 28px;
        font-size: 16px;
    }

    .message-avatar.user {
        font-size: 12px;
    }

    .message-bubble {
        padding: 10px 14px;
        font-size: 13px;
        max-width: 95%;
    }

    .ai-product-card {
        flex-direction: column;
        align-items: flex-start;
    }
}
