/* MUFEPREC - Enhanced Conversational Chatbot CSS */
/* File Location: css/chatbot.css */

/* ===== CHATBOT CONTAINER ===== */
.chatbot-container {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 2000;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

/* ===== CHATBOT TOGGLE BUTTON ===== */
.chatbot-toggle {
    width: 60px;
    height: 60px;
    background: var(--primary-color);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 4px 20px rgba(0, 86, 179, 0.3);
    transition: all 0.3s ease;
    position: relative;
    border: none;
    outline: none;
}

.chatbot-toggle:hover {
    background: var(--accent-color);
    transform: scale(1.1);
    box-shadow: 0 6px 25px rgba(255, 193, 7, 0.4);
}

.chatbot-toggle i {
    font-size: 1.5rem;
    color: white;
    transition: color 0.3s ease;
}

.chatbot-toggle:hover i {
    color: var(--text-color);
}

/* Enhanced Notification Badge */
.chatbot-toggle.has-notification::after {
    content: '';
    position: absolute;
    top: 8px;
    right: 8px;
    width: 12px;
    height: 12px;
    background: #ff4757;
    border-radius: 50%;
    animation: pulse 2s infinite;
}

.chatbot-toggle::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: radial-gradient(circle, rgba(255,255,255,0.1) 0%, transparent 70%);
    border-radius: 50%;
    transform: scale(0);
    transition: transform 0.3s ease;
}

.chatbot-toggle:hover::before {
    transform: scale(1);
}

@keyframes pulse {
    0% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.2); opacity: 0.7; }
    100% { transform: scale(1); opacity: 1; }
}

/* ===== CHATBOT WINDOW ===== */
.chatbot {
    position: absolute;
    bottom: 80px;
    right: 0;
    width: 350px;
    height: 500px;
    background: white;
    border-radius: 15px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    transform: translateY(20px) scale(0.9);
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.chatbot.active {
    transform: translateY(0) scale(1);
    opacity: 1;
    visibility: visible;
}

/* ===== CHATBOT HEADER ===== */
.chatbot-header {
    background: var(--gradient);
    color: white;
    padding: 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: relative;
}

.chatbot-header::before {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.3), transparent);
}

.chatbot-header h4 {
    margin: 0;
    font-size: 1.1rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.chatbot-header h4::before {
    content: '🎓';
    font-size: 1.2rem;
}

/* Enhanced Status Indicator */
.chatbot-status {
    font-size: 0.8rem;
    opacity: 0.9;
    display: flex;
    align-items: center;
    gap: 0.3rem;
    margin-top: 0.2rem;
}

.status-dot {
    width: 6px;
    height: 6px;
    background: #28a745;
    border-radius: 50%;
    animation: pulse 2s infinite;
}

.chatbot-close {
    background: none;
    border: none;
    color: white;
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0.2rem;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.2s ease;
}

.chatbot-close:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: rotate(90deg);
}

/* ===== CHATBOT MESSAGES ===== */
.chatbot-messages {
    flex: 1;
    padding: 1rem;
    overflow-y: auto;
    background: #f8f9fa;
    scrollbar-width: thin;
    scrollbar-color: var(--border-color) transparent;
    scroll-behavior: smooth;
}

.chatbot-messages::-webkit-scrollbar {
    width: 4px;
}

.chatbot-messages::-webkit-scrollbar-track {
    background: transparent;
}

.chatbot-messages::-webkit-scrollbar-thumb {
    background: #ccc;
    border-radius: 2px;
}

.chatbot-messages::-webkit-scrollbar-thumb:hover {
    background: #999;
}

/* ===== MESSAGE BUBBLES ===== */
.message {
    margin-bottom: 1rem;
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
    animation: messageSlideIn 0.3s ease-out;
}

@keyframes messageSlideIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.user-message {
    justify-content: flex-end;
}

.user-message .message-content {
    background: linear-gradient(135deg, var(--primary-color) 0%, #004494 100%);
    color: white;
    padding: 0.8rem 1rem;
    border-radius: 18px 18px 4px 18px;
    max-width: 75%;
    word-wrap: break-word;
    position: relative;
    box-shadow: 0 2px 8px rgba(0, 86, 179, 0.2);
}

.user-message .message-content::after {
    content: '';
    position: absolute;
    bottom: 0;
    right: -6px;
    width: 0;
    height: 0;
    border: 6px solid transparent;
    border-top-color: #004494;
    border-left-color: #004494;
}

.bot-message .message-content {
    background: white;
    color: #333;
    padding: 0.8rem 1rem;
    border-radius: 18px 18px 18px 4px;
    max-width: 85%;
    border: 1px solid #e9ecef;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    position: relative;
}

.bot-message .message-content::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: -6px;
    width: 0;
    height: 0;
    border: 6px solid transparent;
    border-top-color: white;
    border-right-color: white;
}

