/* ============================================
   DENRAMA AI CHATBOT - FLOATING WIDGET
   Modern & Minimalist Design
   ============================================ */

/* Floating Button */
.chatbot-float-btn {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border: none;
    box-shadow: 0 8px 24px rgba(102, 126, 234, 0.4);
    cursor: pointer;
    z-index: 9999;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
}

/* Position variants */
#denrama-chatbot[data-position="bottom-left"] .chatbot-float-btn {
    right: auto;
    left: 24px;
}

#denrama-chatbot[data-position="bottom-left"] .chatbot-window {
    right: auto;
    left: 24px;
}

.chatbot-float-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 12px 32px rgba(102, 126, 234, 0.5);
}

.chatbot-float-btn:active {
    transform: scale(0.95);
}

.chatbot-icon,
.chatbot-close-icon {
    font-size: 24px;
    transition: all 0.3s ease;
}

.chatbot-icon {
    display: block;
}

.chatbot-close-icon {
    display: none;
}

.chatbot-float-btn.active .chatbot-icon {
    display: none;
}

.chatbot-float-btn.active .chatbot-close-icon {
    display: block;
}

/* Notification Badge */
.chatbot-notification-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    background: #ef4444;
    color: white;
    border-radius: 50%;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 700;
    border: 2px solid var(--dark-bg, #0f172a);
    animation: badge-pulse 2s ease-in-out infinite;
}

body.light-mode .chatbot-notification-badge {
    border-color: var(--light-bg, #f8fafc);
}

.chatbot-notification-badge.hidden {
    display: none;
}

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

/* Chat Window */
.chatbot-window {
    position: fixed;
    bottom: 100px;
    right: 24px;
    width: 400px;
    height: 600px;
    background: var(--dark-surface, #1e293b);
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    z-index: 9998;
    display: flex;
    flex-direction: column;
    opacity: 0;
    transform: translateY(20px) scale(0.95);
    pointer-events: none;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

body.light-mode .chatbot-window {
    background: var(--light-surface, #ffffff);
    border-color: rgba(0, 0, 0, 0.1);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.15);
}

.chatbot-window.active {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: all;
}

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

.chatbot-header-content {
    display: flex;
    align-items: center;
    gap: 12px;
}

.chatbot-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    color: white;
}

.chatbot-header-text {
    color: white;
}

.chatbot-title {
    margin: 0;
    font-size: 16px;
    font-weight: 700;
}

.chatbot-status {
    margin: 0;
    font-size: 12px;
    display: flex;
    align-items: center;
    gap: 6px;
    opacity: 0.9;
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #22c55e;
    animation: status-pulse 2s ease-in-out infinite;
}

@keyframes status-pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.5;
    }
}

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

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

/* Messages Container */
.chatbot-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.chatbot-messages::-webkit-scrollbar {
    width: 6px;
}

.chatbot-messages::-webkit-scrollbar-track {
    background: transparent;
}

.chatbot-messages::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
}

body.light-mode .chatbot-messages::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.1);
}

/* Message */
.chatbot-message {
    display: flex;
    gap: 12px;
    animation: message-slide-in 0.3s ease;
}

@keyframes message-slide-in {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.message-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    color: white;
    flex-shrink: 0;
}

