/* Chatbot Styles - Fixed for Production */
.gls-chatbot-container {
    position: fixed;
    bottom: 95px;
    right: 30px;
    z-index: 999;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
}

/* Chatbot Trigger Button */
.gls-chatbot-trigger {
    position: relative;
    width: 60px;
    height: 60px;
    background: linear-gradient(135deg, #16a34a 0%, #22c55e 100%);
    border: none;
    border-radius: 50%;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4rem;
    box-shadow: 0 6px 25px rgba(22, 163, 74, 0.3);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    overflow: hidden;
    flex-shrink: 0; /* Prevent shrinking */
    min-width: 60px; /* Ensure minimum width */
    min-height: 60px; /* Ensure minimum height */
}

.gls-chatbot-trigger::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: radial-gradient(circle, rgba(255,255,255,0.3) 0%, transparent 70%);
    transform: scale(0);
    transition: transform 0.3s ease;
}

.gls-chatbot-trigger:hover {
    transform: translateY(-3px) scale(1.05);
    box-shadow: 0 8px 30px rgba(22, 163, 74, 0.4);
}

.gls-chatbot-trigger:hover::before {
    transform: scale(1);
}

.gls-chatbot-trigger:active {
    transform: translateY(-1px) scale(1.02);
}

/* Notification Badge */
.gls-chatbot-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    width: 20px;
    height: 20px;
    background: #ef4444;
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.7rem;
    font-weight: 600;
    border: 2px solid white;
    animation: glsChatbotPulse 2s infinite;
    flex-shrink: 0;
    min-width: 20px;
    min-height: 20px;
}

@keyframes glsChatbotPulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); }
}

/* Chatbot Icon Animation */
.gls-chatbot-icon {
    transition: all 0.3s ease;
    transform-origin: center;
}

.gls-chatbot-trigger.active .gls-chatbot-icon {
    transform: rotate(180deg);
}

.gls-chatbot-trigger.active .fa-comments {
    opacity: 0;
}

.gls-chatbot-trigger.active .fa-times {
    opacity: 1;
    position: absolute;
}

.gls-chatbot-trigger .fa-times {
    opacity: 0;
    position: absolute;
    transition: opacity 0.3s ease;
}

/* Chatbot Window - Fixed sizing issues */
.gls-chatbot-window {
    position: absolute;
    bottom: 80px;
    right: 0;
    width: 380px; /* Fixed width for desktop */
    height: 550px; /* Fixed height for desktop */
    min-width: 380px; /* Prevent compression */
    min-height: 550px; /* Prevent compression */
    max-width: 90vw; /* Responsive constraint */
    max-height: 85vh; /* Responsive constraint */
    background: white;
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.15);
    border: 1px solid #e2e8f0;
    display: flex;
    flex-direction: column;
    opacity: 0;
    visibility: hidden;
    transform: translateY(20px) scale(0.95);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    overflow: hidden;
    box-sizing: border-box; /* Important for consistent sizing */
}

.gls-chatbot-window.active {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
}

/* Chatbot Header */
.gls-chatbot-header {
    background: linear-gradient(135deg, #16a34a 0%, #22c55e 100%);
    color: white;
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 15px;
    position: relative;
    overflow: hidden;
    flex-shrink: 0; /* Prevent header from shrinking */
    min-height: 85px; /* Ensure consistent header height */
    box-sizing: border-box;
}

.gls-chatbot-header::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 20"><defs><pattern id="grid" width="10" height="10" patternUnits="userSpaceOnUse"><path d="M 10 0 L 0 0 0 10" fill="none" stroke="rgba(255,255,255,0.1)" stroke-width="1"/></pattern></defs><rect width="100" height="20" fill="url(%23grid)"/></svg>') repeat;
    opacity: 0.3;
}

.gls-chatbot-avatar {
    position: relative;
    z-index: 2;
    width: 45px;
    height: 45px;
    min-width: 45px; /* Prevent shrinking */
    min-height: 45px; /* Prevent shrinking */
    background: rgba(255, 255, 255, 0.2);
    backdrop-filter: blur(10px);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    border: 2px solid rgba(255, 255, 255, 0.3);
    flex-shrink: 0;
}

.gls-chatbot-info {
    position: relative;
    z-index: 2;
    flex: 1;
    min-width: 0; /* Allow text to truncate if needed */
}

