/**
 * Roomarkets - Table Styles
 * Consistent data table styling for all list pages
 */

/* ============================================
   TABLE CONTAINER
   ============================================ */

.table-container {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-xl);
    overflow: hidden;
}

/* ============================================
   TABLE TOOLBAR
   ============================================ */

.table-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.875rem 1rem;
    border-bottom: 1px solid var(--border-color);
    background: var(--bg-elevated);
    flex-wrap: wrap;
    gap: 0.75rem;
}

.table-toolbar-left {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.table-toolbar-right {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

/* Search in Toolbar */
.table-search {
    position: relative;
    min-width: 280px;
}

.table-search .form-control {
    padding-left: 2.75rem;
    background: var(--bg-card);
}

.table-search .search-icon {
    position: absolute;
    left: 1rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    pointer-events: none;
}

/* Filter Dropdown */
.table-filter {
    position: relative;
}

.table-filter-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.625rem 1rem;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    font-size: 0.875rem;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.table-filter-btn:hover {
    border-color: var(--border-strong);
    color: var(--text-primary);
}

.table-filter-btn.active {
    border-color: var(--primary);
    color: var(--primary);
}

.filter-badge {
    min-width: 18px;
    height: 18px;
    padding: 0 0.375rem;
    background: var(--primary);
    color: white;
    border-radius: var(--radius-full);
    font-size: 0.6875rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* ============================================
   TABLE STYLES
   ============================================ */

.data-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
}

.data-table thead {
    background: var(--bg-elevated);
}

.data-table thead th {
    font-size: 0.6875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border-color);
    white-space: nowrap;
    text-align: left;
}

.data-table thead th:first-child {
    padding-left: 1.5rem;
}

.data-table thead th:last-child {
    padding-right: 1.5rem;
}

/* Sortable Headers */
.data-table thead th.sortable {
    cursor: pointer;
    user-select: none;
    transition: color var(--transition-fast);
}

.data-table thead th.sortable:hover {
    color: var(--primary);
}

.data-table thead th.sortable .sort-icon {
    margin-left: 0.375rem;
    opacity: 0.5;
}

.data-table thead th.sortable.sorted .sort-icon {
    opacity: 1;
    color: var(--primary);
}

/* Table Body */
.data-table tbody td {
    padding: 0.625rem 1rem;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-primary);
    vertical-align: middle;
    font-size: 0.8125rem;
}

.data-table tbody td:first-child {
    padding-left: 1.5rem;
}

.data-table tbody td:last-child {
    padding-right: 1.5rem;
}

.data-table tbody tr {
    transition: background-color var(--transition-fast);
}

.data-table tbody tr:hover {
    background: var(--bg-hover);
}

.data-table tbody tr:last-child td {
    border-bottom: none;
}

/* Selected Row */
.data-table tbody tr.selected {
    background: rgba(23, 162, 184, 0.08);
}

.data-table tbody tr.selected:hover {
    background: rgba(23, 162, 184, 0.12);
}

/* ============================================
   TABLE CELLS
   ============================================ */

/* Checkbox Cell */
.cell-checkbox {
    width: 48px;
}

.cell-checkbox .form-check {
    margin: 0;
    justify-content: center;
}

/* Avatar Cell */
.cell-avatar {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.table-avatar {
    width: 32px;
    height: 32px;
    border-radius: var(--radius-full);
    background: var(--primary-gradient);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 0.6875rem;
    flex-shrink: 0;
}

.table-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: var(--radius-full);
}

.cell-avatar-info {
    min-width: 0;
}

