/* ===== MODERN CHAT ENHANCEMENTS ===== */

/* Chat List Styling */
.chat-list-unstyled-border li {
    border-bottom: none !important;
    transition: all 0.3s ease;
    border-radius: 12px;
    margin-bottom: 8px;
}

.chat-person {
    padding: 12px 16px !important;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 500;
    color: #4b5563;
    background: transparent;
}

.chat-person:hover {
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.08) 0%, rgba(118, 75, 162, 0.08) 100%);
    transform: translateX(5px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.15);
}

.chat-person.active,
.chat-person:active {
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.15) 0%, rgba(118, 75, 162, 0.15) 100%) !important;
    color: #667eea !important;
    font-weight: 600;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.25);
}

.chat-person i.fa-circle {
    font-size: 8px;
    margin-right: 5px;
    animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* Unread Message Badge */
.badge-chat {
    position: absolute;
    right: 16px;
    top: 50%;
    transform: translateY(-50%);
    background:linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    color: white;
    font-size: 11px;
    font-weight: 700;
    padding: 4px 8px;
    border-radius: 12px;
    min-width: 22px;
    text-align: center;
    box-shadow: 0 4px 12px rgba(245, 87, 108, 0.4);
    animation: bounceIn 0.5s ease;
}

@keyframes bounceIn {
    0% { transform: translateY(-50%) scale(0); }
    50% { transform: translateY(-50%) scale(1.1); }
    100% { transform: translateY(-50%) scale(1); }
}

/* Card Headers */
.chat-card-header {
    padding: 16px 20px !important;
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.05) 0%, rgba(118, 75, 162, 0.05) 100%);
    border-bottom: 2px solid rgba(102, 126, 234, 0.1);
    margin-bottom: 8px;
}

.chat-card-header h4 {
    font-size: 16px;
    font-weight: 700;
    color: #1f2937;
    margin: 0;
    letter-spacing: 0.3px;
}

/* Chat Divider */
.chat_divider {
    text-align: center;
    margin: 20px 0;
    position: relative;
}

.chat_divider::before {
    content: '';
    position: absolute;
    left: 0;
    right: 0;
    top: 50%;
    height: 1px;
    background: linear-gradient(90deg, transparent 0%, rgba(102, 126, 234, 0.3) 50%, transparent 100%);
}

.chat_divider span {
    background: #f8f9fa;
    padding: 6px 16px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    color: #6b7280;
    position: relative;
    z-index: 1;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

/* Go to Bottom Button */
.go-to-bottom-btn {
    cursor: pointer !important;
    width: 42px !important;
    height: 42px !important;
    border-radius: 50% !important;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%) !important;
    color: white !important;
    border: 3px solid #ffffff !important;
    position: absolute !important;
    bottom: 80px !important;
    right: 20px !important;
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.5) !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    z-index: 100 !important;
    transition: all 0.3s ease !important;
}

.go-to-bottom-btn:hover {
    box-shadow: 0 8px 25px rgba(102, 126, 234, 0.7) !important;
    transform: translateY(-3px) !important;
}

.go-to-bottom-btn i {
    font-size: 18px !important;
}

/* Chat Typing Indicator */
.chat-typing .chat-text {
    background: #f3f4f6 !important;
    padding: 16px 20px !important;
}

/* Media Files Preview */
.chat-image-view {
    position: relative;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    transition: all 0.3s ease;
    margin: 8px 0;
}

.chat-image-view:hover {
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.15);
    transform: scale(1.02);
}

.chat-image-view img {
    border-radius: 12px;
    width: 100%;
    height: auto;
}

/* File Attachments */
.chat-files {
    background: linear-gradient(135deg, #f3f4f6 0%, #e5e7eb 100%);
    border-radius: 12px;
    padding: 12px;
    margin: 8px 0;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    transition: all 0.3s ease;
}

.chat-files:hover {
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.12);
    transform: translateY(-2px);
}

/* Download Button */
.download-btn-styling {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%) !important;
    color: white !important;
    padding: 8px 12px !important;
    border-radius: 8px !important;
    font-size: 12px !important;
    font-weight: 600 !important;
    transition: all 0.3s ease !important;
    border: none !important;
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.4) !important;
}

