/* ========================================
   DAYAMA CHAT WIDGET STYLES
   ======================================== */

/* Chat Widget Container & Positioning */
.chat-widget-container {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    z-index: 50;
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 0.75rem;
}

/* Toggle Chat Button */
.chat-toggle-btn {
    background-color: white;
    color: #2f855a;
    padding: 0.75rem;
    border-radius: 50%;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    border: 1px solid #2f855a;
    transition: all 0.3s ease;
    cursor: pointer;
    outline: none;
}

.chat-toggle-btn:hover {
    background-color: #2f855a;
    color: white;
    transform: scale(1.05);
}

.chat-toggle-btn:active {
    transform: scale(0.95);
}

/* Chat button when chat is active - menambahkan efek border tambahan */
.chat-toggle-btn.chat-active {
    border: 1px solid #2f855a;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05), 0 0 0 3px rgba(47, 133, 90, 0.3);
}

.chat-toggle-btn.chat-active:hover {
    background-color: #2f855a;
    color: white;
    transform: scale(1.05);
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05), 0 0 0 3px rgba(47, 133, 90, 0.5);
}

.chat-toggle-btn i {
    font-size: 1.125rem;
    transition: transform 0.2s ease;
}

/* Scroll to Top Button */
.scroll-top-btn {
    background-color: #2f855a;
    color: white;
    padding: 0.75rem;
    border-radius: 50%;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    border: 2px solid transparent;
    transition: all 0.3s ease;
    cursor: pointer;
    outline: none;
}

.scroll-top-btn:hover {
    background-color: #276749;
    transform: scale(1.05);
    border: 2px solid rgba(255, 255, 255, 0.4);
}

.scroll-top-btn:active {
    transform: scale(0.95);
    border: 2px solid rgba(255, 255, 255, 0.6);
}

/* Chat Box Container */
.chat-box {
    position: fixed;
    bottom: 6rem;
    right: 1.5rem;
    width: 20rem;
    max-width: calc(100vw - 3rem);
    background-color: white;
    border: 1px solid #d1d5db;
    border-radius: 0.75rem;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    overflow: hidden;
    z-index: 40;
    display: flex;
    flex-direction: column;
    transform-origin: bottom right;
    transition: all 0.3s ease;
}

.chat-box.hidden {
    opacity: 0;
    transform: scale(0.95) translateY(10px);
    pointer-events: none;
}

.chat-box:not(.hidden) {
    opacity: 1;
    transform: scale(1) translateY(0);
    animation: chatBoxSlideIn 0.3s ease-out;
}

