.mehbot-container {
    position: fixed;
    z-index: 999999;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, sans-serif;
}

.mehbot-right {
    bottom: 20px;
    right: 20px;
}

.mehbot-left {
    bottom: 20px;
    left: 20px;
}

.mehbot-toggle {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: var(--mehbot-primary);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0,0,0,0.25);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    border: none;
    padding: 0;
}

.mehbot-toggle:hover {
    transform: scale(1.08);
    box-shadow: 0 6px 20px rgba(0,0,0,0.3);
}

.mehbot-toggle:focus-visible {
    outline: 3px solid var(--mehbot-primary);
    outline-offset: 3px;
}

.mehbot-toggle svg {
    width: 28px;
    height: 28px;
}

.mehbot-chat {
    display: none;
    position: absolute;
    bottom: 75px;
    width: 370px;
    height: 500px;
    background: #fff;
    color: #333;
    border-radius: 16px;
    box-shadow: 0 8px 30px rgba(0,0,0,0.2);
    overflow: hidden;
    flex-direction: column;
    opacity: 0;
    transform: translateY(20px) scale(0.95);
    transition: opacity 0.3s ease, transform 0.3s ease;
}

.mehbot-right .mehbot-chat {
    right: 0;
}

.mehbot-left .mehbot-chat {
    left: 0;
}

.mehbot-chat.mehbot-active {
    display: flex;
    opacity: 1;
    transform: translateY(0) scale(1);
}

.mehbot-header {
    background: var(--mehbot-header-bg);
    color: var(--mehbot-header-text);
    padding: 16px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}

.mehbot-header-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.mehbot-header-info h3 {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
    color: inherit;
}

.mehbot-header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.mehbot-header-btn {
    background: none;
    border: none;
    color: inherit;
    cursor: pointer;
    padding: 4px;
    opacity: 0.8;
    transition: opacity 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: inherit;
    border-radius: 4px;
}

.mehbot-header-btn:hover {
    opacity: 1;
}

.mehbot-header-btn:focus-visible {
    outline: 2px solid var(--mehbot-header-text);
    outline-offset: 2px;
}

.mehbot-header-btn.muted {
    opacity: 0.4;
}

.mehbot-header-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid rgba(255,255,255,0.3);
}

.mehbot-close {
    font-size: 28px;
    line-height: 1;
    padding: 0 4px;
}

.mehbot-messages {
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    color: #333;
}

.mehbot-message {
    max-width: 80%;
    padding: 10px 14px;
    border-radius: 12px;
    font-size: 14px;
    line-height: 1.5;
    overflow-wrap: anywhere;
    word-break: break-word;
    display: flex;
    align-items: flex-start;
    gap: 8px;
    position: relative;
    animation: mehbot-fadeIn 0.3s ease;
}

@keyframes mehbot-fadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

.bot-message {
    background: var(--mehbot-bot-bg);
    color: #333;
    align-self: flex-start;
    border-bottom-left-radius: 4px;
}

.user-message {
    background: var(--mehbot-user-bg);
    color: var(--mehbot-user-text);
    align-self: flex-end;
    border-bottom-right-radius: 4px;
}

.mehbot-error {
    background: #fee2e2 !important;
    color: #991b1b !important;
    border: 1px solid #fca5a5;
}

.mehbot-error .mehbot-message-content {
    color: #991b1b;
}

.mehbot-message-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
}

.mehbot-message-content {
    flex: 1;
    min-width: 0;
    overflow-wrap: anywhere;
    word-break: break-word;
    cursor: default;
    transition: background 0.15s;
}

.mehbot-message-content:hover {
    cursor: default;
}

.mehbot-message-time {
    font-size: 10px;
    color: rgba(0,0,0,0.35);
    align-self: flex-end;
    margin-left: 4px;
    white-space: nowrap;
}

.user-message .mehbot-message-time {
    color: rgba(255,255,255,0.6);
}

.mehbot-message-content p {
    margin: 0 0 10px;
    line-height: 1.6;
}

.mehbot-message-content p:last-child {
    margin-bottom: 0;
}

.mehbot-message-content ul {
    margin: 8px 0;
    padding-left: 20px;
}

.mehbot-message-content li {
    margin-bottom: 4px;
    line-height: 1.5;
}

.mehbot-message-content strong {
    font-weight: 600;
}

.mehbot-message-content code {
    background: rgba(0,0,0,0.08);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 13px;
    font-family: 'Courier New', monospace;
    word-break: break-all;
    overflow-wrap: anywhere;
}

