/* Reset and base styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: #f5f4f0;
    color: #1a1a1a;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

.messages-container {
    display: flex;
    height: 100vh;
}

/* Sidebar */
.sidebar {
    width: 240px;
    background: #f5f4f0;
    border-right: 1px solid #e5e5e5;
    display: flex;
    flex-direction: column;
}

.sidebar-header {
    padding: 24px;
}

.logo {
    display: flex;
    align-items: baseline;
    gap: 6px;
    text-decoration: none;
}

.logo-text {
    font-size: 22px;
    font-weight: 500;
    color: #1a1a1a;
    letter-spacing: -0.02em;
}

.logo-arabic {
    font-size: 16px;
    color: #716d52;
    font-weight: 400;
}

/* Sidebar Navigation */
.sidebar-nav {
    flex: 1;
    padding: 0 16px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    margin-bottom: 4px;
    border-radius: 8px;
    text-decoration: none;
    color: #666;
    font-size: 14px;
    font-weight: 400;
    transition: all 0.2s;
    position: relative;
}

.nav-item:hover {
    background: #e8e7e3;
    color: #1a1a1a;
}

.nav-item.active {
    background: #e8e7e3;
    color: #1a1a1a;
    font-weight: 500;
}

.nav-item svg {
    flex-shrink: 0;
}

.nav-badge {
    position: absolute;
    right: 16px;
    background: #666;
    color: white;
    font-size: 11px;
    font-weight: 500;
    padding: 2px 6px;
    border-radius: 10px;
    min-width: 18px;
    text-align: center;
}

/* Sidebar Footer */
.sidebar-footer {
    padding: 16px;
    border-top: 1px solid #e5e5e5;
}

.nav-item.support {
    margin-bottom: 16px;
}

.menu-toggle {
    background: none;
    border: none;
    cursor: pointer;
    padding: 8px;
    margin-bottom: 16px;
    color: #666;
    display: block;
    margin-left: auto;
    margin-right: auto;
}

.user-profile {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    background: #e8e7e3;
    border-radius: 8px;
    cursor: pointer;
}

.dropdown-icon {
    color: #666;
}

.user-info {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.user-avatar {
    width: 36px;
    height: 36px;
    background: #1a1a1a;
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: 500;
}

.user-details {
    flex: 1;
    min-width: 0;
}

.user-name {
    font-size: 14px;
    font-weight: 500;
    color: #1a1a1a;
}

.user-role {
    font-size: 12px;
    color: #666;
}

.user-email {
    font-size: 12px;
    color: #666;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.logout-btn {
    background: none;
    border: none;
    padding: 8px;
    cursor: pointer;
    color: #666;
    transition: color 0.2s;
}

.logout-btn:hover {
    color: #1a1a1a;
}

/* Messages Content */
.messages-content {
    flex: 1;
    display: flex;
    overflow: hidden;
}

/* Conversations Panel */
.conversations-panel {
    width: 320px;
    background: white;
    border-right: 1px solid #e5e5e5;
    display: flex;
    flex-direction: column;
}

.conversations-header {
    padding: 24px;
    border-bottom: 1px solid #e5e5e5;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.conversations-header h2 {
    font-size: 20px;
    font-weight: 500;
}

.new-message-btn {
    width: 36px;
    height: 36px;
    background: #1a1a1a;
    color: white;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.new-message-btn:hover {
    background: #333;
    transform: scale(1.05);
}

.search-conversations {
    padding: 16px 24px;
    position: relative;
}

.search-conversations svg {
    position: absolute;
    left: 36px;
    top: 50%;
    transform: translateY(-50%);
}

.search-conversations input {
    width: 100%;
    padding: 10px 16px 10px 44px;
    border: 1px solid #e0e0e0;
    border-radius: 20px;
    font-size: 14px;
}

.search-conversations input:focus {
    outline: none;
    border-color: #95b70f;
}

/* Conversations List */
.conversations-list {
    flex: 1;
    overflow-y: auto;
}

.conversation-item {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 16px 24px;
    cursor: pointer;
    transition: background 0.2s;
    position: relative;
}

.conversation-item:hover {
    background: #f5f4f0;
}

.conversation-item.active {
    background: #e2f699;
}

.conversation-avatar {
    position: relative;
    flex-shrink: 0;
}

.conversation-avatar img {
    width: 48px;
    height: 48px;
    border-radius: 50%;
}

.conversation-avatar.system {
    width: 48px;
    height: 48px;
    background: #f5f4f0;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #666;
}

.online-indicator {
    position: absolute;
    bottom: 2px;
    right: 2px;
    width: 12px;
    height: 12px;
    background: #95b70f;
    border: 2px solid white;
    border-radius: 50%;
}

.conversation-info {
    flex: 1;
    min-width: 0;
    padding-right: 40px;
}

.conversation-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 4px;
}

.conversation-header h4 {
    font-size: 14px;
    font-weight: 500;
    color: #1a1a1a;
}

.time {
    font-size: 12px;
    color: #999;
}

.last-message {
    font-size: 13px;
    color: #666;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.unread-badge {
    position: absolute;
    right: 24px;
    background: #666;
    color: white;
    font-size: 11px;
    font-weight: 500;
    padding: 2px 6px;
    border-radius: 10px;
    min-width: 18px;
    text-align: center;
}

/* Chat Panel */
.chat-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: #f5f4f0;
}

