/* PolMedi Chat Widget Styles - Modern Design with Animations */

:root {
    --polmedi-primary-color: #2563eb;
    --polmedi-primary-hover: #1d4ed8;
    --polmedi-shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --polmedi-shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
    --polmedi-border-radius: 16px;
    --polmedi-transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.polmedi-chat-widget {
    position: fixed;
    z-index: 999999;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease-in-out;
}

.polmedi-chat-widget.loaded {
    opacity: 1;
    pointer-events: auto;
}

/* Widget Positions */
.polmedi-position-bottom-right {
    bottom: 20px;
    right: 20px;
}

.polmedi-position-bottom-left {
    bottom: 20px;
    left: 20px;
}

.polmedi-position-top-right {
    top: 20px;
    right: 20px;
}

.polmedi-position-top-left {
    top: 20px;
    left: 20px;
}

/* Chat Button (Minimized State) */
.polmedi-chat-button {
    width: 90px; /* Increased from 60px to 90px (50% larger) */
    height: 90px; /* Increased from 60px to 90px (50% larger) */
    background: var(--polmedi-primary-color);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: var(--polmedi-shadow-lg);
    transition: var(--polmedi-transition);
    position: relative;
    animation: pulse 2s infinite;
}

.polmedi-chat-button:hover {
    background: var(--polmedi-primary-hover);
    transform: scale(1.05);
    box-shadow: 0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1);
}

.polmedi-chat-button:active {
    transform: scale(0.95);
}

.polmedi-chat-icon {
    width: 42px; /* Increased from 28px to 42px (50% larger) */
    height: 42px; /* Increased from 28px to 42px (50% larger) */
    color: white;
}

/* Pulse Animation */
@keyframes pulse {
    0%, 100% {
        box-shadow: var(--polmedi-shadow-lg);
    }
    50% {
        box-shadow: var(--polmedi-shadow-lg), 0 0 0 0 rgba(37, 99, 235, 0.4);
        box-shadow: var(--polmedi-shadow-lg), 0 0 0 13px rgba(37, 99, 235, 0.1); /* Increased from 10px to 13px (~25% larger) */
    }
}

/* Chat Badge */
.polmedi-chat-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    width: 24px;
    height: 24px;
    background: #ef4444;
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 600;
    border: 2px solid white;
}

/* Chat Window (Expanded State) */
.polmedi-chat-window {
    position: absolute;
    bottom: 80px;
    right: 0;
    width: 380px;
    height: 600px;
    background: white;
    border-radius: var(--polmedi-border-radius);
    box-shadow: var(--polmedi-shadow-lg);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    opacity: 0;
    transform: translateY(20px) scale(0.95);
    pointer-events: none;
    transition: var(--polmedi-transition);
}

.polmedi-position-bottom-left .polmedi-chat-window {
    left: 0;
    right: auto;
}

.polmedi-position-top-right .polmedi-chat-window {
    bottom: auto;
    top: 80px;
}

.polmedi-position-top-left .polmedi-chat-window {
    bottom: auto;
    top: 80px;
    left: 0;
    right: auto;
}

/* Chat Header */
.polmedi-chat-header {
    background: linear-gradient(135deg, var(--polmedi-primary-color), var(--polmedi-primary-hover));
    color: white;
    padding: 16px 20px;
    display: flex;
    align-items: center;
    gap: 12px;
    border-radius: var(--polmedi-border-radius) var(--polmedi-border-radius) 0 0;
}

.polmedi-chat-avatar {
    width: 40px;
    height: 40px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.polmedi-chat-avatar svg {
    width: 24px;
    height: 24px;
}

.polmedi-chat-info {
    flex: 1;
    min-width: 0;
}

.polmedi-chat-name {
    font-weight: 600;
    font-size: 16px;
    margin-bottom: 2px;
}

.polmedi-chat-status {
    font-size: 12px;
    opacity: 0.8;
}

.polmedi-chat-close {
    background: none;
    border: none;
    color: white;
    cursor: pointer;
    padding: 4px;
    border-radius: 8px;
    transition: var(--polmedi-transition);
    flex-shrink: 0;
}

.polmedi-chat-close:hover {
    background: rgba(255, 255, 255, 0.1);
}

.polmedi-chat-close svg {
    width: 20px;
    height: 20px;
}

/* Chat Messages */
.polmedi-chat-messages {
    flex: 1;
    padding: 16px;
    overflow-y: auto;
    scroll-behavior: smooth;
    background: #f8fafc;
}

.polmedi-chat-messages::-webkit-scrollbar {
    width: 4px;
}

.polmedi-chat-messages::-webkit-scrollbar-track {
    background: #f1f5f9;
}

.polmedi-chat-messages::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 2px;
}