.download-btn-styling:hover {
    background: linear-gradient(135deg, #059669 0%, #047857 100%) !important;
    box-shadow: 0 6px 18px rgba(16, 185, 129, 0.6) !important;
    transform: translateY(-2px) !important;
}

/* Chat Preview Button */
.chat-preview-btn {
    transition: all 0.3s ease !important;
    opacity: 0.6;
}

.chat-preview-btn:hover {
    opacity: 1 !important;
    transform: scale(1.1) !important;
}

/* Chat Time Stamp */
.chat-time {
    font-size: 11px !important;
    font-weight: 500 !important;
    color: #9ca3af !important;
    margin-top: 6px !important;
    letter-spacing: 0.3px;
}

/* Scrollbar Styling */
#chat-box-content::-webkit-scrollbar {
    width: 8px;
}

#chat-box-content::-webkit-scrollbar-track {
    background: #f1f5f9;
    border-radius: 10px;
}

#chat-box-content::-webkit-scrollbar-thumb {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 10px;
    transition: all 0.3s ease;
}

#chat-box-content::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(135deg, #5568d3 0%, #6a4199 100%);
}

/* Select2 Dropdown Modern Styling */
.select2-container--default .select2-selection--multiple,
.select2-container--default .select2-selection--single {
    border-radius: 12px !important;
    border: 2px solid #e5e7eb !important;
    padding: 8px !important;
    transition: all 0.3s ease !important;
}

.select2-container--default.select2-container--focus .select2-selection--multiple,
.select2-container--default.select2-container--focus .select2-selection--single {
    border-color: #667eea !important;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1) !important;
}

.select2-container--default .select2-results__option--highlighted[aria-selected] {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%) !important;
}

/* Loading Indicator */
.chat_loader {
    text-align: center;
    padding: 20px;
    color: #9ca3af;
    font-weight: 500;
    font-size: 13px;
    animation: fadeInOut 1.5s ease-in-out infinite;
}

@keyframes fadeInOut {
    0%, 100% { opacity: 0.5; }
    50% { opacity: 1; }
}

/* Empty State  */
.text-muted {
    color: #9ca3af !important;
    font-size: 14px;
    font-weight: 500;
    text-align: center;
    padding: 30px 20px;
}

