/* ===================================
   RenaAI Asisten TEFA TKJ Styles
   SMK Veteran 1 Sukoharjo
   Version: 2.0
   =================================== */

/* === CONTAINER === */
.chatbot-container {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 10000;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

/* === CHAT BUBBLE === */
.chatbot-bubble {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, #D32F2F, #F44336);
    border: none;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
    box-shadow: 0 4px 20px rgba(211, 47, 47, 0.4);
    transition: all 0.3s ease;
    z-index: 10001;
}

.chatbot-bubble:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 30px rgba(211, 47, 47, 0.6);
}

.chatbot-bubble:active {
    transform: scale(0.95);
}

/* Pulse Animation */
.chatbot-bubble.pulse {
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% {
        box-shadow: 0 0 0 0 rgba(211, 47, 47, 0.7);
    }
    50% {
        box-shadow: 0 0 0 20px rgba(211, 47, 47, 0);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(211, 47, 47, 0);
    }
}

/* Notification Badge */
.chatbot-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    background: #FF5722;
    color: white;
    border-radius: 50%;
    width: 22px;
    height: 22px;
    font-size: 13px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    box-shadow: 0 2px 8px rgba(255, 87, 34, 0.5);
    animation: bounce 0.6s ease infinite alternate;
}

@keyframes bounce {
    from {
        transform: translateY(0);
    }
    to {
        transform: translateY(-3px);
    }
}

/* === CHAT WINDOW === */
.chatbot-window {
    position: absolute;
    bottom: 80px;
    right: 0;
    width: 400px;
    max-width: calc(100vw - 40px);
    height: 600px;
    max-height: calc(100vh - 120px);
    background: white;
    border-radius: 20px;
    box-shadow: 0 10px 50px rgba(0, 0, 0, 0.2);
    display: flex;
    flex-direction: column;
    opacity: 0;
    transform: translateY(20px) scale(0.95);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    pointer-events: none;
    overflow: hidden;
}

.chatbot-open .chatbot-window {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: all;
}

