#makechat-widget {
    position: fixed;
    bottom: 20px;
    z-index: 99999;
}

.makechat-position-right {
    right: 20px;
}

.makechat-position-left {
    left: 20px;
}

/* --- Toggle Button --- */
#makechat-toggle {
    min-width: 60px;
    min-height: 60px;
    border-radius: 50%;
    border: none;
    background-color: #00b894;
    color: #fff;
    font-size: 24px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
    padding: 0;
    gap: 6px;
}

#makechat-toggle svg {
    width: 40px;
    height: 40px;
    fill: currentColor;
}

/* --- Chat Window --- */
#makechat-frame-wrapper {
    position: fixed;
    bottom: 90px;
    width: 400px;
    height: 600px;
    border-radius: 16px;
    overflow: hidden;
    box-shadow: 0 8px 40px rgba(0, 0, 0, 0.2);
    background: #fff;
    display: none;
    flex-direction: column;
    transform: scale(0.8);
    opacity: 0;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    transform-origin: center center;
}

#makechat-frame-wrapper.show {
    transform: scale(1);
    opacity: 1;
}

.makechat-position-right #makechat-frame-wrapper {
    right: 20px;
}

.makechat-position-left #makechat-frame-wrapper {
    left: 20px;
}

/* --- Chat Header --- */
#makechat-header {
    background-color: #00b894;
    color: #fff;
    padding: 12px 16px;
    font-weight: bold;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
}

.makechat-header-buttons {
    display: flex;
    gap: 5px;
}

#makechat-fullscreen,
#makechat-close {
    background: none;
    border: none;
    color: #fff;
    font-size: 24px;
    cursor: pointer;
    padding: 10px;
    border-radius: 4px;
}

/* --- Messages Area --- */
#makechat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    background: #f5f5f5;
}

/* --- Message Bubbles --- */
.makechat-message {
    max-width: 80%;
    padding: 10px 14px;
    border-radius: 18px;
    font-size: 14px;
    line-height: 1.4;
    word-wrap: break-word;
    animation: makechat-fade-in 0.2s ease;
}

.makechat-message.user {
    align-self: flex-end;
    background-color: #00b894;
    color: #fff;
    border-bottom-right-radius: 4px;
}

.makechat-message.bot {
    align-self: flex-start;
    background-color: #e9e9eb;
    color: #333;
    border-bottom-left-radius: 4px;
}

.makechat-message.bot a {
    color: #0057b8;
    text-decoration: underline;
    word-break: break-all;
}

.makechat-message.error {
    align-self: center;
    background-color: #ffe0e0;
    color: #c00;
    font-size: 13px;
    max-width: 90%;
    text-align: center;
}

@keyframes makechat-fade-in {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* --- Loading Dots --- */
.makechat-message.loading {
    align-self: flex-start;
    background-color: #e9e9eb;
    padding: 14px 18px;
    display: flex;
    gap: 4px;
    align-items: center;
}

.makechat-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: #999;
    animation: makechat-bounce 1.4s infinite ease-in-out both;
}

.makechat-dot:nth-child(1) { animation-delay: -0.32s; }
.makechat-dot:nth-child(2) { animation-delay: -0.16s; }
.makechat-dot:nth-child(3) { animation-delay: 0s; }

@keyframes makechat-bounce {
    0%, 80%, 100% { transform: scale(0); }
    40% { transform: scale(1); }
}

/* --- Input Area --- */
#makechat-input-area {
    display: flex;
    border-top: 1px solid #ddd;
    background: #fff;
    padding: 8px;
    flex-shrink: 0;
}

#makechat-input {
    flex: 1;
    min-width: 0;
    border: 1px solid #ddd;
    border-radius: 20px;
    padding: 10px 14px;
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s;
}

#makechat-input:focus {
    border-color: #00b894;
}

#makechat-send {
    margin-left: 8px;
    width: 40px;
    height: 40px;
    flex: 0 0 40px;
    border: none;
    background-color: #00b894;
    color: #fff;
    border-radius: 50%;
    padding: 0;
    font-size: 20px;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.2s;
}

#makechat-send svg {
    width: 22px;
    height: 22px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

#makechat-send:hover {
    background-color: #00a383;
}

#makechat-send:active {
    background-color: #008f6f;
}

/* --- Full Screen Mode --- */
#makechat-frame-wrapper.fullscreen {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    border-radius: 0 !important;
    z-index: 999999 !important;
    transform-origin: center center !important;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1) !important;
}

#makechat-frame-wrapper.fullscreen #makechat-messages {
    height: auto;
}

/* --- Mobile Viewport --- */
@media (max-width: 600px) {
    #makechat-widget {
        bottom: calc(12px + env(safe-area-inset-bottom, 0px));
    }

    .makechat-position-right {
        right: calc(12px + env(safe-area-inset-right, 0px));
    }

    .makechat-position-left {
        left: calc(12px + env(safe-area-inset-left, 0px));
    }

    #makechat-frame-wrapper {
        bottom: calc(82px + env(safe-area-inset-bottom, 0px));
        width: calc(100vw - 24px - env(safe-area-inset-left, 0px) - env(safe-area-inset-right, 0px));
        height: calc(100vh - 104px - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px));
        height: calc(100dvh - 104px - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px));
        max-height: 600px;
    }

    .makechat-position-right #makechat-frame-wrapper {
        right: calc(12px + env(safe-area-inset-right, 0px));
    }

    .makechat-position-left #makechat-frame-wrapper {
        left: calc(12px + env(safe-area-inset-left, 0px));
    }

    #makechat-input {
        font-size: 16px;
    }

    #makechat-frame-wrapper.makechat-keyboard-open,
    #makechat-frame-wrapper.fullscreen.makechat-keyboard-open {
        top: calc(var(--makechat-visual-top, 0px) + 8px) !important;
        left: calc(var(--makechat-visual-left, 0px) + 8px) !important;
        right: auto !important;
        bottom: auto !important;
        width: calc(var(--makechat-visual-width, 100vw) - 16px) !important;
        height: calc(var(--makechat-visual-height, 100dvh) - 16px) !important;
        max-height: none !important;
        border-radius: 12px !important;
    }
}