.gls-chatbot-title {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.gls-chatbot-subtitle {
    font-size: 0.85rem;
    opacity: 0.9;
    display: flex;
    align-items: center;
    gap: 5px;
}

.gls-chatbot-status {
    width: 8px;
    height: 8px;
    min-width: 8px;
    min-height: 8px;
    background: #22c55e;
    border-radius: 50%;
    animation: glsChatbotOnline 2s infinite;
    flex-shrink: 0;
}

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

.gls-chatbot-close {
    position: relative;
    z-index: 2;
    background: none;
    border: none;
    color: white;
    font-size: 1.1rem;
    cursor: pointer;
    padding: 8px;
    border-radius: 6px;
    transition: background 0.3s ease;
    flex-shrink: 0;
    min-width: 32px;
    min-height: 32px;
}

.gls-chatbot-close:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* Chatbot Messages */
.gls-chatbot-messages {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 15px;
    scroll-behavior: smooth;
    min-height: 0; /* Allow flex item to shrink */
    box-sizing: border-box;
}

.gls-chatbot-messages::-webkit-scrollbar {
    width: 6px;
}

.gls-chatbot-messages::-webkit-scrollbar-track {
    background: #f1f5f9;
}

.gls-chatbot-messages::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 3px;
}

.gls-chatbot-messages::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

/* Message Styles */
.gls-chatbot-message {
    display: flex;
    gap: 10px;
    animation: glsChatbotMessageSlide 0.3s ease;
    flex-shrink: 0; /* Prevent message compression */
}

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

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

.gls-chatbot-message-avatar {
    width: 35px;
    height: 35px;
    min-width: 35px;
    min-height: 35px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.9rem;
    flex-shrink: 0;
}