.chat-header {
    background: white;
    padding: 16px 24px;
    border-bottom: 1px solid #e5e5e5;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

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

.chat-avatar {
    position: relative;
}

.chat-avatar img {
    width: 40px;
    height: 40px;
    border-radius: 50%;
}

.chat-info h3 {
    font-size: 16px;
    font-weight: 500;
    margin-bottom: 2px;
}

.status {
    font-size: 13px;
    color: #666;
}

.chat-actions {
    display: flex;
    gap: 8px;
}

.action-btn {
    width: 36px;
    height: 36px;
    background: none;
    border: 1px solid #e0e0e0;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    color: #666;
}

.action-btn:hover {
    background: #f5f4f0;
    border-color: #d0d0d0;
    color: #1a1a1a;
}

/* Messages Area */
.messages-area {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.date-divider {
    text-align: center;
    margin: 16px 0;
    position: relative;
}

.date-divider span {
    background: #f5f4f0;
    padding: 0 16px;
    font-size: 12px;
    color: #999;
    position: relative;
}

.date-divider::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 0;
    right: 0;
    height: 1px;
    background: #e0e0e0;
    z-index: -1;
}

.message {
    display: flex;
    margin-bottom: 4px;
}

.message.sent {
    justify-content: flex-end;
}

.message.received {
    justify-content: flex-start;
}

.message-content {
    max-width: 70%;
    padding: 12px 16px;
    border-radius: 16px;
    position: relative;
}

.message.sent .message-content {
    background: #1a1a1a;
    color: white;
    border-bottom-right-radius: 4px;
}

.message.received .message-content {
    background: white;
    color: #1a1a1a;
    border-bottom-left-radius: 4px;
}

.message-content p {
    font-size: 14px;
    line-height: 1.5;
    margin-bottom: 4px;
}

.message-time {
    font-size: 11px;
    color: #999;
    display: block;
}

.message.sent .message-time {
    color: rgba(255, 255, 255, 0.7);
}

/* Attachment */
.attachment {
    background: rgba(149, 183, 15, 0.1);
    border-radius: 8px;
    padding: 12px;
    margin-top: 8px;
    display: flex;
    align-items: center;
    gap: 12px;
}

.message.sent .attachment {
    background: rgba(255, 255, 255, 0.1);
}

.attachment-info {
    flex: 1;
}

.filename {
    font-size: 13px;
    font-weight: 500;
    display: block;
}

.filesize {
    font-size: 11px;
    color: #666;
    display: block;
}

.download-btn {
    width: 32px;
    height: 32px;
    background: white;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.download-btn:hover {
    background: #e2f699;
}

/* Typing Indicator */
.typing-indicator {
    display: flex;
    gap: 4px;
    padding: 12px 16px;
    background: white;
    border-radius: 16px;
    width: fit-content;
    display: none;
}

.typing-indicator.active {
    display: flex;
}

.typing-indicator span {
    width: 8px;
    height: 8px;
    background: #666;
    border-radius: 50%;
    animation: typing 1.4s infinite;
}

.typing-indicator span:nth-child(2) {
    animation-delay: 0.2s;
}

.typing-indicator span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typing {
    0%, 80%, 100% {
        opacity: 0.3;
        transform: scale(1);
    }
    40% {
        opacity: 1;
        transform: scale(1.2);
    }
}

/* Message Input */
.message-input-container {
    background: white;
    padding: 16px 24px;
    border-top: 1px solid #e5e5e5;
    display: flex;
    align-items: center;
    gap: 12px;
}

.input-actions {
    display: flex;
    gap: 8px;
}

.attach-btn {
    width: 36px;
    height: 36px;
    background: none;
    border: none;
    cursor: pointer;
    color: #666;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.attach-btn:hover {
    color: #1a1a1a;
}

#messageInput {
    flex: 1;
    padding: 10px 16px;
    border: 1px solid #e0e0e0;
    border-radius: 20px;
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s;
}

#messageInput:focus {
    border-color: #95b70f;
}

