/* ============================================
   RESET & BASE
   ============================================ */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Segoe UI', 'Tahoma', system-ui, -apple-system, sans-serif;
}

:root {
    --primary: #6C63FF;
    --primary-dark: #5A52D5;
    --primary-light: #8B83FF;
    --primary-bg: #EEF0FF;
    --secondary: #FF6584;
    --bg: #F0F2F5;
    --white: #FFFFFF;
    --shadow: 0 8px 32px rgba(0, 0, 0, 0.08);
    --radius: 16px;
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    --msg-sent: #6C63FF;
    --msg-received: #FFFFFF;
    --text-dark: #1A1A2E;
    --text-light: #9E9E9E;
    --border-color: #E8EAF6;
    --sidebar-width: 380px;
    --header-height: 72px;
    --input-height: 76px;
}

body {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
    font-family: 'Segoe UI', 'Tahoma', system-ui, sans-serif;
}

/* ============================================
   APP CONTAINER
   ============================================ */
.app-container {
    width: 100%;
    max-width: 1360px;
    height: 92vh;
    background: var(--white);
    border-radius: 24px;
    display: flex;
    overflow: hidden;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    position: relative;
}

/* ============================================
   SIDEBAR
   ============================================ */
.sidebar {
    width: var(--sidebar-width);
    background: #F8F9FE;
    border-left: 1px solid rgba(108, 99, 255, 0.1);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    overflow: hidden;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* User Profile */
.user-profile {
    padding: 20px 20px;
    background: var(--white);
    display: flex;
    align-items: center;
    gap: 14px;
    border-bottom: 1px solid var(--border-color);
    flex-shrink: 0;
}

.avatar-circle {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary), var(--primary-light));
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    color: white;
    flex-shrink: 0;
    user-select: none;
}

.user-info {
    flex: 1;
    min-width: 0;
}

.user-info h3 {
    font-size: 15px;
    color: var(--text-dark);
    margin-bottom: 2px;
    font-weight: 600;
}

.status-badge {
    font-size: 11px;
    padding: 2px 12px;
    border-radius: 20px;
    display: inline-block;
    font-weight: 500;
}

.status-badge.online {
    background: #4CAF50;
    color: white;
}
.status-badge.away {
    background: #FFA726;
    color: white;
}
.status-badge.offline {
    background: #9E9E9E;
    color: white;
}

.profile-actions {
    display: flex;
    gap: 6px;
    align-items: center;
}

.profile-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: none;
    background: #F0F2FF;
    color: var(--primary);
    cursor: pointer;
    transition: var(--transition);
    font-size: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.profile-btn:hover {
    background: var(--primary);
    color: white;
    transform: scale(1.05);
}

.logout-btn {
    color: #E74C3C;
    text-decoration: none;
    font-size: 18px;
    padding: 8px;
    border-radius: 50%;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
}

.logout-btn:hover {
    background: #FEE2E2;
    transform: rotate(15deg);
}

/* Search Box */
.search-box {
    padding: 14px 20px;
    position: relative;
    flex-shrink: 0;
}

.search-box i {
    position: absolute;
    right: 34px;
    top: 50%;
    transform: translateY(-50%);
    color: #B0B0B0;
    font-size: 14px;
}

.search-box input {
    width: 100%;
    padding: 10px 44px 10px 16px;
    border: 2px solid var(--border-color);
    border-radius: 30px;
    font-size: 14px;
    transition: var(--transition);
    background: var(--white);
    outline: none;
    color: var(--text-dark);
}

.search-box input::placeholder {
    color: #B0B0B0;
}

.search-box input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(108, 99, 255, 0.1);
}

/* Contacts List */
.contacts-list {
    flex: 1;
    overflow-y: auto;
    padding: 8px 12px 20px;
}

.contacts-list::-webkit-scrollbar {
    width: 4px;
}

.contacts-list::-webkit-scrollbar-track {
    background: transparent;
}

.contacts-list::-webkit-scrollbar-thumb {
    background: var(--primary);
    border-radius: 10px;
}

.section-title {
    padding: 12px 16px 8px;
    font-size: 12px;
    color: var(--text-light);
    font-weight: 600;
    letter-spacing: 0.5px;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 8px;
    text-transform: uppercase;
}

.contact-item {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 12px 16px;
    border-radius: 14px;
    cursor: pointer;
    transition: var(--transition);
    margin-bottom: 2px;
    position: relative;
    -webkit-tap-highlight-color: transparent;
}

