/* ============================================
   PROFESSIONAL MESSAGES TABLE DESIGN
   ============================================ */

/* Table Container & Card */
.messages-table {
    font-size: 0.8rem;
    border-collapse: separate;
    border-spacing: 0;
}

.messages-table .card {
    border-radius: 1rem;
    overflow: hidden;
}

/* Table Header - Premium Gradient Design */
.messages-table thead {
    background: linear-gradient(135deg, #10b981 0%, #aaaa00 100%);
    position: relative;
}

.messages-table thead::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, #10b981, #aaaa00, #aaaa00);
}

.messages-table thead th {
    font-weight: 700;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: white;
    border: none !important;
    white-space: nowrap;
    padding: 0.75rem 0.5rem !important;
    background: transparent;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

/* Table Body Rows - Compact */
.messages-table tbody tr {
    border: none;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    background: white;
}

.messages-table tbody tr:not(:last-child) {
    border-bottom: 1px solid #f1f5f9;
}

.messages-table tbody tr:hover {
    background: linear-gradient(to right, #fafbfc, #ffffff) !important;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.06);
    /* Remove scale to avoid bleed outside rounded card and keep table alignment tight */
    transform: none;
}

.messages-table tbody td {
    padding: 0.5rem 0.5rem !important;
    vertical-align: middle;
    border: none !important;
}

/* Unread Row Highlighting - Elegant Orange Accent */
.table-row-unread {
    /* Simplified unread styling for consistent alignment */
    background-color: rgba(251,146,60,0.06) !important;
    position: relative;
    box-shadow: inset 3px 0 0 #fb923c;
}

/* Remove pseudo-element to avoid overflow beyond table border radius */
.table-row-unread::before { content: none; }

.table-row-unread:hover {
    background: linear-gradient(to right, 
        rgba(251, 146, 60, 0.12) 0%, 
        rgba(251, 146, 60, 0.04) 30%, 
        rgba(250, 250, 250, 1) 100%) !important;
}

/* Status Badges - Modern Pill Design */
.badge-status {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.3rem 0.7rem;
    border-radius: 2rem;
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    white-space: nowrap;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    transition: all 0.3s ease;
}

.badge-status:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.badge-status i {
    font-size: 0.65rem;
}

.badge-read {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    color: white;
}

.badge-unread {
    background: linear-gradient(135deg, #fb923c 0%, #f59e0b 100%);
    color: white;
    animation: pulseGlow 2s ease-in-out infinite;
}

@keyframes pulseGlow {
    0%, 100% {
        box-shadow: 0 2px 8px rgba(251, 146, 60, 0.3);
    }
    50% {
        box-shadow: 0 4px 16px rgba(251, 146, 60, 0.5);
    }
}

/* User Cell - Professional Avatar + Info */
.user-cell {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    min-width: 180px;
}

.user-avatar {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    background: linear-gradient(135deg, #10b981 0%, #aaaa00 100%);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.875rem;
    font-weight: 700;
    flex-shrink: 0;
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.3);
    transition: all 0.3s ease;
}

.user-cell:hover .user-avatar {
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.user-info {
    display: flex;
    flex-direction: column;
    gap: 0.1rem;
    min-width: 0;
    flex: 1;
}

.user-name {
    font-weight: 700;
    color: #1e293b;
    font-size: 0.8rem;
    line-height: 1.2;
}

.user-email {
    font-size: 0.7rem;
    color: #64748b;
    text-decoration: none;
    transition: all 0.2s ease;
}

.user-email:hover {
    color: #10b981;
    transform: translateX(2px);
}

/* Subject Cell - Clean Typography */
.subject-cell {
    font-weight: 600;
    color: #334155;
    font-size: 0.75rem;
    max-width: 150px;
    line-height: 1.3;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Message Preview - Elegant Text Truncation */
.message-preview-cell {
    color: #64748b;
    max-width: 350px;
    line-height: 1.6;
    font-size: 0.875rem;
}

/* Device Cell - Compact Icon List */
.device-cell {
    display: flex;
    flex-direction: row;
    gap: 0.5rem;
    align-items: center;
    min-width: 140px;
    white-space: nowrap;
}

.device-item {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    font-size: 0.65rem;
    color: #475569;
    padding: 0;
    transition: all 0.2s ease;
}

.device-item:hover {
    color: #1e293b;
    transform: translateX(2px);
}

.device-item i {
    width: 14px;
    text-align: center;
    font-size: 0.8rem;
}

/* Brand Colors for Tech Icons */
.device-item .fa-chrome { color: #4285F4; }
.device-item .fa-firefox { color: #FF7139; }
.device-item .fa-safari { color: #006CFF; }
.device-item .fa-edge { color: #0078D7; }
.device-item .fa-opera { color: #FF1B2D; }
.device-item .fa-windows { color: #0078D6; }
.device-item .fa-apple { color: #000000; }
.device-item .fa-linux { color: #FCC624; }
.device-item .fa-android { color: #3DDC84; }
.device-item .fa-desktop,
.device-item .fa-mobile-alt,
.device-item .fa-tablet-alt { color: #94a3b8; }

/* IP Badge - Modern Code Style */
.ip-badge {
    background: linear-gradient(135deg, #f8fafc, #f1f5f9);
    padding: 0.3rem 0.6rem;
    border-radius: 4px;
    font-size: 0.65rem;
    color: #475569;
    border: 1px solid #e2e8f0;
    font-family: 'SF Mono', 'Monaco', 'Cascadia Code', 'Courier New', monospace;
    font-weight: 600;
    white-space: nowrap;
    display: inline-block;
    transition: all 0.2s ease;
}

.ip-badge:hover {
    background: linear-gradient(135deg, #e0e7ff, #ddd6fe);
    border-color: #c7d2fe;
    transform: translateY(-1px);
}

/* Date Cell - Inline Time Display */
.date-cell {
    display: flex;
    flex-direction: row;
    gap: 0.25rem;
    align-items: center;
    min-width: 110px;
    white-space: nowrap;
}

.date-day {
    font-weight: 700;
    color: #1e293b;
    font-size: 0.7rem;
    letter-spacing: 0.2px;
}

.date-time {
    font-size: 0.65rem;
    color: #94a3b8;
    font-weight: 500;
}

/* Action Buttons - Premium Icon Buttons */
.action-buttons {
    display: flex;
    gap: 0.375rem;
    justify-content: center;
    align-items: center;
}

.btn-icon {
    width: 28px;
    height: 28px;
    padding: 0;
    border: none;
    border-radius: 6px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.7rem;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    cursor: pointer;
    position: relative;
    overflow: hidden;
}

.btn-icon::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.3);
    transform: translate(-50%, -50%);
    transition: width 0.6s, height 0.6s;
}

.btn-icon:hover::before {
    width: 80px;
    height: 80px;
}

.btn-icon:hover {
    transform: translateY(-3px) scale(1.05);
}

.btn-icon:active {
    transform: translateY(-1px) scale(0.98);
}

.btn-icon-success {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    color: white;
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);
}

.btn-icon-success:hover {
    box-shadow: 0 6px 20px rgba(16, 185, 129, 0.4);
}

.btn-icon-danger {
    background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
    color: white;
    box-shadow: 0 4px 12px rgba(239, 68, 68, 0.3);
}

.btn-icon-danger:hover {
    box-shadow: 0 6px 20px rgba(239, 68, 68, 0.4);
}

/* Empty State - Elegant No Data Display */
.empty-table-state {
    padding: 4rem 2rem;
    text-align: center;
}

.empty-table-state i {
    color: #cbd5e1;
    margin-bottom: 1.5rem;
}

.empty-table-state p {
    color: #94a3b8;
    font-weight: 500;
}

/* Responsive Design - Mobile Optimization */
@media (max-width: 1400px) {
    .message-preview-cell {
        max-width: 150px;
    }

    .subject-cell {
        max-width: 120px;
    }
}

@media (max-width: 1200px) {
    .messages-table {
        font-size: 0.8rem;
    }

    .user-cell {
        min-width: 160px;
    }

    .device-cell {
        min-width: 120px;
    }

    .user-avatar {
        width: 28px;
        height: 28px;
        font-size: 0.75rem;
    }
}

@media (max-width: 992px) {
    .messages-table thead th {
        font-size: 0.65rem;
        padding: 0.5rem 0.4rem !important;
    }

    .messages-table tbody td {
        padding: 0.4rem 0.4rem !important;
    }

    .badge-status {
        padding: 0.25rem 0.5rem;
        font-size: 0.6rem;
    }

    .btn-icon {
        width: 24px;
        height: 24px;
        font-size: 0.6rem;
    }
}

@media (max-width: 768px) {
    .user-avatar {
        width: 24px;
        height: 24px;
        font-size: 0.7rem;
    }

    .user-cell {
        gap: 0.25rem;
        min-width: 140px;
    }

    .device-cell {
        font-size: 0.6rem;
        gap: 0.25rem;
    }
}

/* ============================================
   VIEW BUTTON - PRIMARY ACTION
   ============================================ */
.btn-icon-primary {
    background: linear-gradient(135deg, #10b981 0%, #aaaa00 100%);
    color: white;
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);
}

.btn-icon-primary:hover {
    box-shadow: 0 6px 20px rgba(16, 185, 129, 0.4);
}

/* ============================================
   COMPACT MESSAGE MODAL
   ============================================ */

.message-modal .modal-content {
    border: none;
    border-radius: 0.75rem;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
    overflow: hidden;
}

.message-modal .modal-header {
    background: linear-gradient(135deg, #10b981 0%, #aaaa00 100%);
    color: white;
    padding: 1rem 1.25rem;
    border-bottom: none;
}

.message-modal .modal-title {
    font-size: 1rem;
    font-weight: 600;
    margin: 0;
    color: white;
}

.message-modal .btn-close {
    filter: brightness(0) invert(1);
    opacity: 0.8;
}

.message-modal .btn-close:hover {
    opacity: 1;
}

/* Modal Body - Simple Inline Layout */
.message-modal .modal-body {
    padding: 1.5rem;
    background: white;
}

.message-details-simple {
    display: flex;
    flex-direction: column;
    gap: 0;
}

/* Inline Detail Rows */
.detail-row-inline {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.5rem;
    padding: 0.75rem 0;
    font-size: 0.8125rem;
    line-height: 1.6;
}

.detail-label-inline {
    font-weight: 700;
    color: #10b981;
}

.detail-value-inline {
    color: #334155;
}

.separator-inline {
    color: #cbd5e1;
    margin: 0 0.25rem;
    font-weight: 400;
}

/* Block Detail Rows (for message) */
.detail-row-block {
    padding: 0.75rem 0;
}

.detail-label-block {
    font-weight: 700;
    color: #10b981;
    font-size: 0.8125rem;
    margin-bottom: 0.625rem;
}

/* Separators between rows */
.detail-separator {
    height: 1px;
    background: linear-gradient(to right, transparent, #e2e8f0, transparent);
    margin: 0.25rem 0;
}

/* Device info inline styling */
.device-info-inline {
    display: inline-flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.375rem;
}

.device-info-inline i {
    margin-right: 0.25rem;
}

.device-info-inline .mx-2 {
    margin: 0 0.375rem;
    color: #cbd5e1;
}

.ip-code-inline {
    background: #f8fafc;
    padding: 0.25rem 0.625rem;
    border-radius: 0.375rem;
    font-size: 0.75rem;
    color: #10b981;
    border: 1px solid #e2e8f0;
    font-family: 'SF Mono', 'Monaco', monospace;
    font-weight: 600;
}

.message-text-box {
    background: #f8fafc;
    padding: 1rem;
    border-radius: 0.5rem;
    border: 1px solid #e2e8f0;
    font-size: 0.875rem;
    line-height: 1.7;
    color: #334155;
    max-height: 250px;
    overflow-y: auto;
}

.message-text-box::-webkit-scrollbar {
    width: 6px;
}

.message-text-box::-webkit-scrollbar-track {
    background: #f1f5f9;
    border-radius: 3px;
}

.message-text-box::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 3px;
}

.message-text-box::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

/* Modal Footer - Compact */
.message-modal .modal-footer {
    padding: 0.875rem 1.25rem;
    background: #f8fafc;
    border-top: 1px solid #e2e8f0;
    gap: 0.5rem;
}

.message-modal .btn-sm {
    font-size: 0.8125rem;
    padding: 0.5rem 1rem;
    border-radius: 0.375rem;
}

/* Arabic/RTL Support */
[dir="rtl"] .messages-table thead th:first-child {
    padding-right: 1.5rem !important;
    padding-left: 1rem !important;
}

[dir="rtl"] .messages-table thead th:last-child {
    padding-left: 1.5rem !important;
    padding-right: 1rem !important;
}

[dir="rtl"] .messages-table tbody td:first-child {
    padding-right: 1.5rem !important;
    padding-left: 1rem !important;
}

[dir="rtl"] .messages-table tbody td:last-child {
    padding-left: 1.5rem !important;
    padding-right: 1rem !important;
}

[dir="rtl"] .user-cell {
    flex-direction: row;
    text-align: right;
}

[dir="rtl"] .user-info {
    text-align: right;
}

[dir="rtl"] .user-email i {
    margin-right: 0;
    margin-left: 0.25rem;
}

[dir="rtl"] .device-cell {
    text-align: right;
}

[dir="rtl"] .device-item {
    flex-direction: row-reverse;
}

[dir="rtl"] .device-item i {
    margin-left: 0.35rem;
    margin-right: 0;
}

[dir="rtl"] .action-buttons {
    flex-direction: row-reverse;
}

[dir="rtl"] .table-row-unread {
    box-shadow: inset -3px 0 0 #fb923c;
}

[dir="rtl"] .modal-title i {
    margin-right: 0;
    margin-left: 0.5rem;
}

[dir="rtl"] .detail-label-compact {
    text-align: right;
}

[dir="rtl"] .detail-row-inline {
    text-align: right;
}

[dir="rtl"] .detail-label-block {
    text-align: right;
}

[dir="rtl"] .message-text-box {
    text-align: right;
    direction: rtl;
}

[dir="rtl"] .date-cell {
    text-align: right;
}

[dir="rtl"] .subject-cell {
    text-align: right;
}

[dir="rtl"] .badge-status {
    flex-direction: row-reverse;
}

[dir="rtl"] .badge-status i {
    margin-left: 0.25rem;
    margin-right: 0;
}

[dir="rtl"] .btn:not(.btn-icon) i {
    margin-right: 0 !important;
    margin-left: 0.25rem !important;
}

/* Keep icons centered in icon-only buttons */
[dir="rtl"] .btn-icon i {
    margin: 0 !important;
}

/* Responsive Modal Design */
@media (max-width: 768px) {
    .message-modal .modal-body {
        padding: 1rem;
    }

    .detail-row-inline {
        font-size: 0.75rem;
        padding: 0.625rem 0;
    }

    .detail-label-inline {
        font-size: 0.75rem;
    }

    .detail-value-inline {
        font-size: 0.75rem;
    }

    .message-text-box {
        font-size: 0.75rem;
        padding: 0.75rem;
    }

    .device-info-inline {
        font-size: 0.7rem;
    }

    .message-modal .modal-footer {
        flex-direction: column;
        gap: 0.5rem;
    }

    .message-modal .btn-sm {
        width: 100%;
    }
}

/* Message Type Badge Styles */
.badge-type {
    display: inline-block;
    padding: 0.3rem 0.6rem;
    border-radius: 4px;
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: white;
    white-space: nowrap;
}

.badge-type.type-guest {
    background: linear-gradient(135deg, #64748b, #475569);
}

.badge-type.type-user {
    background: linear-gradient(135deg, #10b981, #aaaa00);
}

.badge-type.type-member {
    background: linear-gradient(135deg, #aaaa00, #aaaa00);
}

.badge-type.type-member-pro {
    background: linear-gradient(135deg, #f59e0b, #d97706);
}

.badge-type.type-member-max {
    background: linear-gradient(135deg, #ef4444, #dc2626);
}

.badge-type.type-admin {
    background: linear-gradient(135deg, #1f2937, #111827);
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.3);
}

/* ============================================================================
   DARK MODE SUPPORT FOR MESSAGES TABLE
   ============================================================================ */

/* Table body rows */
[data-theme="dark"] .messages-table tbody tr {
    background: var(--bg-card) !important;
}

[data-theme="dark"] .messages-table tbody tr:not(:last-child) {
    border-bottom-color: var(--border-color) !important;
}

[data-theme="dark"] .messages-table tbody tr:hover {
    background: var(--bg-card-hover) !important;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2) !important;
}

[data-theme="dark"] .messages-table tbody td {
    color: var(--text-primary) !important;
}

/* Unread row styling */
[data-theme="dark"] .table-row-unread {
    background-color: rgba(251, 146, 60, 0.15) !important;
}

[data-theme="dark"] .table-row-unread:hover {
    background: linear-gradient(to right, 
        rgba(251, 146, 60, 0.25) 0%, 
        rgba(251, 146, 60, 0.1) 30%, 
        var(--bg-card-hover) 100%) !important;
}

/* User cell */
[data-theme="dark"] .user-name {
    color: var(--text-primary) !important;
}

[data-theme="dark"] .user-email {
    color: var(--text-muted) !important;
}

[data-theme="dark"] .user-email:hover {
    color: #aaaa00 !important;
}

/* Subject and message preview */
[data-theme="dark"] .subject-cell {
    color: var(--text-primary) !important;
}

[data-theme="dark"] .message-preview-cell {
    color: var(--text-secondary) !important;
}

/* Date cell */
[data-theme="dark"] .date-day {
    color: var(--text-primary) !important;
}

[data-theme="dark"] .date-time {
    color: var(--text-muted) !important;
}

/* IP badge */
[data-theme="dark"] .ip-badge {
    background: linear-gradient(135deg, #374151, #1f2937) !important;
    color: #e5e7eb !important;
    border-color: #4b5563 !important;
}

[data-theme="dark"] .ip-badge:hover {
    background: linear-gradient(135deg, #10b981, #aaaa00) !important;
    border-color: #aaaa00 !important;
}

/* Device info */
[data-theme="dark"] .device-cell {
    color: var(--text-secondary) !important;
}

[data-theme="dark"] .device-item {
    color: var(--text-secondary) !important;
}

[data-theme="dark"] .device-item:hover {
    color: var(--text-primary) !important;
}

[data-theme="dark"] .device-item .fa-apple {
    color: #d1d5db !important;
}

[data-theme="dark"] .device-item .fa-desktop,
[data-theme="dark"] .device-item .fa-mobile-alt,
[data-theme="dark"] .device-item .fa-tablet-alt {
    color: #9ca3af !important;
}

/* Modal styles */
[data-theme="dark"] .message-modal .modal-content {
    background-color: var(--bg-card) !important;
    color: var(--text-primary) !important;
}

[data-theme="dark"] .message-modal .modal-header {
    background: linear-gradient(135deg, #10b981 0%, #aaaa00 100%) !important;
}

[data-theme="dark"] .message-modal .modal-body {
    background-color: var(--bg-card) !important;
    background: var(--bg-card) !important;
    color: var(--text-primary) !important;
}

[data-theme="dark"] .message-modal .modal-footer {
    background-color: var(--bg-card) !important;
    border-top-color: var(--border-color) !important;
}

[data-theme="dark"] .message-text-box {
    background: var(--bg-body) !important;
    border-color: var(--border-color) !important;
    color: var(--text-primary) !important;
}

[data-theme="dark"] .message-text-box::-webkit-scrollbar-track {
    background: #1e293b !important;
}

[data-theme="dark"] .message-text-box::-webkit-scrollbar-thumb {
    background: #475569 !important;
}

[data-theme="dark"] .message-text-box::-webkit-scrollbar-thumb:hover {
    background: #64748b !important;
}

/* Detail rows in modal */
[data-theme="dark"] .detail-value-inline {
    color: var(--text-primary) !important;
}

[data-theme="dark"] .detail-label-inline {
    color: #aaaa00 !important;
}

[data-theme="dark"] .detail-label-block {
    color: #aaaa00 !important;
}

[data-theme="dark"] .separator-inline {
    color: var(--text-muted) !important;
}

[data-theme="dark"] .detail-separator {
    background: linear-gradient(to right, transparent, var(--border-color), transparent) !important;
}

[data-theme="dark"] .device-info-inline {
    color: var(--text-secondary) !important;
}

[data-theme="dark"] .device-info-inline .mx-2 {
    color: var(--text-muted) !important;
}

/* Type badges */
[data-theme="dark"] .badge-type {
    color: white !important;
}

/* Action buttons */
[data-theme="dark"] .action-buttons .btn-icon {
    border-color: var(--border-color) !important;
}

/* Empty state */
[data-theme="dark"] .empty-table-state {
    color: var(--text-secondary) !important;
}

[data-theme="dark"] .empty-table-state i {
    color: var(--text-muted) !important;
}

[data-theme="dark"] .empty-table-state p {
    color: var(--text-muted) !important;
}

/* IP code inline */
[data-theme="dark"] .ip-code-inline {
    background: #374151 !important;
    color: #a5b4fc !important;
    border-color: #4b5563 !important;
}

/* Text muted override */
[data-theme="dark"] .messages-table .text-muted {
    color: var(--text-muted) !important;
}

/* Message details simple container */
[data-theme="dark"] .message-details-simple {
    color: var(--text-primary) !important;
}