.message-content p {
    margin: 0;
    font-size: 0.9rem;
    line-height: 1.4;
}

/* Enhanced Message Formatting */
.message-content strong {
    color: var(--primary-color);
    font-weight: 600;
}

.message-content em {
    font-style: italic;
    color: #666;
}

.user-message .message-content strong,
.user-message .message-content em {
    color: rgba(255, 255, 255, 0.9);
}

/* Emoji styling */
.message-content .emoji {
    font-size: 1.1em;
    margin: 0 0.1em;
}

/* ===== BOT AVATAR ===== */
.bot-avatar {
    width: 30px;
    height: 30px;
    background: linear-gradient(135deg, var(--accent-color) 0%, #e0a800 100%);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-color);
    font-size: 0.8rem;
    font-weight: bold;
    flex-shrink: 0;
    box-shadow: 0 2px 8px rgba(255, 193, 7, 0.3);
}

/* ===== QUICK OPTIONS (Legacy support) ===== */
.quick-options {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-top: 1rem;
}

.quick-options button {
    background: var(--secondary-color);
    border: 1px solid var(--border-color);
    padding: 0.6rem 1rem;
    border-radius: 20px;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.3s ease;
    text-align: left;
    color: var(--text-color);
}

.quick-options button:hover {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
    transform: translateX(5px);
}

/* ===== SUGGESTION CHIPS (For conversational chatbot) ===== */
.quick-suggestions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 0.8rem;
}

.suggestion-chip {
    background: #f1f3f4;
    border: 1px solid #dadce0;
    color: var(--primary-color);
    padding: 0.4rem 0.8rem;
    border-radius: 16px;
    font-size: 0.8rem;
    cursor: pointer;
    transition: all 0.2s ease;
    font-weight: 500;
    white-space: nowrap;
}

.suggestion-chip:hover {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(0, 86, 179, 0.2);
}

.suggestion-chip:active {
    transform: translateY(0);
}

/* ===== TYPING INDICATOR ===== */
.typing-indicator {
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
    margin-bottom: 1rem;
    animation: messageSlideIn 0.3s ease-out;
}

.typing-indicator .message-content {
    background: #f1f3f4;
    padding: 1rem;
    border-radius: 18px 18px 18px 4px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.typing-dots {
    display: flex;
    gap: 4px;
    align-items: center;
}

.typing-dot {
    width: 8px;
    height: 8px;
    background: #999;
    border-radius: 50%;
    animation: typingDot 1.4s infinite ease-in-out;
}

.typing-dot:nth-child(1) { animation-delay: -0.32s; }
.typing-dot:nth-child(2) { animation-delay: -0.16s; }

@keyframes typingDot {
    0%, 80%, 100% {
        transform: scale(0.8);
        opacity: 0.5;
    }
    40% {
        transform: scale(1);
        opacity: 1;
    }
}

/* ===== CHATBOT INPUT ===== */
.chatbot-input {
    padding: 1rem;
    background: white;
    border-top: 1px solid var(--border-color);
    display: flex;
    gap: 0.5rem;
    align-items: flex-end;
}

#chatbot-input-field {
    flex: 1;
    padding: 0.8rem 1rem;
    border: 1px solid #dee2e6;
    border-radius: 20px;
    font-size: 0.9rem;
    outline: none;
    transition: all 0.2s ease;
    resize: none;
    min-height: 20px;
    max-height: 100px;
    font-family: inherit;
}

#chatbot-input-field:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px rgba(0, 86, 179, 0.1);
}

#chatbot-input-field::placeholder {
    color: #999;
    font-style: italic;
}

#chatbot-send {
    width: 40px;
    height: 40px;
    background: linear-gradient(135deg, var(--primary-color) 0%, #004494 100%);
    border: none;
    border-radius: 50%;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    font-size: 0.9rem;
}

#chatbot-send:hover {
    transform: scale(1.05);
    box-shadow: 0 2px 8px rgba(0, 86, 179, 0.3);
}

#chatbot-send:active {
    transform: scale(0.95);
}

#chatbot-send:disabled {
    background: #ccc;
    cursor: not-allowed;
    transform: none;
    opacity: 0.6;
}

