/* Toolbar styles */
.table-toolbar {
    background: #f8f9fa;
    padding: 15px 20px;
    border-bottom: 1px solid #e0e0e0;
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
    justify-content: space-between;
}

.toolbar-left, .toolbar-right {
    display: flex;
    gap: 10px;
    align-items: center;
}

.action-btn {
    padding: 8px 16px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 5px;
    text-decoration: none;
    transition: all 0.2s ease;
}

.action-btn:hover {
    opacity: 0.9;
    transform: translateY(-1px);
}

.print-btn {
    background: #17a2b8;
    color: white;
}

.export-btn {
    background: #28a745;
    color: white;
}

.add-btn {
    background: #007bff;
    color: white;
}

.edit-btn {
    background: #ffc107;
    color: #212529;
    padding: 5px 10px;
    font-size: 12px;
}

.delete-btn {
    background: #dc3545;
    color: white;
    padding: 5px 10px;
    font-size: 12px;
}

.save-btn {
    background: #28a745;
    color: white;
}

.cancel-btn {
    background: #6c757d;
    color: white;
}

/* Modal styles */
.edit-modal, .filter-modal {
    display: none;
    position: fixed;
    z-index: 3000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.5);
}

.edit-modal-content, .filter-modal-content {
    background-color: white;
    margin: 5% auto;
    padding: 0;
    border-radius: 8px;
    width: 90%;
    max-width: 800px;
    max-height: 80vh;
    overflow-y: auto;
}

.filter-modal-content {
    max-width: 400px;
}

.edit-form {
    padding: 20px;
}

.form-group {
    margin-bottom: 15px;
}

.form-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: bold;
    color: #495057;
}

.form-control {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid #ced4da;
    border-radius: 4px;
    font-size: 14px;
    font-family: inherit;
}

.multiline-input {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid #ced4da;
    border-radius: 4px;
    font-size: 14px;
    font-family: inherit;
    min-height: 100px;
    resize: vertical;
    line-height: 1.5;
}

.form-control:focus, .multiline-input:focus {
    outline: none;
    border-color: #80bdff;
    box-shadow: 0 0 0 0.2rem rgba(0,123,255,.25);
}

.action-buttons {
    display: flex;
    gap: 10px;
    margin-top: 20px;
    justify-content: flex-end;
}

.action-cell {
    white-space: nowrap;
    min-width: 120px;
}

.table-actions {
    display: flex;
    gap: 5px;
    justify-content: center;
}

/* Breadcrumb */
.breadcrumb {
    background: #f8f9fa;
    border-radius: 4px;
    padding: 10px 15px;
    margin-bottom: 20px;
}

.breadcrumb-item + .breadcrumb-item::before {
    content: ">";
    padding: 0 8px;
}

.breadcrumb a {
    color: #990000;
    text-decoration: none;
}

.breadcrumb a:hover {
    text-decoration: underline;
}

/* Table styles */
.table-container {
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    margin: 20px auto;
    overflow: hidden;
}

.search-container {
    padding: 20px;
    border-bottom: 1px solid #e0e0e0;
    background: #f8f9fa;
}

.search-input {
    width: 100%;
    padding: 12px 20px;
    border: 2px solid #e0e0e0;
    border-radius: 25px;
    font-size: 16px;
    text-align: right;
    transition: border-color 0.3s;
}

.search-input:focus {
    outline: none;
    border-color: #990000;
}

.table-responsive {
    overflow-x: auto;
    position: relative;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    min-width: 100%;
    margin-bottom: 0;
}

.data-table th {
    background-color: #990000;
    color: white;
    padding: 15px 12px;
    text-align: center;
    font-weight: bold;
    cursor: pointer;
    user-select: none;
    position: sticky;
    top: 0;
    z-index: 10;
    border-right: 1px solid rgba(255,255,255,0.1);
}

.data-table th:last-child {
    border-right: none;
}

.data-table th:hover {
    background-color: #7a0000;
}

.data-table th.filterable {
    padding-right: 30px;
    position: relative;
}

.data-table th.filterable::after {
    content: '⯆';
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 12px;
    opacity: 0.7;
}

.data-table th.filterable.filter-active::after {
    content: '⯅';
    color: #ffeb3b;
}

.data-table td {
    padding: 12px 10px;
    border-bottom: 1px solid #e0e0e0;
    text-align: center;
    border-right: 1px solid #f0f0f0;
    max-width: 300px;
}

.data-table td:last-child {
    border-right: none;
}

.data-table tr:hover {
    background-color: #f5f5f5;
}

.cell-content {
    display: block;
    width: 100%;
}

.cell-content.multiline {
    white-space: pre-line;
    word-wrap: break-word;
    line-height: 1.5;
}