/* Responsive Adjustments - Extended to cover all tablets and mobiles */
@media (max-width: 991px) {
    /* ========== CRITICAL: FORCE ALL COLUMNS TO FULL WIDTH ========== */
    /* Universal column targeting */
    [class*="col-"],
    div[class*="col-"],
    .row [class*="col-"],
    body [class*="col-"],
    body div[class*="col-"],
    
    /* Specific column classes */
    .col-12,
    .col-sm-2,
    .col-sm-8,
    .col-md-3,
    .col-md-4,
    .col-md-8,
    .col-md-9,
    .col-lg-6,
    .col-lg-9,
    body .col-12,
    body .col-sm-2,
    body .col-sm-8,
    body .col-lg-6,
    body .col-lg-9,
    
    /* Floating chat specific */
    .floating-chat-users,
    body .floating-chat-users,
    #floating_chat_view [class*="col-"],
    #floating_chat_view .col-sm-2,
    #floating_chat_view .col-12,
    #floating_chat_view .col-sm-8,
    #floating_chat_view .col-lg-6,
    #floating_chat_view .col-lg-9,
    #chat_area,
    #chat_area_wait,
    body #chat_area,
    body #chat_area_wait,
    section #chat_area,
    section #chat_area_wait,
    
    /* Multi-class combinations that appear in floating chat */
    .col-12.col-sm-8,
    .col-12.col-sm-8.col-lg-9,
    .col-lg-6.d-none,
    .col-lg-6.d-none.p-0,
    body .col-12.col-sm-8,
    body .col-12.col-sm-8.col-lg-9,
    body .col-lg-6.d-none,
    body .col-lg-6.d-none.p-0 {
        flex: 0 0 100% !important;
        max-width: 100% !important;
        width: 100% !important;
        min-width: 0 !important;
        padding-left: 5px !important;
        padding-right: 5px !important;
        margin-left: 0 !important;
        margin-right: 0 !important;
        box-sizing: border-box !important;
        flex-basis: 100% !important;
    }
    
    /* Force containers and rows to full width */
    .container,
    .container-fluid,
    .container.mt-2,
    #floating_chat_view,
    #floating_chat_view .row,
    .row,
    body .row,
    div.row {
        width: 100% !important;
        max-width: 100% !important;
        margin-left: 0 !important;
        margin-right: 0 !important;
        padding-left: 10px !important;
        padding-right: 10px !important;
        overflow-x: hidden !important;
        box-sizing: border-box !important;
    }
    
    /* Chat cards full width */
    .card,
    .card.chat-min,
    .card.chat-max,
    .card.chat-box,
    .chat-theme-light,
    .chat-theme-dark,
    div.card,
    div.chat-theme-light {
        width: 100% !important;
        max-width: 100% !important;
        min-width: 0 !important;
        overflow-x: hidden !important;
        margin-left: 0 !important;
        margin-right: 0 !important;
        box-sizing: border-box !important;
    }
    
    /* Global overflow prevention */
    html,
    body {
        overflow-x: hidden !important;
        max-width: 100vw !important;
    }
    
    /* Chat height adjustments */
    .chat-min, 
    .chat-max {
        height: 60vh !important;
        border-radius: 12px !important;
        width: 100% !important;
        max-width: 100% !important;
        box-sizing: border-box !important;
    }
    
    .chat-person {
        padding: 10px 12px !important;
        max-width: 100% !important;
        overflow: hidden;
        text-overflow: ellipsis;
    }
    
    .chat-box .chat-form .form-control {
        padding: 12px 100px 12px 50px;
        height: 50px;
        max-width: 100%;
        width: 100% !important;
    }
    
    .chat-box .chat-form .btn,
    .chat-box .chat-form .btn-file {
        width: 40px;
        height: 40px;
    }
    
    /* Chat card elements */
    .chat-card-header,
    .chat-card-body,
    .list-unstyled,
    .chat-list-unstyled-border {
        max-width: 100% !important;
        overflow-x: hidden !important;
        width: 100% !important;
    }
    
    /* Media and list items */
    li.media,
    .media-body {
        width: 100% !important;
        max-width: 100% !important;
    }
    
    /* Select2 and search elements */
    .select2-container,
    .search_user,
    #chat_user,
    #chat_user_main {
        width: 100% !important;
        max-width: 100% !important;
    }
    
    /* Input groups */
    .input-group,
    .chat-form .input-group {
        width: 100% !important;
        max-width: 100% !important;
    }
    
    /* Floating chat back button */
    .floating-chat-back-btn {
        padding: 8px !important;
        font-size: 16px;
    }
    
    /* ========== EXTREME OVERRIDE: KILL BOOTSTRAP GRID ========== */
    /* Target exact problematic elements with display block */
    #floating_chat_view > .row > div,
    #floating_chat_view .row > .col-sm-2,
    #floating_chat_view .row > .col-12,
    #floating_chat_view .row > .col-sm-8,
    #floating_chat_view .row > .col-lg-6,
    #floating_chat_view .row > .col-lg-9,
    #floating_chat_view .row.h-100 > div,
    #floating_chat_view .row.h-100 > .col-sm-2,
    #floating_chat_view .row.h-100 > .col-12,
    #floating_chat_view .row.h-100 > .col-sm-8,
    #floating_chat_view .row.h-100 > .col-lg-6,
    #floating_chat_view .row.h-100 > .col-lg-9,
    section .row > [class*="col-"],
    body section .row > [class*="col-"] {
        display: block !important;
        flex: none !important;
        max-width: 100% !important;
        width: 100% !important;
        flex-basis: auto !important;
    }
    
    /* Kill any remaining Bootstrap flex properties on rows */
    .row,
    .row.h-100,
    #floating_chat_view .row,
    #floating_chat_view .row.h-100,
    div.row.h-100 {
        display: block !important;
        flex-wrap: nowrap !important;
    }
    
    /* Force all direct children of rows to full width */
    .row > *,
    .row.h-100 > *,
    #floating_chat_view .row > *,
    #floating_chat_view .row.h-100 > * {
        flex-shrink: 0 !important;
        width: 100% !important;
        max-width: 100% !important;
        flex-basis: 100% !important;
    }
    
    /* Target exact floating chat structure */
    .floating-chat-users.col-sm-2,
    #chat_area_wait.col-12.col-sm-8.col-lg-9,
    #chat_area.col-lg-6,
    body .floating-chat-users.col-sm-2,
    body #chat_area_wait.col-12.col-sm-8.col-lg-9,
    body #chat_area.col-lg-6 {
        width: 100% !important;
        max-width: 100% !important;
        flex: 0 0 100% !important;
    }
}

/* Dark Mode Enhancements */
.chat-theme-dark .chat-person {
    color: #e5e7eb;
}

.chat-theme-dark .chat-person:hover {
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.15) 0%, rgba(118, 75, 162, 0.15) 100%);
}

.chat-theme-dark .chat-card-header {
    background: rgba(255, 255, 255, 0.05);
    border-bottom-color: rgba(255, 255, 255, 0.1);
}

.chat-theme-dark .chat-card-header h4 {
    color: #f3f4f6;
}

.chat-theme-dark #chat-box-content::-webkit-scrollbar-track {
    background: #1f2937;
}