/* === HEADER === */
.chatbot-header {
    background: linear-gradient(135deg, #D32F2F, #F44336);
    color: white;
    padding: 18px 20px;
    border-radius: 20px 20px 0 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.chatbot-header-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.chatbot-avatar {
    width: 42px;
    height: 42px;
    background: rgba(255, 255, 255, 0.25);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.chatbot-title {
    font-weight: 600;
    font-size: 16px;
    line-height: 1.2;
}

.chatbot-subtitle {
    font-size: 12px;
    opacity: 0.95;
    margin-top: 3px;
    font-weight: 400;
}

.chatbot-close {
    background: rgba(255, 255, 255, 0.15);
    border: none;
    color: white;
    cursor: pointer;
    padding: 8px;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    font-weight: bold;
}

.chatbot-close:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: rotate(90deg);
}

/* === MESSAGES AREA === */
.chatbot-messages {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 16px;
    background: #f8f9fa;
    scroll-behavior: smooth;
}

.chatbot-message {
    max-width: 85%;
    padding: 12px 16px;
    border-radius: 18px;
    line-height: 1.5;
    word-wrap: break-word;
    animation: messageSlideIn 0.3s ease;
}

@keyframes messageSlideIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.message-user {
    align-self: flex-end;
    background: linear-gradient(135deg, #D32F2F, #F44336);
    color: white;
    border-bottom-right-radius: 6px;
    box-shadow: 0 2px 8px rgba(211, 47, 47, 0.3);
}

.message-bot {
    align-self: flex-start;
    background: white;
    color: #333;
    border-bottom-left-radius: 6px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    border: 1px solid #e0e0e0;
}

.chatbot-error {
    background: #ffebee !important;
    color: #c62828 !important;
    border: 1px solid #ffcdd2 !important;
}

.message-content {
    font-size: 14px;
}

.message-content strong {
    font-weight: 600;
    color: #D32F2F;
}

.message-bot .message-content strong {
    color: #D32F2F;
}

.message-user .message-content strong {
    color: #FFE082;
}

.message-content em {
    font-style: italic;
}

.message-content code {
    background: rgba(0, 0, 0, 0.1);
    padding: 2px 6px;
    border-radius: 4px;
    font-family: 'Courier New', monospace;
    font-size: 13px;
}

.message-content ul {
    margin: 8px 0;
    padding-left: 20px;
}

.message-content li {
    margin: 6px 0;
    line-height: 1.4;
}

.message-timestamp {
    font-size: 10px;
    opacity: 0.6;
    margin-top: 6px;
    font-weight: 500;
}

/* === TYPING INDICATOR === */
.chatbot-typing {
    display: none;
    align-items: center;
    gap: 8px;
    padding: 12px 20px;
    background: #f8f9fa;
}

.typing-dot {
    width: 8px;
    height: 8px;
    background: #999;
    border-radius: 50%;
    animation: typing-bounce 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 typing-bounce {
    0%, 80%, 100% { 
        transform: scale(0.8);
        opacity: 0.5;
    }
    40% { 
        transform: scale(1.1);
        opacity: 1;
    }
}

.typing-text {
    font-size: 12px;
    color: #666;
    font-style: italic;
}

/* === INPUT AREA === */
.chatbot-input-container {
    border-top: 1px solid #e0e0e0;
    padding: 16px 20px;
    background: white;
    border-radius: 0 0 20px 20px;
}

.chatbot-input-wrapper {
    display: flex;
    align-items: flex-end;
    gap: 10px;
    margin-bottom: 8px;
}

.chatbot-input {
    flex: 1;
    border: 2px solid #e0e0e0;
    border-radius: 24px;
    padding: 12px 16px;
    font-size: 14px;
    resize: none;
    outline: none;
    transition: all 0.2s ease;
    max-height: 120px;
    font-family: inherit;
    line-height: 1.4;
}

.chatbot-input:focus {
    border-color: #D32F2F;
    box-shadow: 0 0 0 3px rgba(211, 47, 47, 0.1);
}

.chatbot-input:disabled {
    background: #f5f5f5;
    color: #999;
    cursor: not-allowed;
    border-color: #ddd;
}

.chatbot-send {
    width: 48px;
    height: 48px;
    background: linear-gradient(135deg, #D32F2F, #F44336);
    border: none;
    border-radius: 50%;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    flex-shrink: 0;
    font-size: 18px;
    box-shadow: 0 2px 8px rgba(211, 47, 47, 0.3);
}

.chatbot-send:hover:not(:disabled) {
    transform: scale(1.08);
    box-shadow: 0 4px 16px rgba(211, 47, 47, 0.4);
}

.chatbot-send:active:not(:disabled) {
    transform: scale(0.95);
}

.chatbot-send:disabled {
    background: #ccc;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
    opacity: 0.6;
}

/* === STATUS BAR === */
.chatbot-status-bar {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 11px;
    padding: 6px 10px;
    border-radius: 12px;
    margin-top: 8px;
}

.chatbot-status-bar.success {
    background: #e8f5e9;
    color: #2e7d32;
}

.chatbot-status-bar.warning {
    background: #fff3e0;
    color: #ef6c00;
}

.chatbot-status-bar.error {
    background: #ffebee;
    color: #c62828;
}

.chatbot-status-bar.info {
    background: #e3f2fd;
    color: #1565c0;
}

/* === SCROLLBAR === */
.chatbot-messages::-webkit-scrollbar {
    width: 6px;
}

.chatbot-messages::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 3px;
}

.chatbot-messages::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 3px;
    transition: background 0.2s ease;
}

.chatbot-messages::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}

/* === QUICK REPLIES === */
.chatbot-quick-replies {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 0 20px 16px;
    background: #f8f9fa;
}

.chatbot-quick-reply {
    background: white;
    border: 1px solid #e0e0e0;
    border-radius: 20px;
    padding: 8px 14px;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
    color: #333;
    font-weight: 500;
}

.chatbot-quick-reply:hover {
    background: #D32F2F;
    border-color: #D32F2F;
    color: white;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(211, 47, 47, 0.2);
}

/* === TOAST NOTIFICATION === */
.chatbot-toast {
    position: fixed;
    bottom: 100px;
    right: 20px;
    padding: 14px 20px;
    border-radius: 12px;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.15);
    z-index: 10002;
    max-width: 320px;
    font-size: 14px;
    font-weight: 500;
    animation: slideInRight 0.3s ease;
}

.chatbot-toast-info {
    background: linear-gradient(135deg, #2196F3, #1976D2);
    color: white;
}

.chatbot-toast-success {
    background: linear-gradient(135deg, #4CAF50, #388E3C);
    color: white;
}

.chatbot-toast-error {
    background: linear-gradient(135deg, #F44336, #D32F2F);
    color: white;
}

.chatbot-toast-warning {
    background: linear-gradient(135deg, #FF9800, #F57C00);
    color: white;
}

.toast-content {
    display: flex;
    align-items: center;
    gap: 10px;
}

/* === RESPONSIVE DESIGN === */
@media (max-width: 768px) {
    .chatbot-container {
        bottom: 15px;
        right: 15px;
    }
    
    .chatbot-window {
        width: calc(100vw - 30px);
        height: calc(100vh - 100px);
        bottom: 75px;
        right: 15px;
        border-radius: 16px;
    }
    
    .chatbot-bubble {
        bottom: 15px;
        right: 15px;
        width: 56px;
        height: 56px;
        font-size: 26px;
    }
    
    .chatbot-header {
        padding: 14px 16px;
        border-radius: 16px 16px 0 0;
    }
    
    .chatbot-avatar {
        width: 38px;
        height: 38px;
        font-size: 18px;
    }
    
    .chatbot-title {
        font-size: 14px;
    }
    
    .chatbot-subtitle {
        font-size: 11px;
    }
    
    .chatbot-messages {
        padding: 16px;
    }
    
    .chatbot-message {
        max-width: 90%;
        padding: 10px 14px;
        font-size: 13px;
    }
    
    .chatbot-input-container {
        padding: 12px 16px;
    }
    
    .chatbot-input {
        font-size: 13px;
        padding: 10px 14px;
    }
    
    .chatbot-send {
        width: 44px;
        height: 44px;
        font-size: 16px;
    }
}

@media (max-width: 480px) {
    .chatbot-window {
        width: calc(100vw - 20px);
        height: calc(100vh - 90px);
        bottom: 70px;
        right: 10px;
    }
    
    .chatbot-bubble {
        width: 52px;
        height: 52px;
        font-size: 24px;
        bottom: 10px;
        right: 10px;
    }
    
    .chatbot-badge {
        width: 20px;
        height: 20px;
        font-size: 11px;
    }
    
    .chatbot-toast {
        bottom: 80px;
        right: 10px;
        max-width: calc(100vw - 80px);
        font-size: 13px;
    }
}

/* === ANIMATIONS === */
@keyframes slideInRight {
    from {
        transform: translateX(400px);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes slideOutRight {
    from {
        transform: translateX(0);
        opacity: 1;
    }
    to {
        transform: translateX(400px);
        opacity: 0;
    }
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

@keyframes fadeOut {
    from {
        opacity: 1;
    }
    to {
        opacity: 0;
    }
}

/* === ACCESSIBILITY === */
.chatbot-bubble:focus,
.chatbot-close:focus,
.chatbot-send:focus,
.chatbot-input:focus {
    outline: 2px solid #D32F2F;
    outline-offset: 2px;
}

/* === PRINT STYLES === */
@media print {
    .chatbot-container {
        display: none !important;
    }
}

/* === HIGH CONTRAST MODE === */
@media (prefers-contrast: high) {
    .chatbot-bubble,
    .chatbot-header,
    .chatbot-send {
        background: #B71C1C;
    }
    
    .message-bot {
        border: 2px solid #333;
    }
    
    .chatbot-input {
        border: 2px solid #333;
    }
}

/* === REDUCED MOTION === */
@media (prefers-reduced-motion: reduce) {
    .chatbot-bubble.pulse,
    .chatbot-badge,
    .typing-dot,
    .chatbot-message {
        animation: none !important;
    }
    
    .chatbot-window {
        transition: opacity 0.1s ease;
    }
    
    * {
        transition-duration: 0.01ms !important;
        animation-duration: 0.01ms !important;
    }
}

/* === LOADING STATE === */
.chatbot-loading {
    pointer-events: none;
    opacity: 0.6;
}

.chatbot-loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 40px;
    height: 40px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #D32F2F;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: translate(-50%, -50%) rotate(0deg); }
    100% { transform: translate(-50%, -50%) rotate(360deg); }
}

/* === CUSTOM UTILITIES === */
.chatbot-hidden {
    display: none !important;
}

.chatbot-visible {
    display: block !important;
}

.chatbot-disabled {
    opacity: 0.5;
    pointer-events: none;
    cursor: not-allowed;
}

/* === BRANDING === */
.chatbot-footer-branding {
    text-align: center;
    font-size: 10px;
    color: #999;
    padding: 8px 0;
    border-top: 1px solid #e0e0e0;
}

.chatbot-footer-branding a {
    color: #D32F2F;
    text-decoration: none;
}

.chatbot-footer-branding a:hover {
    text-decoration: underline;
}