/**
 * Frontend Chatbot Styles with Floating Bubble
 */

:root {
    --optivmd-primary-color: #15becf;
    --optivmd-secondary-color: #15becf;
}

/* Chat Bubble Container */
#optivmd-chatbot-container {
    position: fixed;
    z-index: 999999;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
}

#optivmd-chatbot-container.position-bottom-right {
    bottom: 20px;
    right: 20px;
}

#optivmd-chatbot-container.position-bottom-left {
    bottom: 20px;
    left: 20px;
}

/* Floating Chat Bubble */
#optivmd-chatbot-bubble {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--optivmd-primary-color) 0%, var(--optivmd-secondary-color) 100%);
    border: none;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s cubic-bezier(0.68, -0.55, 0.265, 1.55);
    position: relative;
    overflow: visible;
}

#optivmd-chatbot-bubble:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.4);
}

#optivmd-chatbot-bubble:active {
    transform: scale(0.95);
}

#optivmd-chatbot-bubble.pulse {
    animation: bubblePulse 2s infinite;
}

@keyframes bubblePulse {
    0%, 100% {
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    }
    50% {
        box-shadow: 0 4px 20px rgba(102, 126, 234, 0.6);
    }
}

#optivmd-chatbot-bubble svg {
    width: 30px;
    height: 30px;
    fill: white;
    transition: transform 0.3s ease;
}

#optivmd-chatbot-bubble.active svg {
    transform: rotate(180deg);
}

/* Notification Badge */
#optivmd-chatbot-bubble .optivmd-notification-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    background: #ff4757;
    color: white;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: bold;
    border: 2px solid white;
    animation: badgePop 0.3s ease;
}

@keyframes badgePop {
    0% {
        transform: scale(0);
    }
    50% {
        transform: scale(1.2);
    }
    100% {
        transform: scale(1);
    }
}

/* Chat Window */
#optivmd-chatbot-window {
    position: absolute;
    width: 380px;
    max-width: calc(100vw - 40px);
    height: 600px;
    max-height: calc(100vh - 100px);
    background: white;
    border-radius: 16px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.12);
    display: none;
    flex-direction: column;
    overflow: hidden;
}

#optivmd-chatbot-container.position-bottom-right #optivmd-chatbot-window {
    bottom: 80px;
    right: 0;
}

#optivmd-chatbot-container.position-bottom-left #optivmd-chatbot-window {
    bottom: 80px;
    left: 0;
}

#optivmd-chatbot-window.active {
    display: flex;
    animation: slideUp 0.3s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

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

/* Header */
#optivmd-chatbot-header {
    background: linear-gradient(135deg, var(--optivmd-primary-color) 0%, var(--optivmd-secondary-color) 100%);
    color: white;
    padding: 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

#optivmd-chatbot-header-content {
    display: flex;
    align-items: center;
    gap: 12px;
}

#optivmd-chatbot-avatar {
    width: 40px;
    height: 40px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
}

#optivmd-chatbot-title h3 {
    margin: 0;
    font-size: 20px;
    font-weight: 600;
    color: white;
}

#optivmd-chatbot-title p {
    margin: 2px 0 0 0;
    font-size: 12px;
    opacity: 0.9;
}

#optivmd-chatbot-status {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 11px;
    opacity: 0.9;
}

#optivmd-chatbot-status-dot {
    width: 8px;
    height: 8px;
    background: #4ade80;
    border-radius: 50%;
    animation: statusPulse 2s infinite;
}

@keyframes statusPulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.5;
    }
}

#optivmd-chatbot-close {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

#optivmd-chatbot-close:hover {
    background: rgba(255, 255, 255, 0.3);
}

#optivmd-chatbot-close svg {
    width: 16px;
    height: 16px;
    fill: white;
}

/* Messages Area */
#optivmd-chatbot-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    background: #f8f9fa;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

#optivmd-chatbot-messages::-webkit-scrollbar {
    width: 6px;
}

#optivmd-chatbot-messages::-webkit-scrollbar-track {
    background: transparent;
}

