/* Chatbot Floating Widget Styles */

:root {
    --chat-navbar-offset-mobile: 74px;
    --chat-navbar-offset-desktop: 86px;
}

/* Floating Chat Button */
.chat-widget-button {
    position: fixed;
    bottom: 30px;
    right: 30px;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, #27ae60 0%, #229954 100%);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    transition: all 0.3s ease;
    z-index: 12000;
}

.chat-widget-button:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 20px rgba(39, 174, 96, 0.4);
}

.chat-widget-button svg {
    width: 32px;
    height: 32px;
    fill: white;
}

.chat-widget-button.active svg {
    display: none;
}

.chat-widget-button.active::before {
    content: '✕';
    color: white;
    font-size: 24px;
    font-weight: bold;
}

/* Chat Container */
.chat-widget-container {
    position: fixed;
    top: var(--chat-navbar-offset-desktop);
    bottom: 24px;
    right: 30px;
    width: min(420px, calc(100vw - 36px));
    height: auto;
    max-height: calc(100vh - var(--chat-navbar-offset-desktop) - 24px);
    background: #ffffff;
    border: 1px solid #d5e6dc;
    border-radius: 18px;
    box-shadow: 0 18px 44px rgba(0, 0, 0, 0.2);
    display: none;
    flex-direction: column;
    z-index: 11999;
    overflow: hidden;
}

.chat-widget-container.active {
    display: flex;
}

