/**
 * Modern Tables CSS
 * Enhanced styling for admin data tables
 */

/* Modern Table Container */
.modern-table-container {
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    overflow: hidden;
    margin-bottom: 20px;
}

.modern-table-header {
    padding: 20px 25px;
    /* Formal navy gradient */
    background: linear-gradient(135deg, #0b3d91 0%, #1a4f9c 100%);
    color: #fff;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
}

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

.modern-table-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.modern-btn {
    padding: 8px 16px;
    border-radius: 6px;
    border: none;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    text-decoration: none;
}

/* Primary button now uses formal navy */
.modern-btn-primary {
    background: #0b3d91;
    color: white;
}

.modern-btn-primary:hover {
    background: #09306f;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(11, 61, 145, 0.25);
}

.modern-btn-secondary {
    background: #2196F3;
    color: white;
}

.modern-btn-secondary:hover {
    background: #0b7dda;
}

.modern-btn-danger {
    background: #f44336;
    color: white;
}

.modern-btn-danger:hover {
    background: #da190b;
}

/* Additional color variants used across views */
.modern-btn-success {
    background: #28a745;
    color: white;
}

.modern-btn-success:hover {
    background: #218838;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(40, 167, 69, 0.25);
}

.modern-btn-warning {
    background: #f39c12;
    color: white;
}

.modern-btn-warning:hover {
    background: #d48806;
}

.modern-btn-info {
    background: #00bcd4;
    color: white;
}

.modern-btn-info:hover {
    background: #00acc1;
}

/* Modern Table */
.modern-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
}

/* أنماط عامة لجميع عناوين الجداول لضمان الوضوح */
table th, table thead th {
    background: #4a90e2 !important;
    color: white !important;
    font-weight: 600 !important;
    text-shadow: 0 1px 2px rgba(0,0,0,0.2) !important;
    border: none !important;
}

.modern-table thead {
    background: #4a90e2; /* أزرق هادئ بدون تدرج */
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.modern-table thead th {
    padding: 18px 22px;
    text-align: right;
    font-weight: 600;
    font-size: 13px;
    color: white !important; /* خط أبيض */
    border-bottom: 2px solid #e9ecef;
    position: sticky;
    top: 0;
    background: #4a90e2 !important; /* خلفية أزرق هادئ بدون تدرج */
    z-index: 10;
    white-space: nowrap;
    text-shadow: 0 1px 2px rgba(0,0,0,0.2);
}

.modern-table thead th i {
    display: none;
}

.modern-table tbody tr {
    transition: all 0.3s ease;
    border-bottom: 1px solid #f1f3f5;
}

.modern-table tbody tr:hover {
    background: #f5f8ff; /* very light formal blue */
    transform: none; /* keep subtle, no scaling for formal look */
    box-shadow: 0 1px 6px rgba(0,0,0,0.04);
}

.modern-table tbody td {
    padding: 16px 22px;
    text-align: right;
    font-size: 14px;
    color: #495057;
    vertical-align: middle;
    white-space: nowrap;
}

/* Badges & Status */
.modern-badge {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 500;
    line-height: 1.5;
}

.modern-badge-success {
    background: #e6f3ea;
    color: #1b5e20;
}

.modern-badge-warning {
    background: #fff7e6;
    color: #8a6d00;
}

.modern-badge-danger {
    background: #fdecea;
    color: #8a1b1b;
}

.modern-badge-info {
    background: #e9f3fb;
    color: #0b5ea8;
}

.modern-badge-primary {
    background: #eef6ff;
    color: #08306f;
}

/* Action Buttons in Table */
.action-buttons {
    display: flex;
    gap: 8px;
    justify-content: flex-start;
}

.action-btn {
    width: 32px;
    height: 32px;
    border-radius: 6px;
    border: none;
    cursor: pointer;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    font-size: 16px;
}

.action-btn-edit {
    background: #e3f2fd;
    color: #1976d2;
}

.action-btn-edit:hover {
    background: #1976d2;
    color: white;
    transform: translateY(-2px);
}

.action-btn-delete {
    background: #ffebee;
    color: #c62828;
}

.action-btn-delete:hover {
    background: #c62828;
    color: white;
    transform: translateY(-2px);
}

.action-btn-view {
    background: #f3e5f5;
    color: #7b1fa2;
}

.action-btn-view:hover {
    background: #7b1fa2;
    color: white;
    transform: translateY(-2px);
}

.action-btn-print {
    background: #e8f5e9;
    color: #2e7d32;
}

.action-btn-print:hover {
    background: #2e7d32;
    color: white;
    transform: translateY(-2px);
}

/* Search & Filter Section */
.modern-search-section {
    padding: 20px 25px;
    background: #f8f9fa;
    border-bottom: 1px solid #e9ecef;
}

.modern-search-form {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    align-items: center;
}

.modern-input {
    padding: 10px 16px;
    border: 1px solid #ced4da;
    border-radius: 6px;
    font-size: 14px;
    transition: all 0.3s ease;
    flex: 1;
    min-width: 200px;
}

.modern-input:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.modern-select {
    padding: 10px 16px;
    border: 1px solid #ced4da;
    border-radius: 6px;
    font-size: 14px;
    background: white;
    cursor: pointer;
    transition: all 0.3s ease;
}

.modern-select:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

/* Statistics Cards */
.stats-row {
    display: flex;
    gap: 20px;
    margin-bottom: 25px;
    flex-wrap: wrap;
}

.stat-card {
    flex: 1;
    min-width: 200px;
    background: white;
    border-radius: 8px;
    padding: 20px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    display: flex;
    align-items: center;
    gap: 16px;
    transition: all 0.3s ease;
}

.stat-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 4px 16px rgba(0,0,0,0.12);
}