.contact-item:active {
    transform: scale(0.97);
}

.contact-item:hover {
    background: #EEF0FF;
}

.contact-item.active {
    background: var(--primary);
}

.contact-item.active h4,
.contact-item.active .last-message,
.contact-item.active .message-time {
    color: white !important;
}

.contact-item.active .last-message {
    color: rgba(255, 255, 255, 0.8) !important;
}

.contact-item.active .unread-badge {
    background: white;
    color: var(--primary);
}

.contact-avatar {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: linear-gradient(135deg, #E8EAF6, #D5D8EF);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    position: relative;
    flex-shrink: 0;
    user-select: none;
}

.status-dot {
    position: absolute;
    bottom: 1px;
    right: 1px;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    border: 2px solid white;
}

.status-dot.online {
    background: #4CAF50;
}
.status-dot.away {
    background: #FFA726;
}
.status-dot.offline {
    background: #9E9E9E;
}

.contact-info {
    flex: 1;
    min-width: 0;
}

.contact-info h4 {
    font-size: 14px;
    color: var(--text-dark);
    margin-bottom: 2px;
    font-weight: 600;
}

.contact-info .last-message {
    font-size: 12px;
    color: var(--text-light);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.contact-meta {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 4px;
    flex-shrink: 0;
}

.message-time {
    font-size: 10px;
    color: #B0B0B0;
}

.unread-badge {
    background: var(--primary);
    color: white;
    font-size: 10px;
    font-weight: 600;
    padding: 1px 8px;
    border-radius: 12px;
    min-width: 18px;
    text-align: center;
}

.empty-chats {
    text-align: center;
    padding: 30px 20px;
    color: var(--text-light);
}

.empty-chats i {
    font-size: 40px;
    opacity: 0.3;
    display: block;
    margin-bottom: 12px;
}

.empty-chats p {
    font-weight: 500;
    color: var(--text-dark);
    margin-bottom: 4px;
}

.empty-chats span {
    font-size: 12px;
}

/* ============================================
   CHAT AREA
   ============================================ */
.chat-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: #FAFAFF;
    min-width: 0;
}

/* Chat Header */
.chat-header {
    padding: 16px 24px;
    background: var(--white);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    min-height: var(--header-height);
    flex-shrink: 0;
}

.chat-user {
    display: flex;
    align-items: center;
    gap: 14px;
    min-width: 0;
    flex: 1;
}

.chat-avatar {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary), var(--primary-light));
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    color: white;
    flex-shrink: 0;
    user-select: none;
}

