/* Enhanced Dark theme styles for messages with maximum readability */
.dark-theme .messages-container,
.dark-theme .email-container,
.dark-theme .email-container .inbox-panel,
.dark-theme .email-container .message-view,
.dark-theme .email-container .main-content,
.dark-theme .messages-container .conversations-panel,
.dark-theme .messages-container .chat-panel {
    background: var(--card-bg);
    box-shadow: 0 2px 8px var(--card-shadow);
    color: var(--text-color);
    border: 1px solid var(--border-color);
}

.dark-theme .inbox-header,
.dark-theme .conversations-header,
.dark-theme .chat-header {
    border-bottom-color: var(--border-color);
    background: rgba(37, 37, 41, 0.8);
}

/* All text elements with maximum readability */
.dark-theme .email-header h2,
.dark-theme .messages-header h2,
.dark-theme .inbox-header h3,
.dark-theme .conversations-header h3,
.dark-theme .chat-info h3,
.dark-theme .modal-header h3,
.dark-theme .email-message-sender,
.dark-theme .conversation-name,
.dark-theme .conversation-last-message,
.dark-theme .recipient-display,
.dark-theme .email-message-subject,
.dark-theme .message-placeholder h3,
.dark-theme .message-placeholder p,
.dark-theme .chat-placeholder h3,
.dark-theme .chat-placeholder p,
.dark-theme .no-conversations p,
.dark-theme .no-conversations small {
    color: var(--text-color) !important;
}

/* Secondary text with good contrast */
.dark-theme .email-message-time,
.dark-theme .conversation-time,
.dark-theme .email-message-attachments h4,
.dark-theme .message-time,
.dark-theme .conversation-last-message,
.dark-theme .email-message-content,
.dark-theme .chat-info p {
    color: var(--sidebar-text) !important;
}

/* Borders and separators */
.dark-theme .email-message-subject,
.dark-theme .email-message,
.dark-theme .conversation-item {
    border-bottom-color: var(--border-color) !important;
}

/* Message content */
.dark-theme .message-content {
    background: var(--card-bg);
    color: var(--text-color);
    border: 1px solid var(--border-color);
}

.dark-theme .message.own .message-content {
    background: #a05c2f;
    color: white;
}

.dark-theme .message.own .message-time {
    color: rgba(255,255,255,0.85) !important;
}

/* Input fields with high contrast */
.dark-theme .message-input,
.dark-theme .form-group select,
.dark-theme .form-group textarea,
.dark-theme .message-input:focus,
.dark-theme .form-group select:focus,
.dark-theme .form-group textarea:focus {
    background: var(--input-bg) !important;
    border-color: var(--input-border) !important;
    color: var(--text-color) !important;
}

.dark-theme .message-input::placeholder,
.dark-theme .form-group select::placeholder,
.dark-theme .form-group textarea::placeholder {
    color: var(--sidebar-text) !important;
}

/* Toolbars and UI elements */
.dark-theme .compose-toolbar,
.dark-theme .chat-format-tools,
.dark-theme .modal-footer,
.dark-theme .chat-input-area {
    background: var(--card-bg) !important;
    border-color: var(--border-color) !important;
}

.dark-theme .chat-input-area {
    border-top-color: var(--border-color) !important;
}

.dark-theme .reply-quote {
    background: var(--sidebar-bg) !important;
    border-left-color: #a05c2f !important;
}

.dark-theme .modal-content,
.dark-theme .product-modal-content {
    background: var(--card-bg) !important;
    color: var(--text-color) !important;
}

/* Formatting buttons */
.dark-theme .format-btn {
    border-color: var(--border-color) !important;
}

.dark-theme .format-btn:hover {
    background: var(--sidebar-hover-bg) !important;
    color: var(--text-color) !important;
}

.dark-theme .format-btn.active {
    background: #a05c2f !important;
    color: white !important;
}

/* Attachments */
.dark-theme .attachment-preview,
.dark-theme .attachment-item {
    background: var(--sidebar-bg) !important;
    border-color: var(--border-color) !important;
}

