/* AI Chatbot Styles */

/* Welcome back message styling */
.message.welcome-back {
    background: linear-gradient(135deg, #e3f2fd 0%, #bbdefb 100%);
    border-left: 4px solid #2196F3;
    margin-bottom: 10px;
    padding: 12px;
    border-radius: 15px;
}

/* Remove the duplicate bot-label styling since we're not using it anymore */

/* Conversation separator */
.conversation-separator {
    margin: 15px 0;
    text-align: center;
}

.conversation-separator hr {
    border: none;
    border-top: 2px solid #e9ecef;
    margin: 10px 0;
    position: relative;
}

.conversation-separator hr::after {
    content: "Previous conversation";
    background: white;
    color: #6c757d;
    font-size: 11px;
    padding: 0 10px;
    position: absolute;
    top: -8px;
    left: 50%;
    transform: translateX(-50%);
}

/* Video thumbnail styles */
.video-thumbnail {
    margin: 8px 0;
    width: 120px;
    cursor: pointer;
    display: inline-block;
}

.thumbnail-img {
    width: 120px;
    height: 68px;
    object-fit: cover;
    border-radius: 4px;
    display: block;
    border: 1px solid #ddd;
    transition: opacity 0.2s;
}

.thumbnail-img:hover {
    opacity: 0.8;
}

.thumbnail-img:error {
    display: none;
}

.ai-chatbot {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 9999;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

.chatbot-button {
    width: 64px;
    height: 64px;
    background: linear-gradient(145deg, var(--dme-primary) 0%, #5ba839 50%, #4a9132 100%);
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    box-shadow: 
        0 8px 25px rgba(106, 188, 68, 0.4),
        0 4px 12px rgba(0, 0, 0, 0.15),
        inset 0 1px 0 rgba(255, 255, 255, 0.2);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    color: white;
    font-size: 56px;
    position: relative;
    overflow: hidden;
}

.chatbot-button i {
    font-size: 28px;
    z-index: 2;
    position: relative;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}



.chatbot-button::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(45deg, transparent 30%, rgba(255, 255, 255, 0.1) 50%, transparent 70%);
    border-radius: 50%;
    transform: translateX(-100%);
    transition: transform 0.6s ease;
}

.chatbot-button:hover::before {
    transform: translateX(100%);
}

.chatbot-button:hover {
    transform: scale(1.15) rotate(5deg);
    box-shadow: 
        0 12px 40px rgba(106, 188, 68, 0.5),
        0 6px 20px rgba(0, 0, 0, 0.2),
        inset 0 1px 0 rgba(255, 255, 255, 0.3);
    border-color: rgba(255, 255, 255, 0.5);
}

.chatbot-button.active {
    background: linear-gradient(145deg, #dc3545 0%, #c82333 50%, #a91e2f 100%);
    box-shadow: 
        0 8px 25px rgba(220, 53, 69, 0.4),
        0 4px 12px rgba(0, 0, 0, 0.15),
        inset 0 1px 0 rgba(255, 255, 255, 0.2);
    border-color: rgba(255, 255, 255, 0.3);
}

/* Enhanced glowing pulsing animation for the button */
@keyframes pulse {
    0% {
        box-shadow: 
            0 8px 25px rgba(106, 188, 68, 0.4),
            0 4px 12px rgba(0, 0, 0, 0.15),
            inset 0 1px 0 rgba(255, 255, 255, 0.2),
            0 0 0 0 rgba(106, 188, 68, 0.8),
            0 0 20px rgba(106, 188, 68, 0.6);
    }
    50% {
        box-shadow: 
            0 12px 35px rgba(106, 188, 68, 0.6),
            0 6px 18px rgba(0, 0, 0, 0.2),
            inset 0 1px 0 rgba(255, 255, 255, 0.2),
            0 0 0 15px rgba(106, 188, 68, 0.3),
            0 0 40px rgba(106, 188, 68, 0.8);
    }
    100% {
        box-shadow: 
            0 8px 25px rgba(106, 188, 68, 0.4),
            0 4px 12px rgba(0, 0, 0, 0.15),
            inset 0 1px 0 rgba(255, 255, 255, 0.2),
            0 0 0 0 rgba(106, 188, 68, 0),
            0 0 20px rgba(106, 188, 68, 0.6);
    }
}

.chatbot-button:not(.active) {
    animation: pulse 2.5s infinite, float 6s ease-in-out infinite;
}

/* Floating animation */
@keyframes float {
    0%, 100% {
        transform: translateY(0px);
    }
    50% {
        transform: translateY(-3px);
    }
}

.chatbot-window {
    position: absolute;
    bottom: 80px;
    right: 0;
    width: 380px;
    height: 520px;
    background: white;
    border-radius: 20px;
    box-shadow: 
        0 20px 60px rgba(0, 0, 0, 0.15),
        0 5px 20px rgba(106, 188, 68, 0.1);
    border: 1px solid rgba(106, 188, 68, 0.1);
    display: none;
    flex-direction: column;
    overflow: hidden;
    animation: slideUp 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.chatbot-window.active {
    display: flex;
}

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

.chatbot-header {
    background: linear-gradient(135deg, #333333 0%, #000000 100%);
    color: white;
    padding: 15px 20px;
    display: flex;
    align-items: center;
    gap: 12px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
    border-bottom: 2px solid var(--dme-primary);
}

.chatbot-avatar {
    width: 40px;
    height: 40px;
    background: var(--dme-primary);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    color: white;
    border: 2px solid #555;
}

.chatbot-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.chatbot-title {
    font-weight: 700;
    font-size: 18px;
    margin: 0;
    line-height: 1.2;
    letter-spacing: 0.5px;
}

.chatbot-subtitle {
    font-size: 12px;
    opacity: 0.9;
    font-weight: 400;
    line-height: 1;
}

.chatbot-close {
    background: none;
    border: none;
    color: white;
    font-size: 18px;
    cursor: pointer;
    padding: 0;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.chatbot-messages {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    background: linear-gradient(135deg, #ffffff 0%, #f8f9fa 100%);
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.message {
    max-width: 80%;
    padding: 12px 16px;
    border-radius: 18px;
    font-size: 14px;
    line-height: 1.4;
    word-wrap: break-word;
}

.message.user {
    background: linear-gradient(135deg, #333333 0%, #000000 100%);
    color: white;
    align-self: flex-end;
    margin-left: auto;
    border: 3px solid var(--dme-primary);
}

.message.bot {
    background: linear-gradient(135deg, #ffffff 0%, #f8f9fa 100%);
    color: #333;
    align-self: flex-start;
    border: 3px solid var(--dme-primary);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    position: relative;
    margin-top: 10px;
}

.message.bot::before {
    content: 'ARIA';
    position: absolute;
    top: -8px;
    left: 12px;
    background: linear-gradient(135deg, var(--dme-primary) 0%, #5ba839 100%);
    color: white;
    font-size: 10px;
    font-weight: 700;
    padding: 3px 10px;
    border-radius: 12px;
    letter-spacing: 0.5px;
    box-shadow: 0 2px 5px rgba(106, 188, 68, 0.3);
}

.message.follow-up {
    background: linear-gradient(135deg, #f0f9ff 0%, #e0f2fe 100%);
    color: #333;
    align-self: flex-start;
    border: 3px solid var(--dme-primary);
    box-shadow: 0 2px 8px rgba(0, 150, 136, 0.1);
    position: relative;
    margin-top: 5px;
    font-style: italic;
    opacity: 0.95;
}

.message.follow-up::before {
    content: 'ARIA';
    position: absolute;
    top: -8px;
    left: 12px;
    background: linear-gradient(135deg, #00acc1 0%, #0097a7 100%);
    color: white;
    font-size: 10px;
    font-weight: 700;
    padding: 3px 10px;
    border-radius: 12px;
    letter-spacing: 0.5px;
    box-shadow: 0 2px 5px rgba(0, 172, 193, 0.3);
}

.message.error {
    background: #ffebee;
    color: #c62828;
    border: 1px solid #ffcdd2;
}

.message.navigation {
    background: linear-gradient(135deg, #e8f5e8 0%, #f1f8e9 100%);
    color: #2e7d32;
    align-self: flex-start;
    border: 3px solid var(--dme-primary);
    box-shadow: 0 2px 8px rgba(106, 188, 68, 0.2);
    position: relative;
    margin-top: 10px;
    font-style: italic;
    animation: navigationGlow 0.8s ease-out;
}

.message.navigation::before {
    content: '🔗 ARIA';
    position: absolute;
    top: -8px;
    left: 12px;
    background: linear-gradient(135deg, var(--dme-primary) 0%, #4caf50 100%);
    color: white;
    font-size: 10px;
    font-weight: 700;
    padding: 3px 10px;
    border-radius: 12px;
    letter-spacing: 0.5px;
    box-shadow: 0 2px 5px rgba(106, 188, 68, 0.4);
}

@keyframes navigationGlow {
    0% {
        box-shadow: 0 2px 8px rgba(106, 188, 68, 0.2);
    }
    50% {
        box-shadow: 0 4px 20px rgba(106, 188, 68, 0.6);
        transform: scale(1.02);
    }
    100% {
        box-shadow: 0 2px 8px rgba(106, 188, 68, 0.2);
        transform: scale(1);
    }
}

.message.typing {
    background: white;
    border: 1px solid #e0e0e0;
    display: flex;
    align-items: center;
    gap: 5px;
}

.typing-indicator {
    display: flex;
    gap: 3px;
    align-items: center;
}

.typing-indicator.search-mode {
    gap: 6px;
}

.typing-indicator.reasoning-mode {
    gap: 6px;
}

.search-globe {
    font-size: 14px;
    animation: pulse 1.5s infinite;
    margin-right: 4px;
}

.reasoning-brain {
    font-size: 14px;
    animation: pulse 1.5s infinite;
    margin-right: 4px;
}

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

.typing-dot {
    width: 6px;
    height: 6px;
    background: #999;
    border-radius: 50%;
    animation: typing 1.4s infinite ease-in-out;
}

.typing-dot:nth-child(1),
.typing-indicator.search-mode .typing-dot:nth-child(2),
.typing-indicator.reasoning-mode .typing-dot:nth-child(2) { 
    animation-delay: -0.32s; 
}

.typing-dot:nth-child(2),
.typing-indicator.search-mode .typing-dot:nth-child(3),
.typing-indicator.reasoning-mode .typing-dot:nth-child(3) { 
    animation-delay: -0.16s; 
}

.typing-indicator.search-mode .typing-dot:nth-child(4),
.typing-indicator.reasoning-mode .typing-dot:nth-child(4) { 
    animation-delay: 0s; 
}

@keyframes typing {
    0%, 80%, 100% {
        transform: scale(0.8);
        opacity: 0.5;
    }
    40% {
        transform: scale(1);
        opacity: 1;
    }
}

.chatbot-input-area {
    padding: 15px 20px;
    background: white;
    border-top: 2px solid var(--dme-primary);
    display: flex;
    gap: 10px;
}

.chatbot-input {
    flex: 1;
    border: 1px solid #ddd;
    border-radius: 20px;
    padding: 10px 15px;
    font-size: 14px;
    outline: none;
    resize: none;
    max-height: 80px;
    min-height: 40px;
    background-color: white;
    color: black;
}

.chatbot-input:focus {
    border-color: var(--dme-primary);
    box-shadow: 0 0 0 2px rgba(106, 188, 68, 0.1);
}

.chatbot-input::placeholder {
    color: rgba(0, 0, 0, 0.5);
}

.chatbot-send {
    background: var(--dme-primary);
    border: none;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: white;
    font-size: 16px;
    transition: all 0.2s ease;
}

.chatbot-send:hover:not(:disabled) {
    background: #5ba839;
    transform: scale(1.05);
}

.chatbot-send:disabled {
    background: #ccc;
    cursor: not-allowed;
}

.welcome-message {
    background: linear-gradient(135deg, #f8f9fa 0%, #ffffff 100%);
    color: #333;
    padding: 20px;
    border-radius: 15px;
    margin-bottom: 20px;
    font-size: 14px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    display: flex;
    align-items: flex-start;
    gap: 15px;
    border: 2px solid var(--dme-primary);
}

.welcome-avatar {
    width: 45px;
    height: 45px;
    background: var(--dme-primary);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    color: white;
    border: 2px solid #e0e0e0;
    flex-shrink: 0;
}

.welcome-text {
    flex: 1;
    line-height: 1.5;
}

.welcome-text strong {
    font-size: 16px;
    display: block;
    margin-bottom: 5px;
    font-weight: 700;
}

/* Mobile responsiveness */
@media (max-width: 768px) {
    .ai-chatbot {
        bottom: 20px;
        right: 20px;
    }
    
    .chatbot-window {
        width: calc(100vw - 30px);
        height: 70vh;
        max-width: 350px;
        bottom: 90px;
    }
    
    .chatbot-button {
        width: 62px;
        height: 62px;
        font-size: 50px;
        box-shadow: 
            0 6px 20px rgba(106, 188, 68, 0.4),
            0 3px 10px rgba(0, 0, 0, 0.15),
            inset 0 1px 0 rgba(255, 255, 255, 0.2);
    }
    
    .chatbot-button i {
        font-size: 48px;
    }
    
    .chatbot-button:hover {
        transform: scale(1.1) rotate(3deg);
    }
    
    /* Force medium thumbnails on mobile */
    .chatbot-window img[alt="Video thumbnail"] {
        width: 120px !important;
        max-width: 120px !important;
        height: 68px !important;
    }
    
    /* Hide leaked style text completely */
    .message:after {
        content: "";
        display: block;
        clear: both;
    }
}

/* Link styling in chat messages */
.chatbot-link {
    color: #4CAF50;
    text-decoration: underline;
    font-weight: 500;
    transition: color 0.2s ease;
}

.chatbot-link:hover {
    color: #45a049;
    text-decoration: none;
}

.chatbot-link:visited {
    color: #388e3c;
}

/* Ensure links in bot messages are visible */
.message.bot .chatbot-link {
    color: #81C784;
}

.message.bot .chatbot-link:hover {
    color: #66BB6A;
}

/* Help Balloon Styles */
.chatbot-help-balloon {
    position: fixed;
    bottom: 95px;
    right: 20px;
    background: linear-gradient(135deg, #ffffff 0%, #f8f9fa 100%);
    color: #333;
    padding: 12px 16px;
    border-radius: 20px;
    box-shadow: 
        0 8px 25px rgba(0, 0, 0, 0.15),
        0 2px 10px rgba(106, 188, 68, 0.1);
    border: 1px solid rgba(106, 188, 68, 0.2);
    font-size: 14px;
    font-weight: 500;
    white-space: nowrap;
    opacity: 0;
    visibility: hidden;
    transform: translateY(10px) scale(0.8);
    transition: all 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    z-index: 10001;
    pointer-events: none;
}

.chatbot-help-balloon::after {
    content: '';
    position: absolute;
    bottom: -8px;
    right: 30px;
    width: 0;
    height: 0;
    border-left: 8px solid transparent;
    border-right: 8px solid transparent;
    border-top: 8px solid #ffffff;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.1));
}

.chatbot-help-balloon.show {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
    pointer-events: auto;
}

.chatbot-help-balloon.pulse {
    animation: balloonPulse 2s infinite;
}

@keyframes balloonPulse {
    0%, 100% {
        transform: translateY(0) scale(1);
    }
    50% {
        transform: translateY(-2px) scale(1.02);
    }
}

/* Accessibility */
@media (prefers-reduced-motion: reduce) {
    .chatbot-button,
    .chatbot-window,
    .chatbot-send {
        transition: none;
    }
    
    .chatbot-window {
        animation: none;
    }
    
    .typing-dot {
        animation: none;
    }
}

/* Video thumbnail styles */
.video-thumbnail-container {
    margin: 8px 0;
    border-radius: 8px;
    overflow: hidden;
    display: inline-block;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.video-thumbnail-container:hover {
    transform: scale(1.02);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
}

.video-thumbnail {
    width: 280px;
    height: auto;
    max-width: 100%;
    border-radius: 8px;
    cursor: pointer;
    transition: opacity 0.2s ease;
    position: relative;
}

.video-thumbnail::after {
    content: '▶';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(0, 0, 0, 0.7);
    color: white;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.video-thumbnail-container:hover .video-thumbnail::after {
    opacity: 1;
}

.video-thumbnail:hover {
    opacity: 0.9;
}

/* Mobile responsive thumbnails */
@media (max-width: 480px) {
    .video-thumbnail {
        width: 220px;
    }
    
    .video-thumbnail-container {
        margin: 6px 0;
    }
}

/* Online search indicator */
.online-search-indicator {
    background: linear-gradient(135deg, #28a745, #20c997);
    color: white;
    padding: 8px 15px;
    border-radius: 20px;
    margin-bottom: 10px;
    text-align: center;
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    box-shadow: 0 2px 10px rgba(40, 167, 69, 0.3);
}

.pulse {
    animation: pulse-glow 2s infinite;
}

@keyframes pulse-glow {
    0%, 100% {
        text-shadow: 0 0 5px rgba(255, 255, 255, 0.8);
        transform: scale(1);
    }
    50% {
        text-shadow: 0 0 15px rgba(255, 255, 255, 1);
        transform: scale(1.05);
    }
}

/* Online globe indicator in typing dots */
.online-globe {
    font-size: 14px;
    margin-right: 8px;
    animation: pulse-globe 1.5s infinite;
}

@keyframes pulse-globe {
    0%, 100% {
        opacity: 0.7;
        transform: scale(1);
    }
    50% {
        opacity: 1;
        transform: scale(1.1);
    }
}