@import url('https://fonts.googleapis.com/css2?family=Playfair+Display:ital,wght@0,400..900;1,400..900&family=Poppins:ital,wght@0,100;0,200;0,300;0,400;0,500;0,600;0,700;0,800;0,900;1,100;1,200;1,300;1,400;1,500;1,600;1,700;1,800;1,900&display=swap');

#chatbot-toggle {
    position: fixed;
    right: 20px;
    bottom: 20px;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: #F4A3AE;
    border: none;
    cursor: pointer;
    box-shadow: 0px 4px 4px 0px #00000029, 0px 5px 7.1px 3px #FE8293 inset;

    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 999998;
    padding: 0;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

#chatbot-toggle img {
    width: 100%;
    height: 100%;
    max-width: 52px;
    object-fit: contain;
    animation: chatbotIconRotate 3s linear infinite;
}
@keyframes chatbotIconRotate {
    0% {
        transform: scale(0.8);
    }
    50% {
        transform: scale(1);
    }
    100% {
        transform: scale(0.8);
    }
}

/* ========================================
   CHATBOT WINDOW
   ======================================== */

.chat-wrapper {
    position: fixed;
    right: 20px;
    bottom: 10px;
    width: 510px;
    max-width: calc(100% - 40px);
    display: none;
    height: calc(100vh - 50px);
    max-height: 600px;
    min-height: 280px;
    background: #ffffff;
    border-radius: 16px;
    overflow: hidden;
    flex-direction: column;
    box-shadow: 0 15px 40px rgba(0, 0, 0, 0.15);
    z-index: 999999;
    animation: chatbotSlideIn 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes chatbotSlideIn {
    from {
        opacity: 0;
        transform: translate(20px, 20px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translate(0, 0) scale(1);
    }
}

/* ========================================
   CHATBOT HEADER
   ======================================== */

.chat-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    
    color: #1E212D;
    font-family: "Poppins", sans-serif;
    font-weight: 400;
    font-size: 14px;
    line-height: 20px;

    background: #FFFFFF;
    padding: 16px 16px 16px 32px;
}

.chat-header-left{
    display: flex;
    align-items: center;
    gap: 17px;
}

.chat-header-left .chatbot-name {
    font-family: "Playfair Display", serif;
    font-weight: 600;
    font-size: 24px;
    line-height: 30px;
    margin: 0;
}

.chat-header-left .chatbot-status{
    color: #1E212D;
    font-family: "Poppins", sans-serif;
    font-weight: 400;
    font-size: 14px;
    line-height: 20px;
}

.chat-header-icon {
    width: 51px;
    height: 51px;
    border-radius: 50%;

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

    flex-shrink: 0;
    overflow: hidden;
}

.chat-header-icon img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

#chatbot-close {
    background: none;
    border: none;

    color: #343330;
    font-size: 28px;
    font-weight: 300;
    line-height: 1;

    cursor: pointer;
    padding: 4px;

    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;

    transition: all 0.2s linear;
}

/* ========================================
   MESSAGES CONTAINER
   ======================================== */

.chat-box {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    background: #f5f3f7;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    scroll-behavior: smooth;
}

/* Custom Scrollbar Styling */
.chat-box::-webkit-scrollbar {
    width: 6px;
}

.chat-box::-webkit-scrollbar-track {
    background: transparent;
}

.chat-box::-webkit-scrollbar-thumb {
    background: #d4c5dc;
    border-radius: 3px;
    transition: background 0.3s ease;
}

.chat-box::-webkit-scrollbar-thumb:hover {
    background: #c4b5cc;
}

/* Firefox Scrollbar */
.chat-box {
    scrollbar-color: #d4c5dc transparent;
    scrollbar-width: thin;
}

.chat-date-divider {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    gap: 8px;
}
.chat-date-divider .divider-line {
    width: 100%;
    height: 1px;
    border-top: 1px solid rgb(113 113 113 / 50%);
    text-align: center;
    vertical-align: middle;
}
.chat-date-divider .chat-date{
    color: #717171;
    font-family: "Poppins", sans-serif;
    font-weight: 400;
    font-size: 11px;
    line-height: 16px;
}

/* ========================================
   MESSAGE STYLES (Bot & User)
   ======================================== */