.dark-theme .attachment-name,
.dark-theme .attachment-item i,
.dark-theme .attachment-item a {
    color: var(--text-color) !important;
}

/* Modal overlays with better contrast */
.dark-theme .modal {
    background: rgba(0,0,0,0.7) !important;
}

.dark-theme .modal-content.image-gallery-modal {
    background: var(--card-bg) !important;
    color: var(--text-color) !important;
    border: 2px solid var(--border-color);
}

/* Status badges and notifications */
.dark-theme .unread-badge {
    background: #e85959 !important;
    color: white !important;
}

/* Toast notifications */
.dark-theme .toast.success { background-color: rgba(76, 175, 80, 0.9) !important; }
.dark-theme .toast.error { background-color: rgba(244, 67, 54, 0.9) !important; }
.dark-theme .toast.info { background-color: rgba(33, 150, 243, 0.9) !important; }
.dark-theme .toast.warning { background-color: rgba(255, 152, 0, 0.9) !important; }

.dark-theme .toast-message {
    color: white !important;
}

.dark-theme .toast-close:hover {
    background: rgba(255,255,255,0.1) !important;
}

/* Messages Interface Styles */

.email-container {
    padding: 24px;
    max-width: 1400px;
    margin: 0 auto;
    height: calc(100vh - 120px);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.email-header {
    margin-bottom: 24px;
}

.email-header h2 {
    color: #333;
    font-size: 28px;
    font-weight: 700;
    margin: 0 0 8px 0;
    display: flex;
    align-items: center;
    gap: 12px;
}

.email-header h2 i {
    color: #a05c2f;
}

.email-header p {
    color: #666;
    font-size: 16px;
    margin: 0;
}

.email-grid {
    display: grid;
    grid-template-columns: 350px 1fr;
    gap: 24px;
    flex: 1;
    min-height: 0;
}

.inbox-panel {
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

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

.inbox-header h3 {
    margin: 0;
    color: #333;
    font-size: 18px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
}

.inbox-header h3 i {
    color: #a05c2f;
}

.btn-compose {
    background: #a05c2f;
    color: white;
    border: none;
    padding: 10px 16px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    width: 36%;
}

.btn-compose:hover {
    background: #8b4a26;
    transform: translateY(-2px);
}

.message-view {
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.message-placeholder {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    color: #999;
    padding: 40px;
}

.message-placeholder i {
    font-size: 64px;
    margin-bottom: 24px;
    opacity: 0.5;
}

.message-placeholder h3 {
    margin: 0 0 8px 0;
    font-size: 24px;
    font-weight: 600;
}

.message-placeholder p {
    margin: 0;
    font-size: 16px;
}

/* Loading message styles */
.message-loading {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    color: #666;
    padding: 40px;
}

.message-loading i {
    font-size: 48px;
    margin-bottom: 24px;
    color: #a05c2f;
}

.message-loading h3 {
    margin: 0 0 8px 0;
    font-size: 24px;
    font-weight: 600;
}

/* Email message display styles */
.email-message-thread {
    flex: 1;
    overflow-y: auto;
    padding: 0;
}

.email-message {
    border-bottom: 1px solid #f0f0f0;
    padding: 24px;
}

.email-message:last-child {
    border-bottom: none;
}

.email-message-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
}

.email-message-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: #a05c2f;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 16px;
    flex-shrink: 0;
}

.email-message-info {
    flex: 1;
}

.email-message-sender {
    font-weight: 600;
    color: #333;
    margin: 0 0 4px 0;
    font-size: 16px;
}

.email-message-time {
    color: #666;
    font-size: 14px;
    margin: 0;
}

.email-message-subject {
    font-size: 18px;
    font-weight: 600;
    color: #333;
    margin: 0 0 12px 0;
    padding: 8px 0;
    border-bottom: 1px solid #e1e5e9;
}

.email-message-content {
    color: #555;
    line-height: 1.6;
    margin: 0 0 16px 0;
}

.email-message-attachments {
    margin-top: 16px;
}

.email-message-attachments h4 {
    margin: 0 0 8px 0;
    font-size: 14px;
    font-weight: 600;
    color: #666;
}

.email-reply-btn {
    background: #6c757d;
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 6px;
    font-size: 14px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.3s;
    margin-top: 16px;
    width: 9vh;
}

.email-reply-btn:hover {
    background: #5a6268;
    transform: translateY(-2px);
}

/* Reply to Conversation button - more prominent */
.reply-to-conversation-btn {
    background: #a05c2f;
    color: white;
    border: none;
    padding: 12px 20px;
    border-radius: 8px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.3s;
    margin-top: 20px;
    box-shadow: 0 2px 4px rgba(160, 92, 47, 0.2);
}

.reply-to-conversation-btn:hover {
    background: #8b4a26;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(160, 92, 47, 0.3);
}

.reply-to-conversation-btn:active {
    transform: translateY(0);
    box-shadow: 0 2px 4px rgba(160, 92, 47, 0.2);
}



/* Compose modal enhancements */
.email-compose-modal .modal-content {
    max-width: 1200px;
}

/* Reply modal enhancements */
.email-reply-modal .modal-content {
    max-width: 1200px;
}

.compose-toolbar {
    display: flex;
    gap: 4px;
    padding: 8px;
    background: #f8f9fa;
    border: 1px solid #e1e5e9;
    border-radius: 8px;
    margin-bottom: 8px;
    flex-wrap: wrap;
}

.compose-toolbar .format-btn {
    background: none;
    border: 1px solid #ddd;
    border-radius: 4px;
    width: 32px;
    height: 32px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #666;
    transition: all 0.2s;
}

.compose-toolbar .format-btn:hover {
    background: #e9ecef;
    border-color: #a05c2f;
    color: #a05c2f;
}

.compose-toolbar .format-btn.active {
    background: #a05c2f;
    border-color: #a05c2f;
    color: white;
}

.toolbar-separator {
    width: 1px;
    height: 24px;
    background: #ddd;
    margin: 4px 8px;
}

/* Reply quote styling */
.reply-quote {
    background: #f8f9fa;
    border-left: 4px solid #a05c2f;
    padding: 12px 16px;
    margin-bottom: 16px;
    font-style: italic;
    color: #666;
}

.recipient-display {
    font-weight: 600;
    color: #333;
    padding: 8px 12px;
    background: #f8f9fa;
    border-radius: 6px;
    border: 1px solid #e1e5e9;
}

/* Legacy styles for backward compatibility */
.messages-container {
    padding: 24px;
    max-width: 1400px;
    margin: 0 auto;
    height: calc(100vh - 120px);
    display: flex;
    flex-direction: column;
}

.messages-header {
    margin-bottom: 24px;
}

.messages-header h2 {
    color: #333;
    font-size: 28px;
    font-weight: 700;
    margin: 0 0 8px 0;
}

.messages-header p {
    color: #666;
    font-size: 16px;
    margin: 0;
}

.messages-grid {
    display: grid;
    grid-template-columns: 350px 1fr;
    gap: 24px;
    flex: 1;
    min-height: 0;
}

@media (max-width: 1024px) {
    .messages-grid {
        grid-template-columns: 300px 1fr;
    }
}

@media (max-width: 768px) {
    .messages-grid {
        grid-template-columns: 1fr;
    }
    .conversations-panel {
        display: none;
    }
}

.conversations-panel {
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

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

.conversations-header h3 {
    margin: 0;
    color: #333;
    font-size: 18px;
    font-weight: 600;
}

.btn-new-conversation {
    background: #a05c2f;
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.3s;
}

.btn-new-conversation:hover {
    background: #8b4a26;
    transform: translateY(-2px);
}

.conversations-list {
    flex: 1;
    overflow-y: auto;
    padding: 0;
}

.conversation-item {
    padding: 16px 20px;
    border-bottom: 1px solid #f0f0f0;
    cursor: pointer;
    transition: background 0.2s;
    display: flex;
    align-items: center;
    gap: 12px;
}

.conversation-item:hover,
.conversation-item.active {
    background: #f8f9fa;
}

.conversation-item:active {
    background: #e9ecef;
    transform: scale(0.98);
}

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

.conversation-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: #a05c2f;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 16px;
    flex-shrink: 0;
}

.conversation-info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.conversation-name {
    font-weight: 600;
    color: #333;
    margin: 0 0 4px 0;
    font-size: 15px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.unread-badge {
    background: #dc3545;
    color: white;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 600;
    padding: 2px 6px;
    min-width: 16px;
    text-align: center;
    animation: unreadBounce 2s infinite;
    align-self: center;
    display: flex;
    align-items: center;
    justify-content: center;
}

@keyframes unreadBounce {
    0%, 20%, 50%, 80%, 100% {
        transform: scale(1);
    }
    40% {
        transform: scale(1.1);
    }
    60% {
        transform: scale(1.05);
    }
}

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

.conversation-time {
    color: #999;
    font-size: 12px;
    flex-shrink: 0;
}

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

.no-conversations i {
    font-size: 48px;
    margin-bottom: 16px;
    display: block;
}

.no-conversations p {
    margin: 0 0 8px 0;
    font-size: 16px;
    font-weight: 600;
}

.no-conversations small {
    font-size: 14px;
}

.chat-panel {
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.chat-placeholder {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    color: #999;
    padding: 40px;
}

.chat-placeholder i {
    font-size: 64px;
    margin-bottom: 24px;
    opacity: 0.5;
}

.chat-placeholder h3 {
    margin: 0 0 8px 0;
    font-size: 24px;
    font-weight: 600;
}

.chat-placeholder p {
    margin: 0;
    font-size: 16px;
}

.chat-header {
    padding: 20px;
    border-bottom: 1px solid #e1e5e9;
    display: flex;
    align-items: center;
    gap: 12px;
}

.chat-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: #a05c2f;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 16px;
}

.chat-info h3 {
    margin: 0 0 4px 0;
    font-size: 18px;
    font-weight: 600;
    color: #333;
}

.chat-info p {
    margin: 0;
    font-size: 14px;
    color: #666;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.message {
    display: flex;
    gap: 12px;
    max-width: 70%;
}

.message.own {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.message-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: #a05c2f;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 14px;
    flex-shrink: 0;
}

.message-content {
    background: #f8f9fa;
    padding: 12px 16px;
    border-radius: 16px;
    position: relative;
}

.message.own .message-content {
    background: #a05c2f;
    color: white;
}

.message-text {
    margin: 0;
    font-size: 14px;
    line-height: 1.4;
    word-wrap: break-word;
}

.message-time {
    font-size: 12px;
    color: #999;
    margin-top: 4px;
    text-align: right;
}

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

.message-attachment {
    margin-top: 8px;
    padding: 8px 12px;
    background: rgba(0,0,0,0.05);
    border-radius: 8px;
    display: flex;
    align-items: center;
    gap: 8px;
}

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

.message-attachment i {
    color: #666;
}

.message-attachment a {
    color: #007bff;
    text-decoration: none;
    font-weight: 500;
}

.message-attachment a:hover {
    text-decoration: underline;
}

.chat-input-area {
    padding: 20px;
    border-top: 1px solid #e1e5e9;
    background: #f8f9fa;
}

.chat-form {
    display: flex;
    gap: 12px;
    align-items: flex-end;
}

.message-input-section {
    flex: 3;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.chat-format-tools {
    display: flex;
    gap: 8px;
    padding: 4px 8px;
    background: #f8f9fa;
    border-radius: 8px;
    border: 1px solid #e1e5e9;
}

.message-input-container {
    position: relative;
}

.message-input {
    width: 100%;
    min-height: 44px;
    max-height: 120px;
    padding: 12px 16px;
    border: 2px solid #e1e1e1;
    border-radius: 22px;
    font-size: 14px;
    resize: none;
    outline: none;
    transition: border-color 0.3s;
    font-family: inherit;
}

.message-input:focus {
    border-color: #a05c2f;
}

.file-input-container {
    position: relative;
}

.file-input {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

.file-btn {
    background: #6c757d;
    color: white;
    border: none;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s;
}

.file-btn:hover {
    background: #5a6268;
    transform: translateY(-2px);
}

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

.send-btn:hover {
    background: #8b4a26;
    transform: translateY(-2px);
}

.send-btn:disabled {
    background: #ccc;
    cursor: not-allowed;
    transform: none;
}
.main-content{
    min-height: 90vh;
}

/* Modal Styles */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    z-index: 1000;
    align-items: center;
    justify-content: center;
}

.modal.show {
    display: flex;
}

.modal-content {
    background: white;
    border-radius: 12px;
    width: 90%;
    max-width: 800px;
    max-height: 90vh;
    overflow: hidden;
    box-shadow: 0 10px 40px rgba(0,0,0,0.2);
}

/* Image Gallery Modal Styles */
.modal-content.image-gallery-modal {
    max-width: 90vw;
    max-height: 90vh;
    background: white;
    color: #000;
}

.modal-content.image-gallery-modal .modal-close {
    width: 3%;
    color: gray;
}

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

.modal-header h3 {
    margin: 0;
    font-size: 20px;
    font-weight: 600;
}

.modal-close {
    background: none;
    border: none;
    font-size: 20px;
    cursor: pointer;
    color: #666;
    padding: 4px;
    border-radius: 4px;
    transition: all 0.2s;
    width: 10%;
}

.modal-close:hover {
    background: #f0f0f0;
    color: #333;
}

.modal-body {
    padding: 20px;
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: #333;
    font-size: 14px;
}

.form-group select,
.form-group textarea {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid #e1e1e1;
    border-radius: 8px;
    font-size: 14px;
    transition: border-color 0.3s;
    box-sizing: border-box;
    font-family: inherit;
}

.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: #a05c2f;
}

.form-actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
    margin-top: 24px;
}

.btn-primary, .btn-secondary {
    padding: 6px 12px;
    border: none;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
}

.btn-primary {
    background: #a05c2f;
    color: white;
}

.btn-primary:hover {
    background: #8b4a26;
    transform: translateY(-2px);
}

.btn-secondary {
    background: #6c757d;
    color: white;
}

.btn-secondary:hover {
    background: #5a6268;
    transform: translateY(-2px);
}

.format-tools {
    display: flex;
    gap: 8px;
    margin-bottom: 8px;
    padding: 8px;
    background: #f8f9fa;
    border-radius: 8px;
    border: 1px solid #e1e5e9;
}

.format-btn {
    background: none;
    border: 1px solid #ddd;
    border-radius: 4px;
    width: 32px;
    height: 32px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #666;
    transition: all 0.2s;
}

.format-btn:hover {
    background: #e9ecef;
    border-color: #a05c2f;
    color: #a05c2f;
}

.format-btn.active {
    background: #a05c2f;
    border-color: #a05c2f;
    color: white;
}

.attachment-section {
    margin-top: 12px;
}

.file-attach-btn {
    background: #6c757d;
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 6px;
    font-size: 14px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.3s;
}

.file-attach-btn:hover {
    background: #5a6268;
    transform: translateY(-2px);
}

.attachment-preview {
    margin-bottom: 12px;
    padding: 12px;
    background: #fff;
    border-radius: 8px;
    border: 1px solid #e1e5e9;
}

.attachment-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.attachment-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 10px;
    background: #f8f9fa;
    border-radius: 6px;
    border: 1px solid #e1e5e9;
    font-size: 14px;
}