.stat-icon {
    width: 56px;
    height: 56px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
}

.stat-icon-primary {
    background: linear-gradient(135deg, #0b3d91 0%, #1a4f9c 100%);
    color: white;
}

.stat-icon-success {
    background: linear-gradient(135deg, #4caf50 0%, #7ac17a 100%);
    color: white;
}

.stat-icon-warning {
    background: linear-gradient(135deg, #f2994a 0%, #f2c94c 100%);
    color: white;
}

.stat-icon-danger {
    background: linear-gradient(135deg, #eb3349 0%, #f45c43 100%);
    color: white;
}

.stat-content h4 {
    margin: 0 0 4px 0;
    font-size: 28px;
    font-weight: 700;
    color: #212529;
}

.stat-content p {
    margin: 0;
    font-size: 14px;
    color: #6c757d;
}

/* Pagination */
.modern-pagination {
    padding: 20px 25px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-top: 1px solid #e9ecef;
}

.pagination-info {
    font-size: 14px;
    color: #6c757d;
}

.pagination-buttons {
    display: flex;
    gap: 6px;
}

.pagination-btn {
    padding: 8px 14px;
    border: 1px solid #dee2e6;
    background: white;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 14px;
}

.pagination-btn:hover:not(:disabled) {
    background: #0b3d91;
    color: white;
    border-color: #0b3d91;
}

.pagination-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.pagination-btn.active {
    background: #0b3d91;
    color: white;
    border-color: #0b3d91;
}

/* Empty State */
.modern-empty-state {
    text-align: center;
    padding: 60px 20px;
}

.modern-empty-state i {
    font-size: 64px;
    color: #dee2e6;
    margin-bottom: 16px;
}

.modern-empty-state h4 {
    font-size: 18px;
    color: #495057;
    margin-bottom: 8px;
}

.modern-empty-state p {
    font-size: 14px;
    color: #6c757d;
}

/* Loading State */
.modern-loading {
    text-align: center;
    padding: 40px 20px;
}

.modern-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #667eea;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 16px;
}

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

/* Responsive */
@media (max-width: 768px) {
    .modern-table-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }
    
    .modern-table thead th,
    .modern-table tbody td {
        padding: 12px 14px;
        font-size: 13px;
    }
    
    .modern-table thead th i {
        font-size: 12px;
    }
    
    .action-btn {
        width: 36px;
        height: 36px;
        font-size: 18px;
    }
    
    .stat-card {
        min-width: 100%;
    }
    
    .modern-search-form {
        flex-direction: column;
    }
    
    .modern-input {
        width: 100%;
    }
}

/* Make DataTables responsive */
.dataTables_wrapper {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

table.dataTable {
    width: 100% !important;
}

table.dataTable th,
table.dataTable td {
    white-space: nowrap;
}

/* Responsive table wrapper */
.table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    width: 100%;
}

.table-responsive .modern-table {
    margin-bottom: 0;
}

/* Ensure modern table container handles overflow */
.modern-table-container {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

@media (max-width: 1200px) {
    .modern-table {
        min-width: 100%;
    }
    
    .dataTables_wrapper {
        overflow-x: auto;
    }
}

@media (max-width: 992px) {
    .modern-table tbody td {
        font-size: 13px;
        padding: 14px 18px;
    }
}

@media (max-width: 576px) {
    .modern-table tbody td {
        font-size: 12px;
        padding: 12px 14px;
    }
    
    .modern-table thead th {
        font-size: 14px;
        padding: 14px 12px;
    }
    
    .modern-table thead th i {
        font-size: 11px;
    }
    
    .action-btn {
        width: 28px;
        height: 28px;
        font-size: 14px;
    }
}

/* RTL Support */
[dir="rtl"] .modern-table thead th,
[dir="rtl"] .modern-table tbody td {
    text-align: right;
}

[dir="rtl"] .action-buttons {
    justify-content: flex-end;
}