.polmedi-chat-messages::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

/* Message Bubbles */
.polmedi-message {
    margin-bottom: 12px;
    display: flex;
}

.polmedi-message-user {
    justify-content: flex-end;
}

.polmedi-message-bot {
    justify-content: flex-start;
}

.polmedi-message-bubble {
    max-width: 280px;
    padding: 12px 16px;
    border-radius: 18px;
    font-size: 14px;
    line-height: 1.4;
    word-wrap: break-word;
    animation: messageSlideIn 0.3s ease-out;
}

.polmedi-message-user .polmedi-message-bubble {
    background: var(--polmedi-primary-color);
    color: white;
    border-bottom-right-radius: 6px;
}

.polmedi-message-bot .polmedi-message-bubble {
    background: white;
    color: #374151;
    border-bottom-left-radius: 6px;
    box-shadow: var(--polmedi-shadow);
}

@keyframes messageSlideIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Typing Indicator */
.polmedi-typing-indicator {
    padding: 16px;
    display: flex;
    align-items: center;
}

.polmedi-typing-dots {
    display: flex;
    gap: 4px;
    padding: 12px 16px;
    background: white;
    border-radius: 18px;
    box-shadow: var(--polmedi-shadow);
}

.polmedi-typing-dots span {
    width: 6px;
    height: 6px;
    background: #cbd5e1;
    border-radius: 50%;
    animation: typingBounce 1.4s infinite ease-in-out;
}

.polmedi-typing-dots span:nth-child(1) { animation-delay: -0.32s; }
.polmedi-typing-dots span:nth-child(2) { animation-delay: -0.16s; }

@keyframes typingBounce {
    0%, 80%, 100% {
        transform: scale(0);
    }
    40% {
        transform: scale(1);
    }
}

/* Chat Form */
.polmedi-chat-form {
    border-top: 1px solid #e2e8f0;
    padding: 16px 20px;
    background: white;
    display: flex;
    gap: 12px;
    align-items: center;
    border-radius: 0 0 var(--polmedi-border-radius) var(--polmedi-border-radius);
}

.polmedi-chat-form input {
    flex: 1;
    border: 1px solid #d1d5db;
    border-radius: 24px;
    padding: 12px 16px;
    font-size: 14px;
    outline: none;
    transition: var(--polmedi-transition);
}

.polmedi-chat-form input:focus {
    border-color: var(--polmedi-primary-color);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.polmedi-chat-form button {
    width: 44px;
    height: 44px;
    background: var(--polmedi-primary-color);
    border: none;
    border-radius: 50%;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--polmedi-transition);
    flex-shrink: 0;
}

.polmedi-chat-form button:hover {
    background: var(--polmedi-primary-hover);
    transform: scale(1.05);
}

.polmedi-chat-form button:active {
    transform: scale(0.95);
}

.polmedi-chat-form button svg {
    width: 20px;
    height: 20px;
}

/* States */
.polmedi-chat-widget.minimized .polmedi-chat-window {
    opacity: 0;
    transform: translateY(20px) scale(0.95);
    pointer-events: none;
}

.polmedi-chat-widget.expanded .polmedi-chat-window {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: auto;
}