.chat-user h3 {
    font-size: 16px;
    color: var(--text-dark);
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-user .last-seen {
    font-size: 11px;
    color: var(--text-light);
    display: block;
}

.chat-actions {
    display: flex;
    gap: 6px;
    flex-shrink: 0;
}

.action-btn {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    border: none;
    background: #F0F2FF;
    color: var(--primary);
    cursor: pointer;
    transition: var(--transition);
    font-size: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.action-btn:hover {
    background: var(--primary);
    color: white;
    transform: scale(1.05);
}

/* Messages Container */
.messages-container {
    flex: 1;
    padding: 16px 24px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 4px;
    scroll-behavior: smooth;
}

.messages-container::-webkit-scrollbar {
    width: 5px;
}

.messages-container::-webkit-scrollbar-track {
    background: transparent;
}

.messages-container::-webkit-scrollbar-thumb {
    background: var(--primary);
    border-radius: 10px;
}

.messages-container::-webkit-scrollbar-thumb:hover {
    background: var(--primary-dark);
}

/* Welcome Message */
.welcome-message {
    text-align: center;
    margin: auto;
    color: #B0B0B0;
    padding: 20px;
}

.welcome-message i {
    font-size: 56px;
    color: var(--primary);
    opacity: 0.3;
    margin-bottom: 16px;
    display: block;
}

.welcome-message h3 {
    color: var(--text-dark);
    margin-bottom: 8px;
    font-size: 20px;
}

.welcome-message p {
    font-size: 14px;
}

/* Share Link Box */
.share-link-box {
    margin-top: 24px;
    padding: 16px 20px;
    background: #F8F9FE;
    border-radius: 12px;
    text-align: right;
    border: 1px solid var(--border-color);
}

.share-link-box > span {
    font-size: 13px;
    color: var(--text-dark);
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
}

.link-display {
    display: flex;
    gap: 8px;
    align-items: center;
}

.link-display input {
    flex: 1;
    padding: 8px 12px;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    font-size: 13px;
    font-family: 'Courier New', monospace;
    background: white;
    color: var(--text-dark);
    outline: none;
    direction: ltr;
    text-align: left;
    min-width: 0;
}

.link-display input:focus {
    border-color: var(--primary);
}

.copy-link-btn {
    padding: 8px 16px;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: var(--transition);
    font-size: 13px;
    white-space: nowrap;
    display: flex;
    align-items: center;
    gap: 6px;
}

.copy-link-btn:hover {
    background: var(--primary-dark);
    transform: scale(1.03);
}

.share-link-box small {
    display: block;
    margin-top: 8px;
    color: var(--text-light);
    font-size: 11px;
}

/* ============================================
   DATE DIVIDER
   ============================================ */
.date-divider {
    text-align: center;
    margin: 12px 0 8px;
    position: relative;
}

.date-divider span {
    font-size: 11px;
    color: var(--text-light);
    background: #FAFAFF;
    padding: 0 12px;
    position: relative;
    z-index: 1;
}

.date-divider::after {
    content: '';
    position: absolute;
    left: 0;
    right: 0;
    top: 50%;
    height: 1px;
    background: var(--border-color);
}

/* ============================================
   MESSAGE STYLES
   ============================================ */
.message-wrapper {
    display: flex;
    flex-direction: column;
    max-width: 75%;
    animation: messageIn 0.3s ease;
}

.message-wrapper.sent {
    align-self: flex-end;
    align-items: flex-end;
}

.message-wrapper.received {
    align-self: flex-start;
    align-items: flex-start;
}

@keyframes messageIn {
    from {
        opacity: 0;
        transform: translateY(10px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.message-sender {
    font-size: 11px;
    color: var(--text-light);
    margin-bottom: 2px;
    padding: 0 4px;
    font-weight: 500;
}

.message-wrapper.sent .message-sender {
    display: none;
}

.message-bubble {
    padding: 10px 16px;
    border-radius: 18px;
    word-wrap: break-word;
    position: relative;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06);
    max-width: 100%;
}

.message-wrapper.sent .message-bubble {
    background: var(--msg-sent);
    color: white;
    border-bottom-right-radius: 4px;
}

.message-wrapper.received .message-bubble {
    background: var(--msg-received);
    color: var(--text-dark);
    border-bottom-left-radius: 4px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

/* Reply Preview */
.reply-preview {
    background: rgba(0, 0, 0, 0.05);
    padding: 6px 10px;
    border-radius: 8px;
    margin-bottom: 6px;
    border-right: 3px solid var(--primary);
    font-size: 12px;
}

.message-wrapper.sent .reply-preview {
    background: rgba(255, 255, 255, 0.15);
    border-right-color: rgba(255, 255, 255, 0.5);
}

.reply-preview .reply-to-label {
    font-weight: 600;
    font-size: 10px;
    opacity: 0.7;
    display: block;
    margin-bottom: 2px;
}

.reply-preview .reply-to-text {
    opacity: 0.8;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    display: block;
}

.message-text {
    font-size: 14px;
    line-height: 1.6;
}

.message-footer {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-top: 4px;
    font-size: 10px;
    opacity: 0.7;
    padding: 0 2px;
    flex-wrap: wrap;
}

.message-wrapper.sent .message-footer {
    justify-content: flex-end;
}

.message-wrapper.received .message-footer {
    justify-content: flex-start;
}

.message-footer .msg-time {
    font-size: 10px;
}

.message-footer .msg-status {
    font-size: 12px;
}

/* ============================================
   REPLY BUTTON
   ============================================ */
.reply-msg-btn {
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.4);
    cursor: pointer;
    font-size: 11px;
    padding: 0 4px;
    transition: all 0.3s ease;
    opacity: 0;
    border-radius: 50%;
    width: 22px;
    height: 22px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.message-wrapper:hover .reply-msg-btn {
    opacity: 1;
}

.message-wrapper.received .reply-msg-btn {
    color: rgba(0, 0, 0, 0.25);
}

.message-wrapper.received .reply-msg-btn:hover {
    color: #6C63FF;
    background: rgba(108, 99, 255, 0.1);
}

.message-wrapper.sent .reply-msg-btn:hover {
    color: #8B83FF;
    background: rgba(255, 255, 255, 0.15);
}

/* ============================================
   DELETE MESSAGE BUTTON
   ============================================ */
.delete-msg-btn {
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.4);
    cursor: pointer;
    font-size: 11px;
    padding: 0 4px;
    transition: all 0.3s ease;
    opacity: 0;
    border-radius: 50%;
    width: 22px;
    height: 22px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.message-wrapper:hover .delete-msg-btn {
    opacity: 1;
}

.message-wrapper.received .delete-msg-btn {
    color: rgba(0, 0, 0, 0.25);
}

.message-wrapper.received .delete-msg-btn:hover {
    color: #E74C3C;
    background: rgba(231, 76, 60, 0.1);
}

.message-wrapper.sent .delete-msg-btn:hover {
    color: #FF6B6B;
    background: rgba(255, 107, 107, 0.15);
}

/* مرتب‌سازی دکمه‌ها در فوتر */
.message-footer .reply-msg-btn {
    order: 0;
}

.message-footer .delete-msg-btn {
    order: 1;
}

.message-wrapper.sent .message-footer .reply-msg-btn {
    order: -2;
}

.message-wrapper.sent .message-footer .delete-msg-btn {
    order: -1;
}

.message-wrapper.received .message-footer .reply-msg-btn {
    order: 0;
}

.message-wrapper.received .message-footer .delete-msg-btn {
    order: 1;
}

/* ============================================
   CONTEXT MENU
   ============================================ */
.context-menu {
    animation: contextIn 0.15s ease;
}

@keyframes contextIn {
    from {
        opacity: 0;
        transform: scale(0.95);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.context-menu .context-item:first-child {
    border-radius: 12px 12px 0 0;
}

.context-menu .context-item:last-child {
    border-radius: 0 0 12px 12px;
}

.context-menu .context-item:only-child {
    border-radius: 12px;
}

/* ============================================
   REPLY BOX
   ============================================ */
.reply-box {
    padding: 8px 20px;
    background: #F8F9FE;
    border-top: 1px solid var(--border-color);
    animation: slideDown 0.3s ease;
    flex-shrink: 0;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.reply-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.reply-info {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
}

.reply-label {
    font-size: 11px;
    color: var(--text-light);
    font-weight: 600;
    flex-shrink: 0;
}

.reply-text {
    font-size: 13px;
    color: var(--text-dark);
    background: white;
    padding: 4px 12px;
    border-radius: 8px;
    border-right: 3px solid var(--primary);
    max-width: 70%;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.reply-close {
    background: none;
    border: none;
    color: var(--text-light);
    cursor: pointer;
    font-size: 18px;
    padding: 4px 8px;
    transition: var(--transition);
    flex-shrink: 0;
}

.reply-close:hover {
    color: #E74C3C;
    transform: rotate(90deg);
}

/* ============================================
   MESSAGE INPUT
   ============================================ */
.message-input-area {
    padding: 12px 20px 16px;
    background: var(--white);
    border-top: 1px solid var(--border-color);
    flex-shrink: 0;
}

.input-tools {
    display: flex;
    gap: 4px;
    margin-bottom: 8px;
}

.tool-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: none;
    background: transparent;
    color: #9E9E9E;
    cursor: pointer;
    transition: var(--transition);
    font-size: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.tool-btn:hover {
    background: #F0F2FF;
    color: var(--primary);
}

.tool-btn.recording {
    background: #FFE5E5;
    color: #E74C3C;
    animation: pulse 1s infinite;
}

@keyframes pulse {
    0%,
    100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.1);
    }
}

.input-wrapper {
    display: flex;
    gap: 10px;
    align-items: center;
}

.input-wrapper input {
    flex: 1;
    padding: 10px 18px;
    border: 2px solid var(--border-color);
    border-radius: 30px;
    font-size: 14px;
    outline: none;
    transition: var(--transition);
    background: #F8F9FE;
    color: var(--text-dark);
    min-width: 0;
}

.input-wrapper input::placeholder {
    color: #B0B0B0;
}

.input-wrapper input:focus {
    border-color: var(--primary);
    background: white;
    box-shadow: 0 0 0 4px rgba(108, 99, 255, 0.1);
}

.input-wrapper input:disabled {
    background: #F0F0F0;
    cursor: not-allowed;
}

.send-btn {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: none;
    background: var(--primary);
    color: white;
    cursor: pointer;
    transition: var(--transition);
    font-size: 18px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.send-btn:hover:not(:disabled) {
    background: var(--primary-dark);
    transform: scale(1.05) rotate(-5deg);
}

.send-btn:active:not(:disabled) {
    transform: scale(0.95);
}

.send-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* ============================================
   RECORDING INDICATOR
   ============================================ */
.recording-indicator {
    display: none;
    position: fixed;
    bottom: 120px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--white);
    padding: 24px 36px;
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.2);
    z-index: 1000;
    min-width: 280px;
}

.recording-indicator.active {
    display: block;
    animation: slideUp 0.3s ease;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateX(-50%) translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }
}

.recording-content {
    text-align: center;
}

.recording-wave {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 4px;
    height: 40px;
    margin-bottom: 12px;
}

.recording-wave span {
    width: 4px;
    height: 20px;
    background: var(--primary);
    border-radius: 4px;
    animation: waveAnim 0.8s ease-in-out infinite;
}

.recording-wave span:nth-child(2) {
    animation-delay: 0.1s;
    height: 30px;
}
.recording-wave span:nth-child(3) {
    animation-delay: 0.2s;
    height: 40px;
}
.recording-wave span:nth-child(4) {
    animation-delay: 0.3s;
    height: 35px;
}
.recording-wave span:nth-child(5) {
    animation-delay: 0.4s;
    height: 25px;
}
.recording-wave span:nth-child(6) {
    animation-delay: 0.5s;
    height: 45px;
}
.recording-wave span:nth-child(7) {
    animation-delay: 0.6s;
    height: 30px;
}
.recording-wave span:nth-child(8) {
    animation-delay: 0.7s;
    height: 20px;
}

@keyframes waveAnim {
    0%,
    100% {
        transform: scaleY(0.5);
    }
    50% {
        transform: scaleY(1);
    }
}

.recording-content p {
    color: var(--text-dark);
    font-weight: 500;
    margin-bottom: 12px;
    font-size: 14px;
}

.stop-recording-btn {
    padding: 8px 24px;
    background: #E74C3C;
    color: white;
    border: none;
    border-radius: 20px;
    cursor: pointer;
    font-size: 14px;
    transition: var(--transition);
}

.stop-recording-btn:hover {
    background: #C0392B;
    transform: scale(1.05);
}

/* ============================================
   TOAST MESSAGE
   ============================================ */
.toast-message {
    position: fixed;
    bottom: 100px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--text-dark);
    color: white;
    padding: 12px 24px;
    border-radius: 12px;
    z-index: 9999;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.3);
    animation: slideUp 0.3s ease;
    font-size: 14px;
    max-width: 90%;
    text-align: center;
}

/* ============================================
   RESPONSIVE - TABLET
   ============================================ */
@media (max-width: 968px) {
    .app-container {
        height: 100vh;
        border-radius: 0;
    }

    .sidebar {
        width: 320px;
    }

    .message-wrapper {
        max-width: 80%;
    }
}

/* ============================================
   RESPONSIVE - MOBILE
   ============================================ */
@media (max-width: 768px) {
    body {
        padding: 0;
        background: var(--white);
    }

    .app-container {
        flex-direction: row;
        height: 100vh;
        border-radius: 0;
        box-shadow: none;
        background: var(--white);
    }

    /* ===== سایدبار در موبایل ===== */
    .sidebar {
        width: 100%;
        height: 100%;
        border-left: none;
        border-bottom: none;
        position: absolute;
        top: 0;
        left: 0;
        z-index: 10;
        background: #F8F9FE;
        transform: translateX(0);
        transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1);
        box-shadow: 0 0 40px rgba(0, 0, 0, 0.1);
    }

    .sidebar.hidden {
        transform: translateX(100%);
    }

    /* ===== چت در موبایل ===== */
    .chat-area {
        width: 100%;
        height: 100%;
        position: absolute;
        top: 0;
        left: 0;
        z-index: 5;
        background: #FAFAFF;
        transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1);
    }

    .chat-area.hidden {
        transform: translateX(100%);
    }

    /* ===== دکمه بازگشت ===== */
    .mobile-back-btn {
        display: flex !important;
        align-items: center;
        gap: 4px;
        background: none;
        border: none;
        color: var(--text-dark);
        font-size: 13px;
        padding: 4px 6px;
        cursor: pointer;
        flex-shrink: 0;
    }

    .mobile-back-btn i {
        font-size: 16px;
    }

    .mobile-back-btn span {
        font-size: 12px;
    }

    /* ===== هدر چت ===== */
    .chat-header {
        padding: 10px 12px;
        min-height: 56px;
    }

    .chat-user {
        gap: 10px;
        min-width: 0;
        flex: 1;
    }

    .chat-avatar {
        width: 36px;
        height: 36px;
        font-size: 16px;
        flex-shrink: 0;
    }

    .chat-user h3 {
        font-size: 14px;
        max-width: 120px;
    }

    .chat-user .last-seen {
        font-size: 10px;
    }

    .chat-actions .action-btn {
        width: 32px;
        height: 32px;
        font-size: 13px;
    }

    /* ===== پیام‌ها ===== */
    .messages-container {
        padding: 12px 14px;
    }

    .message-wrapper {
        max-width: 88%;
    }

    .message-bubble {
        padding: 8px 12px;
        font-size: 13px;
        border-radius: 14px;
    }

    .message-wrapper.sent .message-bubble {
        border-bottom-right-radius: 3px;
    }

    .message-wrapper.received .message-bubble {
        border-bottom-left-radius: 3px;
    }

    .message-image {
        max-width: 160px;
        max-height: 220px;
    }

    .message-text {
        font-size: 13px;
        line-height: 1.5;
    }

    .message-footer {
        font-size: 9px;
        gap: 3px;
    }

    .message-footer .msg-time {
        font-size: 9px;
    }

    .message-footer .msg-status {
        font-size: 10px;
    }

    /* ===== دکمه‌های ریپلای و حذف در موبایل ===== */
    .reply-msg-btn,
    .delete-msg-btn {
        opacity: 0.6;
        width: 20px;
        height: 20px;
        font-size: 10px;
    }

    /* ===== ریپلای باکس ===== */
    .reply-box {
        padding: 6px 14px;
    }

    .reply-text {
        max-width: 60%;
        font-size: 12px;
        padding: 3px 10px;
    }

    .reply-label {
        font-size: 10px;
    }

    .reply-close {
        font-size: 16px;
        padding: 2px 6px;
    }

    /* ===== ورودی پیام ===== */
    .message-input-area {
        padding: 8px 12px 12px;
    }

    .input-tools {
        gap: 2px;
        margin-bottom: 6px;
    }

    .tool-btn {
        width: 32px;
        height: 32px;
        font-size: 14px;
    }

    .input-wrapper input {
        font-size: 13px;
        padding: 8px 14px;
        border-radius: 24px;
    }

    .send-btn {
        width: 38px;
        height: 38px;
        font-size: 15px;
    }

    /* ===== پیام خوش‌آمدگویی ===== */
    .welcome-message {
        padding: 16px;
    }

    .welcome-message i {
        font-size: 40px;
    }

    .welcome-message h3 {
        font-size: 17px;
    }

    .welcome-message p {
        font-size: 13px;
    }

    /* ===== لینک اشتراک ===== */
    .share-link-box {
        padding: 12px 14px;
        margin-top: 16px;
    }

    .share-link-box > span {
        font-size: 12px;
    }

    .link-display {
        flex-direction: column;
        align-items: stretch;
        gap: 6px;
    }

    .link-display input {
        font-size: 12px;
        padding: 6px 10px;
        width: 100%;
    }

    .copy-link-btn {
        width: 100%;
        justify-content: center;
        padding: 6px 12px;
        font-size: 12px;
    }

    /* ===== تاریخ ===== */
    .date-divider span {
        font-size: 10px;
        padding: 0 10px;
    }

    /* ===== منوی راست‌کلیک ===== */
    .context-menu {
        min-width: 140px !important;
    }

    .context-menu .context-item {
        padding: 10px 14px !important;
        font-size: 13px !important;
    }

    /* ===== اندیکاتور ضبط ===== */
    .recording-indicator {
        min-width: 200px;
        padding: 16px 24px;
        bottom: 100px;
    }

    .recording-wave span {
        height: 15px;
    }

    .recording-content p {
        font-size: 13px;
    }

    .stop-recording-btn {
        padding: 6px 18px;
        font-size: 13px;
    }

    /* ===== توست ===== */
    .toast-message {
        font-size: 13px;
        padding: 10px 18px;
        bottom: 80px;
        max-width: 85%;
    }

    /* ===== آواتار سایدبار ===== */
    .user-profile {
        padding: 14px 16px;
    }

    .avatar-circle {
        width: 40px;
        height: 40px;
        font-size: 20px;
    }

    .user-info h3 {
        font-size: 14px;
    }

    .profile-btn,
    .logout-btn {
        width: 32px;
        height: 32px;
        font-size: 14px;
    }

    /* ===== جستجو ===== */
    .search-box {
        padding: 10px 16px;
    }

    .search-box input {
        font-size: 13px;
        padding: 8px 38px 8px 14px;
    }

    .search-box i {
        right: 28px;
        font-size: 13px;
    }

    /* ===== مخاطبین ===== */
    .contact-item {
        padding: 10px 12px;
        gap: 10px;
    }

    .contact-avatar {
        width: 38px;
        height: 38px;
        font-size: 16px;
    }

    .status-dot {
        width: 10px;
        height: 10px;
    }

    .contact-info h4 {
        font-size: 13px;
    }

    .contact-info .last-message {
        font-size: 11px;
    }

    .section-title {
        font-size: 11px;
        padding: 8px 12px 6px;
    }

    .unread-badge {
        font-size: 9px;
        min-width: 16px;
        padding: 0 6px;
    }

    .message-time {
        font-size: 9px;
    }
}

/* ============================================
   RESPONSIVE - SMALL MOBILE (تا 480px)
   ============================================ */
@media (max-width: 480px) {
    .chat-user h3 {
        max-width: 80px;
        font-size: 13px;
    }

    .chat-avatar {
        width: 32px;
        height: 32px;
        font-size: 14px;
    }

    .chat-header {
        padding: 8px 10px;
        min-height: 50px;
    }

    .chat-actions .action-btn {
        width: 28px;
        height: 28px;
        font-size: 12px;
    }

    .messages-container {
        padding: 10px 10px;
    }

    .message-wrapper {
        max-width: 92%;
    }

    .message-bubble {
        padding: 6px 10px;
        font-size: 12px;
        border-radius: 12px;
    }

    .message-image {
        max-width: 130px;
        max-height: 180px;
    }

    .message-text {
        font-size: 12px;
    }

    .reply-preview {
        font-size: 10px;
        padding: 3px 8px;
    }

    .reply-preview .reply-to-text {
        font-size: 10px;
    }

    .message-input-area {
        padding: 6px 8px 10px;
    }

    .input-wrapper input {
        font-size: 12px;
        padding: 6px 12px;
    }

    .send-btn {
        width: 34px;
        height: 34px;
        font-size: 14px;
    }

    .tool-btn {
        width: 28px;
        height: 28px;
        font-size: 12px;
    }

    .reply-text {
        max-width: 50%;
        font-size: 11px;
    }

    .mobile-back-btn {
        font-size: 12px;
        padding: 2px 4px;
    }

    .mobile-back-btn i {
        font-size: 14px;
    }

    .mobile-back-btn span {
        font-size: 11px;
    }

    .context-menu {
        min-width: 120px !important;
    }

    .context-menu .context-item {
        padding: 8px 12px !important;
        font-size: 12px !important;
    }
}

/* ============================================
   DARK MODE SUPPORT (اختیاری)
   ============================================ */
@media (prefers-color-scheme: dark) {
    /* حالت تاریک - غیرفعال شده */
}

/* ============================================
   UTILITY CLASSES
   ============================================ */
.text-center {
    text-align: center;
}

.text-muted {
    color: var(--text-light);
}

.flex-center {
    display: flex;
    align-items: center;
    justify-content: center;
}

.gap-2 {
    gap: 8px;
}

.gap-4 {
    gap: 16px;
}

.w-100 {
    width: 100%;
}

.overflow-hidden {
    overflow: hidden;
}

.position-relative {
    position: relative;
}

/* ============================================
   PRINT STYLES
   ============================================ */
@media print {
    .sidebar,
    .chat-header .chat-actions,
    .message-input-area,
    .reply-box,
    .recording-indicator,
    .toast-message,
    .mobile-back-btn {
        display: none !important;
    }

    .app-container {
        height: auto !important;
        border-radius: 0 !important;
        box-shadow: none !important;
        flex-direction: column !important;
    }

    .chat-area {
        height: auto !important;
        position: relative !important;
        transform: none !important;
    }

    .messages-container {
        height: auto !important;
        overflow: visible !important;
    }

    .message-wrapper {
        break-inside: avoid;
    }
}