/* CHAT WINDOW STYLES - PREMIUM LIGHT THEME */
.chat-window {
    position: fixed;
    bottom: 85px;
    right: 25px;
    width: 780px;
    height: 700px;
    background: white;
    backdrop-filter: blur(25px) saturate(200%);
    -webkit-backdrop-filter: blur(25px) saturate(200%);
    border-radius: 20px;
    z-index: 10000;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: 0 15px 40px rgba(0, 0, 0, 0.12), 0 0 0 1px rgba(0, 0, 0, 0.02);
    transition: all 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
    border: none !important;
}

.chat-window.drag-over {
    border: 2px dashed #0d6efd !important;
    background-color: rgba(13, 110, 253, 0.05) !important;
    transform: scale(1.01);
}

.chat-window.minimized {
    height: 60px;
    width: 280px;
    border-radius: 30px;
}

.chat-header {
    background: linear-gradient(135deg, var(--primary-color), #0a58ca);
    padding: 12px 18px;
    color: white;
    cursor: grab;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.chat-header h6 {
    font-weight: 700 !important;
    margin: 0;
    font-size: 0.95rem;
    letter-spacing: -0.01em;
}

.chat-recipient-selector {
    background: rgba(243, 244, 246, 0.8) !important;
    border-bottom: 1px solid rgba(0,0,0,0.05) !important;
}

.chat-recipient-selector .form-select {
    font-size: 0.85rem !important;
    color: #495057 !important;
}

/* SIDEBAR LIST ITEMS */
.chat-sidebar {
    width: 280px !important;
    overflow-x: hidden !important;
    display: flex;
    flex-direction: column;
}

.chat-user-filters {
    background: #fff;
    flex-shrink: 0;
    z-index: 5;
    padding: 8px 10px !important;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.chat-user-filters select, 
.chat-user-filters input {
    margin-bottom: 2px !important;
    font-size: 0.75rem !important;
    padding: 2px 5px !important;
}

.chat-user-filters .btn-reset-filters {
    width: 100%;
    font-size: 0.7rem !important;
    padding: 2px !important;
    margin-top: 2px !important;
}

.chat-sidebar .list-group-item {
    padding: 3px 10px;
    background: transparent;
    border-bottom: 1px solid rgba(0,0,0,0.03);
    cursor: pointer;
    transition: all 0.2s ease;
    overflow: hidden;
    width: 100%;
    display: flex;
    align-items: center;
    min-width: 0;
    gap: 6px;
    min-height: 40px;
}

.chat-sidebar .list-group-item:hover {
    background: rgba(0,0,0,0.02);
}

.chat-sidebar .list-group-item.active {
    background: white;
    font-weight: 600;
    border-left: 4px solid var(--primary-color);
    color: var(--primary-color) !important;
}

.chat-sidebar .text-truncate {
    max-width: 100%;
    display: block;
    font-size: 0.8rem;
    font-weight: 700;
}

.chat-sidebar .extra-small {
    font-size: 0.62rem;
    line-height: 1.1;
    opacity: 0.8;
    display: block;
    margin-top: 1px;
}

.chat-body {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 15px;
    background: rgba(250, 251, 252, 0.4);
    scrollbar-width: thin;
    scrollbar-color: rgba(0, 0, 0, 0.1) transparent;
    transition: opacity 0.15s ease;
}

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

.chat-body::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.1);
    border-radius: 10px;
}

/* MESSAGE BUBBLES */
.message-entry {
    margin-bottom: 15px;
    display: flex;
    flex-direction: column;
}

.message-sender {
    font-size: 0.7rem;
    font-weight: 800;
    margin-bottom: 4px;
    color: #495057;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 0 5px;
}

.message-bubble {
    padding: 10px 14px;
    border-radius: 18px;
    background: white;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.03), 0 0 0 1px rgba(0, 0, 0, 0.05);
    max-width: 85%;
    font-size: 0.92rem;
    line-height: 1.5;
    position: relative;
    color: #2d3436;
}

.own-message .message-bubble {
    background: var(--primary-color);
    color: white;
    border: none;
    box-shadow: 0 4px 12px rgba(13, 110, 253, 0.25);
    border-bottom-right-radius: 4px;
}

.own-message .message-sender {
    color: var(--primary-color);
}

.message-time {
    font-size: 0.65rem;
    color: #adb5bd;
    margin-top: 5px;
    padding: 0 5px;
}

.system-message {
    align-self: center;
    background: rgba(0, 0, 0, 0.04);
    padding: 6px 15px;
    border-radius: 20px;
    font-size: 0.75rem;
    color: #6c757d;
    font-weight: 600;
    margin: 10px 0;
}

/* INPUT AREA */
/* Expiration Notice */
.chat-expiration-notice {
    background: rgba(255, 193, 7, 0.1);
    color: #856404;
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
    font-size: 0.75rem;
    font-weight: 500;
}

