/* Project88 Licensed Chatbot Widget Styles */
.project88-chat-bubble,
.project88-chat-panel {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    line-height: 1.5;
    box-sizing: border-box;
}

.project88-chat-bubble *,
.project88-chat-panel * {
    box-sizing: border-box;
}

/* Chat Bubble Button */
.project88-chat-bubble {
    position: fixed;
    bottom: 16px;
    right: 16px;
    width: 60px;
    height: 60px;
    background: var(--project88-primary, #2563eb);
    border: none;
    border-radius: 50%;
    color: white;
    font-size: 24px;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    transition: all 0.3s ease;
    z-index: 999998;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
}

.project88-chat-bubble:hover {
    background: var(--project88-primary-dark, #1e40af);
    transform: scale(1.05);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.2);
}

.project88-chat-bubble:active {
    transform: scale(0.95);
}

/* Chat Panel */
.project88-chat-panel {
    position: fixed;
    bottom: 80px;
    right: 16px;
    width: 380px;
    max-width: calc(100vw - 32px);
    height: 500px;
    max-height: calc(100vh - 120px);
    background: white;
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    display: none;
    flex-direction: column;
    z-index: 999999;
    overflow: hidden;
    font-size: 14px;
}

/* Mobile responsive */
@media (max-width: 480px) {
    .project88-chat-panel {
        width: calc(100vw - 16px);
        height: calc(100vh - 100px);
        right: 8px;
        bottom: 70px;
    }

    .project88-chat-bubble {
        right: 8px;
    }
}

/* Chat Header */
.project88-chat-header {
    background: var(--project88-primary, #2563eb);
    color: white;
    padding: 16px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-weight: 600;
}

.project88-minimize-btn {
    background: none;
    border: none;
    color: white;
    font-size: 18px;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 4px;
    transition: background-color 0.2s ease;
}

.project88-minimize-btn:hover {
    background: rgba(255, 255, 255, 0.1);
}

/* Chat Body */
.project88-chat-body {
    flex: 1;
    padding: 16px;
    overflow-y: auto;
    background: #f8fafc;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.project88-chat-body::-webkit-scrollbar {
    width: 6px;
}

.project88-chat-body::-webkit-scrollbar-track {
    background: #f1f5f9;
}

.project88-chat-body::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 3px;
}

.project88-chat-body::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

/* Chat Messages */
.project88-msg {
    display: flex;
    margin-bottom: 12px;
}

.project88-msg.me {
    justify-content: flex-end;
}

.project88-me,
.project88-bot {
    max-width: 80%;
    padding: 10px 14px;
    border-radius: 18px;
    word-wrap: break-word;
    line-height: 1.4;
}

.project88-me {
    background: var(--project88-primary, #2563eb);
    color: white;
    margin-left: auto;
    border-bottom-right-radius: 6px;
}

.project88-bot {
    background: white;
    color: #374151;
    border: 1px solid #e5e7eb;
    border-bottom-left-radius: 6px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

/* Markdown rendering inside bot bubbles */
.project88-bot p { margin: 0; }
.project88-bot p + p { margin-top: 8px; }
.project88-bot strong { font-weight: 600; }
.project88-bot em { font-style: italic; }
.project88-bot a {
    color: var(--project88-primary, #2563eb);
    text-decoration: underline;
    word-break: break-word;
}
.project88-bot ul,
.project88-bot ol { margin: 6px 0; padding-left: 20px; }
.project88-bot li { margin: 2px 0; }
.project88-bot h4 {
    font-size: 14px;
    font-weight: 600;
    margin: 8px 0 4px;
}
.project88-bot code {
    background: rgba(0, 0, 0, 0.06);
    padding: 1px 5px;
    border-radius: 4px;
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 12.5px;
}
.project88-bot pre {
    background: rgba(0, 0, 0, 0.06);
    padding: 8px 10px;
    border-radius: 6px;
    margin: 6px 0;
    overflow-x: auto;
}
.project88-bot pre code {
    background: transparent;
    padding: 0;
    font-size: 12.5px;
}

/* Chat Footer */
.project88-chat-footer {
    padding: 16px;
    background: white;
    border-top: 1px solid #e5e7eb;
    display: flex;
    gap: 8px;
    align-items: center;
}

.project88-chat-footer input {
    flex: 1;
    border: 1px solid #d1d5db;
    border-radius: 20px;
    padding: 10px 16px;
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s ease;
}

.project88-chat-footer input:focus {
    border-color: var(--project88-primary, #2563eb);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.project88-send {
    background: var(--project88-primary, #2563eb);
    color: white;
    border: none;
    border-radius: 20px;
    padding: 10px 20px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: background-color 0.2s ease;
    min-width: 60px;
}

.project88-send:hover:not(:disabled) {
    background: var(--project88-primary-dark, #1e40af);
}

.project88-send:disabled {
    background: #9ca3af;
    cursor: not-allowed;
}

/* Branding */
.project88-branding {
    padding: 8px 16px;
    background: #f8fafc;
    border-top: 1px solid #e5e7eb;
    text-align: center;
}

.project88-branding small {
    color: #6b7280;
    font-size: 12px;
}

.project88-branding a {
    color: var(--project88-primary, #2563eb);
    text-decoration: none;
}

.project88-branding a:hover {
    text-decoration: underline;
}

/* Loading state */
.project88-msg.loading .project88-bot {
    background: #f3f4f6;
    color: #6b7280;
    font-style: italic;
}

/* Error state */
.project88-msg.error .project88-bot {
    background: #fef2f2;
    border-color: #fecaca;
    color: #dc2626;
}

/* Success animations */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.project88-msg {
    animation: fadeInUp 0.3s ease-out;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .project88-chat-panel {
        border: 2px solid #000;
    }

    .project88-me {
        border: 1px solid #fff;
    }

    .project88-bot {
        border: 2px solid #000;
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    .project88-chat-bubble,
    .project88-minimize-btn,
    .project88-send,
    .project88-chat-footer input {
        transition: none;
    }

    .project88-msg {
        animation: none;
    }

    .project88-chat-bubble:hover {
        transform: none;
    }
}

/* Focus styles for accessibility */
.project88-chat-bubble:focus,
.project88-minimize-btn:focus,
.project88-send:focus {
    outline: 2px solid #fbbf24;
    outline-offset: 2px;
}

.project88-chat-footer input:focus {
    outline: none; /* Custom focus style already applied */
}

/* Custom properties for theming */
:root {
    --project88-primary: #2563eb;
    --project88-primary-dark: #1e40af;
}