/* ============================================
   CHATBOT ASISTEN SEJARAH BUNGKU - STYLES
   ============================================

   Floating chat widget untuk homepage
   Mobile-first responsive design
   Tema: Hijau Segar (#2ecc71)
   ============================================ */

/* ============================================
   CHAT FLOATING BUTTON
   ============================================ */

.chat-floating-btn {
    position: fixed;
    bottom: 100px; /* Posisi di atas install button (install button ada di bottom: 20px) */
    right: 24px;
    width: 60px;
    height: 60px;
    background: linear-gradient(135deg, #2ecc71 0%, #27ae60 100%);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(46, 204, 113, 0.4);
    z-index: 9998;
    transition: all 0.3s ease;
    border: none;
    outline: none;
}

.chat-floating-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 20px rgba(46, 204, 113, 0.6);
}

.chat-floating-btn:active {
    transform: scale(0.95);
}

.chat-floating-btn i {
    color: #fff;
    font-size: 28px;
    transition: transform 0.3s ease;
}

.chat-floating-btn.active i.fa-comments {
    transform: rotate(360deg);
}

/* Pulse animation untuk menarik perhatian */
@keyframes pulse {
    0% {
        box-shadow: 0 4px 12px rgba(46, 204, 113, 0.4);
    }
    50% {
        box-shadow: 0 4px 20px rgba(46, 204, 113, 0.8);
    }
    100% {
        box-shadow: 0 4px 12px rgba(46, 204, 113, 0.4);
    }
}

.chat-floating-btn.pulse {
    animation: pulse 2s infinite;
}

/* Badge untuk notifikasi (optional) */
.chat-floating-btn .badge {
    position: absolute;
    top: -5px;
    right: -5px;
    background: #e74c3c;
    color: white;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: bold;
    border: 2px solid white;
}

/* ============================================
   CHAT WIDGET CONTAINER
   ============================================ */

.chat-widget {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 380px;
    max-width: calc(100vw - 48px);
    height: 550px;
    max-height: calc(100vh - 100px);
    background: #ffffff;
    border-radius: 16px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
    display: flex;
    flex-direction: column;
    z-index: 9999;
    opacity: 0;
    transform: translateY(20px) scale(0.95);
    pointer-events: none;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    overflow: hidden;
}

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

/* ============================================
   CHAT HEADER
   ============================================ */

.chat-header {
    background: linear-gradient(135deg, #2ecc71 0%, #27ae60 100%);
    color: white;
    padding: 18px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-radius: 16px 16px 0 0;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.chat-header-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

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

.chat-header-text h3 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
    font-family: 'Poppins', sans-serif;
}

.chat-header-text p {
    margin: 2px 0 0 0;
    font-size: 12px;
    opacity: 0.9;
}

.chat-header-close {
    background: transparent;
    border: none;
    color: white;
    font-size: 24px;
    cursor: pointer;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background 0.2s ease;
}

.chat-header-close:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* ============================================
   CHAT MESSAGES AREA
   ============================================ */

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    background: #f8f9fa;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

/* Custom scrollbar */
.chat-messages::-webkit-scrollbar {
    width: 6px;
}

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

.chat-messages::-webkit-scrollbar-thumb {
    background: rgba(46, 204, 113, 0.3);
    border-radius: 3px;
}

.chat-messages::-webkit-scrollbar-thumb:hover {
    background: rgba(46, 204, 113, 0.5);
}

/* ============================================
   CHAT MESSAGE BUBBLES
   ============================================ */

.chat-message {
    display: flex;
    gap: 10px;
    animation: messageSlideIn 0.3s ease;
}

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

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

.chat-message-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    flex-shrink: 0;
}

