/**
 * AI Chatbot Full Page - Custom Styles
 * SLiMS 9 Bulian - Librain AI
 * Responsive bubble chat design
 */

/* Message Bubbles - SIMPLE */
.message-bubble {
    margin-bottom: 12px;
    animation: fadeIn 0.2s ease-in;
}

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

.message-content {
    display: inline-block;
    max-width: 85%;
    padding: 10px 14px;
    border-radius: 8px;
    line-height: 1.5;
    word-wrap: break-word;
    font-size: 0.95rem;
}

/* User Message (Right) - LIGHT VERSION */
.user-message {
    text-align: right;
}

.user-message .message-content {
    background: #e3f2fd;
    color: #0d47a1;
    border: 1px solid #90caf9;
    border-bottom-right-radius: 2px;
}

.user-message .message-content strong {
    color: #1565c0;
    font-size: 0.85rem;
}

/* Bot Message (Left) - LIGHT VERSION */
.bot-message {
    text-align: left;
}

.bot-message .message-content {
    background: #fafafa;
    color: #424242;
    border: 1px solid #e0e0e0;
    border-bottom-left-radius: 2px;
}

.bot-message .message-content strong {
    color: #1976d2;
    font-size: 0.85rem;
}

/* Links dalam bot message - LIGHT VERSION */
.bot-message .message-content a {
    color: #1976d2;
    text-decoration: underline;
    font-weight: normal;
}

.bot-message .message-content a:hover {
    color: #764ba2;
}

/* Images dalam bot message (cover buku) - SIMPLE */
.bot-message .message-content img {
    max-width: 120px;
    height: auto;
    border-radius: 4px;
    margin: 8px 0;
    display: block;
}

/* Typing Indicator */
.typing-indicator {
    display: inline-block;
    margin-right: 10px;
}

.typing-indicator span {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: #42a5f5;
    margin-right: 4px;
    animation: typing 1.4s infinite;
}

.typing-indicator span:nth-child(2) {
    animation-delay: 0.2s;
}

.typing-indicator span:nth-child(3) {
    animation-delay: 0.4s;
}

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

/* Scrollbar styling */
#messages::-webkit-scrollbar {
    width: 8px;
}

#messages::-webkit-scrollbar-track {
    background: #f1f1f1;
}

#messages::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 4px;
}

#messages::-webkit-scrollbar-thumb:hover {
    background: #555;
}

/* Input Focus - LIGHT VERSION */
#user-input:focus {
    border-color: #64b5f6;
    box-shadow: 0 0 0 0.2rem rgba(100, 181, 246, 0.25);
}

/* Button Styles - LIGHT VERSION */
#send-btn {
    background: #42a5f5;
    border: none;
    transition: background 0.2s ease;
}

#send-btn:hover:not(:disabled) {
    background: #1e88e5;
}

#send-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    background: #b3e5fc;
}

#clear-btn {
    font-size: 0.85rem;
}

#clear-btn:hover {
    color: #495057 !important;
}

/* Remove unnecessary styles */

/* Full Page Layout Overrides */
#ai-chatbot-container .container-fluid {
    max-width: 100%;
    padding-left: 15px;
    padding-right: 15px;
}

/* Smooth scrolling */
#messages {
    scroll-behavior: smooth;
}

/* Better mobile experience */
@media (max-width: 576px) {
    #ai-chatbot-container {
        padding: 0 !important;
        margin: 0 !important;
    }
    
    #ai-chatbot-container .col-12 {
        padding: 5px;
    }
    
    #messages {
        padding: 10px;
    }
    
    .message-content {
        font-size: 0.9rem;
    }
}

/* Responsive Design */
@media (max-width: 768px) {
    #messages {
        height: 70vh !important;
    }

    .message-content {
        max-width: 90%;
        font-size: 0.95rem;
    }

    .card-header h4 {
        font-size: 1.3rem;
    }

    #user-input {
        font-size: 16px; /* Prevent zoom on iOS */
    }
}

@media (max-width: 576px) {
    #messages {
        height: 75vh !important;
    }

    .message-content {
        max-width: 95%;
        padding: 10px 14px;
    }

    .message-bubble .message-content img {
        max-width: 120px;
    }

    #send-btn {
        padding: 0.5rem 1rem;
    }
}

/* Print Styles */
@media print {
    #user-input,
    #send-btn,
    #clear-btn,
    .card-header {
        display: none;
    }

    #messages {
        height: auto !important;
        overflow: visible !important;
    }

    .message-bubble {
        page-break-inside: avoid;
    }
}

/* Dark Mode Support (Optional) */
@media (prefers-color-scheme: dark) {
    #messages {
        background: #2d3748 !important;
    }

    .bot-message .message-content {
        background: #4a5568;
        color: #e2e8f0;
        border-color: #2d3748;
    }

    .card {
        background-color: #1a202c;
        color: #e2e8f0;
    }

    .text-muted {
        color: #a0aec0 !important;
    }
}

/* Accessibility */
.message-content:focus {
    outline: 2px solid #667eea;
    outline-offset: 2px;
}

/* Loading State */
#send-btn.loading::after {
    content: "⏳";
    margin-left: 8px;
}

/* Error Message Styles */
.bot-message .message-content:has(> :first-child:contains("⚠️")) {
    border-color: #dc3545;
    background-color: #fff5f5;
}

/* Success Indicators */
.text-success {
    color: #28a745 !important;
    font-weight: 500;
}

.text-danger {
    color: #dc3545 !important;
    font-weight: 500;
}