.attachment-name {
    flex: 1;
    min-width: 15vh;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: #333;
}

.image-preview {
    min-width: 20vh;
}

.attachment-thumbnail {
    min-width: 30vh;
}

.attachment-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    opacity: 0;
    transition: opacity 0.3s;
    cursor: pointer;
}

.image-preview:hover .attachment-overlay {
    opacity: 1;
}

.attachment-item.image-preview {
    position: relative;
}

.attachment-remove {
    background: none;
    border: none;
    color: #999;
    cursor: pointer;
    padding: 2px;
    border-radius: 2px;
    transition: all 0.2s;
}

.attachment-remove:hover {
    background: #dc3545;
    color: white;
}

/* Responsive */
@media (max-width: 768px) {
    .messages-container {
        padding: 16px;
        height: calc(100vh - 100px);
    }

    .chat-messages {
        padding: 16px;
    }

    .chat-input-area {
        padding: 16px;
    }

    .modal-content {
        width: 95%;
        margin: 20px;
    }

    .attachment-list {
        flex-direction: column;
    }

    .attachment-item {
        justify-content: space-between;
    }
}

/* Toast Notifications */
.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 10000;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.toast {
    min-width: 300px;
    max-width: 500px;
    padding: 12px 16px;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    color: white;
    font-weight: 500;
    display: flex;
    align-items: center;
    justify-content: space-between;
    animation: toastSlideIn 0.3s ease-out;
    font-family: 'Aeonik', sans-serif;
}

