@import url("https://cdn.jsdelivr.net/npm/bootstrap-icons@1.11.3/font/bootstrap-icons.min.css");

/* ═══════════════════════════════════════════════════════════════════════════
 *  SUGGESTIONS BOX
 * ═══════════════════════════════════════════════════════════════════════════ */

.suggestions-box {
    position: absolute;
    bottom: 100%;
    left: 0;
    right: 0;
    margin-bottom: 14px;
    background: rgba(255, 255, 255, 0.98);
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
    border-radius: 16px;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.12);
    max-height: 380px;
    overflow-y: auto;
    display: none;
    z-index: 1000;
    border: 1px solid rgba(226, 232, 240, 0.8);
    padding: 0;
    transform-origin: bottom center;
    animation: slideUpFade 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.suggestions-header {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    padding: 6px 12px;
    border-bottom: 1px solid rgba(226, 232, 240, 0.8);
    background: #f8fafc;
    border-radius: 16px 16px 0 0;
}

.close-suggestions {
    cursor: pointer;
    font-size: 14px;
    color: #a0aec0;
    transition: all 0.2s;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
}

.close-suggestions:hover {
    background: rgba(0, 0, 0, 0.05);
    color: #e53e3e;
}

.suggestions-list {
    padding: 8px 0;
}

@keyframes slideUpFade {
    0% { opacity: 0; transform: translateY(10px) scale(0.95); }
    100% { opacity: 1; transform: translateY(0) scale(1); }
}

.suggestion-item {
    padding: 10px 20px;
    cursor: pointer;
    font-size: 14px;
    color: #2d3748;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    align-items: center;
    gap: 12px;
    line-height: 1.4;
    position: relative;
    overflow: hidden;
    font-weight: 500;
}

.suggestion-item::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 3px;
    height: 0;
    background-color: #007bff;
    transition: height 0.2s ease;
    border-radius: 0 4px 4px 0;
}

.suggestion-item:hover::before,
.suggestion-item.selected::before {
    height: 60%;
}

.suggestion-item:not(:last-child) {
    border-bottom: 1px solid rgba(237, 242, 247, 0.8);
}

.suggestion-icon {
    margin-top: 2px;
    flex-shrink: 0;
    color: #a0aec0;
    transition: color 0.2s ease, transform 0.2s ease;
}