#optivmd-chatbot-messages::-webkit-scrollbar-thumb {
    background: #cbd5e0;
    border-radius: 3px;
}

#optivmd-chatbot-messages::-webkit-scrollbar-thumb:hover {
    background: #a0aec0;
}

/* Message Bubbles */
.optivmd-message {
    display: flex;
    gap: 8px;
    animation: fadeIn 0.3s ease-out;
}

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

.optivmd-message.user {
    flex-direction: row-reverse;
}

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

.optivmd-message.bot .optivmd-message-avatar {
    background: linear-gradient(135deg, var(--optivmd-primary-color) 0%, var(--optivmd-secondary-color) 100%);
    color: white;
}

.optivmd-message.user .optivmd-message-avatar {
    background: #e2e8f0;
    color: #4a5568;
}

.optivmd-message-content {
    max-width: 75%;
}

.optivmd-message-bubble {
    padding: 12px 16px;
    border-radius: 16px;
    line-height: 1.5;
    font-size: 14px;
    word-wrap: break-word;
}

.optivmd-message.bot .optivmd-message-bubble {
    background: white;
    color: #2d3748;
    border-bottom-left-radius: 4px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.optivmd-message.user .optivmd-message-bubble {
    background: linear-gradient(135deg, var(--optivmd-primary-color) 0%, var(--optivmd-secondary-color) 100%);
    color: white;
    border-bottom-right-radius: 4px;
}

.optivmd-message-time {
    font-size: 11px;
    color: #a0aec0;
    margin-top: 4px;
    padding: 0 4px;
}

/* Typing Indicator */
.optivmd-typing-indicator {
    display: flex;
    gap: 4px;
    padding: 12px 16px;
}

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

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

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

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

/* Error Message */
.optivmd-error-message {
    background: #fed7d7;
    color: #c53030;
    padding: 12px 16px;
    border-radius: 8px;
    font-size: 14px;
    text-align: center;
}

/* Input Area */
#optivmd-chatbot-input-area {
    padding: 16px 20px;
    background: white;
    border-top: 1px solid #e2e8f0;
}

#optivmd-chatbot-input-form {
    display: flex;
    gap: 8px;
    align-items: flex-end;
}

#optivmd-chatbot-input {
    flex: 1;
    border: 1px solid #e2e8f0;
    border-radius: 24px;
    padding: 10px 16px;
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s;
    font-family: inherit;
    resize: none;
    max-height: 100px;
    min-height: 40px;
}

#optivmd-chatbot-input:focus {
    border-color: var(--optivmd-primary-color);
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

#optivmd-chatbot-input::placeholder {
    color: #a0aec0;
}

#optivmd-chatbot-send {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--optivmd-primary-color) 0%, var(--optivmd-secondary-color) 100%);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    flex-shrink: 0;
}

#optivmd-chatbot-send:hover:not(:disabled) {
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

#optivmd-chatbot-send:active:not(:disabled) {
    transform: scale(0.95);
}

#optivmd-chatbot-send:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

#optivmd-chatbot-send svg {
    width: 18px;
    height: 18px;
    fill: white;
}

/* Disclaimer */
.optivmd-disclaimer {
    font-size: 11px;
    color: #718096;
    text-align: center;
    padding: 8px 16px 0;
}

/* Mobile Responsive */
@media (max-width: 480px) {
    #optivmd-chatbot-container {
        bottom: 10px !important;
        right: 10px !important;
        left: 10px !important;
    }
    
    #optivmd-chatbot-window {
        width: 100% !important;
        height: calc(100vh - 80px) !important;
        max-height: none !important;
        bottom: 70px !important;
        right: 0 !important;
        left: 0 !important;
        border-radius: 16px 16px 0 0;
    }
    
    #optivmd-chatbot-bubble {
        width: 56px;
        height: 56px;
    }
    
    #optivmd-chatbot-bubble svg {
        width: 26px;
        height: 26px;
    }
}

/* Print Styles */
@media print {
    #optivmd-chatbot-container {
        display: none !important;
    }
}