@keyframes chatBoxSlideIn {
    0% {
        opacity: 0;
        transform: scale(0.9) translateY(20px);
    }
    100% {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

/* Chat Header */
.chat-header {
    background-color: #2f855a;
    color: white;
    padding: 0.75rem 1rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.chat-header img {
    width: 2rem;
    height: 2rem;
    border-radius: 50%;
    object-fit: cover;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.chat-header-title {
    font-size: 0.875rem;
    font-weight: 600;
    flex: 1;
}

/* Chat Clear Button */
.chat-clear-btn {
    background: transparent;
    border: none;
    color: white;
    padding: 0.5rem;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transform: scale(0.8);
    pointer-events: none;
}

.chat-clear-btn.visible {
    opacity: 1;
    transform: scale(1);
    pointer-events: auto;
}

.chat-clear-btn:hover {
    background-color: rgba(255, 255, 255, 0.1);
    transform: scale(1.1);
}

.chat-clear-btn:active {
    transform: scale(0.95);
}

.chat-clear-btn i {
    font-size: 0.875rem;
}

@media (min-width: 768px) {
    .chat-header-title {
        font-size: 1rem;
    }
}

/* Chat Messages Area */
.chat-messages {
    flex: 1;
    padding: 0.75rem 1rem;
    gap: 0.75rem;
    overflow-y: auto;
    font-size: 0.875rem;
    background-color: #f9fafb;
    max-height: 20rem;
    display: flex;
    flex-direction: column;
}

.chat-messages::-webkit-scrollbar {
    width: 4px;
}

.chat-messages::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 2px;
}

.chat-messages::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 2px;
}

.chat-messages::-webkit-scrollbar-thumb:hover {
    background: #a1a1a1;
}

/* Chat Message Bubbles */
.chat-message {
    margin-bottom: 0.5rem;
    display: flex;
    word-wrap: break-word;
}

.chat-message.user {
    justify-content: flex-end;
}

.chat-message.bot {
    justify-content: flex-start;
}

.chat-message-content {
    padding: 0.5rem 0.75rem;
    border-radius: 0.5rem;
    display: inline-block;
    max-width: 16rem;
    font-size: 0.875rem;
    line-height: 1.4;
    word-break: break-word;
}

.chat-message.user .chat-message-content {
    background-color: #2f855a;
    color: white;
    border-bottom-right-radius: 0.25rem;
}

.chat-message.bot .chat-message-content {
    background-color: #e5e7eb;
    color: #374151;
    border: 1px solid #d1d5db;
    border-bottom-left-radius: 0.25rem;
}

/* Typing Indicator */
.typing-indicator {
    display: flex;
    justify-content: flex-start;
    margin-bottom: 0.5rem;
    padding-left: 1rem;
}

.typing-indicator .chat-message-content {
    background: transparent;
    border: none;
    padding: 0.75rem 0;
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

/* Animated typing dots */
.typing-dots {
    display: inline-flex;
    gap: 0.15rem;
    align-items: center;
    height: 20px; /* Fixed height to prevent overflow */
}

.typing-dot {
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background-color: #9ca3af;
    animation: typingBounce 1.2s ease-in-out infinite;
    transform-origin: center bottom;
}

.typing-dot:nth-child(1) {
    animation-delay: 0s;
}

.typing-dot:nth-child(2) {
    animation-delay: 0.15s;
}

.typing-dot:nth-child(3) {
    animation-delay: 0.3s;
}

@keyframes typingBounce {
    0%, 80%, 100% {
        transform: translateY(0) scale(1);
        opacity: 0.6;
    }
    40% {
        transform: translateY(-6px) scale(1.1);
        opacity: 1;
    }
}

/* Initial Message */
.chat-initial-message {
    text-align: center;
    color: #9ca3af;
    font-size: 0.875rem;
    padding: 1rem;
}

/* Chat Input Form */
.chat-form {
    display: flex;
    align-items: center;
    border-top: 1px solid #d1d5db;
    background-color: white;
}

.chat-input {
    flex: 1;
    padding: 0.75rem 1rem;
    font-size: 0.875rem;
    border: none;
    outline: none;
    background: transparent;
    color: #374151;
    cursor: text !important;
    caret-color: #333 !important;
}

.chat-input::placeholder {
    color: #9ca3af;
}

.chat-input:focus {
    outline: none;
    box-shadow: none;
}

.chat-submit-btn {
    background-color: #2f855a;
    color: white;
    padding: 0.75rem 1rem;
    border: none;
    cursor: pointer;
    transition: background-color 0.3s ease;
    outline: none;
}

.chat-submit-btn:hover {
    background-color: #276749;
}

.chat-submit-btn:active {
    background-color: #22543d;
}

/* Mobile Responsive */
@media (max-width: 640px) {
    .chat-widget-container {
        bottom: 1rem;
        right: 1rem;
    }
    
    .chat-box {
        bottom: 5rem;
        right: 1rem;
        width: calc(100vw - 2rem);
        max-width: 22rem;
    }
    
    .chat-messages {
        max-height: 16rem;
    }
    
    .chat-message-content {
        max-width: 14rem;
    }
}

/* Animation for message appearance */
.chat-message {
    animation: messageSlideIn 0.3s ease-out;
}

@keyframes messageSlideIn {
    0% {
        opacity: 0;
        transform: translateY(10px);
    }
    100% {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Focus states for accessibility */
.chat-toggle-btn:focus,
.chat-submit-btn:focus {
    box-shadow: 0 0 0 3px rgba(47, 133, 90, 0.3);
}

.chat-input:focus {
    background-color: #f9fafb;
}

/* Prevent text selection on UI elements */
.chat-header,
.chat-toggle-btn,
.chat-submit-btn {
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
}

/* Allow text selection in messages */
.chat-message-content {
    user-select: text;
    -webkit-user-select: text;
    -moz-user-select: text;
    -ms-user-select: text;
}

/* Temporary Messages */
.chat-temp-message {
    padding: 0.75rem;
    border-radius: 0.5rem;
    margin-bottom: 0.5rem;
    font-size: 0.875rem;
    text-align: center;
    animation: tempMessageSlide 0.3s ease-out;
}

.chat-temp-success {
    background-color: #d1fae5;
    color: #065f46;
    border: 1px solid #a7f3d0;
}

.chat-temp-info {
    background-color: #dbeafe;
    color: #1e40af;
    border: 1px solid #93c5fd;
}

.chat-temp-error {
    background-color: #fee2e2;
    color: #991b1b;
    border: 1px solid #fca5a5;
}

@keyframes tempMessageSlide {
    0% {
        opacity: 0;
        transform: translateY(-10px);
    }
    100% {
        opacity: 1;
        transform: translateY(0);
    }
}