.message-container {
    display: flex;
    align-items: flex-start;
    gap: 7px;
}

.message-container.user{
    text-align: right;
    justify-content: flex-end;
}

.msg {
    margin-bottom: 4px;
    animation: messageSlideIn 0.3s linear;
}

@keyframes messageSlideIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ========================================
   BOT MESSAGE
   ======================================== */
.bot-avatar{
    max-width: 35px !important;
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.msg.bot {
    justify-content: flex-start;
}

/* Add styling directly to .msg.bot for simple text */
.msg.bot {
    background: #ffffff;
    padding: 10px 12px;
    border-radius: 12px;
    word-wrap: break-word;
    max-width: 80%;
    width: fit-content;
    margin-top: 0;
    
    color: #121A37;
    font-family: "Poppins", sans-serif;
    font-size: 14px;
    font-weight: 300;
    line-height: 20px;
}

.msg.bot a {
    color: #ee8f9f;
    text-decoration: none;
    font-weight: 500;
    transition: color 0.2s ease;
}

.msg.bot a:hover {
    color: #e07589;
    text-decoration: underline;
}

.msg.bot ul,
.msg.bot ol {
    margin: 8px 0;
    padding-left: 20px;
}

.msg.bot li {
    margin: 4px 0;
}

.msg.bot strong {
    font-weight: 700;
    color: #111111;
}

/* ========================================
   USER MESSAGE
   ======================================== */

.msg.user {
    justify-content: flex-end;
    margin-left: auto;
}

.msg.user {
    padding: 10px 12px;
    border-radius: 12px;
    word-wrap: break-word;
    max-width: 80%;
    width: fit-content;
    background: #f4a6b6;

    color: #ffffff;
    font-family: "Poppins", sans-serif;
    font-size: 14px;
    font-weight: 300;
    line-height: 20px;
}

.msg.user a {
    color: #ffffff;
    text-decoration: underline;
}

.msg.user a:hover {
    opacity: 0.9;
}

/* ========================================
   MESSAGE TIMESTAMP (if added)
   ======================================== */

.msg-time {
    text-align: left;
    
    color: #7D85AB;
    font-family: "Poppins", sans-serif;
    font-weight: 400;
    font-size: 11px;
    line-height: 16px;
}

.msg.user ~ .msg-time {
    text-align: right;
}

/* ========================================
   PRODUCT CARDS
   ======================================== */

.product-container {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    gap: 6px;
    margin: 8px 0;
    animation: messageSlideIn 0.3s ease;
    width: 100%;
}

.product-card {
    background: #ffffff;
    border: 1px solid #e8e3ef;
    border-radius: 6px; 
    overflow: hidden;
    text-decoration: none;
    color: inherit;
    transition: all 0.3s ease;
    display: flex;
    flex-direction: column;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.05);
}

.product-card a{
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 4px 6px;
    text-decoration: none;
}
.product-card a:hover {
    text-decoration: none;
}

.product-card a img{
    width: 100%;
    object-fit: contain;
    height: 100px;
}

.product-card:hover {
    border-color: #d4c5dc;
    box-shadow: 0 6px 16px rgba(238, 143, 159, 0.15);
    transform: translateY(-2px);
}

.product-image {
    width: 100%;
    height: 120px;
    background: #f5f3f7;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.product-image img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    padding: 8px;
}

.product-info {
    padding: 10px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    flex: 1;
}

.product-name {
    font-size: 12px;
    font-weight: 600;
    color: #222222;
    line-height: 1.3;
    word-break: break-word;
    min-height: 28px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-decoration: none;
}

.product-price {
    font-size: 13px;
    font-weight: 700;
    color: #ee8f9f;
    margin-top: 2px;
}

.product-rating {
    font-size: 11px;
    color: #999999;
    margin-top: 2px;
}

.product-button {
    background: #ee8f9f;
    color: #ffffff;
    border: none;
    border-radius: 6px;
    padding: 6px 10px;
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    margin-top: 8px;
    transition: all 0.2s ease;
}

.product-button:hover {
    background: #e07589;
}

.product-button:active {
    transform: scale(0.97);
}

/* ========================================
   ACTION BUTTONS
   ======================================== */

