/* ========================================
   CHATBOT WIDGET POPUP - Laravel Integration
   ======================================== */

/* Toggle Button - Floating di kanan bawah */
#chatbot-toggle {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 9998;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border: none;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    color: white;
    font-size: 24px;
}

#chatbot-toggle:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.25);
}

#chatbot-toggle:active {
    transform: scale(0.95);
}

/* Popup Container */
#chatbot-popup {
    position: fixed;
    bottom: 90px;
    right: 20px;
    width: 380px;
    max-width: calc(100vw - 40px);
    height: 550px;
    max-height: calc(100vh - 120px);
    background: white;
    border-radius: 16px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
    z-index: 9999;
    display: none;
    flex-direction: column;
    overflow: hidden;
    animation: slideUp 0.3s ease;
}

#chatbot-popup.active {
    display: flex;
}

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

/* Header Chatbot */
.chatbot-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 16px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-top-left-radius: 16px;
    border-top-right-radius: 16px;
}

.chatbot-header h3 {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
}

.chatbot-header-actions {
    display: flex;
    gap: 10px;
}

.chatbot-header button {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
    font-size: 16px;
}

.chatbot-header button:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* Chat Area */
.chatbot-body {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    background: #f8f9fa;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* Messages */
.chatbot-message {
    display: flex;
    margin-bottom: 8px;
    animation: fadeIn 0.3s ease;
}

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

.chatbot-message.user {
    justify-content: flex-end;
}

.chatbot-message.bot {
    justify-content: flex-start;
}

.chatbot-message-content {
    max-width: 75%;
    padding: 10px 14px;
    border-radius: 16px;
    word-wrap: break-word;
    white-space: pre-wrap;
    font-size: 14px;
    line-height: 1.5;
}

.chatbot-message.user .chatbot-message-content {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-bottom-right-radius: 4px;
}

.chatbot-message.bot .chatbot-message-content {
    background: white;
    color: #333;
    border: 1px solid #e0e0e0;
    border-bottom-left-radius: 4px;
}

.chatbot-message.bot .chatbot-message-content.thinking {
    font-style: italic;
    color: #666;
}

/* Enhanced formatting for bot messages */
.chatbot-message-content pre {
    font-family: inherit;
    margin: 0;
    white-space: pre-wrap;
    word-wrap: break-word;
}

/* Style untuk emoji dan icons */
.chatbot-message-content strong {
    font-weight: 600;
    color: #667eea;
}

/* Style untuk lists */
.chatbot-message-content ul,
.chatbot-message-content ol {
    margin: 8px 0;
    padding-left: 20px;
}

.chatbot-message-content li {
    margin: 4px 0;
}

/* Style untuk line breaks */
.chatbot-message-content br {
    display: block;
    content: "";
    margin: 8px 0;
}

/* Chat Footer - Input Area */
.chatbot-footer {
    padding: 16px;
    background: white;
    border-top: 1px solid #e0e0e0;
    border-bottom-left-radius: 16px;
    border-bottom-right-radius: 16px;
}

/* Voice Status Indicator */
.voice-status {
    padding: 10px 16px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 12px;
    margin-bottom: 12px;
    animation: pulseGlow 1.5s ease-in-out infinite;
}

@keyframes pulseGlow {
    0%, 100% {
        box-shadow: 0 0 10px rgba(102, 126, 234, 0.5);
    }
    50% {
        box-shadow: 0 0 20px rgba(102, 126, 234, 0.8);
    }
}

.voice-indicator {
    display: flex;
    align-items: center;
    justify-content: space-between;
    color: white;
}

.voice-text {
    font-size: 14px;
    font-weight: 500;
}

/* Audio Wave Animation */
.audio-wave {
    display: flex;
    align-items: center;
    gap: 3px;
    height: 20px;
}

.wave-bar {
    width: 3px;
    height: 100%;
    background: white;
    border-radius: 3px;
    animation: waveAnimation 1.2s ease-in-out infinite;
}

.wave-bar:nth-child(1) { animation-delay: 0s; }
.wave-bar:nth-child(2) { animation-delay: 0.1s; }
.wave-bar:nth-child(3) { animation-delay: 0.2s; }
.wave-bar:nth-child(4) { animation-delay: 0.3s; }
.wave-bar:nth-child(5) { animation-delay: 0.4s; }

@keyframes waveAnimation {
    0%, 100% {
        height: 30%;
    }
    50% {
        height: 100%;
    }
}

/* Voice Transcription Display */
.voice-transcription {
    padding: 10px 14px;
    background: #f0f0f0;
    border-radius: 12px;
    margin-bottom: 12px;
    font-size: 14px;
    color: #333;
    font-style: italic;
    border-left: 3px solid #667eea;
}

.chatbot-input-wrapper {
    display: flex;
    gap: 10px;
    align-items: center;
}

/* Voice Button Styles */
.voice-btn {
    width: 40px;
    height: 40px;
    min-width: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, #28a745 0%, #20c997 100%);
    border: none;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    font-size: 18px;
    position: relative;
}

.voice-btn:hover:not(:disabled) {
    transform: scale(1.1);
    box-shadow: 0 4px 12px rgba(40, 167, 69, 0.4);
}

.voice-btn:active:not(:disabled) {
    transform: scale(0.95);
}

.voice-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Voice Button - Listening State */
.voice-btn.listening {
    background: linear-gradient(135deg, #dc3545 0%, #c82333 100%);
    animation: voicePulse 1.5s ease-in-out infinite;
}

@keyframes voicePulse {
    0%, 100% {
        box-shadow: 0 0 0 0 rgba(220, 53, 69, 0.7);
    }
    50% {
        box-shadow: 0 0 0 10px rgba(220, 53, 69, 0);
    }
}

/* Voice Button - Not Supported State */
.voice-btn.not-supported {
    background: #6c757d;
    cursor: not-allowed;
}

/* Stop Voice Button Styles */
.stop-voice-btn {
    width: 40px;
    height: 40px;
    min-width: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, #dc3545 0%, #c82333 100%);
    border: none;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    font-size: 20px;
    position: relative;
    animation: stopPulse 1.5s ease-in-out infinite;
}

@keyframes stopPulse {
    0%, 100% {
        box-shadow: 0 0 0 0 rgba(220, 53, 69, 0.7);
    }
    50% {
        box-shadow: 0 0 0 10px rgba(220, 53, 69, 0);
    }
}

.stop-voice-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 4px 12px rgba(220, 53, 69, 0.5);
}

.stop-voice-btn:active {
    transform: scale(0.95);
}

.chatbot-input-wrapper input {
    flex: 1;
    padding: 10px 14px;
    border: 1px solid #ddd;
    border-radius: 24px;
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s;
}

.chatbot-input-wrapper input:focus {
    border-color: #667eea;
}

.chatbot-input-wrapper button {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border: none;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    font-size: 18px;
}

.chatbot-input-wrapper button:hover:not(:disabled) {
    transform: scale(1.1);
}

.chatbot-input-wrapper button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Scrollbar styling */
.chatbot-body::-webkit-scrollbar {
    width: 6px;
}

.chatbot-body::-webkit-scrollbar-track {
    background: #f1f1f1;
}

.chatbot-body::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 3px;
}

.chatbot-body::-webkit-scrollbar-thumb:hover {
    background: #555;
}

/* Desktop Responsive - Ukuran lebih besar untuk layar desktop */
@media (min-width: 1024px) {
    #chatbot-popup {
        width: 480px;
        height: 650px;
        max-height: calc(100vh - 120px);
    }
    
    .chatbot-header h3 {
        font-size: 20px;
    }
    
    .chatbot-message-content {
        font-size: 15px;
        padding: 12px 16px;
    }
}

/* Tablet Responsive */
@media (min-width: 768px) and (max-width: 1023px) {
    #chatbot-popup {
        width: 420px;
        height: 600px;
    }
}

/* Mobile Responsive */
@media (max-width: 480px) {
    #chatbot-popup {
        bottom: 80px;
        right: 10px;
        left: 10px;
        width: auto;
        max-width: none;
        height: 500px;
    }
    
    #chatbot-toggle {
        bottom: 15px;
        right: 15px;
        width: 56px;
        height: 56px;
    }
    
    .chatbot-message-content {
        max-width: 85%;
    }
}

/* Notification Badge */
#chatbot-toggle .badge {
    position: absolute;
    top: -5px;
    right: -5px;
    background: #ff4444;
    color: white;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: bold;
}
