/* assets/css/style.css */

:root {
    --primary-color: #00a884;
    --secondary-color: #008069;
    --chat-bg: #efeae2;
    --my-message-bg: #d9fdd3;
    --other-message-bg: #ffffff;
    --sidebar-width: 30%;
}

body {
    font-family: 'Segoe UI', 'Helvetica Neue', Helvetica, Arial, sans-serif;
    height: 100vh;
    overflow: hidden;
}

#sidebar {
    width: var(--sidebar-width);
    height: 100%;
    min-width: 300px;
    display: flex;
    flex-direction: column;
}

#chat-area {
    width: calc(100% - var(--sidebar-width));
    height: 100%;
}

.chat-item {
    cursor: pointer;
    transition: background-color 0.2s;
}

.chat-item:hover {
    background-color: #f5f6f6;
}

.chat-item.active {
    background-color: #f0f2f5;
}

.message-bubble {
    max-width: 65%;
    padding: 8px 12px;
    border-radius: 7.5px;
    margin-bottom: 8px;
    position: relative;
    font-size: 14.2px;
    line-height: 19px;
    word-wrap: break-word;
}

.message-sent {
    background-color: var(--my-message-bg);
    margin-left: auto;
    border-top-right-radius: 0;
}

.message-received {
    background-color: var(--other-message-bg);
    margin-right: auto;
    border-top-left-radius: 0;
}

.message-time {
    font-size: 11px;
    color: #999;
    text-align: right;
    margin-top: 2px;
    display: block;
}

@media (max-width: 768px) {
    .container-fluid.h-100 {
        display: block !important;
    }

    #sidebar {
        width: 100% !important;
        min-width: 100% !important;
        height: 100dvh !important;
        display: flex !important;
        flex-direction: column !important;
    }

    #chat-area {
        display: none !important;
        /* Managed by .active class */
    }

    #chat-area.active {
        display: block !important;
    }

    #main-chat-view {
        position: fixed !important;
        top: 0 !important;
        left: 0 !important;
        width: 100vw !important;
        height: 100dvh !important;
        /* Dynamic Viewport Height for mobile browsers */
        z-index: 1040 !important;
        /* Above sidebar, below Bootstrap modals (1050) */
        background: white !important;
        display: flex !important;
        flex-direction: column !important;
        margin: 0 !important;
        padding: 0 !important;
        overflow: hidden !important;
        /* Contain all children */
    }

    /* Force direct children of main-chat-view to stack and not overflow */
    #main-chat-view>div {
        width: 100% !important;
        flex-shrink: 0 !important;
    }

    #messages-container {
        flex: 1 1 0 !important;
        /* Essential for flexbox shrinking */
        min-height: 0 !important;
        /* Essential for flexbox shrinking */
        width: 100% !important;
        height: auto !important;
        overflow-y: auto !important;
        /* Local scrolling for messages */
    }

    #chat-input-area {
        flex-shrink: 0 !important;
        /* Never push input off-screen */
        width: 100% !important;
    }

    .message-bubble {
        max-width: 85% !important;
    }

    .chat-list {
        flex: 1 1 0 !important;
        min-height: 0 !important;
        overflow-y: auto !important;
    }

    #chat-filters {
        flex-direction: column !important;
        gap: 8px !important;
    }

    #chat-filters button {
        margin: 0 !important;
        width: 100% !important;
    }

    #chat-input-area .input-group {
        flex-wrap: nowrap !important;
    }

    #message-input {
        font-size: 16px !important;
        /* Prevent zoom on iOS */
    }
}

.hover-danger:hover {
    color: #dc3545 !important;
}

/* Multi-Select Styles */
/* Multi-Select Styles - Refined */
.message-bubble.selected {
    background-color: rgba(0, 123, 255, 0.1) !important;
    /* Very light blue overlay */
    border-color: transparent;
    /* Remove harsh border */
    position: relative;
    border: 1px solid rgba(0, 123, 255, 0.2);
    /* Subtle blue border */
}

/* Checkbox overlay (Optional visual cue) */
.message-bubble.selected::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 123, 255, 0.05);
    border-radius: 7.5px;
    pointer-events: none;
}

.message-bubble.selected::after {
    content: '\f00c';
    /* FontAwesome Check */
    font-family: "Font Awesome 5 Free";
    font-weight: 900;
    position: absolute;
    bottom: -6px;
    /* Moved to bottom right corner */
    right: -6px;
    top: auto;
    background: #007bff;
    color: white;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    z-index: 2;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.15);
    border: 2px solid #fff;
    /* White ring for separation */
}

#selection-actions-bar {
    /*position: absolute; */
    top: 0;
    left: 0;
    width: 100%;
    height: 60px;
    background-color: #f0f2f5;
    z-index: 105;
    /* Above normal header */
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

/* Message Actions Dropdown (Hover) */
.message-actions-btn {
    display: none !important;
    /* Force hide by default */
    position: absolute;
    top: 0;
    right: 0;
    background: linear-gradient(to left, rgba(255, 255, 255, 0.95) 30%, rgba(255, 255, 255, 0));
    padding: 5px 10px 5px 20px;
    border-top-right-radius: 7.5px;
    z-index: 10;
}