/* Responsive Design */
@media (max-width: 480px) {
    /* Mobile-specific positioning - center the chat window */
    .polmedi-chat-widget.expanded {
        position: fixed !important;
        top: 0 !important;
        left: 0 !important;
        right: 0 !important;
        bottom: 0 !important;
        z-index: 1000000;
    }

    .polmedi-chat-widget.expanded .polmedi-chat-window {
        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;
        transform: none !important;
        z-index: 1000001;
    }

    /* Ensure button stays in corner on mobile when minimized */
    .polmedi-chat-widget.minimized.polmedi-position-bottom-right {
        top: auto !important;
        left: auto !important;
        bottom: 20px !important;
        right: 20px !important;
    }

    .polmedi-chat-widget.minimized.polmedi-position-bottom-left {
        top: auto !important;
        right: auto !important;
        bottom: 20px !important;
        left: 20px !important;
    }

    .polmedi-chat-widget.minimized.polmedi-position-top-right {
        bottom: auto !important;
        left: auto !important;
        top: 20px !important;
        right: 20px !important;
    }

    .polmedi-chat-widget.minimized.polmedi-position-top-left {
        bottom: auto !important;
        right: auto !important;
        top: 20px !important;
        left: 20px !important;
    }

    /* Expanded state - full screen with proper spacing for mobile UI */
    .polmedi-chat-widget.expanded .polmedi-chat-window {
        border-radius: 0 !important;
        padding-bottom: env(safe-area-inset-bottom) !important;
        padding-bottom: calc(env(safe-area-inset-bottom) + 20px) !important;
    }

    .polmedi-chat-widget.expanded .polmedi-chat-header {
        border-radius: 0 !important;
        padding-top: env(safe-area-inset-top) !important;
        padding-top: calc(env(safe-area-inset-top) + 12px) !important;
    }

    .polmedi-chat-widget.expanded .polmedi-chat-form {
        border-radius: 0 !important;
        position: fixed !important;
        bottom: 0 !important;
        left: 0 !important;
        right: 0 !important;
        background: white !important;
        border-top: 1px solid #e2e8f0 !important;
        padding-bottom: env(safe-area-inset-bottom) !important;
        padding-bottom: calc(env(safe-area-inset-bottom) + 10px) !important;
        z-index: 10 !important;
    }

    .polmedi-chat-widget.expanded .polmedi-chat-messages {
        padding-bottom: 80px !important; /* Space for fixed form */
        padding-bottom: calc(80px + env(safe-area-inset-bottom)) !important;
    }

    .polmedi-chat-header {
        padding: 12px 16px;
    }

    .polmedi-chat-messages {
        padding: 12px;
    }

    .polmedi-chat-form {
        padding: 12px 16px;
    }

    .polmedi-message-bubble {
        max-width: 280px;
        padding: 10px 14px;
        font-size: 13px;
    }

    /* Keyboard handling */
        @supports (-webkit-touch-callout: none) {
            .polmedi-chat-widget.expanded {
                height: 100vh !important;
                height: calc(100vh - env(safe-area-inset-bottom)) !important;
            }
    
            .polmedi-chat-widget.expanded .polmedi-chat-window {
                height: 100vh !important;
                height: calc(100vh - env(safe-area-inset-bottom)) !important;
            }
        }
    
        /* Force typing indicator visibility on mobile */
        .polmedi-chat-widget.expanded .polmedi-typing-indicator {
            display: flex !important;
            visibility: visible !important;
            opacity: 1 !important;
            position: relative !important;
            z-index: 5 !important;
        }
    
        .polmedi-chat-widget.expanded .polmedi-typing-indicator[style*="display: none"] {
            display: flex !important;
        }

    /* No overlay needed since it's full screen */
}

/* Animations for open/close */
.polmedi-chat-widget .polmedi-chat-window {
    animation: chatSlideIn 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes chatSlideIn {
    from {
        opacity: 0;
        transform: translateY(20px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* Focus styles for accessibility */
.polmedi-chat-button:focus,
.polmedi-chat-close:focus,
.polmedi-chat-form button:focus {
    outline: 2px solid #3b82f6;
    outline-offset: 2px;
}

/* Loading state */
.polmedi-chat-widget.loading .polmedi-chat-button::after {
    content: '';
    position: absolute;
    width: 20px;
    height: 20px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top: 2px solid white;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Link styles in chat messages */
.polmedi-link {
    color: var(--polmedi-primary-color);
    text-decoration: underline;
    word-break: break-all;
    transition: opacity 0.2s ease;
}

.polmedi-link:hover {
    opacity: 0.8;
}

/* Dynamic color application */
.polmedi-chat-widget {
    --polmedi-primary-color: #2563eb;
}

.polmedi-chat-widget[data-primary-color] {
    --polmedi-primary-color: var(--primary-color);
}