.send-btn {
    width: 36px;
    height: 36px;
    background: #1a1a1a;
    color: white;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.send-btn:hover {
    background: #333;
    transform: scale(1.05);
}

/* Loading and Empty States */
.loading-spinner {
    border: 3px solid #f3f4f6;
    border-top: 3px solid #666;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
    margin: 0 auto 16px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.loading-conversations {
    text-align: center;
    padding: 40px 20px;
    color: #666;
}

.empty-chat-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    text-align: center;
    padding: 40px;
}

.empty-chat-state svg {
    margin-bottom: 24px;
}

.empty-chat-state h3 {
    font-size: 20px;
    font-weight: 500;
    color: #1a1a1a;
    margin-bottom: 8px;
}

.empty-chat-state p {
    font-size: 14px;
    color: #666;
}

.no-conversations {
    text-align: center;
    padding: 60px 20px;
    color: #666;
}

.no-conversations svg {
    margin-bottom: 16px;
}

.no-conversations p {
    font-size: 14px;
    margin: 0;
}

/* Chat Info Panel */
.chat-info-panel {
    width: 300px;
    background: white;
    border-left: 1px solid #e5e5e5;
    display: none;
    flex-direction: column;
}

.chat-info-panel.active {
    display: flex;
}

.info-header {
    padding: 20px;
    border-bottom: 1px solid #e5e5e5;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.info-header h3 {
    font-size: 16px;
    font-weight: 500;
}

.close-btn {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: #666;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.close-btn:hover {
    color: #1a1a1a;
}

.info-content {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
}

.info-section {
    margin-bottom: 32px;
}

.info-section h4 {
    font-size: 14px;
    font-weight: 500;
    color: #666;
    margin-bottom: 12px;
}

.vendor-details {
    display: flex;
    gap: 12px;
}

.vendor-details img {
    width: 48px;
    height: 48px;
    border-radius: 8px;
}

.vendor-name {
    font-size: 14px;
    font-weight: 500;
    margin-bottom: 4px;
}

.vendor-category,
.vendor-rating {
    font-size: 12px;
    color: #666;
}

.rfq-link {
    padding: 12px;
    background: #f5f4f0;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.2s;
}

.rfq-link:hover {
    background: #e8e7e3;
}

.rfq-id {
    font-size: 12px;
    color: #666;
    display: block;
}

.rfq-title {
    font-size: 14px;
    font-weight: 500;
    margin: 4px 0;
    display: block;
}

.rfq-status {
    display: inline-block;
    padding: 4px 8px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 500;
}

.rfq-status.active {
    background: #e2f699;
    color: #716d52;
}

.shared-files {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.file-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.2s;
}

.file-item:hover {
    background: #f5f4f0;
}

.file-item span {
    font-size: 13px;
    color: #333;
}

/* Responsive */
@media (max-width: 1024px) {
    .sidebar {
        width: 200px;
    }
    
    .conversations-panel {
        width: 280px;
    }
}

@media (max-width: 768px) {
    .sidebar {
        display: none;
    }
    
    .conversations-panel {
        position: absolute;
        left: -100%;
        z-index: 10;
        height: 100%;
        transition: left 0.3s;
    }
    
    .conversations-panel.mobile-active {
        left: 0;
    }
    
    .chat-info-panel {
        position: absolute;
        right: -100%;
        z-index: 10;
        height: 100%;
        transition: right 0.3s;
    }
    
    .chat-info-panel.active {
        right: 0;
    }
}