/**
 * ETables - Advanced Elementor Table Widget Styles
 * Version: 1.0.0
 */

/* Base Table Styles */
.etables-wrapper {
    position: relative;
    overflow-x: auto;
    margin: 0;
    padding: 0;
}

.etables-table {
    width: 100%;
    border-collapse: collapse;
    border-spacing: 0;
    background: transparent;
    font-size: 14px;
    line-height: 1.6;
}

.etables-table th,
.etables-table td {
    padding: 12px 15px;
    text-align: left;
    vertical-align: middle;
    border: 1px solid #e1e5e9;
    word-wrap: break-word;
    position: relative;
}

/* Header Styles */
.etables-table thead th {
    background-color: #f8f9fa;
    font-weight: 600;
    color: #495057;
    border-bottom: 2px solid #dee2e6;
    position: relative;
}

.etables-header-cell {
    position: relative;
    cursor: default;
}

.etables-header-icon {
    margin-right: 8px;
    display: inline-flex;
    align-items: center;
}

.etables-header-text {
    display: inline-block;
}

.etables-sort-icon {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    opacity: 0.5;
    transition: opacity 0.3s ease;
    cursor: pointer;
}

.etables-sortable .etables-header-cell:hover .etables-sort-icon {
    opacity: 1;
}

.etables-sortable .etables-header-cell {
    cursor: pointer;
    user-select: none;
}

.etables-sortable .etables-header-cell:hover {
    background-color: #e9ecef;
}

/* Row Styles */
.etables-table tbody tr {
    transition: background-color 0.3s ease;
}

.etables-table tbody tr:hover {
    background-color: #f8f9fa;
}

.etables-table tbody tr:nth-child(even) {
    background-color: #ffffff;
}

.etables-table tbody tr:nth-child(odd) {
    background-color: #f8f9fa;
}

/* Featured Row Styles */
.etables-row-featured {
    background-color: #fff3cd !important;
    border-left: 4px solid #ffc107;
}

.etables-row-featured:hover {
    background-color: #ffeaa7 !important;
}

/* Sub Header Row Styles */
.etables-row-header {
    background-color: #e9ecef !important;
    font-weight: 600;
    color: #495057;
}

.etables-row-header:hover {
    background-color: #dee2e6 !important;
}

/* Merged Row Styles */
.etables-merged-row {
    position: relative;
}