.mehbot-message-content pre {
    background: rgba(0,0,0,0.06);
    padding: 10px 14px;
    border-radius: 8px;
    font-size: 13px;
    font-family: 'Courier New', monospace;
    white-space: pre-wrap;
    word-break: break-all;
    overflow-x: auto;
    margin: 8px 0;
    line-height: 1.5;
}

.mehbot-message-content em {
    font-style: italic;
}

.mehbot-input-area {
    display: flex;
    align-items: center;
    padding: 12px;
    border-top: 1px solid #e5e5e5;
    background: var(--mehbot-bot-bg, #fff);
    color: #333;
    flex-shrink: 0;
}

.mehbot-input-area input {
    flex: 1;
    border: 1px solid #ddd;
    border-radius: 24px;
    padding: 10px 16px;
    font-size: 14px;
    color: #333;
    background: #fff;
    outline: 2px solid transparent;
    outline-offset: -2px;
    transition: border-color 0.2s, outline-color 0.2s;
    min-width: 0;
}

#mehbot-input {
    color: #333 !important;
    background: #fff !important;
    -webkit-text-fill-color: #333 !important;
}

#mehbot-input:-webkit-autofill,
#mehbot-input:-webkit-autofill:hover,
#mehbot-input:-webkit-autofill:focus {
    -webkit-text-fill-color: #333 !important;
    -webkit-box-shadow: 0 0 0 30px #fff inset !important;
}

.mehbot-input-area input:focus {
    border-color: var(--mehbot-primary);
    outline-color: var(--mehbot-primary);
}

.mehbot-char-count {
    font-size: 11px;
    color: #999;
    padding: 0 4px;
    white-space: nowrap;
    flex-shrink: 0;
}

.mehbot-send {
    background: var(--mehbot-primary);
    border: none;
    color: #fff;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    margin-left: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.2s, transform 0.15s;
    padding: 0;
    flex-shrink: 0;
}

.mehbot-send:hover {
    opacity: 0.85;
    transform: scale(1.05);
}

.mehbot-send:active {
    transform: scale(0.95);
}

.mehbot-send:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.mehbot-send:focus-visible {
    outline: 3px solid var(--mehbot-primary);
    outline-offset: 3px;
}

.mehbot-send svg {
    width: 18px;
    height: 18px;
}

.mehbot-typing {
    display: flex;
    gap: 4px;
    padding: 10px 14px;
    align-self: flex-start;
}

.mehbot-typing span {
    width: 8px;
    height: 8px;
    background: #999;
    border-radius: 50%;
    animation: mehbot-bounce 1.4s infinite ease-in-out;
}

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

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

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

.mehbot-suggestions {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 8px 16px 16px;
    max-height: 200px;
    overflow-y: auto;
}

.mehbot-suggestion-btn {
    background: var(--mehbot-bot-bg);
    border: 1px solid var(--mehbot-primary);
    border-radius: 16px;
    padding: 8px 14px;
    font-size: 13px;
    color: var(--mehbot-primary);
    cursor: pointer;
    text-align: left;
    transition: all 0.2s ease;
    line-height: 1.4;
}

.mehbot-suggestion-btn:hover {
    background: var(--mehbot-primary);
    color: #fff;
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}

.mehbot-suggestion-btn:focus-visible {
    outline: 2px solid var(--mehbot-primary);
    outline-offset: 2px;
}

.mehbot-reserve-btn {
    background: var(--mehbot-primary);
    color: #fff;
    font-weight: 600;
    border: 2px solid var(--mehbot-primary);
}

.mehbot-reserve-btn:hover {
    background: transparent;
    color: var(--mehbot-primary);
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}

#mehbot-history-view {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: #fff;
    display: flex;
    flex-direction: column;
    z-index: 10;
}

.mehbot-history-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 20px;
    border-bottom: 1px solid #e5e5e5;
}

.mehbot-history-header h4 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
}

.mehbot-history-back {
    background: none;
    border: none;
    color: var(--mehbot-primary);
    cursor: pointer;
    font-size: 14px;
    padding: 4px 8px;
    border-radius: 4px;
    transition: background 0.2s;
}

.mehbot-history-back:hover {
    background: rgba(0,0,0,0.05);
}

.mehbot-history-list {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
}

.mehbot-history-item {
    margin-bottom: 16px;
    padding-bottom: 16px;
    border-bottom: 1px solid #eee;
}