/* Chat Header */
.chat-header {
    background: radial-gradient(circle at top right, #2dae65 0%, #1d8f53 35%, #167a45 100%);
    color: white;
    padding: 20px 22px;
    border-radius: 18px 18px 0 0;
    position: sticky;
    top: 0;
    z-index: 2;
}

.chat-header h3 {
    margin: 0;
    font-size: 24px;
    font-weight: 700;
    line-height: 1.15;
}

.chat-header p {
    margin: 6px 0 0 0;
    font-size: 14px;
    opacity: 0.95;
}

/* Chat Messages Area */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    background: #edf2ef;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

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

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

.chat-messages::-webkit-scrollbar-thumb {
    background: #ddd;
    border-radius: 3px;
}

.chat-messages::-webkit-scrollbar-thumb:hover {
    background: #ccc;
}

/* Chat Message Styles */
.message {
    display: flex;
    gap: 10px;
    animation: slideIn 0.3s ease;
}

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

.message.user {
    justify-content: flex-end;
}

.message.bot {
    justify-content: flex-start;
}

.message-bubble {
    max-width: 80%;
    padding: 13px 16px;
    border-radius: 16px;
    word-wrap: break-word;
    font-size: 16px;
    line-height: 1.5;
}

.message.user .message-bubble {
    background: #1a8f50;
    color: white;
    border-bottom-right-radius: 6px;
}

.message.bot .message-bubble {
    background: #ffffff;
    color: #1c2b22;
    border: 1px solid #d4e4db;
    border-bottom-left-radius: 6px;
    box-shadow: 0 6px 16px rgba(25, 60, 42, 0.07);
}

.message.error .message-bubble {
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

/* Loading Indicator */
.typing-indicator {
    display: flex;
    gap: 4px;
    align-items: center;
}

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

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

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

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

/* Chat Input Area */
.chat-input-area {
    padding: 15px;
    background: white;
    border-top: 1px solid #e0e0e0;
    display: flex;
    flex-direction: column;
    gap: 10px;
    position: relative;
    z-index: 2;
    border-radius: 0 0 18px 18px;
    overflow: visible;
}

.chat-attachment-preview {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.chat-attachment-chip {
    border: 1px solid #cfe0d6;
    background: #f1f8f4;
    color: #185d38;
    border-radius: 999px;
    font-size: 12px;
    padding: 5px 10px;
    cursor: pointer;
}

.chat-input-field {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #ddd;
    border-radius: 10px;
    font-size: 14px;
    font-family: inherit;
    resize: none;
    max-height: 80px;
    transition: border-color 0.3s;
}

.chat-input-field:focus {
    outline: none;
    border-color: #27ae60;
    box-shadow: 0 0 0 3px rgba(39, 174, 96, 0.1);
}

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

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

.chat-tool-btn {
    border: none;
    background: transparent;
    color: #557165;
    font-size: 20px;
    line-height: 1;
    cursor: pointer;
    padding: 2px 4px;
}

.chat-tool-btn:hover {
    color: #1a8f50;
}

.chat-gif-btn {
    border: 1px solid #c8dad0;
    border-radius: 6px;
    font-size: 11px;
    font-weight: 700;
    padding: 3px 6px;
}

.chat-tool-btn.recording {
    color: #d33b3b;
    background: #ffeaea;
    border-radius: 8px;
}

.chat-send-btn {
    margin-left: auto;
    width: auto;
    height: 42px;
    min-width: 74px;
    flex-shrink: 0;
    background: #27ae60;
    color: white;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 700;
    padding: 0 14px;
    transition: background 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
    visibility: visible;
    opacity: 1;
}

.chat-popover {
    display: none;
    position: absolute;
    left: 12px;
    right: 12px;
    bottom: 58px;
    margin-bottom: 0;
    background: #ffffff;
    border: 1px solid #d8e6df;
    border-radius: 12px;
    box-shadow: 0 14px 32px rgba(0, 0, 0, 0.16);
    z-index: 13000;
    max-height: min(320px, 48vh);
    overflow: hidden;
}

.chat-popover.active {
    display: block;
}

.chat-emoji-popover {
    padding: 0;
    overflow: hidden;
    height: min(320px, 48vh);
}

.chat-emoji-grid {
    display: grid;
    grid-template-columns: repeat(8, minmax(0, 1fr));
    gap: 6px;
}

.chat-emoji-item {
    border: none;
    background: #f4f9f6;
    border-radius: 8px;
    font-size: 20px;
    line-height: 1;
    padding: 8px 0;
    cursor: pointer;
}

.chat-emoji-item:hover {
    background: #e3f3ea;
}

.chat-emoji-loading {
    color: #5c7569;
    font-size: 13px;
    padding: 14px;
}

.chat-emoji-picker {
    width: 100%;
    height: 100%;
    --border-color: transparent;
    --category-icon-color: #4f6a5e;
    --category-icon-active-color: #1a8f50;
    --indicator-color: #1a8f50;
    --input-border-color: #d2e1d8;
}

.chat-gif-popover {
    padding: 10px;
    flex-direction: column;
}

.chat-gif-popover.active {
    display: flex;
}

.chat-gif-search-row {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 8px;
    margin-bottom: 10px;
}

.chat-gif-search-input {
    border: 1px solid #d0ddd6;
    border-radius: 8px;
    padding: 8px 10px;
    font-size: 14px;
}

.chat-gif-search-btn {
    border: none;
    border-radius: 8px;
    background: #1a8f50;
    color: #fff;
    padding: 0 12px;
    font-weight: 700;
    cursor: pointer;
}

.chat-gif-grid {
    flex: 1;
    min-height: 0;
    overflow: auto;
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
}

.chat-gif-item {
    border: none;
    padding: 0;
    background: #f4f8f6;
    border-radius: 8px;
    overflow: hidden;
    cursor: pointer;
    aspect-ratio: 1 / 1;
}

.chat-gif-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.chat-gif-loading {
    color: #5c7569;
    font-size: 13px;
    padding: 10px 4px;
}

.chat-send-btn:hover {
    background: #229954;
}

.chat-send-btn:disabled {
    background: #ccc;
    cursor: not-allowed;
}

.chat-user-attachments {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 8px;
}

.chat-inline-attachment {
    background: rgba(255, 255, 255, 0.22);
    border: 1px solid rgba(255, 255, 255, 0.4);
    padding: 3px 8px;
    border-radius: 999px;
    font-size: 11px;
}

/* Mobile Responsive */
@media (max-width: 600px) {
    .chat-widget-container {
        width: calc(100% - 12px);
        left: 6px;
        right: 6px;
        top: var(--chat-navbar-offset-mobile);
        bottom: 8px;
        height: auto;
        max-height: none;
        border-radius: 20px;
        border: 1px solid #cde0d5;
        z-index: 12000;
    }

    .chat-header {
        border-radius: 20px 20px 0 0;
        padding-top: 16px;
    }

    .chat-widget-button {
        bottom: 15px;
        right: 15px;
        z-index: 12001;
    }

    .chat-widget-button.active {
        top: calc(var(--chat-navbar-offset-mobile) + 14px);
        right: 16px;
        bottom: auto;
        width: 34px;
        height: 34px;
        background: transparent;
        box-shadow: none;
    }

    .chat-widget-button.active::before {
        font-size: 30px;
        line-height: 1;
        color: #ffffff;
        text-shadow: 0 1px 2px rgba(0, 0, 0, 0.22);
    }

    .message-bubble {
        max-width: 90%;
    }

    .chat-emoji-grid {
        grid-template-columns: repeat(6, minmax(0, 1fr));
    }

    .chat-popover {
        left: 8px;
        right: 8px;
        bottom: 56px;
        margin-bottom: 0;
        max-height: min(270px, 38vh);
    }

    .chat-emoji-popover {
        height: min(270px, 38vh);
    }
}