.toast.success {
    background-color: #4CAF50;
}

.toast.error {
    background-color: #f44336;
}

.toast.info {
    background-color: #2196F3;
}

.toast.warning {
    background-color: #ff9800;
}

.toast-icon {
    margin-right: 12px;
    font-size: 18px;
}

.toast-message {
    flex: 1;
    font-size: 14px;
}

.toast-close {
    background: none;
    border: none;
    color: white;
    cursor: pointer;
    font-size: 16px;
    margin-left: 12px;
    opacity: 0.8;
    transition: opacity 0.2s;
    width: 5vh;
}

.toast-close:hover {
    opacity: 1;
    background: none;
}

@keyframes toastSlideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

.toast.fade-out {
    animation: toastFadeOut 0.3s ease-in forwards;
}

@keyframes toastFadeOut {
    from {
        transform: translateX(0);
        opacity: 1;
    }
    to {
        transform: translateX(100%);
        opacity: 0;
    }
}

/* Centered Error Message Styles */
.centered-error-message {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    animation: fadeIn 0.3s ease-out;
}

.centered-error-content {
    background: white;
    border-radius: 12px;
    padding: 24px;
    max-width: 400px;
    width: 90%;
    text-align: center;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    position: relative;
    border: 2px solid #f44336;
}

.error-icon {
    font-size: 48px;
    color: #f44336;
    margin-bottom: 16px;
}