.action-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: 8px 0;
    animation: messageSlideIn 0.3s ease;
}

.action-button {
    background: #f4a6b6;
    color: #ffffff;
    border: none;
    border-radius: 20px;
    padding: 8px 16px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.action-button:hover {
    background: #ed8fa6;
    transform: translateY(-1px);
}

.action-button:active {
    transform: translateY(0);
}

/* ========================================
   INPUT AREA
   ======================================== */

.chat-input {
    background: #ffffff;
    margin: 12px;
    flex-shrink: 0;
    display: flex;
    gap: 8px;
    align-items: center;
    position: relative;
}

#message {
    flex: 1;
    background: #FFFFFF;
    border: 1px solid #DDE0E9;
    border-radius: 8px;
    padding: 12px 115px 12px 12px;
    min-height: 52px;
    outline: none;
    transition: all 0.2s ease;
    
    color: #121A37;
    font-family: 'Poppins', sans-serif;
    font-weight: 300;
    font-size: 14px;
    line-height: 20px;
}

#message::placeholder {
    color: #7D85AB;
}

#message:focus {
    border-color: #121A37;
    box-shadow: none;
}

.chat-input button {
    background: #1f2937;
    border: none;
    border-radius: 8px;
    padding: 8px 20px;
    cursor: pointer;
    height: 32px;
    
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    
    color: #ffffff;
    font-family: 'Poppins', sans-serif;
    font-size: 12px;
    font-weight: 600;
    line-height: 16px;
    text-align: center;
    transition: all 0.2s ease;    
    min-width: 95px;

    position: absolute;
    top: 0;
    bottom: 0;
    right: 12px;
    margin: auto 0;
}

.chat-input button:hover {
    background: #111827;
}

.chat-input button:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* Paper plane icon styling if SVG used */
.chat-input button svg {
    width: 18px;
    height: 18px;
}

/* Hide button text on mobile, show only icon */
@media (max-width: 480px) {
    .chat-input button span {
        display: none;
    }
}

/* ========================================
   TYPING INDICATOR
   ======================================== */

.typing-indicator {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 12px 14px;
    background: #ffffff;
    border-radius: 12px;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
    width: fit-content;
}

.typing-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #cccccc;
    animation: typing 1.4s infinite;
}

.typing-dot:nth-child(2) {
    animation-delay: 0.2s;
}

.typing-dot:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typing {
    0%, 60%, 100% {
        opacity: 0.5;
        transform: translateY(0);
    }
    30% {
        opacity: 1;
        transform: translateY(-10px);
    }
}

/* ========================================
   RESPONSIVE DESIGN
   ======================================== */

@media (max-width: 767px) {
    .chat-wrapper {
        right: 8px;
        bottom: 12px;
        width: calc(100% - 30px);
        max-width: 100%;
    }

    #chatbot-toggle {
        right: 16px;
        bottom: 16px;
    }

    .msg {
        max-width: 85%;
    }

    .msg.bot {
        max-width: 85%;
    }

    .msg.user {
        max-width: 85%;
    }

    .product-container {
        grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    }
}

@media (max-width: 479px) {
    #chatbot-toggle {
        width: 56px;
        height: 56px;
    }

    .chat-header {
        padding: 12px;
        font-size: 15px;
    }

    .chat-header-name {
        font-size: 15px;
    }

    .chat-header-status {
        font-size: 11px;
    }

    .chat-box {
        padding: 12px;
        gap: 10px;
    }
    .bot-avatar{
        max-width: 30px !important;
    }

    .chat-input {
        margin: 8px;
    }

    .msg {
        max-width: 90%;
    }

    .msg.bot {
        max-width: 90%;
        font-size: 13px;
        padding: 10px 12px;
    }

    .msg.user {
        max-width: 90%;
        font-size: 13px;
        padding: 10px 12px;
    }

    .product-container {
        grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    }

    .product-card {
        border-radius: 8px;
    }

    .product-image {
        height: 100px;
    }

    .product-info {
        padding: 8px;
        gap: 4px;
    }

    .product-name {
        font-size: 11px;
        min-height: 24px;
    }

    .product-button {
        font-size: 10px;
        padding: 5px 8px;
    }

    #message {
        font-size: 14px;
        padding: 10px 12px;
    }
}