.mehbot-history-item:last-child {
    border-bottom: none;
}

.mehbot-history-time {
    font-size: 11px;
    color: #999;
    margin-bottom: 8px;
}

.mehbot-history-user {
    background: var(--mehbot-user-bg);
    color: var(--mehbot-user-text);
    padding: 8px 12px;
    border-radius: 8px;
    margin-bottom: 8px;
    font-size: 13px;
}

.mehbot-history-bot {
    background: var(--mehbot-bot-bg);
    padding: 8px 12px;
    border-radius: 8px;
    font-size: 13px;
}

.mehbot-history-empty {
    text-align: center;
    color: #999;
    padding: 40px 20px;
}

.mehbot-resize-handle {
    position: absolute;
    bottom: 0;
    right: 0;
    width: 20px;
    height: 20px;
    cursor: nwse-resize;
    z-index: 5;
    background: linear-gradient(135deg, transparent 50%, rgba(0,0,0,0.15) 50%);
    border-radius: 0 0 16px 0;
    transition: background 0.15s;
}
.mehbot-resize-handle:hover {
    background: linear-gradient(135deg, transparent 45%, rgba(0,0,0,0.25) 45%);
}
.mehbot-resize-handle:active {
    background: linear-gradient(135deg, transparent 40%, rgba(0,0,0,0.35) 40%);
}

@media (min-width: 769px) {
    .mehbot-resize-handle {
        display: block;
    }
}

@media (max-width: 768px) {
    .mehbot-resize-handle {
        display: none;
    }
}

@media (max-width: 480px) {
    .mehbot-chat {
        width: calc(100vw - 20px);
        height: 70vh;
    }

    .mehbot-right,
    .mehbot-left {
        left: 10px;
        right: 10px;
    }

    .mehbot-right .mehbot-chat,
    .mehbot-left .mehbot-chat {
        left: 0;
        right: 0;
    }
}

@media (max-height: 500px) and (orientation: landscape) {
    .mehbot-chat {
        height: 85vh;
    }
}

@media (prefers-color-scheme: dark) {
    .mehbot-chat {
        background: #1e1e1e;
        color: #e5e5e5;
    }
    .mehbot-header {
        color: #fff;
    }
    .mehbot-messages {
        background: #1e1e1e;
        color: #e5e5e5;
    }
    .bot-message {
        background: #2d2d2d !important;
        color: #e5e5e5;
    }
    .mehbot-input-area {
        border-color: #333;
        background: #1e1e1e;
    }
    .mehbot-input-area input,
    #mehbot-input {
        background: #2d2d2d !important;
        color: #e5e5e5 !important;
        -webkit-text-fill-color: #e5e5e5 !important;
        border-color: #444;
    }
    #mehbot-input:-webkit-autofill,
    #mehbot-input:-webkit-autofill:hover,
    #mehbot-input:-webkit-autofill:focus {
        -webkit-text-fill-color: #e5e5e5 !important;
        -webkit-box-shadow: 0 0 0 30px #2d2d2d inset !important;
    }
    .mehbot-suggestion-btn {
        background: #2d2d2d;
        color: #8bb8e8;
    }
    .mehbot-suggestion-btn:hover {
        background: #3a3a3a;
    }
    .mehbot-error {
        background: #3b1515 !important;
        color: #fca5a5 !important;
        border-color: #7f1d1d;
    }
    .mehbot-char-count {
        color: #777;
    }
}

[dir="rtl"] .mehbot-message.bot-message,
html[dir="rtl"] .mehbot-message.bot-message,
body.rtl .mehbot-message.bot-message {
    border-bottom-right-radius: 4px;
    border-bottom-left-radius: 12px;
}
[dir="rtl"] .mehbot-message.user-message,
html[dir="rtl"] .mehbot-message.user-message,
body.rtl .mehbot-message.user-message {
    border-bottom-left-radius: 4px;
    border-bottom-right-radius: 12px;
}
[dir="rtl"] .mehbot-right .mehbot-chat,
html[dir="rtl"] .mehbot-right .mehbot-chat,
body.rtl .mehbot-right .mehbot-chat {
    right: auto;
    left: 0;
}
[dir="rtl"] .mehbot-left .mehbot-chat,
html[dir="rtl"] .mehbot-left .mehbot-chat,
body.rtl .mehbot-left .mehbot-chat {
    left: auto;
    right: 0;
}