/* ===== SPECIALIZED MESSAGE TYPES ===== */
.welcome-message {
    text-align: center;
    padding: 1rem;
    background: linear-gradient(135deg, var(--primary-color), #004494);
    color: white;
    border-radius: 10px;
    margin-bottom: 1rem;
    box-shadow: 0 4px 12px rgba(0, 86, 179, 0.2);
}

.welcome-message h5 {
    margin: 0 0 0.5rem 0;
    font-size: 1rem;
    font-weight: 600;
}

.welcome-message p {
    margin: 0;
    font-size: 0.85rem;
    opacity: 0.9;
    line-height: 1.4;
}

.info-card {
    background: #e3f2fd;
    border-left: 4px solid var(--primary-color);
    padding: 1rem;
    border-radius: 8px;
    margin: 0.5rem 0;
}

.info-card h6 {
    margin: 0 0 0.5rem 0;
    color: var(--primary-color);
    font-size: 0.9rem;
    font-weight: 600;
}

.info-card p {
    margin: 0;
    font-size: 0.85rem;
    color: #333;
    line-height: 1.4;
}

.contact-card {
    background: #f0f8ff;
    padding: 1rem;
    border-radius: 8px;
    margin: 0.5rem 0;
    text-align: center;
    border: 1px solid #e1f3ff;
}

.contact-card .btn {
    margin: 0.5rem;
    padding: 0.5rem 1rem;
    font-size: 0.85rem;
}

.system-message {
    text-align: center;
    color: #666;
    font-size: 0.8rem;
    font-style: italic;
    margin: 1rem 0;
    padding: 0.5rem;
}

.error-message {
    background: #fef2f2;
    color: #dc2626;
    border: 1px solid #fecaca;
    padding: 0.8rem;
    border-radius: 8px;
    margin-bottom: 1rem;
    font-size: 0.9rem;
}

/* ===== CHATBOT STATES ===== */
.chatbot.minimized {
    height: 60px;
    overflow: hidden;
}

.chatbot.loading .chatbot-messages {
    display: flex;
    align-items: center;
    justify-content: center;
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--border-color);
    border-top: 3px solid var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* ===== ACCESSIBILITY ===== */
.chatbot-toggle:focus,
.chatbot-close:focus,
#chatbot-send:focus,
#chatbot-input-field:focus,
.quick-options button:focus,
.suggestion-chip:focus {
    outline: 2px solid var(--accent-color);
    outline-offset: 2px;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* ===== MOBILE RESPONSIVE ===== */
@media (max-width: 768px) {
    .chatbot-container {
        bottom: 15px;
        right: 15px;
    }
    
    .chatbot {
        width: 300px;
        height: 450px;
        bottom: 75px;
    }
    
    .chatbot-toggle {
        width: 55px;
        height: 55px;
    }
    
    .chatbot-toggle i {
        font-size: 1.3rem;
    }
    
    .suggestion-chip {
        font-size: 0.75rem;
        padding: 0.3rem 0.6rem;
    }
    
    .quick-suggestions {
        gap: 0.3rem;
    }
}

@media (max-width: 480px) {
    .chatbot-container {
        bottom: 10px;
        right: 10px;
        left: 10px;
    }
    
    .chatbot {
        width: calc(100vw - 20px);
        height: 70vh;
        max-height: 500px;
        min-height: 300px;
        right: 0;
        left: 0;
        margin: 0 auto;
        border-radius: 15px 15px 0 0;
    }
    
    .chatbot-toggle {
        width: 50px;
        height: 50px;
        font-size: 1.2rem;
    }
    
    .message-content {
        max-width: 85%;
    }
    
    .user-message .message-content {
        max-width: 80%;
    }
    
    .quick-options button {
        font-size: 0.8rem;
        padding: 0.5rem 0.8rem;
    }
    
    .suggestion-chip {
        font-size: 0.7rem;
        padding: 0.25rem 0.5rem;
    }
    
    .chatbot-messages {
        padding: 0.8rem;
    }
    
    .chatbot-input {
        padding: 0.8rem;
    }
    
    #chatbot-input-field {
        font-size: 0.85rem;
        padding: 0.7rem 0.9rem;
    }
    
    #chatbot-send {
        width: 36px;
        height: 36px;
        font-size: 0.8rem;
    }
}

/* ===== DARK MODE SUPPORT ===== */
@media (prefers-color-scheme: dark) {
    .chatbot {
        background: #2d3748;
        color: white;
    }
    
    .chatbot-messages {
        background: #1a202c;
    }
    
    .bot-message .message-content {
        background: #4a5568;
        color: white;
        border-color: #2d3748;
    }
    
    .suggestion-chip {
        background: #4a5568;
        color: white;
        border-color: #2d3748;
    }
    
    .suggestion-chip:hover {
        background: var(--primary-color);
    }
    
    .chatbot-input {
        background: #2d3748;
        border-color: #4a5568;
    }
    
    #chatbot-input-field {
        background: #4a5568;
        color: white;
        border-color: #2d3748;
    }
    
    #chatbot-input-field::placeholder {
        color: #a0aec0;
    }
}

/* ===== PERFORMANCE OPTIMIZATIONS ===== */
@media (prefers-reduced-motion: reduce) {
    .chatbot-toggle,
    .chatbot,
    .message,
    .suggestion-chip,
    .quick-options button {
        animation: none;
        transition: none;
    }
    
    .typing-dot {
        animation: none;
    }
    
    .pulse {
        animation: none;
    }
}

/* ===== PRINT STYLES ===== */
@media print {
    .chatbot-container {
        display: none;
    }
}