/* ═══════════════════════════════════════════════════════════
   NETSENSE IOT - TABLE ENHANCED v2.1
   Tabla moderna de assets con filtros y búsqueda
   ════════════════════════════════════════════════════════════ */

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

.table-enhanced-container {
    background: var(--bg-tertiary);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-primary);
    overflow: hidden;
    margin-bottom: var(--space-8);
}

/* ==================== TABLE HEADER ==================== */

.table-enhanced-header {
    padding: var(--space-6);
    border-bottom: 1px solid var(--border-primary);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-4);
    flex-wrap: wrap;
}

.table-enhanced-title {
    font-size: var(--font-size-lg);
    font-weight: var(--font-weight-semibold);
    color: var(--text-primary);
}

.table-enhanced-controls {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    flex-wrap: wrap;
}

/* ==================== SEARCH INPUT ==================== */

.table-search-input {
    padding: var(--space-2) var(--space-4);
    border: 1px solid var(--border-primary);
    border-radius: var(--radius-md);
    background: var(--bg-primary);
    color: var(--text-primary);
    font-size: var(--font-size-sm);
    min-width: 200px;
    transition: all var(--transition-fast);
}

.table-search-input:focus {
    outline: none;
    border-color: var(--brand-primary);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

.table-search-input::placeholder {
    color: var(--text-muted);
}

/* ==================== FILTER SELECT ==================== */

.table-filter-select {
    padding: var(--space-2) var(--space-4);
    border: 1px solid var(--border-primary);
    border-radius: var(--radius-md);
    background: var(--bg-primary);
    color: var(--text-primary);
    font-size: var(--font-size-sm);
    min-width: 120px;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.table-filter-select:focus {
    outline: none;
    border-color: var(--brand-primary);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

.table-filter-select:hover {
    border-color: var(--border-secondary);
}

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

.table-enhanced {
    width: 100%;
    border-collapse: collapse;
}

.table-enhanced thead {
    background: var(--bg-secondary);
    border-bottom: 2px solid var(--border-primary);
}

.table-enhanced th {
    padding: var(--space-4) var(--space-5);
    text-align: left;
    font-size: var(--font-size-sm);
    font-weight: var(--font-weight-semibold);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-secondary);
    cursor: pointer;
    user-select: none;
    position: relative;
    white-space: nowrap;
    transition: all var(--transition-fast);
}

.table-enhanced th:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

/* Sorting indicators */
.table-enhanced th.sortable::after {
    content: '↕';
    margin-left: var(--space-2);
    opacity: 0.3;
    font-size: var(--font-size-xs);
}

.table-enhanced th.sort-asc::after {
    content: '↑';
    opacity: 1;
    color: var(--brand-primary);
}

.table-enhanced th.sort-desc::after {
    content: '↓';
    opacity: 1;
    color: var(--brand-primary);
}

/* ==================== TABLE BODY ==================== */

.table-enhanced tbody tr {
    border-bottom: 1px solid var(--border-primary);
    transition: all var(--transition-fast);
}

.table-enhanced tbody tr:hover {
    background: rgba(6, 182, 212, 0.06);
}

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

.table-enhanced td {
    padding: var(--space-4) var(--space-5);
    font-size: var(--font-size-sm);
    color: var(--text-primary);
    vertical-align: middle;
}

/* ==================== STATUS BADGES ==================== */

.status-badge {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-1) var(--space-3);
    border-radius: var(--radius-full);
    font-size: var(--font-size-xs);
    font-weight: var(--font-weight-medium);
    white-space: nowrap;
}

.status-badge-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    flex-shrink: 0;
}

/* Status variants */
.status-badge.healthy {
    background: rgba(34, 197, 94, 0.1);
    color: var(--success);
}

.status-badge.healthy .status-badge-dot {
    background: var(--success);
}

.status-badge.warning {
    background: rgba(251, 191, 36, 0.1);
    color: var(--warning);
}

.status-badge.warning .status-badge-dot {
    background: var(--warning);
}

.status-badge.critical {
    background: rgba(239, 68, 68, 0.1);
    color: var(--danger);
}