.cell-content.singleline {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.cell-content.singleline:hover {
    white-space: normal;
    overflow: visible;
    word-wrap: break-word;
    background-color: #f0f0f0;
    position: relative;
    z-index: 5;
    padding: 2px;
    border-radius: 2px;
}

.rtl-text {
    direction: rtl;
    text-align: right;
}

/* Pagination styles */
.pagination-container {
    padding: 20px;
    background: #f8f9fa;
    border-top: 1px solid #e0e0e0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 15px;
}

.pagination {
    display: flex;
    gap: 5px;
    align-items: center;
    flex-wrap: wrap;
}

.page-link {
    padding: 8px 12px;
    border: 1px solid #dee2e6;
    background: white;
    color: #990000;
    text-decoration: none;
    border-radius: 4px;
    transition: all 0.2s;
}

.page-link:hover {
    background-color: #e9ecef;
    border-color: #dee2e6;
}

.page-link.active {
    background-color: #990000;
    border-color: #990000;
    color: white;
}

.page-link.disabled {
    color: #6c757d;
    pointer-events: none;
    background-color: #fff;
}

.page-size-selector {
    display: flex;
    align-items: center;
    gap: 10px;
}

.page-size-selector select {
    padding: 6px 10px;
    border: 1px solid #ced4da;
    border-radius: 4px;
    background: white;
}

.results-info {
    color: #6c757d;
    font-size: 14px;
}

/* Filter Modal */
.filter-modal-header {
    background: #990000;
    color: white;
    padding: 15px 20px;
    border-radius: 8px 8px 0 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.filter-modal-header h3 {
    margin: 0;
    font-size: 16px;
}

.close-btn {
    background: none;
    border: none;
    color: white;
    font-size: 24px;
    cursor: pointer;
}

.filter-modal-body {
    padding: 20px;
}

.filter-input {
    width: 100%;
    padding: 10px 15px;
    border: 2px solid #e0e0e0;
    border-radius: 5px;
    font-size: 14px;
    text-align: right;
    margin-bottom: 15px;
}

.filter-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
}

.filter-btn {
    padding: 8px 16px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
}

.filter-clear {
    background: #6c757d;
    color: white;
}

.filter-apply {
    background: #990000;
    color: white;
}

/* Active filter indicator */
.active-filter {
    background: #7a0000 !important;
}

.active-filters {
    padding: 10px 20px;
    background: #e3f2fd;
    border-right: 4px solid #2196f3;
    margin: 0 20px;
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
}

.filter-tag {
    background: #2196f3;
    color: white;
    padding: 5px 10px;
    border-radius: 15px;
    font-size: 12px;
    display: flex;
    align-items: center;
    gap: 5px;
}

.filter-tag-remove {
    background: none;
    border: none;
    color: white;
    cursor: pointer;
    font-size: 14px;
    padding: 0;
    margin-right: 3px;
}

.clear-all-filters {
    background: #ff4444;
    color: white;
    border: none;
    padding: 5px 10px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
}

.results-count {
    padding: 10px 20px;
    background: #e8f5e8;
    border-right: 4px solid #4caf50;
    margin: 10px 20px;
    border-radius: 4px;
    text-align: center;
}

.no-results {
    text-align: center;
    padding: 40px;
    color: #666;
    font-size: 18px;
}

/* Loading indicator */
.loading-indicator {
    display: none;
    text-align: center;
    padding: 20px;
    color: #666;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    z-index: 100;
}

.loading-indicator.active {
    display: block;
}

/* Print Header */
.print-header {
    display: none;
    text-align: center;
    margin-bottom: 20px;
    padding-bottom: 10px;
    border-bottom: 2px solid #000;
}

.print-header h1 {
    font-size: 18pt !important;
    margin: 0 0 5px 0 !important;
    font-weight: bold !important;
}

.print-header p {
    font-size: 11pt !important;
    margin: 0 !important;
}

/* Print-specific styles */
@media print {
    body {
        margin: 0 !important;
        padding: 0 !important;
    }
    
    .breadcrumb,
    .table-toolbar,
    .search-container,
    .active-filters,
    .results-count,
    .action-cell,
    .pagination-container,
    .filter-modal,
    .edit-modal,
    .modal,
    .no-results,
    .loading-indicator {
        display: none !important;
    }
    
    .print-header {
        display: block !important;
        text-align: center;
        margin-bottom: 20px;
        padding-bottom: 10px;
        border-bottom: 2px solid #000;
        page-break-after: avoid;
    }
    
    .container-fluid {
        padding: 0 !important;
        margin: 0 !important;
        width: 100% !important;
    }
    
    .table-container {
        box-shadow: none !important;
        border: none !important;
        margin: 0 !important;
        page-break-inside: avoid;
    }
    
    .data-table {
        width: 100% !important;
        border-collapse: collapse !important;
        font-size: 9pt !important;
        table-layout: auto !important;
    }
    
    .data-table th,
    .data-table td {
        border: 1px solid #000 !important;
        padding: 6px 4px !important;
        text-align: center !important;
        word-wrap: break-word !important;
    }
    
    .data-table th {
        background-color: #f0f0f0 !important;
        color: #000 !important;
        font-weight: bold !important;
        font-size: 10pt !important;
        position: static !important;
    }
    
    @page {
        size: A4 landscape;
        margin: 1cm;
    }
    
    @page {
        @bottom-center {
            content: "صفحه " counter(page) " از " counter(pages);
            font-size: 10pt;
        }
    }
    
    * {
        color: #000000 !important;
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
    }
}

/* Responsive */
@media (max-width: 768px) {
    .pagination-container {
        flex-direction: column;
        align-items: center;
    }
    
    .toolbar-left, .toolbar-right {
        width: 100%;
        justify-content: center;
    }
    
    .table-toolbar {
        flex-direction: column;
        gap: 10px;
    }
    
    .data-table th, .data-table td {
        padding: 8px 6px;
        font-size: 12px;
    }
}