/* Enhanced Gemini Chatbot Styles */

/* Chatbot Container */
#gemini-chatbot {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 9999;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    direction: rtl;
    text-align: right;
}

/* Toggle Button */
#chatbot-toggle {
    width: 60px;
    height: 60px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    color: white;
}

#chatbot-toggle:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 25px rgba(0, 0, 0, 0.2);
}

#chatbot-toggle svg {
    transition: transform 0.3s ease;
}

#chatbot-toggle.active svg {
    transform: rotate(45deg);
}

/* Notification Badge */
#chatbot-notification {
    position: absolute;
    top: -5px;
    right: -5px;
    background: #ff4757;
    color: white;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    font-size: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.2); }
    100% { transform: scale(1); }
}

/* Chatbot Window */
#chatbot-window {
    position: absolute;
    bottom: 80px;
    right: 0;
    width: 380px;
    height: 500px;
    background: white;
    border-radius: 16px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: slideUp 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

#chatbot-window.minimized {
    height: 60px;
    animation: slideDown 0.3s ease;
}

@keyframes slideDown {
    from {
        height: 500px;
    }
    to {
        height: 60px;
    }
}

/* Header */
#chatbot-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 15px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-radius: 16px 16px 0 0;
}

#chatbot-header h3 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
}

#chatbot-actions {
    display: flex;
    gap: 5px;
}

#chatbot-actions button {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s ease;
    font-size: 16px;
    font-weight: bold;
}

#chatbot-actions button:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* Messages Container */
#chatbot-messages {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    background: #f8f9fa;
    scrollbar-width: thin;
    scrollbar-color: #ddd transparent;
}

#chatbot-messages::-webkit-scrollbar {
    width: 6px;
}

#chatbot-messages::-webkit-scrollbar-track {
    background: transparent;
}

#chatbot-messages::-webkit-scrollbar-thumb {
    background: #ddd;
    border-radius: 3px;
}

#chatbot-messages::-webkit-scrollbar-thumb:hover {
    background: #ccc;
}

/* Messages */
.message {
    display: flex;
    margin-bottom: 16px;
    animation: fadeInUp 0.3s ease;
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.message-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    margin-left: 8px;
    flex-shrink: 0;
}

.message-content {
    background: white;
    padding: 12px 16px;
    border-radius: 18px;
    max-width: 260px;
    word-wrap: break-word;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    position: relative;
}

.message-time {
    font-size: 11px;
    color: #999;
    margin-top: 4px;
    text-align: center;
}

/* Bot Messages */
.bot-message {
    justify-content: flex-start;
}

.bot-message .message-avatar {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.bot-message .message-content {
    background: white;
    border: 1px solid #e9ecef;
}

.bot-message .message-content::before {
    content: '';
    position: absolute;
    top: 12px;
    right: -6px;
    width: 0;
    height: 0;
    border-left: 6px solid white;
    border-top: 6px solid transparent;
    border-bottom: 6px solid transparent;
}

/* User Messages */
.user-message {
    justify-content: flex-end;
    flex-direction: row-reverse;
}

.user-message .message-avatar {
    background: #28a745;
    color: white;
    margin-left: 0;
    margin-right: 8px;
}

.user-message .message-content {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.user-message .message-content::before {
    content: '';
    position: absolute;
    top: 12px;
    left: -6px;
    width: 0;
    height: 0;
    border-right: 6px solid #667eea;
    border-top: 6px solid transparent;
    border-bottom: 6px solid transparent;
}

/* Typing Indicator */
.typing-indicator {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    background: white;
    border-radius: 18px;
    max-width: 80px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.typing-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #999;
    margin: 0 2px;
    animation: typingAnimation 1.4s infinite;
}

.typing-dot:nth-child(2) {
    animation-delay: 0.2s;
}

.typing-dot:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typingAnimation {
    0%, 60%, 100% {
        transform: translateY(0);
        opacity: 0.5;
    }
    30% {
        transform: translateY(-10px);
        opacity: 1;
    }
}

/* Input Area */
#chatbot-input-area {
    padding: 16px 20px;
    background: white;
    border-top: 1px solid #e9ecef;
    display: flex;
    align-items: center;
    gap: 8px;
}

#chatbot-input {
    flex: 1;
    border: 1px solid #e9ecef;
    border-radius: 20px;
    padding: 10px 16px;
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s ease;
    background: #f8f9fa;
}

#chatbot-input:focus {
    border-color: #667eea;
    background: white;
}

#chatbot-send {
    width: 40px;
    height: 40px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border: none;
    border-radius: 50%;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

#chatbot-send:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

#chatbot-send:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

/* Error Messages */
.error-message .message-content {
    background: #fee;
    border: 1px solid #fcc;
    color: #c33;
}

/* Success Messages */
.success-message .message-content {
    background: #efe;
    border: 1px solid #cfc;
    color: #3c3;
}

/* Message Formatting */
.message-content strong {
    font-weight: 600;
}

.message-content em {
    font-style: italic;
}

.message-content ul {
    margin: 8px 0;
    padding-right: 20px;
}

.message-content li {
    margin: 4px 0;
}

.message-content a {
    color: #667eea;
    text-decoration: none;
}

.message-content a:hover {
    text-decoration: underline;
}

/* Mobile Responsive */
@media (max-width: 768px) {
    #gemini-chatbot {
        bottom: 10px;
        right: 10px;
        left: 10px;
    }
    
    #chatbot-window {
        width: 100%;
        height: 70vh;
        max-height: 500px;
        right: 0;
        bottom: 80px;
    }
    
    #chatbot-toggle {
        position: absolute;
        right: 20px;
        bottom: 0;
    }
    
    .message-content {
        max-width: 240px;
    }
}

@media (max-width: 480px) {
    #chatbot-window {
        height: 80vh;
        bottom: 70px;
    }
    
    .message-content {
        max-width: 200px;
    }
    
    #chatbot-header {
        padding: 12px 16px;
    }
    
    #chatbot-messages {
        padding: 16px;
    }
    
    #chatbot-input-area {
        padding: 12px 16px;
    }
}

/* Loading Animation */
.loading {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: white;
    animation: spin 1s ease-in-out infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Smooth Transitions */
* {
    transition: all 0.2s ease;
}

/* Custom Scrollbar for Webkit */
#chatbot-messages {
    scrollbar-width: thin;
    scrollbar-color: rgba(0, 0, 0, 0.2) transparent;
}

/* Source Indicator */
.message-source {
    font-size: 10px;
    color: #999;
    margin-top: 4px;
    font-style: italic;
}

.source-ai {
    color: #667eea;
}

.source-knowledge {
    color: #28a745;
}

.source-prepared {
    color: #ffc107;
}

/* 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) {
    #chatbot-window {
        border: 2px solid #000;
    }
    
    .message-content {
        border: 1px solid #000;
    }
    
    #chatbot-input {
        border: 2px solid #000;
    }
}

.messenger-typing {
    display: inline-flex;
    align-items: center;
    padding: 8px 12px;
    background-color: #f1f3f4;
    border-radius: 18px;
    margin: 5px 0;
}

.typing-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: #90949c;
    margin: 0 1px;
    animation: messenger-typing 1.5s infinite ease-in-out;
}

.typing-dot:nth-child(1) {
    animation-delay: 0s;
}

.typing-dot:nth-child(2) {
    animation-delay: 0.2s;
}

.typing-dot:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes messenger-typing {
    0%, 60%, 100% {
        transform: translateY(0);
    }
    30% {
        transform: translateY(-10px);
    }
}