.user-message .message-avatar {
    background: linear-gradient(135deg, #22c55e 0%, #16a34a 100%);
}

.message-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.message-bubble {
    background: rgba(255, 255, 255, 0.05);
    padding: 12px 16px;
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: var(--dark-text, #f1f5f9);
}

body.light-mode .message-bubble {
    background: rgba(0, 0, 0, 0.05);
    border-color: rgba(0, 0, 0, 0.1);
    color: var(--light-text, #1e293b);
}

.user-message .message-bubble {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border: none;
    color: white;
    margin-left: auto;
}

.message-bubble p {
    margin: 0;
    font-size: 14px;
    line-height: 1.5;
}

.message-bubble p + p {
    margin-top: 8px;
}

/* Markdown styling in message bubbles */
.message-bubble strong {
    font-weight: 600;
    color: inherit;
}

.message-bubble em {
    font-style: italic;
}

.message-bubble code {
    background: rgba(0, 0, 0, 0.2);
    padding: 2px 6px;
    border-radius: 4px;
    font-family: 'Courier New', monospace;
    font-size: 13px;
}

body.light-mode .message-bubble code {
    background: rgba(0, 0, 0, 0.08);
}

.message-bubble a {
    color: #60a5fa;
    text-decoration: underline;
}

.message-bubble a:hover {
    color: #93c5fd;
}

body.light-mode .message-bubble a {
    color: #3b82f6;
}

body.light-mode .message-bubble a:hover {
    color: #2563eb;
}

.message-bubble ul {
    margin: 8px 0;
    padding-left: 20px;
    list-style-type: none;
}

.message-bubble li {
    position: relative;
    margin: 4px 0;
    padding-left: 4px;
}

/* Numbered lists */
.message-bubble li[data-num]:before {
    content: attr(data-num) ".";
    position: absolute;
    left: -20px;
    color: inherit;
    font-weight: 600;
}

/* Bullet lists */
.message-bubble li:not([data-num]):before {
    content: "•";
    position: absolute;
    left: -16px;
    color: inherit;
    font-weight: bold;
}

.message-time {
    font-size: 11px;
    color: var(--dark-text-secondary, #94a3b8);
}

body.light-mode .message-time {
    color: var(--light-text-secondary, #64748b);
}

.user-message {
    flex-direction: row-reverse;
}

.user-message .message-content {
    align-items: flex-end;
}

/* Typing Indicator */
.chatbot-typing {
    display: flex;
    gap: 12px;
    padding: 0 20px;
    animation: message-slide-in 0.3s ease;
}

.typing-dots {
    background: rgba(255, 255, 255, 0.05);
    padding: 12px 16px;
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    gap: 6px;
}

body.light-mode .typing-dots {
    background: rgba(0, 0, 0, 0.05);
    border-color: rgba(0, 0, 0, 0.1);
}

.typing-dots span {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--dark-text-secondary, #94a3b8);
    animation: typing-bounce 1.4s ease-in-out infinite;
}

body.light-mode .typing-dots span {
    background: var(--light-text-secondary, #64748b);
}

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

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

@keyframes typing-bounce {
    0%, 60%, 100% {
        transform: translateY(0);
    }
    30% {
        transform: translateY(-8px);
    }
}

/* Input Container */
.chatbot-input-container {
    padding: 16px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    background: var(--dark-surface, #1e293b);
}

body.light-mode .chatbot-input-container {
    background: var(--light-surface, #ffffff);
    border-color: rgba(0, 0, 0, 0.1);
}

.chatbot-form {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.chatbot-input-wrapper {
    display: flex;
    gap: 8px;
    align-items: flex-end;
}

.chatbot-input {
    flex: 1;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    padding: 12px 16px;
    color: var(--dark-text, #f1f5f9);
    font-size: 14px;
    font-family: inherit;
    resize: none;
    max-height: 120px;
    transition: all 0.2s ease;
}

body.light-mode .chatbot-input {
    background: rgba(0, 0, 0, 0.05);
    border-color: rgba(0, 0, 0, 0.1);
    color: var(--light-text, #1e293b);
}

.chatbot-input:focus {
    outline: none;
    border-color: #667eea;
    background: rgba(102, 126, 234, 0.1);
}

.chatbot-input::placeholder {
    color: var(--dark-text-secondary, #94a3b8);
}

body.light-mode .chatbot-input::placeholder {
    color: var(--light-text-secondary, #64748b);
}

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

.chatbot-send-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.chatbot-send-btn:active {
    transform: scale(0.95);
}

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

.chatbot-footer-text {
    text-align: center;
    margin-top: 8px;
}

.chatbot-footer-text small {
    font-size: 11px;
    color: var(--dark-text-secondary, #94a3b8);
}

body.light-mode .chatbot-footer-text small {
    color: var(--light-text-secondary, #64748b);
}

/* Mobile Responsive */
@media (max-width: 480px) {
    .chatbot-window {
        width: calc(100vw - 32px);
        height: calc(100vh - 140px);
        right: 16px;
        bottom: 90px;
    }

    .chatbot-float-btn {
        bottom: 16px;
        right: 16px;
        width: 56px;
        height: 56px;
    }

    .chatbot-icon,
    .chatbot-close-icon {
        font-size: 22px;
    }
}

/* Smooth Scrolling */
.chatbot-messages {
    scroll-behavior: smooth;
}

/* Loading State */
.chatbot-send-btn.loading {
    pointer-events: none;
}

.chatbot-send-btn.loading i {
    animation: spin 1s linear infinite;
}

@keyframes spin {
    from {
        transform: rotate(0deg);
    }
    to {
        transform: rotate(360deg);
    }
}