/* Message Bubble Enhancements */
.message-bubble {
    position: relative;
    max-width: 90%;
    padding: 0.6rem 0.9rem;
    border-radius: 1.2rem;
    font-size: 0.9rem;
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
    word-break: break-word;
    overflow-wrap: break-word;
    transition: transform 0.2s ease;
}

.message-sent .message-bubble {
    padding-bottom: 0.4rem; /* Spacing for timestamp */
}

.message-time {
    font-size: 0.65rem;
    opacity: 0.6;
    margin-top: 2px;
    display: block;
}

.message-sent .message-time {
    text-align: right;
    color: rgba(255, 255, 255, 0.8);
}

.message-received .message-time {
    text-align: left;
    color: rgba(0, 0, 0, 0.4);
}

/* Delete Button */
.btn-delete-msg {
    position: absolute;
    top: -5px;
    right: -5px;
    width: 20px;
    height: 20px;
    padding: 0;
    font-size: 0.7rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: #dc3545;
    color: white;
    border: 2px solid white;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
    opacity: 0;
    transition: opacity 0.2s ease, transform 0.2s ease;
    cursor: pointer;
    z-index: 10;
}

.message-sent:hover .btn-delete-msg {
    opacity: 1;
}

.btn-delete-msg:hover {
    transform: scale(1.1);
    background: #bb2d3b;
}

/* CHAT TOOLBAR BUTTONS */
.btn-chat-tool {
    background: transparent;
    border: none;
    color: #64748b;
    font-size: 1.1rem;
    padding: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    border-radius: 8px;
}

.btn-chat-tool:hover {
    color: var(--primary-color);
    background: rgba(13, 110, 253, 0.05);
}

#chat-btn-buzz {
    transition: all 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    color: #ffca28; /* Amber/Yellow for attention */
    font-size: 1.2rem;
}

#chat-btn-buzz:hover {
    transform: scale(1.2) rotate(10deg);
    color: #ffb300;
    background: rgba(255, 202, 40, 0.1);
}

#chat-btn-buzz:disabled {
    opacity: 0.4 !important;
    pointer-events: none;
    filter: grayscale(1);
}

/* Translate Button */
.btn-translate-msg {
    position: absolute;
    top: -5px;
    right: -5px;
    width: 22px;
    height: 22px;
    padding: 0;
    font-size: 0.8rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: #0d6efd;
    color: white;
    border: 2px solid white;
    box-shadow: 0 2px 4px rgba(0,0,0,0.15);
    opacity: 0;
    transition: all 0.2s ease;
    cursor: pointer;
    z-index: 10;
}

.message-received:hover .btn-translate-msg {
    opacity: 1;
}

.btn-translate-msg:hover {
    transform: scale(1.1);
    background: #0b5ed7;
    box-shadow: 0 3px 6px rgba(0,0,0,0.2);
}

.translated-text {
    font-weight: 500;
    color: #1a1a1a;
}

.animate-spin {
    animation: spin 1s linear infinite;
}

@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

.chat-footer {
    padding: 10px 15px !important;
    background: white !important;
    border-top: 1px solid rgba(0, 0, 0, 0.06) !important;
}

#chat-footer-toolbar {
    min-height: 32px;
}

.bi-check, .bi-check-all {
    font-size: 0.95rem !important;
    vertical-align: middle !important;
    color: #94a3b8 !important; /* WhatsApp-like light grey */
    margin-left: 2px !important;
}

.bi-check-all.text-primary {
    color: #34b7f1 !important; /* WhatsApp-like light blue */
}

#chat-input {
    background-color: #f8f9fa !important;
    border: 1px solid #edf2f7 !important;
    color: #2d3436 !important;
    padding: 10px 16px !important;
    font-size: 0.85rem !important;
    line-height: 1.4 !important;
    min-height: 45px !important;
    max-height: 120px !important;
    overflow-y: auto !important;
}

#chat-input:focus {
    background-color: white !important;
    border-color: var(--primary-color) !important;
    box-shadow: 0 0 0 3px rgba(13, 110, 253, 0.1) !important;
}

.rounded-3 {
    border-radius: 12px !important;
}

/* FLOATING TOGGLE BUTTON */
.chat-toggle-btn {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 65px;
    height: 65px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary-color), #0a58ca);
    color: white;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.6rem;
    z-index: 10000;
    box-shadow: 0 8px 25px rgba(13, 110, 253, 0.4);
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.chat-toggle-btn:hover {
    transform: scale(1.1) translateY(-5px);
    box-shadow: 0 12px 30px rgba(13, 110, 253, 0.5);
}

.chat-toggle-btn #chat-badge {
    position: absolute;
    top: -2px;
    right: -2px;
    font-size: 0.75rem;
    padding: 5px 8px;
    background: #ff4757;
    border: 3px solid white;
    border-radius: 50%;
    font-weight: 800;
}

