/* Shared Dashboard Styles */
*,
::after,
::before {
    box-sizing: border-box;
}

body {
    overflow: auto;
    background-color: rgba(248, 247, 247, 1);
}

/* Sidebar Scrollbar */
.sidebar::-webkit-scrollbar {
    width: 6px;
}

.sidebar::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.05);
    border-radius: 10px;
}

.sidebar::-webkit-scrollbar-thumb {
    background: linear-gradient(180deg, #b7924f, #d4af37);
    border-radius: 10px;
    transition: background 0.3s ease;
}

.sidebar::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(180deg, #d4af37, #b7924f);
}

/* Navbar Utilities */
.mw-95 {
    max-width: 95%;
}

/* Sidebar Logo - Always Visible */
.sidebar .logo {
    display: block !important;
    opacity: 1 !important;
    visibility: visible !important;
}

/* Sidebar */
.sidebar {
    width: 300px;
    background-color: #fff;
    box-shadow: 0px 14px 10px rgba(8, 15, 52, 0.06);
    position: fixed;
    top: 0;
    bottom: 0;
    right: 0;
    z-index: 10000;
    transition: transform 0.3s ease-in-out;
    overflow-y: auto;
}

.sidebar .logo img {
    max-width: 152px;
    height: auto;
}

.sidebar ul {
    list-style: none;
    padding: 0;
}

.sidebar ul li {
    margin-bottom: 0.8rem;
}

.sidebar ul li a {
    color: rgba(39, 58, 65, 1);
    text-decoration: none;
    font-size: 16px;
    padding: 0.7rem;
}

.sidebar ul li.active a {
    color: #b7924f !important;
    font-weight: bold;
}

.sidebar ul li a:hover {
    color: #b7924f;
}

.sidebar .nav-link.active {
    color: #b7924f;
}

.sidebar .icon {
    width: 20px;
    height: 20px;
    transition: all 0.3s ease-in-out;
}

.sidebar ul li.active .icon,
.sidebar ul li:hover .icon {
    filter: brightness(0) saturate(100%) invert(64%) sepia(29%) saturate(343%) hue-rotate(8deg) brightness(95%) contrast(90%);
    transform: scale(1.05);
}

.sidebar .nav-item:hover {
    background-color: rgba(249, 248, 244, 1);
    border-radius: 8px;
}

.sidebar .nav-item.active {
    background-color: rgba(249, 248, 244, 1);
    border-radius: 8px;
}

/* Close Button */
.sidebar-close {
    display: none;
    position: absolute;
    top: 2%;
    left: 0;
    font-size: 2rem;
    color: black;
}

/* custom container */

.custom-container {
    padding: 0 20rem 0 0;
}

/* navbar */
.search-bar {
    padding-right: 1rem;
    width: 100%;
}

.search-bar input {
    background-color: rgba(39, 58, 65, 0.05);
    border: none;
    padding: 0.7rem;
}

.search-bar input::placeholder {
    color: rgba(156, 156, 156, 1);
    font-size: 14px;
    padding: 0.5rem;
}

.search-bar input {
    background-color: #f7f7f7;
    border: none;
    padding-right: 2.5rem;
}

.search-bar input:focus {
    box-shadow: none;
    background-color: #f7f7f7;
}

.search-bar i {
    color: rgba(158, 158, 158, 1);
    font-size: 16px;
}

/* Content */
.content {
    margin-right: 270px;
    padding: 1rem 3rem;
    transition: margin-left 0.3s ease-in-out;
}

@media (max-width: 767.98px) {
    .header h1 {
        font-size: 1.5rem;
    }
}

/* Responsive Sidebar */
@media (max-width: 991.98px) {
    .sidebar {
        transform: translateX(100%);
    }

    .sidebar.show {
        transform: translateX(0%);
    }

    .sidebar-close {
        display: block;
    }

    .content {
        margin-right: 0 !important;
        padding: 0.5rem;
    }

    .custom-container {
        padding: 0;
    }

    .search-bar {
        width: 100%;
    }
}

/* تحسينات عامة */
.container-fluid {
    padding: 0;
}

.chat-container {
    height: calc(100vh - 2rem);
    /* حساب الارتفاع مع مراعاة الهوامش */
    display: flex;
    overflow: hidden;
    background-color: #fff;
}

/* الشريط الجانبي */
.chat-sidebar {
    width: 30%;
    min-width: 300px;
    /* حد أدنى للعرض */
    background: #fff;
    border-left: 1px solid #dee2e6;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    transition: all 0.3s ease;
}

/* منطقة المحادثة */
.chat-area {
    width: 70%;
    display: flex;
    flex-direction: column;
    background-color: #f8f9fd;
    height: 100%;
    min-height: 600px;
}

/* رأس المحادثة */
.chat-header {
    background: #fff;
    padding: 15px;
    border-bottom: 1px solid #dee2e6;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    position: sticky;
    top: 0;
    z-index: 10;
}

.chat-header .info {
    display: flex;
    align-items: center;
    gap: 10px;
}

/* جسم المحادثة */
.chat-body {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    background-color: transparent;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

/* الرسائل */
.chat-message {
    max-width: 70%;
    padding: 12px 16px;
    border-radius: 20px;
    position: relative;
    word-wrap: break-word;
    font-size: 15px;
    line-height: 1.4;
}

.chat-message.user {
    background-color: #f2f2f2;
    align-self: flex-end;
    border-bottom-left-radius: 0;
    color: #000;
    border-radius: 32px 32px 0 32px;
}

.chat-message.receiver {
    background-color: #D3AB55;
    align-self: flex-start;
    border-bottom-right-radius: 0;
    color: #fff;
    border-radius: 32px 32px 32px 0;
}

.chat-message small {
    display: block;
    margin-top: 5px;
    color: rgba(255, 255, 255, 0.7);
    font-size: 11px;
    text-align: end;
}

.chat-message.user small {
    color: rgba(0, 0, 0, 0.5);
}

/* منطقة الإدخال */
.chat-input-container {
    background-color: white;
    padding: 15px;
    border-top: 1px solid #dee2e6;
    position: sticky;
    bottom: 0;
}

.chat-input-box {
    border-radius: 50px;
    display: flex;
    align-items: center;
    width: 100%;
    background-color: #f8f9fd;
    padding: 0 15px;
}

.chat-input-box input {
    border: none;
    background: transparent;
    outline: none;
    flex-grow: 1;
    font-size: 14px;
    padding: 12px 0;
}

.icon-btn {
    background-color: transparent;
    border: none;
    cursor: pointer;
    padding: 8px;
    border-radius: 50%;
    transition: background-color 0.2s;
}

.icon-btn:hover {
    background-color: rgba(0, 0, 0, 0.05);
}

/* قائمة الرسائل */
.message-list {
    list-style: none;
    padding: 0;
    margin: 0;
    flex: 1;
    overflow-y: auto;
}

.message-list li {
    padding: 12px 15px;
    border-bottom: 1px solid #f0f0f0;
    display: flex;
    gap: 12px;
    align-items: center;
    cursor: pointer;
    transition: background-color 0.2s;
}

.message-list li:hover {
    background-color: #f8f9fa;
}

.message-list li img {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
}

.message-list li div {
    flex: 1;
}

.message-list li strong {
    display: block;
    font-size: 14px;
    margin-bottom: 2px;
}

.message-list li p {
    font-size: 13px;
    color: #6c757d;
    margin: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-search {
    padding: 15px;
    border-top: 1px solid #dee2e6;
}

/* مشغل الصوت */
.audio-player {
    padding: 12px 16px;
    border-radius: 20px;
    max-width: 70%;
    display: flex;
    align-items: center;
}

.audio-player.user {
    align-self: flex-end;
    background-color: #f2f2f2;
    border-radius: 32px 32px 0 32px;
}

.audio-player.receiver {
    align-self: flex-start;
    background-color: #fff;
    border: 1px solid #dee2e6;
    border-radius: 32px 32px 32px 0;
}

.audio-player audio {
    flex: 1;
    max-width: 200px;
}

/* تأثيرات الدروب داون */
.dropdown-toggle::after {
    display: none;
}

.dropdown-menu {
    border-radius: 10px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
    border: none;
}

/* التكيف مع الشاشات الصغيرة */
@media (max-width: 992px) {
    .chat-sidebar {
        width: 35%;
        min-width: 250px;
    }

    .chat-area {
        width: 65%;
    }
}

@media (max-width: 768px) {
    .chat-container {
        flex-direction: column;
        height: 100vh;
    }

    .chat-sidebar {
        width: 100% !important;
        height: 40vh;
        border-left: none;
        border-bottom: 1px solid #dee2e6;
    }

    .chat-area {
        width: 100% !important;
        height: 60vh;
    }

    .chat-header {
        padding: 12px;
    }

    .chat-body {
        padding: 15px;
    }

    .chat-message {
        max-width: 85%;
        font-size: 14px;
    }

    .message-list li {
        padding: 10px 12px;
    }
}

@media (max-width: 576px) {
    .chat-sidebar {
        height: 45vh;
    }

    .chat-area {
        height: 55vh;
    }

    .chat-message {
        max-width: 90%;
        padding: 10px 12px;
    }

    .chat-input-container {
        padding: 10px;
    }

    .chat-input-box input {
        font-size: 13px;
        padding: 10px 0;
    }

    .icon-btn {
        padding: 6px;
    }

    .message-list li img {
        width: 36px;
        height: 36px;
    }
}

/* Contact Details Styles */
.contact-item {
    cursor: pointer;
    transition: background-color 0.2s;
}

.contact-item.active {
    background-color: #e3f2fd;
    border-right: 3px solid #2196f3;
}

.contact-details-card {
    background: white;
    border-radius: 12px;
    padding: 24px;
}

.contact-info-section,
.contact-message-section {
    border-bottom: 1px solid #f0f0f0;
    padding-bottom: 20px;
}

.contact-message-section {
    border-bottom: none;
}

.info-item {
    padding: 8px 0;
    font-size: 14px;
    color: #333;
}

.info-item strong {
    color: #666;
    margin-left: 8px;
}

.info-item a {
    color: #2196f3;
    text-decoration: none;
}

.info-item a:hover {
    text-decoration: underline;
}

.message-content {
    min-height: 100px;
    font-size: 14px;
    line-height: 1.8;
    color: #333;
}

.border-none {
    border: none;
}
.custom-width-50 {
    width: 50px;
}
.custom-width-60 {
    width: 60px;
}

/* Image Messages */
.message-image {
    margin-bottom: 8px;
}

.message-image img {
    display: block;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    transition: transform 0.2s ease;
    width: 100%;
    height: auto;
}

.message-image img:hover {
    transform: scale(1.02);
    cursor: pointer;
}

.message-text {
    margin-top: 8px;
    word-wrap: break-word;
}

/* Chat message with image */
.chat-message .message-image {
    margin-bottom: 4px;
}

.chat-message.user .message-image img {
    border-radius: 12px 12px 0 12px;
}

.chat-message.receiver .message-image img {
    border-radius: 12px 12px 12px 0;
}

/* Empty State */
.chat-empty-state {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    min-height: 400px;
}

/* Active Chat */
.chat-active {
    display: flex;
    flex-direction: column;
    height: 100%;
}

/* Conversation Item Active State */
.conversation-item {
    cursor: pointer;
    transition: background-color 0.2s;
    padding: 12px;
    border-radius: 8px;
    margin-bottom: 4px;
}

.conversation-item:hover {
    background-color: rgba(211, 171, 85, 0.1);
}

.conversation-item.active {
    background-color: rgba(211, 171, 85, 0.15);
    border-right: 3px solid #D3AB55;
}

.conversation-item img {
    width: 45px;
    height: 45px;
    border-radius: 50%;
    object-fit: cover;
    margin-left: 12px;
}

/* Chat Input with Image Button */
#imageUploadBtn {
    border-radius: 50%;
    width: 45px;
    height: 45px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid #dee2e6;
    background: white;
    color: #D3AB55;
    transition: all 0.2s;
}

#imageUploadBtn:hover {
    background: rgba(211, 171, 85, 0.1);
    border-color: #D3AB55;
}

#sendMessageBtn {
    border-radius: 50%;
    width: 45px;
    height: 45px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #D3AB55 0%, #B7924F 100%);
    border: none;
    color: white;
    transition: all 0.2s;
}

#sendMessageBtn:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(211, 171, 85, 0.3);
}

#sendMessageBtn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* Image Modal */
#imageModal .modal-content {
    background: rgba(0, 0, 0, 0.9);
}

#imageModal .btn-close-white {
    filter: invert(1);
    opacity: 1;
}

/* Loading States */
.spinner-border-sm {
    width: 1.5rem;
    height: 1.5rem;
}