.etables-merged-row::before {
    content: "";
    position: absolute;
    left: -3px;
    top: 0;
    bottom: 0;
    width: 3px;
    background: linear-gradient(to bottom, #007bff 0%, #28a745 50%, #6f42c1 100%);
}

.etables-merged-row:nth-child(odd) {
    background-color: #f8f9fa;
}

.etables-merged-row:nth-child(even) {
    background-color: #ffffff;
}

.etables-merged-row:hover {
    background-color: #e3f2fd !important;
    transform: translateX(2px);
    transition: all 0.3s ease;
}

/* Search Functionality */
.etables-search-wrapper {
    margin-bottom: 20px;
    position: relative;
}

.etables-search {
    width: 100%;
    max-width: 300px;
    padding: 10px 15px;
    border: 1px solid #ced4da;
    border-radius: 4px;
    font-size: 14px;
    background-color: #ffffff;
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
}

.etables-search:focus {
    outline: none;
    border-color: #80bdff;
    box-shadow: 0 0 0 0.2rem rgba(0, 123, 255, 0.25);
}

/* Pagination Styles */
.etables-pagination-wrapper {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 20px;
    flex-wrap: wrap;
    gap: 15px;
}

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

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

.etables-pagination-controls button {
    padding: 8px 12px;
    border: 1px solid #dee2e6;
    background-color: #ffffff;
    color: #495057;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.3s ease;
}

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

.etables-pagination-controls button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.etables-page-numbers {
    display: flex;
    gap: 5px;
}

.etables-page-numbers button {
    min-width: 35px;
    padding: 8px 10px;
}

.etables-page-numbers button.active {
    background-color: #007bff;
    border-color: #007bff;
    color: #ffffff;
}

/* Responsive Styles */
@media (max-width: 768px) {
    .etables-wrapper {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    .etables-table {
        min-width: 600px;
    }
    
    .etables-table th,
    .etables-table td {
        padding: 8px 10px;
        font-size: 13px;
    }
    
    .etables-search {
        max-width: 100%;
    }
    
    .etables-pagination-wrapper {
        flex-direction: column;
        align-items: stretch;
        text-align: center;
    }
    
    .etables-pagination-controls {
        justify-content: center;
    }
}

@media (max-width: 480px) {
    .etables-table th,
    .etables-table td {
        padding: 6px 8px;
        font-size: 12px;
    }
    
    .etables-pagination-controls {
        flex-wrap: wrap;
    }
    
    .etables-page-numbers {
        order: 3;
        width: 100%;
        justify-content: center;
        margin-top: 10px;
    }
}

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

.etables-loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    margin: -10px 0 0 -10px;
    border: 2px solid #f3f3f3;
    border-top: 2px solid #007bff;
    border-radius: 50%;
    animation: etables-spin 1s linear infinite;
}

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

/* Accessibility */
.etables-table th[aria-sort="ascending"] .etables-sort-icon::before {
    content: "▲";
}

.etables-table th[aria-sort="descending"] .etables-sort-icon::before {
    content: "▼";
}

.etables-table th[aria-sort="none"] .etables-sort-icon::before {
    content: "⇅";
}

/* Remove sync indicator - it's causing display issues */
.etables-wrapper[data-input-method="synced"] {
    /* Remove border and positioning that causes layout issues */
}

/* Fix table display without overriding width control */
.etables-table {
    table-layout: auto;
    max-width: 100%;
}

.etables-cell {
    min-width: 100px;
    word-wrap: break-word;
}

/* Empty State Messages */
.etables-empty-message {
    text-align: center;
    padding: 40px 20px;
    color: #6c757d;
    font-style: italic;
    background-color: #f8f9fa;
    border: 2px dashed #dee2e6;
    border-radius: 8px;
}

/* Column Data Type Styles */
.etables-cell[data-column-type="number"] {
    text-align: right;
    font-family: 'Courier New', monospace;
}

.etables-cell[data-column-type="currency"] {
    text-align: right;
    font-family: 'Courier New', monospace;
    font-weight: 600;
}

.etables-cell[data-column-type="currency"]::before {
    content: "$";
    margin-right: 2px;
}

.etables-cell[data-column-type="date"] {
    text-align: center;
    white-space: nowrap;
}

.etables-cell[data-column-type="image"] {
    text-align: center;
    padding: 5px;
}

.etables-cell[data-column-type="image"] img {
    max-width: 50px;
    max-height: 50px;
    border-radius: 4px;
}

.etables-cell[data-column-type="link"] a {
    color: #007bff;
    text-decoration: none;
    transition: color 0.3s ease;
}

.etables-cell[data-column-type="link"] a:hover {
    color: #0056b3;
    text-decoration: underline;
}

.etables-cell[data-column-type="html"] {
    line-height: 1.4;
}

/* Column Structure Indicators */
.etables-wrapper[data-structure="columns"] .etables-table {
    border: 2px solid #e9ecef;
}

.etables-wrapper[data-structure="columns"] .etables-header-cell {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    font-weight: 600;
}

.etables-wrapper[data-structure="rows"] .etables-header-cell {
    background-color: #f8f9fa;
    color: #495057;
}

/* Column Alignment Classes */
.etables-column-left {
    text-align: left !important;
}

.etables-column-center {
    text-align: center !important;
}

.etables-column-right {
    text-align: right !important;
}

/* Enhanced Column Sorting */
.etables-table[data-structure="columns"] .etables-sort-icon {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 3px;
    padding: 2px 4px;
}

/* Column Data Type Icons */
.etables-cell[data-column-type="number"]::after,
.etables-cell[data-column-type="currency"]::after,
.etables-cell[data-column-type="date"]::after {
    content: "";
    display: inline-block;
    width: 12px;
    height: 12px;
    margin-left: 5px;
    opacity: 0.3;
    background-size: contain;
    background-repeat: no-repeat;
    vertical-align: middle;
}

/* Print Styles */
@media print {
    .etables-search-wrapper,
    .etables-pagination-wrapper {
        display: none !important;
    }

    .etables-table {
        border-collapse: collapse !important;
    }

    .etables-table th,
    .etables-table td {
        border: 1px solid #000 !important;
        padding: 8px !important;
    }

    .etables-cell[data-column-type="currency"]::before {
        content: "$" !important;
    }
}
