/**
 * Frontend Styles for Excel Tables
 */

/* Table Wrapper */
.excel-table-wrapper {
    margin: 20px 0;
    overflow-x: auto;
}

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

/* Search Box */
.excel-table-controls {
    display: flex;
    gap: 15px;
    margin-bottom: 15px;
    flex-wrap: wrap;
    align-items: flex-end;
}

.excel-table-filter {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.excel-table-filter label {
    font-size: 14px;
    font-weight: 600;
    color: #495057;
}

.excel-table-filter-select {
    min-width: 200px;
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
    background-color: #fff;
    cursor: pointer;
    transition: border-color 0.3s ease;
}

.excel-table-filter-select:focus {
    outline: none;
    border-color: #0073aa;
    box-shadow: 0 0 0 3px rgba(0, 115, 170, 0.1);
}

.excel-table-search {
    display: flex;
    flex-direction: column;
    gap: 5px;
    flex: 1;
    min-width: 200px;
}

.excel-table-search-input {
    width: 100%;
    max-width: 400px;
    padding: 10px 15px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
    transition: border-color 0.3s ease;
}

.excel-table-search-input:focus {
    outline: none;
    border-color: #0073aa;
    box-shadow: 0 0 0 3px rgba(0, 115, 170, 0.1);
}

/* Base Table Styles */
.excel-table {
    width: 100%;
    border-collapse: collapse;
    background: #fff;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    font-size: 14px;
    line-height: 1.6;
}

.excel-table th,
.excel-table td {
    padding: 12px 15px;
    text-align: left;
}

.excel-table th {
    background: #f8f9fa;
    font-weight: 600;
    color: #2c3e50;
    border-bottom: 2px solid #dee2e6;
}

.excel-table td {
    color: #495057;
}

/* Bordered Table */
.excel-table-bordered {
    border: 1px solid #dee2e6;
}

.excel-table-bordered th,
.excel-table-bordered td {
    border: 1px solid #dee2e6;
}

/* Striped Rows */
.excel-table-striped tbody tr:nth-of-type(odd) {
    background-color: #f8f9fa;
}

/* Hover Effect */
.excel-table-hover tbody tr:hover {
    background-color: #f1f3f5;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

/* Sortable Headers */
.excel-table-sortable th.sortable {
    cursor: pointer;
    user-select: none;
    position: relative;
    padding-right: 30px;
}

.excel-table-sortable th.sortable:hover {
    background-color: #e9ecef;
}

.excel-table-sortable th .sort-indicator {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    opacity: 0.3;
}

.excel-table-sortable th .sort-indicator:before {
    content: "⇅";
    font-size: 14px;
}

.excel-table-sortable th.sorted-asc .sort-indicator {
    opacity: 1;
}

.excel-table-sortable th.sorted-asc .sort-indicator:before {
    content: "↑";
    color: #0073aa;
}

.excel-table-sortable th.sorted-desc .sort-indicator {
    opacity: 1;
}

.excel-table-sortable th.sorted-desc .sort-indicator:before {
    content: "↓";
    color: #0073aa;
}

/* Cell Formatting */
.excel-cell-bold,
.excel-bold {
    font-weight: bold !important;
}

.excel-cell-italic,
.excel-italic {
    font-style: italic !important;
}

/* Alignment Classes */
.excel-align-left {
    text-align: left !important;
}

.excel-align-center {
    text-align: center !important;
}

.excel-align-right {
    text-align: right !important;
}

/* Errors and Notices */
.excel-table-error,
.excel-table-notice {
    padding: 15px;
    border-radius: 4px;
    margin: 20px 0;
}

.excel-table-error {
    background: #fee;
    border-left: 4px solid #dc3545;
    color: #721c24;
}

.excel-table-notice {
    background: #fff3cd;
    border-left: 4px solid #ffc107;
    color: #856404;
}

/* Pagination */
.excel-table-pagination {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 0;
    margin-top: 15px;
    border-top: 1px solid #dee2e6;
}

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

.pagination-controls {
    display: flex;
    align-items: center;
    gap: 5px;
}

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

.pagination-btn:hover:not(:disabled) {
    background: #e9ecef;
    border-color: #adb5bd;
}

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

.pagination-pages {
    padding: 0 10px;
    color: #495057;
    font-size: 14px;
}

.current-page {
    font-weight: 600;
    color: #0073aa;
}

/* Hide rows that don't match search or filter */
.search-hidden,
.filter-hidden {
    display: none !important;
}

/* Responsive Behavior */
@media screen and (max-width: 768px) {
    .excel-table {
        font-size: 12px;
    }
    
    .excel-table th,
    .excel-table td {
        padding: 8px 10px;
    }
    
    .excel-table-controls {
        flex-direction: column;
        align-items: stretch;
    }
    
    .excel-table-filter,
    .excel-table-search {
        width: 100%;
    }
    
    .excel-table-filter-select,
    .excel-table-search-input {
        max-width: 100%;
        width: 100%;
    }
    
    .excel-table-pagination {
        flex-direction: column;
        gap: 10px;
        align-items: stretch;
    }
    
    .pagination-info {
        text-align: center;
    }
    
    .pagination-controls {
        justify-content: center;
    }
    
    .pagination-btn {
        padding: 8px 12px;
    }
}

/* Print Styles */
@media print {
    .excel-table-search {
        display: none;
    }
    
    .excel-table th,
    .excel-table td {
        padding: 8px;
        font-size: 11px;
    }
    
    .excel-table-hover tbody tr:hover {
        background-color: transparent;
    }
}

/* Color Presets (common Excel-like colors) */
.excel-bg-yellow {
    background-color: #fff3cd !important;
}

.excel-bg-green {
    background-color: #d4edda !important;
}

.excel-bg-red {
    background-color: #f8d7da !important;
}

.excel-bg-blue {
    background-color: #d1ecf1 !important;
}

.excel-bg-gray {
    background-color: #e9ecef !important;
}

/* Alignment Classes */
.excel-align-left {
    text-align: left !important;
}

.excel-align-center {
    text-align: center !important;
}

.excel-align-right {
    text-align: right !important;
}

/* Loading State */
.excel-table-loading {
    opacity: 0.6;
    pointer-events: none;
    position: relative;
}

.excel-table-loading::after {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    width: 40px;
    height: 40px;
    margin: -20px 0 0 -20px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #0073aa;
    border-radius: 50%;
    animation: excel-spin 1s linear infinite;
}

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