/* ==========================================================================
   Tenbag Global Chat Widget Styles
   ========================================================================== */

/* Floating Launcher Button */
.chat-launcher-btn {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 54px;
    height: 54px;
    border-radius: 50%;
    background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
    color: #ffffff;
    border: none;
    box-shadow: 0 4px 16px rgba(37, 99, 235, 0.35);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4rem;
    z-index: 9990;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.chat-launcher-btn:hover {
    transform: scale(1.08);
    box-shadow: 0 6px 20px rgba(37, 99, 235, 0.45);
}

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

.chat-badge {
    position: absolute;
    top: -3px;
    right: -3px;
    background-color: #ef4444;
    color: #ffffff;
    font-size: 0.72rem;
    font-weight: 700;
    min-width: 20px;
    height: 20px;
    padding: 0 5px;
    border-radius: 10px;
    display: none;
    align-items: center;
    justify-content: center;
    border: 2px solid #ffffff;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
}

/* Chat Window Modal */
.chat-window {
    position: fixed;
    bottom: 88px;
    right: 24px;
    width: 380px;
    max-width: calc(100vw - 32px);
    height: 520px;
    max-height: calc(100vh - 110px);
    background-color: #ffffff;
    border-radius: 14px;
    box-shadow: 0 12px 36px rgba(0, 0, 0, 0.18), 0 4px 12px rgba(0, 0, 0, 0.08);
    border: 1px solid #e2e8f0;
    display: none;
    flex-direction: column;
    z-index: 9990;
    overflow: hidden;
    animation: chatSlideUp 0.25s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

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

/* Chat Header */
.chat-header {
    background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%);
    color: #ffffff;
    padding: 12px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    user-select: none;
}

.chat-header-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.95rem;
    font-weight: 600;
}

.chat-status-dot {
    width: 8px;
    height: 8px;
    background-color: #22c55e;
    border-radius: 50%;
    box-shadow: 0 0 6px #22c55e;
}

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

.chat-header-btn {
    background: none;
    border: none;
    color: #94a3b8;
    cursor: pointer;
    font-size: 1.1rem;
    padding: 4px 6px;
    border-radius: 4px;
    transition: all 0.15s ease;
}

.chat-header-btn:hover {
    color: #ffffff;
    background: rgba(255, 255, 255, 0.1);
}

/* Chat Body (Message List) */
.chat-body {
    flex: 1;
    padding: 14px;
    overflow-y: auto;
    background-color: #f8fafc;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.chat-body::-webkit-scrollbar {
    width: 5px;
}
.chat-body::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 4px;
}
.chat-body::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

/* Chat Messages */
.chat-msg-row {
    display: flex;
    flex-direction: column;
    max-width: 85%;
}

.chat-msg-row.self {
    align-self: flex-end;
    align-items: flex-end;
}

.chat-msg-row.other {
    align-self: flex-start;
    align-items: flex-start;
}

.chat-msg-sender {
    font-size: 0.76rem;
    color: #64748b;
    margin-bottom: 3px;
    font-weight: 600;
}

.chat-msg-content-wrap {
    display: flex;
    align-items: flex-end;
    gap: 6px;
}

.chat-msg-row.self .chat-msg-content-wrap {
    flex-direction: row-reverse;
}