.cell-avatar-name {
    font-weight: 500;
    font-size: 0.8125rem;
    color: var(--text-primary);
    margin-bottom: 0.0625rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.cell-avatar-email {
    font-size: 0.6875rem;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Status Cell */
.cell-status {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.25rem 0.5rem;
    border-radius: var(--radius-full);
    font-size: 0.6875rem;
    font-weight: 500;
}

.cell-status-active {
    background: rgba(16, 185, 129, 0.15);
    color: var(--success);
}

.cell-status-inactive {
    background: rgba(239, 68, 68, 0.15);
    color: var(--danger);
}

.cell-status-pending {
    background: rgba(245, 158, 11, 0.15);
    color: var(--warning);
}

.cell-status-draft {
    background: var(--bg-elevated);
    color: var(--text-muted);
}

.cell-status .status-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
}

.cell-status-active .status-dot { background: var(--success); }
.cell-status-inactive .status-dot { background: var(--danger); }
.cell-status-pending .status-dot { background: var(--warning); }
.cell-status-draft .status-dot { background: var(--text-muted); }

/* Badge Cell */
.cell-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.25rem 0.625rem;
    border-radius: var(--radius-md);
    font-size: 0.75rem;
    font-weight: 500;
}

/* Date Cell */
.cell-date {
    color: var(--text-secondary);
    font-size: 0.875rem;
    white-space: nowrap;
}