.status-badge.critical .status-badge-dot {
    background: var(--danger);
}

.status-badge.offline {
    background: rgba(156, 163, 175, 0.1);
    color: var(--text-muted);
}

.status-badge.offline .status-badge-dot {
    background: var(--text-muted);
}

/* ==================== ANALYTICS BADGE ==================== */

.analytics-badge {
    display: inline-flex;
    align-items: center;
    gap: var(--space-1);
    padding: var(--space-1) var(--space-2);
    border-radius: var(--radius-sm);
    font-size: var(--font-size-xs);
    font-weight: var(--font-weight-medium);
}

.analytics-badge.active {
    background: rgba(34, 197, 94, 0.1);
    color: var(--success);
}

.analytics-badge.inactive {
    background: rgba(156, 163, 175, 0.1);
    color: var(--text-muted);
}

/* ==================== LEVEL BAR ==================== */

.level-bar-container {
    display: flex;
    align-items: center;
    gap: var(--space-2);
}

.level-bar {
    flex: 1;
    height: 6px;
    background: var(--bg-secondary);
    border-radius: var(--radius-full);
    overflow: hidden;
    min-width: 60px;
}

.level-bar-fill {
    height: 100%;
    border-radius: var(--radius-full);
    transition: width var(--transition-normal);
}

.level-bar-fill.high {
    background: var(--success);
}

.level-bar-fill.medium {
    background: var(--warning);
}

.level-bar-fill.low {
    background: var(--danger);
}

.level-bar-text {
    font-size: var(--font-size-xs);
    font-weight: var(--font-weight-medium);
    color: var(--text-secondary);
    min-width: 35px;
}

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

.table-empty-state {
    padding: var(--space-12) var(--space-6);
    text-align: center;
}

.table-empty-icon {
    font-size: 48px;
    margin-bottom: var(--space-4);
    opacity: 0.5;
}

.table-empty-title {
    font-size: var(--font-size-lg);
    font-weight: var(--font-weight-semibold);
    color: var(--text-primary);
    margin-bottom: var(--space-2);
}

.table-empty-message {
    font-size: var(--font-size-sm);
    color: var(--text-muted);
}

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

.table-loading {
    padding: var(--space-12) var(--space-6);
    text-align: center;
    color: var(--text-muted);
}

.table-loading-spinner {
    display: inline-block;
    width: 32px;
    height: 32px;
    border: 3px solid var(--border-primary);
    border-top-color: var(--brand-primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin-bottom: var(--space-4);
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

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

@media (max-width: 1024px) {
    .table-enhanced-header {
        flex-direction: column;
        align-items: stretch;
    }

    .table-enhanced-controls {
        width: 100%;
        justify-content: stretch;
    }

    .table-search-input,
    .table-filter-select {
        flex: 1;
        min-width: 0;
    }
}

@media (max-width: 768px) {

    /* Stack table on mobile */
    .table-enhanced {
        display: block;
    }

    .table-enhanced thead {
        display: none;
    }

    .table-enhanced tbody {
        display: block;
    }

    .table-enhanced tbody tr {
        display: block;
        margin-bottom: var(--space-4);
        border: 1px solid var(--border-primary);
        border-radius: var(--radius-md);
        overflow: hidden;
    }

    .table-enhanced td {
        display: flex;
        justify-content: space-between;
        padding: var(--space-3) var(--space-4);
        border-bottom: 1px solid var(--border-primary);
    }

    .table-enhanced td:last-child {
        border-bottom: none;
    }

    .table-enhanced td::before {
        content: attr(data-label);
        font-weight: var(--font-weight-semibold);
        color: var(--text-secondary);
        font-size: var(--font-size-xs);
        text-transform: uppercase;
    }
}

/* ==================== DARK MODE ==================== */

[data-theme="dark"] .table-enhanced-container {
    background: var(--bg-tertiary);
}

[data-theme="dark"] .table-enhanced thead {
    background: var(--bg-secondary);
}

[data-theme="dark"] .table-enhanced tbody tr:hover {
    background: color-mix(in srgb, var(--bg-secondary) 95%, white);
}