/* Chat Widget Styles */
:root {
    --chat-primary: #007bff;
    --chat-primary-dark: #0056b3;
    --chat-surface: #ffffff;
    --chat-bg: #f4f6f9;
    --chat-border: #e6e9ee;
    --chat-radius: 18px;
    --chat-shadow: 0 20px 45px rgba(15, 45, 90, 0.22), 0 4px 12px rgba(15, 45, 90, 0.12);
}

#chat-widget-container {
    cursor: pointer;
    position: fixed;
    bottom: 154px;
    right: 10px;
    z-index: 9999;
}

#chat-widget-btn {
    width: 60px;
    height: 60px;
    background-color: transparent;
    background-image: url('../../../assets/images/lela.gif');
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    filter: drop-shadow(0 8px 16px rgba(15, 45, 90, 0.35));
    transition: transform 0.25s ease;
}

#chat-widget-btn i {
    display: none;
}

#chat-widget-btn:hover {
    transform: scale(1.08) translateY(-2px);
}

#chat-widget-btn:focus-visible {
    outline: 3px solid var(--chat-primary);
    outline-offset: 4px;
    border-radius: 50%;
}

#chat-widget-box {
    display: none;
    width: 360px;
    height: 480px;
    background-color: var(--chat-surface);
    border-radius: var(--chat-radius);
    box-shadow: var(--chat-shadow);
    flex-direction: column;
    overflow: hidden;
    position: absolute;
    bottom: 0px;
    right: 0;
    animation: chat-box-in 0.28s cubic-bezier(0.16, 1, 0.3, 1);
    transform-origin: bottom right;
}

@keyframes chat-box-in {
    from {
        opacity: 0;
        transform: translateY(16px) scale(0.96);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

@media (prefers-reduced-motion: reduce) {
    #chat-widget-box {
        animation: none;
    }
}

.chat-header {
    background: linear-gradient(135deg, var(--chat-primary), var(--chat-primary-dark));
    color: white;
    padding: 14px 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-weight: 600;
    letter-spacing: 0.01em;
    flex-shrink: 0;
}

.chat-header-title {
    display: flex;
    align-items: center;
    gap: 8px;
}

.chat-status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: #3ddc84;
    box-shadow: 0 0 0 3px rgba(61, 220, 132, 0.28);
    flex-shrink: 0;
}

.chat-header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.chat-end-btn.btn.btn-danger {
    font-size: 12px;
    line-height: 1;
    padding: 6px 10px;
    border-radius: 999px;
    border: none;
    background-color: rgba(255, 255, 255, 0.16);
    color: white;
    transition: background-color 0.2s ease;
}

.chat-end-btn.btn.btn-danger:hover {
    background-color: #dc3545;
}

.chat-close-btn {
    width: 28px;
    height: 28px;
    min-width: 44px;
    min-height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    background: transparent;
    color: white;
    font-size: 20px;
    line-height: 1;
    border-radius: 50%;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.chat-close-btn:hover,
.chat-close-btn:focus-visible {
    background-color: rgba(255, 255, 255, 0.2);
    outline: none;
}

.chat-body {
    flex: 1;
    padding: 16px;
    overflow-y: auto;
    background-color: var(--chat-bg);
    display: flex;
    flex-direction: column;
    gap: 4px;
    scrollbar-width: thin;
    scrollbar-color: #c7cedb transparent;
}

.chat-body::-webkit-scrollbar {
    width: 6px;
}

.chat-body::-webkit-scrollbar-thumb {
    background-color: #c7cedb;
    border-radius: 999px;
}

.chat-widget-input-container {
    padding: 10px 12px;
    border-top: 1px solid var(--chat-border);
    display: flex;
    background-color: var(--chat-surface);
    align-items: flex-end;
    gap: 4px;
    flex-shrink: 0;
}

#chat-widget-input {
    flex: 1;
    border: 1px solid var(--chat-border);
    background-color: var(--chat-bg);
    color: #333; /* ponytail: page has a dark-mode "color: inherit" cascade that turns this white-on-white without an explicit color */
    border-radius: 20px;
    padding: 9px 15px;
    outline: none;
    resize: none;
    max-height: 100px;
    font-family: inherit;
    font-size: 14px;
    margin: 0 4px;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

#chat-widget-input:focus {
    border-color: var(--chat-primary);
    box-shadow: 0 0 0 3px rgba(0, 123, 255, 0.15);
    background-color: var(--chat-surface);
}

.chat-widget-input-container button {
    background: none;
    border: none;
    color: #8a94a6;
    cursor: pointer;
    font-size: 16px;
    width: 36px;
    height: 36px;
    min-width: 44px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.2s ease, color 0.2s ease;
}

.chat-widget-input-container button:hover {
    color: var(--chat-primary);
    background-color: rgba(0, 123, 255, 0.08);
}

.chat-widget-input-container button.text-success {
    color: #28a745 !important;
}

#chat-widget-send {
    background-color: var(--chat-primary) !important;
    color: white !important;
}

#chat-widget-send:hover {
    background-color: var(--chat-primary-dark) !important;
}

.chat-msg {
    margin-bottom: 4px;
    max-width: 80%;
    padding: 9px 13px;
    border-radius: 16px;
    font-size: 14px;
    line-height: 1.45;
    word-wrap: break-word;
    overflow-wrap: break-word;
    word-break: break-word;
    box-shadow: 0 1px 2px rgba(15, 45, 90, 0.06);
}

.chat-msg.user {
    background-color: var(--chat-primary);
    color: white;
    align-self: flex-end;
    border-bottom-right-radius: 4px;
}

.chat-msg.admin {
    background-color: #ffffff;
    color: #333;
    align-self: flex-start;
    border-bottom-left-radius: 4px;
    border: 1px solid var(--chat-border);
}

/* Mobile Responsiveness */
@media (max-width: 480px) {
    #chat-widget-box {
        width: 90vw; /* Use viewport width */
        height: 70vh; /* Use viewport height */
        right: 0;
        bottom: 80px; /* Keep above the button */
    }

    #chat-widget-container {
        right: 15px;
        bottom: 20px; /* Adjust button position if needed */
    }

    #chat-widget-btn {
        width: 50px;
        height: 50px;
    }
}

/* Tablet/iPad Responsiveness */
@media (max-width: 1024px) {
    #chat-widget-box {
        max-height: 80vh; /* Prevent overflowing top on smaller vertical screens */
        height: auto;     /* Allow it to shrink */
        min-height: 300px; /* Ensure it's not too small */
    }
}