.cell-date-relative {
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* Amount Cell */
.cell-amount {
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.cell-amount-positive {
    color: var(--success);
}

.cell-amount-negative {
    color: var(--danger);
}

/* Progress Cell */
.cell-progress {
    min-width: 100px;
}

.progress-bar-wrapper {
    height: 6px;
    background: var(--bg-elevated);
    border-radius: var(--radius-full);
    overflow: hidden;
    margin-bottom: 0.25rem;
}

.progress-bar-fill {
    height: 100%;
    background: var(--primary-gradient);
    border-radius: var(--radius-full);
    transition: width 0.3s ease;
}

.progress-label {
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* ============================================
   TABLE ACTIONS
   ============================================ */

.cell-actions {
    white-space: nowrap;
    text-align: right;
}

.table-actions {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
}

.table-action-btn {
    width: 28px;
    height: 28px;
    border: none;
    background: transparent;
    color: var(--text-muted);
    border-radius: var(--radius-sm);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all var(--transition-fast);
    text-decoration: none;
    font-size: 0.75rem;
}

.table-action-btn:hover {
    background: var(--bg-elevated);
    color: var(--text-primary);
}

.table-action-btn.view:hover {
    color: var(--primary);
}

.table-action-btn.edit:hover {
    color: var(--warning);
}

.table-action-btn.delete:hover {
    background: rgba(239, 68, 68, 0.1);
    color: var(--danger);
}

/* Actions Dropdown */
.actions-dropdown {
    position: relative;
}

.actions-dropdown-toggle {
    width: 32px;
    height: 32px;
    border: none;
    background: transparent;
    color: var(--text-muted);
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.actions-dropdown-toggle:hover {
    background: var(--bg-elevated);
    color: var(--text-primary);
}

.actions-dropdown-menu {
    position: absolute;
    right: 0;
    top: 100%;
    margin-top: 0.25rem;
    min-width: 160px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    padding: 0.5rem;
    z-index: 100;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-8px);
    transition: all var(--transition-fast);
}

.actions-dropdown.open .actions-dropdown-menu {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.actions-dropdown-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem 0.75rem;
    font-size: 0.875rem;
    color: var(--text-secondary);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--transition-fast);
    text-decoration: none;
    border: none;
    background: none;
    width: 100%;
    text-align: left;
}

.actions-dropdown-item:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.actions-dropdown-item i {
    width: 16px;
    text-align: center;
    opacity: 0.7;
}

.actions-dropdown-item.danger {
    color: var(--danger);
}

.actions-dropdown-item.danger:hover {
    background: rgba(239, 68, 68, 0.1);
}

.actions-dropdown-divider {
    height: 1px;
    background: var(--border-color);
    margin: 0.375rem 0;
}

/* ============================================
   TABLE FOOTER
   ============================================ */

.table-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1rem;
    border-top: 1px solid var(--border-color);
    background: var(--bg-elevated);
    flex-wrap: wrap;
    gap: 0.75rem;
}

.table-info {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.table-info strong {
    color: var(--text-primary);
    font-weight: 600;
}

/* Pagination */
.table-pagination {
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.pagination-btn {
    min-width: 28px;
    height: 28px;
    padding: 0 0.375rem;
    border: 1px solid var(--border-color);
    background: var(--bg-card);
    color: var(--text-secondary);
    border-radius: var(--radius-sm);
    font-size: 0.75rem;
    font-weight: 500;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all var(--transition-fast);
    text-decoration: none;
}

.pagination-btn:hover:not(:disabled) {
    border-color: var(--border-strong);
    color: var(--text-primary);
    background: var(--bg-hover);
}

.pagination-btn.active {
    background: var(--primary);
    border-color: var(--primary);
    color: white;
}

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

.pagination-ellipsis {
    padding: 0 0.5rem;
    color: var(--text-muted);
}

/* Per Page Select */
.per-page-select {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.per-page-select label {
    font-size: 0.875rem;
    color: var(--text-muted);
}

.per-page-select .form-select {
    width: auto;
    min-width: 70px;
    padding: 0.375rem 2rem 0.375rem 0.75rem;
    font-size: 0.875rem;
}

/* ============================================
   EMPTY STATE
   ============================================ */

.table-empty {
    padding: 3rem 2rem;
    text-align: center;
}

.table-empty-icon {
    width: 56px;
    height: 56px;
    margin: 0 auto 1rem;
    background: var(--bg-elevated);
    border-radius: var(--radius-full);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    color: var(--text-muted);
}

.table-empty-title {
    font-size: 0.9375rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.375rem;
}

.table-empty-text {
    font-size: 0.8125rem;
    color: var(--text-muted);
    margin-bottom: 1rem;
}

/* ============================================
   LOADING STATE
   ============================================ */

.table-loading {
    position: relative;
    min-height: 200px;
}

.table-loading::after {
    content: '';
    position: absolute;
    inset: 0;
    background: var(--bg-card);
    opacity: 0.8;
    display: flex;
    align-items: center;
    justify-content: center;
}

.table-loading-spinner {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 10;
}

/* ============================================
   RESPONSIVE TABLE
   ============================================ */

.table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

@media (max-width: 768px) {
    .table-toolbar {
        flex-direction: column;
        align-items: stretch;
    }
    
    .table-toolbar-left,
    .table-toolbar-right {
        width: 100%;
    }
    
    .table-search {
        min-width: 100%;
    }
    
    .table-footer {
        flex-direction: column;
        text-align: center;
    }
    
    .data-table thead th,
    .data-table tbody td {
        padding: 0.75rem 1rem;
    }
    
    .data-table thead th:first-child,
    .data-table tbody td:first-child {
        padding-left: 1rem;
    }
    
    .data-table thead th:last-child,
    .data-table tbody td:last-child {
        padding-right: 1rem;
    }
}

/* ============================================
   BULK ACTIONS BAR
   ============================================ */

.bulk-actions-bar {
    display: none;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1.5rem;
    background: var(--primary);
    color: white;
}

.bulk-actions-bar.show {
    display: flex;
}

.bulk-actions-count {
    font-size: 0.875rem;
    font-weight: 500;
}

.bulk-actions-buttons {
    display: flex;
    gap: 0.5rem;
}

.bulk-action-btn {
    padding: 0.375rem 0.75rem;
    background: rgba(255, 255, 255, 0.2);
    border: none;
    border-radius: var(--radius-md);
    color: white;
    font-size: 0.8125rem;
    cursor: pointer;
    transition: background var(--transition-fast);
}

.bulk-action-btn:hover {
    background: rgba(255, 255, 255, 0.3);
}

.bulk-action-btn.danger:hover {
    background: var(--danger);
}