/* Show on hover */
.message-bubble:hover .message-actions-btn {
    display: block !important;
}

/* Ensure sent messages have matching bg for the gradient (visual polish) */
.message-sent .message-actions-btn {
    background: linear-gradient(to left, var(--my-message-bg) 30%, rgba(217, 253, 211, 0));
}

.message-received .message-actions-btn {
    background: linear-gradient(to left, var(--other-message-bg) 30%, rgba(255, 255, 255, 0));
}

/* Read Receipt Modal Styles */
.read-receipt-section {
    max-height: 300px;
    overflow-y: auto;
    margin-bottom: 15px;
}

.read-receipt-section::-webkit-scrollbar {
    width: 6px;
}

.read-receipt-section::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 10px;
}

.read-receipt-section::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 10px;
}

.read-receipt-section::-webkit-scrollbar-thumb:hover {
    background: #555;
}

.read-receipt-item {
    padding: 10px;
    border-bottom: 1px solid #f0f0f0;
    transition: background-color 0.3s ease;
}

.read-receipt-item:last-child {
    border-bottom: none;
}

.read-receipt-item:hover {
    background-color: #f8f9fa;
}

.read-receipt-item.new-read {
    animation: slideIn 0.5s ease;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateX(-20px);
    }

    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.read-timestamp {
    font-size: 11px;
    color: #667781;
}

.section-header {
    background-color: #f0f2f5;
    padding: 8px 15px;
    font-weight: 600;
    color: #3b4a54;
    border-radius: 5px;
    margin-bottom: 10px;
    cursor: pointer;
    user-select: none;
}

.section-header:hover {
    background-color: #e9ebee;
}

.section-header i {
    transition: transform 0.3s ease;
}

.section-header.collapsed i {
    transform: rotate(-90deg);
}

.loading-spinner {
    text-align: center;
    padding: 20px;
    color: #667781;
}

/* System Messages Styles */
.system-message {
    text-align: center;
    margin: 15px auto;
    max-width: 80%;
    clear: both;
}

.system-message-text {
    display: inline-block;
    background-color: #e9ecef;
    color: #6c757d;
    padding: 6px 12px;
    border-radius: 10px;
    font-size: 13px;
    font-weight: 500;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.system-message-text i {
    opacity: 0.7;
}

.system-message-time {
    display: block;
    font-size: 10px;
    color: #999;
    margin-top: 4px;
}

/* Scroll to Bottom Button */
.scroll-to-bottom-btn {
    position: absolute;
    bottom: 100px;
    right: 30px;
    width: 45px;
    height: 45px;
    border-radius: 50%;
    background-color: #ffffff;
    border: none;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    cursor: pointer;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    color: #667781;
}

.scroll-to-bottom-btn:hover {
    background-color: #f0f2f5;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    transform: translateY(-2px);
}

.scroll-to-bottom-btn i {
    font-size: 20px;
}

.scroll-to-bottom-btn.d-none {
    opacity: 0;
    pointer-events: none;
}

/* Smooth show/hide animation */
.scroll-to-bottom-btn:not(.d-none) {
    animation: fadeInUp 0.3s ease;
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Online/Offline Status Indicators */
.user-status-indicator {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    border: 2px solid white;
    position: absolute;
    bottom: 0;
    right: 0;
    z-index: 1;
}

.user-status-indicator.online {
    background-color: #25d366;
    box-shadow: 0 0 0 2px rgba(37, 211, 102, 0.3);
}

.user-status-indicator.offline {
    background-color: #999;
}

.last-seen-text {
    font-size: 12px;
    color: #667781;
    margin-top: 2px;
}

.chat-header .last-seen-text {
    font-size: 13px;
    color: #8696a0;
}

/* Avatar container for status indicator */
.avatar-container {
    position: relative;
    display: inline-block;
}

/* Status dot in user list */
#status-dot-1,
#status-dot-2,
#status-dot-3,
#status-dot-4,
#status-dot-5,
#status-dot-6,
#status-dot-7,
#status-dot-8,
#status-dot-9,
[id^="status-dot-"] {
    font-size: 14px;
    margin-right: 5px;
}

/* Green color for online status */
.text-success {
    color: #25d366 !important;
}

/* Message Search UI */
#message-search-ui {
    transition: all 0.3s ease;
    border-bottom: 1px solid #e0e0e0;
}

.message-bubble.highlighted {
    background-color: #fff8c4 !important;
    /* A yellow highlight */
    border: 1px solid #f2e061;
}

.message-bubble.search-focus {
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.3);
    transform: scale(1.02);
    transition: all 0.3s ease;
}

.message-text {
    white-space: pre-wrap;
}

/* Call History Styles */
#callHistoryList .chat-item {
    cursor: default !important;
    transition: background 0.2s;
}

#callHistoryList .chat-item:hover {
    background: #f8f9fa;
}

#callHistoryList .fas {
    width: 16px;
    text-align: center;
}

#callHistoryList .text-muted {
    font-size: 0.85rem;
}