.chat-msg-bubble {
    padding: 9px 13px;
    font-size: 0.88rem;
    line-height: 1.4;
    word-break: break-word;
    white-space: pre-wrap;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.chat-msg-row.self .chat-msg-bubble {
    background: #2563eb;
    color: #ffffff;
    border-radius: 14px 14px 2px 14px;
}

.chat-msg-row.other .chat-msg-bubble {
    background: #ffffff;
    color: #1e293b;
    border: 1px solid #e2e8f0;
    border-radius: 14px 14px 14px 2px;
}

.chat-msg-time {
    font-size: 0.7rem;
    color: #94a3b8;
    white-space: nowrap;
}

/* Attached Image in Message */
.chat-msg-image-wrap {
    margin-bottom: 6px;
}
.chat-msg-image {
    max-width: 220px;
    max-height: 180px;
    border-radius: 8px;
    cursor: zoom-in;
    display: block;
    object-fit: cover;
    background-color: #f1f5f9;
    border: 1px solid rgba(0, 0, 0, 0.08);
    transition: transform 0.15s ease;
}
.chat-msg-image:hover {
    transform: scale(1.02);
}

/* Attached Document/File in Message */
.chat-msg-file-card {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    border-radius: 8px;
    text-decoration: none !important;
    margin-bottom: 6px;
    transition: background-color 0.15s ease;
}
.chat-msg-row.self .chat-msg-file-card {
    background-color: rgba(255, 255, 255, 0.15);
    color: #ffffff !important;
}
.chat-msg-row.self .chat-msg-file-card:hover {
    background-color: rgba(255, 255, 255, 0.25);
}
.chat-msg-row.other .chat-msg-file-card {
    background-color: #f1f5f9;
    color: #1e293b !important;
    border: 1px solid #e2e8f0;
}
.chat-msg-row.other .chat-msg-file-card:hover {
    background-color: #e2e8f0;
}
.chat-msg-file-name {
    font-size: 0.82rem;
    font-weight: 600;
    max-width: 150px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.chat-msg-file-size {
    font-size: 0.72rem;
    opacity: 0.75;
}

/* Attachment Preview Bar */
.chat-preview-bar {
    padding: 8px 12px;
    background-color: #f1f5f9;
    border-top: 1px solid #e2e8f0;
}
.chat-preview-item {
    display: flex;
    align-items: center;
    gap: 8px;
    background: #ffffff;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    padding: 6px 10px;
}
.chat-preview-thumb {
    width: 36px;
    height: 36px;
    object-fit: cover;
    border-radius: 4px;
    border: 1px solid #e2e8f0;
}
.chat-preview-icon {
    font-size: 1.3rem;
    color: #2563eb;
    display: flex;
    align-items: center;
}
.chat-preview-details {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
}
.chat-preview-filename {
    font-size: 0.8rem;
    font-weight: 600;
    color: #1e293b;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.chat-preview-filesize {
    font-size: 0.7rem;
    color: #64748b;
}
.chat-preview-cancel-btn {
    background: none;
    border: none;
    color: #94a3b8;
    cursor: pointer;
    font-size: 1.1rem;
    padding: 2px 6px;
    border-radius: 4px;
}
.chat-preview-cancel-btn:hover {
    color: #ef4444;
    background-color: #fee2e2;
}

/* Emoji Picker */
.chat-emoji-picker {
    display: none;
    position: absolute;
    bottom: 74px;
    left: 12px;
    right: 12px;
    background: #ffffff;
    border: 1px solid #cbd5e1;
    border-radius: 12px;
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.12);
    z-index: 9995;
    padding: 10px;
    animation: emojiPopup 0.2s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

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

.chat-emoji-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-bottom: 6px;
    margin-bottom: 6px;
    border-bottom: 1px solid #f1f5f9;
    font-size: 0.8rem;
    font-weight: 600;
    color: #475569;
}

.chat-emoji-close {
    background: none;
    border: none;
    font-size: 1.1rem;
    cursor: pointer;
    color: #94a3b8;
    line-height: 1;
    padding: 0 4px;
}
.chat-emoji-close:hover {
    color: #0f172a;
}

.chat-emoji-tabs {
    display: flex;
    gap: 4px;
    margin-bottom: 8px;
}

.emoji-tab-btn {
    flex: 1;
    padding: 4px 6px;
    font-size: 0.75rem;
    border: 1px solid #e2e8f0;
    background: #f8fafc;
    color: #64748b;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 500;
    transition: all 0.15s ease;
}

.emoji-tab-btn.active {
    background: #2563eb;
    color: #ffffff;
    border-color: #2563eb;
    font-weight: 600;
}

.chat-emoji-grid {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 6px;
    max-height: 140px;
    overflow-y: auto;
    padding-right: 2px;
}

.chat-emoji-grid::-webkit-scrollbar {
    width: 4px;
}
.chat-emoji-grid::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 4px;
}

.chat-emoji-item {
    font-size: 1.3rem;
    height: 34px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    cursor: pointer;
    user-select: none;
    transition: all 0.1s ease;
}

.chat-emoji-item:hover {
    background-color: #f1f5f9;
    transform: scale(1.18);
}

/* Chat Footer / Input */
.chat-footer {
    padding: 8px 10px;
    background-color: #ffffff;
    border-top: 1px solid #e2e8f0;
    display: flex;
    gap: 6px;
    align-items: flex-end;
    position: relative;
}

.chat-tool-btns {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.chat-tool-btn {
    width: 32px;
    height: 25px;
    border-radius: 6px;
    background: #f8fafc;
    border: 1px solid #cbd5e1;
    color: #64748b;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.95rem;
    transition: all 0.15s ease;
    flex-shrink: 0;
}

.chat-tool-btn:hover {
    color: #2563eb;
    border-color: #2563eb;
    background: #eff6ff;
}

.chat-input {
    flex: 1;
    border: 1px solid #cbd5e1;
    border-radius: 10px;
    padding: 8px 10px;
    font-size: 0.88rem;
    line-height: 1.35;
    color: #1e293b;
    outline: none;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
    background: #f8fafc;
    resize: none;
    height: 54px !important;
    min-height: 54px !important;
    max-height: 54px !important;
    font-family: inherit;
    box-sizing: border-box;
    overflow-y: auto;
}

.chat-input:focus {
    border-color: #2563eb;
    background: #ffffff;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.chat-send-btn {
    width: 38px;
    height: 54px;
    border-radius: 10px;
    background: #2563eb;
    color: #ffffff;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    transition: all 0.15s ease;
    flex-shrink: 0;
}

.chat-send-btn:hover {
    background: #1d4ed8;
    transform: scale(1.02);
}

.chat-send-btn:disabled {
    background: #cbd5e1;
    cursor: not-allowed;
    transform: none;
}

/* Image Zoom Lightbox Modal */
.chat-lightbox {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 10010;
    display: flex;
    align-items: center;
    justify-content: center;
}

.chat-lightbox-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(4px);
}

.chat-lightbox-content {
    position: relative;
    max-width: 90vw;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    z-index: 10011;
}

.chat-lightbox-content img {
    max-width: 100%;
    max-height: 75vh;
    object-fit: contain;
    border-radius: 8px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
}

.chat-lightbox-close {
    position: absolute;
    top: -40px;
    right: 0;
    background: none;
    border: none;
    color: #ffffff;
    font-size: 2rem;
    cursor: pointer;
    line-height: 1;
}

.chat-lightbox-download {
    margin-top: 12px;
    padding: 8px 16px;
    background-color: #2563eb;
    color: #ffffff !important;
    border-radius: 6px;
    text-decoration: none !important;
    font-size: 0.88rem;
    font-weight: 600;
    transition: background 0.15s ease;
}
.chat-lightbox-download:hover {
    background-color: #1d4ed8;
}