.chat-message.bot .chat-message-avatar {
    background: linear-gradient(135deg, #2ecc71 0%, #27ae60 100%);
    color: white;
}

.chat-message.user .chat-message-avatar {
    background: linear-gradient(135deg, #4A90E2 0%, #357ABD 100%);
    color: white;
}

.chat-message-content {
    max-width: 75%;
}

.chat-message-bubble {
    padding: 12px 16px;
    border-radius: 16px;
    font-size: 14px;
    line-height: 1.5;
    word-wrap: break-word;
    font-family: 'Poppins', sans-serif;
}

.chat-message.bot .chat-message-bubble {
    background: white;
    color: #333;
    border-bottom-left-radius: 4px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.chat-message.user .chat-message-bubble {
    background: linear-gradient(135deg, #4A90E2 0%, #357ABD 100%);
    color: white;
    border-bottom-right-radius: 4px;
}

.chat-message-time {
    font-size: 11px;
    color: #999;
    margin-top: 4px;
    padding: 0 4px;
}

.chat-message.user .chat-message-time {
    text-align: right;
}

/* ============================================
   WELCOME MESSAGE
   ============================================ */

.chat-welcome {
    text-align: center;
    padding: 20px;
    color: #666;
}

.chat-welcome-icon {
    font-size: 48px;
    color: #2ecc71;
    margin-bottom: 12px;
}

.chat-welcome h4 {
    margin: 0 0 8px 0;
    font-size: 18px;
    color: #333;
    font-family: 'Playfair Display', serif;
}

.chat-welcome p {
    margin: 0 0 16px 0;
    font-size: 14px;
    line-height: 1.6;
}

.chat-welcome-suggestions {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 16px;
}

.chat-suggestion-btn {
    background: white;
    border: 1px solid #e0e0e0;
    padding: 10px 16px;
    border-radius: 20px;
    font-size: 13px;
    color: #666;
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: left;
}

.chat-suggestion-btn:hover {
    background: #f8f9fa;
    border-color: #2ecc71;
    color: #2ecc71;
}

/* ============================================
   TYPING INDICATOR
   ============================================ */

.chat-typing {
    display: flex;
    gap: 10px;
    align-items: flex-end;
}

.chat-typing .chat-message-bubble {
    padding: 16px;
    display: flex;
    gap: 4px;
}

.typing-dot {
    width: 8px;
    height: 8px;
    background: #999;
    border-radius: 50%;
    animation: typingAnimation 1.4s infinite;
}

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

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

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

/* ============================================
   CHAT INPUT AREA
   ============================================ */

.chat-input-container {
    padding: 16px;
    background: white;
    border-top: 1px solid #e0e0e0;
    border-radius: 0 0 16px 16px;
}

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

.chat-input {
    flex: 1;
    border: 1px solid #e0e0e0;
    border-radius: 24px;
    padding: 12px 16px;
    font-size: 14px;
    font-family: 'Poppins', sans-serif;
    resize: none;
    max-height: 100px;
    min-height: 44px;
    outline: none;
    transition: border-color 0.2s ease;
}

.chat-input:focus {
    border-color: #2ecc71;
}

.chat-input::placeholder {
    color: #999;
}

.chat-send-btn {
    background: linear-gradient(135deg, #2ecc71 0%, #27ae60 100%);
    border: none;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.chat-send-btn:hover:not(:disabled) {
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(46, 204, 113, 0.3);
}

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

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

.chat-send-btn i {
    color: white;
    font-size: 18px;
}

/* Character counter */
.chat-char-counter {
    font-size: 11px;
    color: #999;
    text-align: right;
    margin-top: 4px;
}

.chat-char-counter.warning {
    color: #e74c3c;
}

/* ============================================
   ERROR MESSAGE
   ============================================ */

.chat-error {
    background: #fee;
    border: 1px solid #fcc;
    border-radius: 12px;
    padding: 12px 16px;
    margin: 0 20px;
    display: flex;
    align-items: center;
    gap: 10px;
    animation: messageSlideIn 0.3s ease;
}

.chat-error i {
    color: #e74c3c;
    font-size: 18px;
}

.chat-error-text {
    flex: 1;
    font-size: 13px;
    color: #c0392b;
}

/* ============================================
   DAILY LIMIT MESSAGE
   ============================================ */

.chat-daily-limit {
    background: linear-gradient(135deg, #fff5e6 0%, #ffe4cc 100%);
    border: 2px solid #ff9933;
    border-radius: 16px;
    padding: 20px;
    margin: 0 20px 16px 20px;
    display: flex;
    gap: 16px;
    animation: messageSlideIn 0.3s ease;
    box-shadow: 0 4px 12px rgba(255, 153, 51, 0.2);
}

.daily-limit-icon {
    flex-shrink: 0;
    width: 50px;
    height: 50px;
    background: linear-gradient(135deg, #ff9933 0%, #ff6600 100%);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 24px;
    box-shadow: 0 2px 8px rgba(255, 102, 0, 0.3);
}

.daily-limit-content {
    flex: 1;
}

.daily-limit-content h4 {
    margin: 0 0 10px 0;
    font-size: 16px;
    font-weight: 600;
    color: #c66900;
    font-family: 'Poppins', sans-serif;
}

.daily-limit-content p {
    margin: 0 0 8px 0;
    font-size: 14px;
    line-height: 1.6;
    color: #2ecc71;
}

.daily-limit-content p:last-child {
    margin-bottom: 0;
}

.daily-limit-content strong {
    font-weight: 600;
    color: #ff6600;
}

.daily-limit-reset {
    background: rgba(255, 153, 51, 0.15);
    padding: 8px 12px;
    border-radius: 8px;
    margin-top: 8px !important;
    font-size: 13px;
}

.daily-limit-hint {
    font-size: 12px !important;
    color: #999 !important;
    font-style: italic;
    margin-top: 12px !important;
}

/* ============================================
   MOBILE RESPONSIVE
   ============================================ */

@media (max-width: 768px) {
    .chat-widget {
        bottom: 0;
        right: 0;
        left: 0;
        width: 100%;
        max-width: 100%;
        height: 100%;
        max-height: 100%;
        border-radius: 0;
    }

    .chat-header {
        border-radius: 0;
    }

    .chat-floating-btn {
        bottom: 90px; /* Tetap di atas install button pada mobile */
        right: 16px; /* Agak ke kiri untuk mobile */
        width: 56px;
        height: 56px;
    }

    .chat-floating-btn i {
        font-size: 26px;
    }

    .chat-message-content {
        max-width: 80%;
    }

    .chat-daily-limit {
        padding: 16px;
        margin: 0 16px 12px 16px;
    }

    .daily-limit-icon {
        width: 40px;
        height: 40px;
        font-size: 20px;
    }

    .daily-limit-content h4 {
        font-size: 15px;
    }

    .daily-limit-content p {
        font-size: 13px;
    }
}

@media (max-width: 480px) {
    .chat-floating-btn {
        bottom: 80px; /* Sedikit lebih dekat untuk layar kecil */
        right: 12px;
        width: 50px;
        height: 50px;
    }

    .chat-floating-btn i {
        font-size: 22px;
    }

    .chat-header-text h3 {
        font-size: 15px;
    }

    .chat-header-text p {
        font-size: 11px;
    }

    .chat-welcome h4 {
        font-size: 16px;
    }

    .chat-welcome p {
        font-size: 13px;
    }
}

/* ============================================
   ACCESSIBILITY
   ============================================ */

.chat-floating-btn:focus,
.chat-header-close:focus,
.chat-send-btn:focus,
.chat-input:focus {
    outline: 2px solid #2ecc71;
    outline-offset: 2px;
}

/* Screen reader only */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border-width: 0;
}

/* ============================================
   DARK MODE SUPPORT (Optional)
   ============================================ */

@media (prefers-color-scheme: dark) {
    /* Uncomment jika ingin dark mode support
    .chat-widget {
        background: #1e1e1e;
    }

    .chat-messages {
        background: #2a2a2a;
    }

    .chat-message.bot .chat-message-bubble {
        background: #3a3a3a;
        color: #e0e0e0;
    }

    .chat-input-container {
        background: #1e1e1e;
        border-top-color: #444;
    }

    .chat-input {
        background: #2a2a2a;
        border-color: #444;
        color: #e0e0e0;
    }

    .chat-welcome {
        color: #ccc;
    }

    .chat-welcome h4 {
        color: #e0e0e0;
    }
    */
}

/* ============================================
   ANIMATION UTILITIES
   ============================================ */

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

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

.fade-in {
    animation: fadeIn 0.3s ease;
}

.slide-up {
    animation: slideUp 0.3s ease;
}

/* ============================================
   EXTRA SMALL SCREENS (< 360px)
   ============================================ */

@media (max-width: 360px) {
    .chat-floating-btn {
        bottom: 75px;
        right: 10px;
        width: 48px;
        height: 48px;
    }

    .chat-floating-btn i {
        font-size: 20px;
    }

    .chat-widget {
        width: 100%;
        max-width: 100%;
        right: 0;
        left: 0;
    }
}

/* ============================================
   PRINT STYLES
   ============================================ */

@media print {
    .chat-widget,
    .chat-floating-btn {
        display: none !important;
    }
}