.gls-chatbot-message.bot .gls-chatbot-message-avatar {
    background: linear-gradient(135deg, #16a34a, #22c55e);
    color: white;
}

.gls-chatbot-message.user .gls-chatbot-message-avatar {
    background: #f1f5f9;
    color: #64748b;
}

.gls-chatbot-message-content {
    max-width: 70%;
    min-width: 60px; /* Prevent too narrow messages */
    padding: 12px 16px;
    border-radius: 18px;
    font-size: 0.9rem;
    line-height: 1.4;
    word-wrap: break-word;
    box-sizing: border-box;
}

.gls-chatbot-message.bot .gls-chatbot-message-content {
    background: #f8fafc;
    color: #1e293b;
    border-bottom-left-radius: 6px;
}

.gls-chatbot-message.user .gls-chatbot-message-content {
    background: #16a34a;
    color: white;
    border-bottom-right-radius: 6px;
}

.gls-chatbot-message-time {
    font-size: 0.75rem;
    color: #94a3b8;
    margin-top: 4px;
    text-align: center;
}

/* Quick Actions */
.gls-chatbot-quick-actions {
    padding: 15px 20px 0;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    flex-shrink: 0;
    box-sizing: border-box;
}

.gls-chatbot-quick-action {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    color: #16a34a;
    padding: 8px 14px;
    border-radius: 20px;
    font-size: 0.8rem;
    cursor: pointer;
    transition: all 0.3s ease;
    white-space: nowrap;
    flex-shrink: 0;
}

.gls-chatbot-quick-action:hover {
    background: #16a34a;
    color: white;
    transform: translateY(-1px);
}

/* Typing Indicator */
.gls-chatbot-typing {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    background: #f8fafc;
    border-radius: 18px;
    border-bottom-left-radius: 6px;
    max-width: 70%;
    min-width: 100px;
}

.gls-chatbot-typing-dots {
    display: flex;
    gap: 4px;
}

.gls-chatbot-typing-dot {
    width: 6px;
    height: 6px;
    min-width: 6px;
    min-height: 6px;
    background: #94a3b8;
    border-radius: 50%;
    animation: glsChatbotTyping 1.4s infinite;
    flex-shrink: 0;
}

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

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

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

/* Input Area */
.gls-chatbot-input-area {
    padding: 20px;
    border-top: 1px solid #e2e8f0;
    background: #fafbfc;
    flex-shrink: 0;
    min-height: 85px; /* Ensure consistent input area height */
    box-sizing: border-box;
}

.gls-chatbot-input-container {
    display: flex;
    gap: 10px;
    align-items: flex-end;
}

.gls-chatbot-input {
    flex: 1;
    min-width: 0; /* Allow flex item to shrink */
    border: 2px solid #e2e8f0;
    border-radius: 25px;
    padding: 12px 16px;
    font-size: 0.9rem;
    outline: none;
    resize: none;
    min-height: 20px;
    max-height: 80px;
    transition: all 0.3s ease;
    font-family: inherit;
    box-sizing: border-box;
}

.gls-chatbot-input:focus {
    border-color: #16a34a;
    box-shadow: 0 0 0 3px rgba(22, 163, 74, 0.1);
}

.gls-chatbot-input::placeholder {
    color: #94a3b8;
}

.gls-chatbot-send {
    width: 45px;
    height: 45px;
    min-width: 45px;
    min-height: 45px;
    background: #16a34a;
    border: none;
    border-radius: 50%;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    transition: all 0.3s ease;
    flex-shrink: 0;
}

.gls-chatbot-send:hover:not(:disabled) {
    background: #15803d;
    transform: scale(1.05);
}

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

/* Welcome Message */
.gls-chatbot-welcome {
    text-align: center;
    padding: 20px;
    color: #64748b;
    flex-shrink: 0;
}

.gls-chatbot-welcome-icon {
    font-size: 2rem;
    color: #16a34a;
    margin-bottom: 15px;
}

.gls-chatbot-welcome-title {
    font-size: 1.1rem;
    font-weight: 600;
    color: #1e293b;
    margin-bottom: 8px;
}

.gls-chatbot-welcome-text {
    font-size: 0.9rem;
    line-height: 1.5;
    margin-bottom: 20px;
}

/* Desktop-specific styles for large screens */
@media (min-width: 1024px) {
    .gls-chatbot-window {
        width: 380px !important; /* Force desktop width */
        height: 550px !important; /* Force desktop height */
        min-width: 380px !important;
        min-height: 550px !important;
    }
    
    .gls-chatbot-container {
        bottom: 95px;
        right: 30px;
    }
    
    .gls-chatbot-trigger {
        width: 60px;
        height: 60px;
        font-size: 1.4rem;
    }
}

/* Tablet styles */
@media (min-width: 768px) and (max-width: 1023px) {
    .gls-chatbot-window {
        width: 360px;
        height: 520px;
        min-width: 360px;
        min-height: 520px;
    }
}

/* Mobile styles */
@media (max-width: 767px) {
    .gls-chatbot-container {
        bottom: 80px;
        right: 20px;
    }

    .gls-chatbot-trigger {
        width: 55px;
        height: 55px;
        font-size: 1.3rem;
    }

    .gls-chatbot-window {
        width: calc(100vw - 40px);
        height: calc(100vh - 140px);
        max-width: 380px;
        max-height: 550px;
        min-width: 300px;
        min-height: 400px;
        right: -10px;
        bottom: 70px;
    }

    .gls-chatbot-header {
        padding: 18px;
        min-height: 80px;
    }

    .gls-chatbot-avatar {
        width: 40px;
        height: 40px;
        min-width: 40px;
        min-height: 40px;
        font-size: 1.1rem;
    }

    .gls-chatbot-title {
        font-size: 1rem;
    }

    .gls-chatbot-subtitle {
        font-size: 0.8rem;
    }

    .gls-chatbot-messages {
        padding: 15px;
    }

    .gls-chatbot-message-content {
        max-width: 85%;
        padding: 10px 14px;
        font-size: 0.85rem;
    }

    .gls-chatbot-input-area {
        padding: 15px;
        min-height: 80px;
    }

    .gls-chatbot-input {
        padding: 10px 14px;
        font-size: 0.85rem;
    }

    .gls-chatbot-send {
        width: 40px;
        height: 40px;
        min-width: 40px;
        min-height: 40px;
        font-size: 0.9rem;
    }
}

@media (max-width: 480px) {
    .gls-chatbot-container {
        bottom: 70px;
        right: 15px;
    }

    .gls-chatbot-trigger {
        width: 50px;
        height: 50px;
        font-size: 1.2rem;
    }

    .gls-chatbot-window {
        width: calc(100vw - 30px);
        height: calc(100vh - 120px);
        min-width: 280px;
        min-height: 350px;
        right: -7px;
        bottom: 65px;
    }

    .gls-chatbot-header {
        padding: 15px;
        min-height: 75px;
    }

    .gls-chatbot-title {
        font-size: 0.95rem;
    }

    .gls-chatbot-subtitle {
        font-size: 0.75rem;
    }

    .gls-chatbot-messages {
        padding: 12px;
    }

    .gls-chatbot-quick-actions {
        padding: 12px 12px 0;
    }

    .gls-chatbot-quick-action {
        padding: 6px 12px;
        font-size: 0.75rem;
    }
}

/* Accessibility */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* High Contrast Mode */
@media (prefers-contrast: high) {
    .gls-chatbot-trigger {
        background: #0a5a0a;
        border: 2px solid #fff;
    }

    .gls-chatbot-header {
        background: #0a5a0a;
    }

    .gls-chatbot-window {
        border: 2px solid #0a5a0a;
    }
}