.suggestion-item:hover,
.suggestion-item.selected {
    background: linear-gradient(90deg, #f7fafc 0%, #edf2f7 100%);
    color: #007bff;
    padding-left: 24px;
}

.suggestion-item:hover .suggestion-icon,
.suggestion-item.selected .suggestion-icon {
    color: #007bff;
    transform: translateX(4px) scale(1.1);
}

/* ═══════════════════════════════════════════════════════════════════════════
 *  MAIN CONTAINER & BUBBLE
 * ═══════════════════════════════════════════════════════════════════════════ */

#chat-widget-container {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    width: 0;
    z-index: 9999;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

.chat-bubble {
    position: absolute;
    top: 50%;
    right: 0;
    transform: translateY(-50%);
    width: 48px;
    height: auto;
    padding: 20px 0;
    border-radius: 24px 0 0 24px;
    background: linear-gradient(135deg, #005ce6, #007bff);
    color: white;
    font-weight: 600;
    font-size: 15px;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    box-shadow: -4px 4px 15px rgba(0, 92, 230, 0.25);
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275), opacity 0.3s, box-shadow 0.3s;
    pointer-events: all;
    white-space: nowrap;
    transform-origin: right center;
    writing-mode: vertical-rl;
    text-orientation: upright;
}

/* Entrance animation for the bubble */
.chat-bubble.bubble-entrance {
    animation: bubblePopIn 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes bubblePopIn {
    0%   { transform: translateY(-50%) scale(0); opacity: 0; }
    60%  { transform: translateY(-50%) scale(1.05); opacity: 1; }
    100% { transform: translateY(-50%) scale(1); opacity: 1; }
}

.chat-bubble:hover {
    transform: translateY(-50%) scale(1.05);
    box-shadow: -6px 6px 20px rgba(0, 92, 230, 0.35);
}

.chat-bubble.hidden {
    transform: translateY(-50%) scale(0);
    opacity: 0;
    pointer-events: none;
}

/* ═══════════════════════════════════════════════════════════════════════════
 *  CHAT WINDOW
 * ═══════════════════════════════════════════════════════════════════════════ */

.chat-window {
    width: 420px;
    height: 100vh;
    max-height: 100vh;
    background: #ffffff;
    border-radius: 0;
    box-shadow: -12px 0 35px rgba(0, 0, 0, 0.12);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    transform: translateX(100%);
    opacity: 0;
    pointer-events: none;
    transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.4s ease, box-shadow 0.3s ease;
    border: none;
}

.chat-window:hover {
    box-shadow: -20px 0 45px rgba(0, 0, 0, 0.18);
}

.chat-window.active {
    transform: translateX(0);
    opacity: 1;
    pointer-events: all;
}

.chat-header {
    background: white;
    /* background: linear-gradient(135deg, #005ce6, #007bff); */
    color: black;
    padding: 16px 20px;
    font-size: 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
    z-index: 2;
}

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

.close-chat {
    color: black;
    cursor: pointer;
    opacity: 0.8;
    transition: opacity 0.2s, transform 0.2s;
    display: flex;
}

.close-chat:hover {
    opacity: 1;
    transform: rotate(90deg);
}

/* Options button and menu */
.chat-options-container {
    position: relative;
    display: flex;
}

.chat-options-btn {
    cursor: pointer;
    opacity: 0.8;
    transition: all 0.2s;
    display: flex;
    padding: 6px;
    border-radius: 6px;
    background-color: transparent;
    color: black;
}

.chat-options-btn:hover, .chat-options-btn.active {
    opacity: 1;
    background-color: rgba(0, 0, 0, 0.05);
}

.chat-options-menu {
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 8px;
    background: #ffffff;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.15);
    min-width: 180px;
    opacity: 0;
    transform: translateY(-10px);
    pointer-events: none;
    transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
    z-index: 100;
}

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

.chat-option-item {
    padding: 12px 16px;
    font-size: 14px;
    color: #1a1a1a;
    cursor: pointer;
    transition: background 0.2s;
    font-weight: 500;
}

.chat-option-item:hover {
    background: #f5f7f9;
}

/* ═══════════════════════════════════════════════════════════════════════════
 *  MESSAGES AREA
 * ═══════════════════════════════════════════════════════════════════════════ */

.chat-messages {
    flex: 1;
    min-height: 0; /* Critical: allows flex child to shrink and enable scrolling */
    padding: 4px 16px;
    overflow-y: auto;
    background-color: #f7f9fc;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.chat-messages::-webkit-scrollbar { width: 6px; }
.chat-messages::-webkit-scrollbar-track { background: transparent; }
.chat-messages::-webkit-scrollbar-thumb { background: #cdd2d6; border-radius: 3px; }

.chat-message { display: flex; flex-direction: column; }
.chat-message.bot { align-items: flex-start; }
.chat-message.user { align-items: flex-end; }

.msg-bubble {
    padding: 8px 12px;
    border-radius: 12px;
    font-size: 14.5px;
    max-width: 85%;
    line-height: 1.3;
    word-wrap: break-word;
    font-weight: 400 !important;
}

.chat-message.bot .msg-bubble {
    background-color: #ffffff;
    color: #333333;
    border-bottom-left-radius: 4px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

/* Formatted HTML content inside bot bubbles */
.chat-message.bot .msg-bubble p {
    margin: 4px 0;
}
.chat-message.bot .msg-bubble p:first-child {
    margin-top: 0;
}
.chat-message.bot .msg-bubble p:last-child {
    margin-bottom: 0;
}
.chat-message.bot .msg-bubble ul,
.chat-message.bot .msg-bubble ol {
    margin: 6px 0;
    padding-left: 20px;
}
.chat-message.bot .msg-bubble li {
    margin: 3px 0;
}
.chat-message.bot .msg-bubble a {
    color: #007bff;
    text-decoration: underline;
    word-break: normal;
    overflow-wrap: break-word;
    word-wrap: break-word;
}
.chat-message.bot .msg-bubble a:hover {
    color: #0056b3;
}
.chat-message.bot .msg-bubble strong {
    font-weight: 600;
    color: #1a1a1a;
}
.chat-message.bot .msg-bubble .highlight {
    font-weight: 600;
    color: #005ce6;
}
.chat-message.bot .msg-bubble .contact-info {
    font-weight: 600;
    color: #005ce6;
}

.chat-message.bot .msg-bubble.typing { padding: 14px 18px; }

.chat-message.user .msg-bubble {
    background-color: #007bff;
    color: #ffffff;
    border-bottom-right-radius: 4px;
    box-shadow: 0 2px 4px rgba(0, 123, 255, 0.2);
}

/* ═══════════════════════════════════════════════════════════════════════════
 *  TOPIC CHIPS — Icons, Colors, Grid
 * ═══════════════════════════════════════════════════════════════════════════ */

.topic-chips-container {
    padding: 0;
    margin-top: -4px;
}

.topic-chips-grid {
    display: flex;
    flex-direction: column;
    gap: 6px;
    width: 100%;
}

.topic-chip {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 10px;
    border: 1.5px solid #dce1e8;
    border-radius: 12px;
    padding: 5px 12px;
    font-size: 13px;
    color: #333;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: inherit;
    line-height: 1.3;
    outline: none;
    white-space: nowrap;
    width: 100%;
    box-sizing: border-box;
    letter-spacing: 1px;
}

.topic-chip-icon {
    font-size: 14px;
    line-height: 1;
    flex-shrink: 0;
}

.topic-chip-label {
    font-size: 12.5px;
}

.topic-chip:hover {
    transform: translateY(-2px);
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.12);
    filter: brightness(0.97);
}

.topic-chip.active {
    background: #007bff !important;
    color: #fff !important;
    border-color: #007bff !important;
    box-shadow: 0 2px 8px rgba(0, 123, 255, 0.3);
}

.topic-chip.active .topic-chip-label {
    color: #fff;
}

/* ═══════════════════════════════════════════════════════════════════════════
 *  INPUT AREA + CATEGORY BADGE
 * ═══════════════════════════════════════════════════════════════════════════ */

.chat-input-container {
    display: flex;
    flex-direction: column;
    padding: 12px 15px;
    background: #ffffff;
    border-top: 1px solid #e9eef5;
    box-shadow: 0 -10px 22px rgba(15, 23, 42, 0.08);
    align-items: stretch;
    gap: 0;
    z-index: 2;
    position: relative;
}

.chat-compose {
    position: relative;
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding-top: 2px;
}

.selected-category-badge {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: #edf2ff;
    border: 1px solid #c6d4f0;
    border-radius: 8px;
    padding: 6px 12px;
    font-size: 12.5px;
    color: #3b5998;
    font-weight: 500;
}

.change-category-x {
    cursor: pointer;
    font-size: 14px;
    color: #8899aa;
    transition: color 0.2s;
    line-height: 1;
    padding: 0 2px;
    user-select: none;
}

.change-category-x:hover { color: #d9534f; }

.chat-input-row {
    display: flex;
    align-items: center;
    gap: 10px;
}

.chat-input-row input {
    flex: 1;
    padding: 12px 18px;
    border: 1px solid #e0e0e0;
    border-radius: 24px;
    outline: none;
    font-size: 14.5px;
    transition: border-color 0.3s;
    background-color: #f8f9fa;
}

.chat-input-row input:disabled { opacity: 0.65; cursor: not-allowed; }
.chat-input-row input:focus:not(:disabled) { border-color: #007bff; background-color: #ffffff; }

.chat-input-row button {
    background-color: #007bff;
    color: white;
    border: none;
    width: 42px;
    height: 42px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: background-color 0.3s, transform 0.2s;
    flex-shrink: 0;
}

.chat-input-row button:hover:not(:disabled) { background-color: #005ce6; transform: scale(1.05); }
.chat-input-row button:active:not(:disabled) { transform: scale(0.95); }
.chat-input-row button:disabled { background-color: #9ec5fe; cursor: not-allowed; transform: none; }

/* ═══════════════════════════════════════════════════════════════════════════
 *  TYPING INDICATOR
 * ═══════════════════════════════════════════════════════════════════════════ */

.msg-bubble.typing {
    display: flex;
    gap: 5px;
    align-items: center;
    font-weight: 400 !important;
}

.dot {
    width: 7px;
    height: 7px;
    background-color: #888;
    border-radius: 50%;
    animation: typing 1.4s infinite ease-in-out both;
}

.dot:nth-child(1) { animation-delay: -0.32s; }
.dot:nth-child(2) { animation-delay: -0.16s; }

@keyframes typing {
    0%, 80%, 100% { transform: translateY(0); }
    40% { transform: translateY(-5px); }
}

/* ═══════════════════════════════════════════════════════════════════════════
 *  RESPONSIVE
 * ═══════════════════════════════════════════════════════════════════════════ */

@media (max-width: 480px) {
    .chat-window {
        width: 92vw;
        max-width: 420px;
        height: 80vh;
    }
}