/* LARGE EMOJI SUPPORT */
.large-emoji-bubble {
    font-size: 3.5rem !important;
    background: transparent !important;
    box-shadow: none !important;
    padding: 0 !important;
}

.own-message .large-emoji-bubble {
    color: inherit;
}

/* FILE ATTACHMENTS */
.chat-attachment {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 5px;
    background: rgba(0,0,0,0.03);
    border-radius: 10px;
    margin-top: 5px;
    text-decoration: none !important;
    color: inherit !important;
    max-width: 100%;
}

.own-message .chat-attachment {
    background: rgba(255,255,255,0.15);
}

.chat-attachment i {
    font-size: 1.5rem;
}

.chat-attachment-info {
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.chat-attachment-name {
    font-size: 0.8rem;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-attachment-size {
    font-size: 0.65rem;
    opacity: 0.7;
}

.chat-image-attachment {
    max-width: 100%;
    max-height: 300px;
    border-radius: 10px;
    margin-top: 5px;
    cursor: pointer;
    transition: transform 0.2s;
}

.chat-image-attachment:hover {
    transform: scale(1.02);
}

/* INPUT FOOTER BUTTONS */
.chat-footer .input-group {
    gap: 8px;
}

.btn-chat-attach {
    color: #6c757d;
    background: transparent;
    border: none;
    padding: 0 5px;
    font-size: 1.2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.2s;
}

.btn-chat-attach:hover {
    color: var(--primary-color);
}

/* EMOJI PICKER */
.emoji-picker {
    position: absolute;
    bottom: 75px;
    left: 20px;
    background: rgba(255, 255, 255, 0.98);
    backdrop-filter: blur(25px);
    -webkit-backdrop-filter: blur(25px);
    border-radius: 18px;
    box-shadow: 0 15px 50px rgba(0, 0, 0, 0.2), 0 0 0 1px rgba(0, 0, 0, 0.05);
    width: 340px;
    height: 420px;
    display: flex;
    flex-direction: column;
    z-index: 10001;
    overflow: hidden;
    border: none;
    animation: slideUp 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    box-sizing: border-box;
}

.emoji-picker * {
    box-sizing: border-box;
}

.emoji-picker-tabs {
    display: flex;
    flex-wrap: wrap;
    background: rgba(0, 0, 0, 0.03);
    border-bottom: 1px solid rgba(0, 0, 0, 0.08);
    padding: 10px;
    gap: 6px;
    overflow-x: hidden !important;
    scrollbar-width: none;
    max-height: 120px;
    overflow-y: auto;
}

.emoji-picker-tabs::-webkit-scrollbar {
    display: none;
}

.emoji-tab {
    flex: 0 0 42px;
    height: 42px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    border-radius: 10px;
    font-size: 1.2rem;
    transition: all 0.2s ease;
    filter: grayscale(1) opacity(0.5);
}

.emoji-tab:hover {
    background: rgba(0, 0, 0, 0.05);
    filter: grayscale(0) opacity(1);
}

.emoji-tab.active {
    background: white;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
    filter: grayscale(0) opacity(1);
    color: var(--primary-color);
}

.emoji-picker-content {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden !important;
    padding: 15px;
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 6px;
    align-content: start;
}

.emoji-category-title {
    grid-column: 1 / -1;
    font-size: 0.75rem;
    font-weight: 700;
    color: #64748b;
    text-transform: uppercase;
    margin: 10px 0 5px 0;
    padding-bottom: 3px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.03);
}

.emoji-item {
    cursor: pointer;
    text-align: center;
    padding: 8px 0;
    border-radius: 8px;
    font-size: 1.4rem;
    transition: all 0.15s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    aspect-ratio: 1;
}

.emoji-item:hover {
    background: rgba(0, 0, 0, 0.05);
    transform: scale(1.2);
}
/* AVATARS IN SIDEBAR */
.avatar-img {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    object-fit: cover;
    transition: none; /* Evitar animaciones en avatares que causan flashazos */
}

.avatar-circle {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    font-size: 0.75rem;
}

.bg-primary-soft {
    background-color: rgba(13, 110, 253, 0.1);
}
/* ANIMATIONS */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

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

.animate-fade-in {
    animation: fadeIn 0.5s ease-out forwards;
}

.animate-slide-up {
    animation: slideUp 0.5s ease-out forwards;
}

/* SHAKE ANIMATION FOR BUZZ */
@keyframes shake {
    0%, 100% { transform: translateX(0); }
    10%, 30%, 50%, 70%, 90% { transform: translateX(-5px); }
    20%, 40%, 60%, 80% { transform: translateX(5px); }
}

.chat-shake {
    animation: shake 0.5s cubic-bezier(.36,.07,.19,.97) both;
}