.error-text {
    font-size: 18px;
    color: #333;
    margin-bottom: 20px;
    line-height: 1.4;
    font-weight: 500;
}

.error-close-btn {
    position: absolute;
    top: 12px;
    right: 12px;
    background: none;
    border: none;
    font-size: 20px;
    color: #666;
    cursor: pointer;
    padding: 4px;
    border-radius: 50%;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.error-close-btn:hover {
    background: #f0f0f0;
    color: #333;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

/* Dark theme support for centered error */
.dark-theme .centered-error-content {
    background: var(--card-bg);
    color: var(--text-color);
    border-color: #f44336;
}

.dark-theme .error-text {
    color: var(--text-color);
}

.dark-theme .error-close-btn:hover {
    background: var(--sidebar-hover-bg);
    color: var(--text-color);
}

/* Mobile-Responsive Styles */

/* 320px - Extra Small Mobile */
@media (max-width: 320px) {
    .messages-container, .email-container {
        flex-direction: column;
        height: auto;
    }
    
    .conversations-panel, .inbox-panel {
        width: 100%;
        min-height: auto;
        max-height: 200px;
    }
    
    .chat-panel, .message-view {
        width: 100%;
        min-height: auto;
    }
    
    .message-input {
        font-size: 14px;
        padding: 8px;
        min-height: 40px;
    }
    
    .send-btn {
        min-height: 40px;
        font-size: 12px;
    }
}

/* 480px - Small Mobile */
@media (max-width: 480px) {
    .messages-container, .email-container {
        flex-direction: column;
        height: auto;
    }
    
    .conversations-panel, .inbox-panel {
        width: 100%;
        max-height: 250px;
        border-right: none;
        border-bottom: 1px solid #e1e5e9;
    }
    
    .chat-panel, .message-view {
        width: 100%;
        min-height: 300px;
    }
    
    .chat-header, .inbox-header {
        padding: 12px;
        font-size: 16px;
    }
    
    .message-input {
        font-size: 16px;
        padding: 10px;
        min-height: 44px;
    }
    
    .send-btn {
        min-height: 44px;
        min-width: 44px;
        padding: 10px;
    }
    
    .message-content {
        max-width: 85%;
        padding: 8px 12px;
        font-size: 14px;
    }
}

/* 600px - Large Mobile / Small Tablet */
@media (max-width: 600px) {
    .messages-container, .email-container {
        flex-direction: column;
    }
    
    .conversations-panel, .inbox-panel {
        width: 100%;
        max-height: 300px;
    }
    
    .message-input {
        font-size: 16px;
        min-height: 44px;
    }
}

/* =============================================== */
/* ENHANCED MOBILE RESPONSIVE STYLES */
/* =============================================== */

.mobile-only {
    display: none;
}

/* 768px - Tablet & Mobile */
@media (max-width: 768px) {
    .mobile-only {
        display: block !important;
    }
    .email-container {
        padding: 16px;
        height: auto;
        min-height: calc(100vh - 140px);
        padding-bottom: 80px;
    }

    .email-header {
        margin-bottom: 16px;
    }

    .email-header h2 {
        font-size: 22px;
    }

    .email-grid {
        display: flex;
        flex-direction: column;
        gap: 16px;
        height: auto;
    }

    .inbox-panel {
        width: 100%;
        max-height: none;
        border-radius: 12px;
        display: block;
    }

    .email-grid.mobile-view-active .inbox-panel {
        display: none;
    }

    .inbox-panel.collapsed {
        max-height: 70px;
        overflow: hidden;
    }

    .inbox-panel.collapsed .conversations-list {
        display: none;
    }

    .inbox-header {
        padding: 16px;
        cursor: pointer;
    }

    .inbox-header h3 {
        font-size: 16px;
    }

    .btn-compose {
        padding: 8px 12px;
        font-size: 13px;
        width: auto;
    }

    .btn-compose i {
        font-size: 14px;
    }

    .conversations-list {
        max-height: 250px;
        overflow-y: auto;
    }

    .conversation-item {
        padding: 12px 16px;
    }

    .conversation-name {
        font-size: 14px;
    }

    .conversation-last-message {
        font-size: 12px;
    }

    .message-view {
        width: 100%;
        min-height: 400px;
        flex: 1;
        display: none;
    }

    .email-grid.mobile-view-active .message-view {
        display: flex;
        flex-direction: column;
        height: calc(100vh - 140px);
    }

    .message-placeholder {
        padding: 40px 20px;
    }

    .message-placeholder i {
        font-size: 48px;
    }

    .message-placeholder h3 {
        font-size: 18px;
    }

    .message-placeholder p {
        font-size: 14px;
    }

    /* Email message thread styles */
    .email-messages-list {
        padding: 16px;
    }

    .email-message {
        padding: 16px;
        margin-bottom: 12px;
    }

    .email-message-header {
        flex-direction: column;
        gap: 8px;
        align-items: flex-start;
    }

    .email-message-sender {
        font-size: 14px;
    }

    .email-message-time {
        font-size: 11px;
    }

    .email-message-content {
        font-size: 14px;
        line-height: 1.6;
    }

    /* Reply area */
    .reply-area {
        padding: 16px;
    }

    .reply-textarea {
        min-height: 100px;
        font-size: 14px;
    }

    /* Messages grid padding */
    .messages-grid {
        padding-bottom: 80px;
    }

    .main-container {
        padding-bottom: 80px;
    }

    /* Modal adjustments */
    .modal-content {
        width: 95%;
        max-width: 100%;
        margin: 10px auto;
        max-height: calc(100vh - 100px);
        overflow-y: auto;
        border-radius: 12px;
    }

    .modal-header {
        padding: 16px 20px;
        position: sticky;
        top: 0;
        background: #fff;
        z-index: 10;
    }

    .modal-header h3 {
        font-size: 18px;
    }

    .modal-body {
        padding: 16px 20px;
    }

    .email-compose-modal {
        width: 95%;
        max-height: calc(100vh - 80px);
    }

    .compose-toolbar {
        flex-wrap: wrap;
        gap: 4px;
        padding: 8px;
    }

    .format-btn {
        width: 36px;
        height: 36px;
        min-width: 36px;
    }

    .form-group label {
        font-size: 14px;
        margin-bottom: 6px;
    }

    .form-group input,
    .form-group select,
    .form-group textarea {
        font-size: 16px;
        padding: 12px;
        min-height: 44px;
    }

    .form-group textarea {
        min-height: 120px;
    }

    .form-actions {
        flex-direction: column;
        gap: 10px;
        padding: 16px 0 0;
    }

    .form-actions button {
        width: 100%;
        padding: 14px;
        font-size: 15px;
        min-height: 48px;
    }

    .btn-primary, .btn-secondary {
        justify-content: center;
    }

    /* Attachment section */
    .attachment-section {
        margin-top: 12px;
    }

    .file-attach-btn {
        width: 100%;
        padding: 12px;
        justify-content: center;
    }

    .attachment-preview {
        flex-direction: column;
    }

    .attachment-item {
        width: 100%;
    }

    /* No conversations state */
    .no-conversations {
        padding: 30px 20px;
    }

    .no-conversations i {
        font-size: 36px;
    }

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

    .no-conversations small {
        font-size: 12px;
    }
}

/* 480px - Small Mobile */
@media (max-width: 480px) {
    .email-container {
        padding: 12px;
        padding-bottom: 90px;
    }

    .email-header h2 {
        font-size: 20px;
    }

    .email-grid {
        gap: 12px;
    }

    .inbox-header {
        padding: 12px;
    }

    .inbox-header h3 {
        font-size: 15px;
    }

    .btn-compose {
        padding: 8px 10px;
        font-size: 12px;
    }

    .btn-compose span {
        display: none;
    }

    .conversation-item {
        padding: 10px 12px;
    }

    .conversation-avatar {
        width: 36px;
        height: 36px;
        font-size: 14px;
    }

    .message-view {
        min-height: 350px;
    }

    .modal-content {
        margin: 5px;
        max-height: calc(100vh - 60px);
    }

    .compose-toolbar {
        padding: 6px;
    }

    .format-btn {
        width: 32px;
        height: 32px;
        min-width: 32px;
    }

    .toolbar-separator {
        display: none;
    }

    /* Image gallery */
    .image-gallery-modal {
        width: 100%;
        height: 100%;
        max-width: 100%;
        max-height: 100%;
        border-radius: 0;
        margin: 0;
    }

    .gallery-nav {
        width: 40px;
        height: 40px;
    }
}

/* Touch Device Optimizations */
@media (hover: none) and (pointer: coarse) {
    .send-btn {
        min-height: 48px;
        min-width: 48px;
    }
    
    .message-input {
        font-size: 16px;
        min-height: 48px;
        padding: 12px;
    }

    .conversation-item {
        min-height: 60px;
    }

    .btn-compose {
        min-height: 44px;
    }

    .format-btn {
        min-height: 44px;
        min-width: 44px;
    }

    .modal-close {
        min-height: 44px;
        min-width: 44px;
    }
}
