/* ═══════════════════════════════════════════════════════════
   NETSENSE IOT - DASHBOARD V4
   Command Center Style - Dense but Calm
   ════════════════════════════════════════════════════════════ */

/* ═══ DASHBOARD CONTAINER ═══ */
.dashboard-v4 {
    display: flex;
    flex-direction: column;
    gap: 20px;
    padding: 0;
}

/* ═══ DASHBOARD HEADER ═══ */
.dash-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 0;
    border-bottom: 1px solid var(--border-color, rgba(255,255,255,0.1));
    flex-wrap: wrap;
    gap: 12px;
}

.dash-header-left {
    display: flex;
    align-items: center;
    gap: 20px;
}

.dash-header-title {
    font-size: 22px;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
}

.dash-site-selector {
    padding: 8px 32px 8px 12px;
    background: var(--bg-tertiary, #1a2142);
    border: 1px solid var(--border-color, rgba(255,255,255,0.1));
    border-radius: 6px;
    color: var(--text-primary);
    font-size: 13px;
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%2394a3b8' d='M6 9L1 4h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    min-width: 160px;
}

.dash-site-selector:focus {
    outline: none;
    border-color: var(--brand-primary, #0066cc);
}

.dash-header-right {
    display: flex;
    align-items: center;
    gap: 16px;
}

.dash-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    background: var(--bg-tertiary, #1a2142);
    border-radius: 20px;
    font-size: 12px;
    color: var(--text-secondary);
}

.dash-badge-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--color-success, #00c853);
    animation: pulse-dot 2s infinite;
}

@keyframes pulse-dot {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.dash-user-badge {
    font-weight: 500;
    color: var(--text-muted);
}

/* ═══ HERO STRIP ═══ */
.hero-strip {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 1px;
    background: var(--border-color, rgba(255,255,255,0.1));
    border-radius: 10px;
    overflow: hidden;
}

.hero-block {
    background: var(--bg-secondary, #141b3d);
    padding: 20px 24px;
    min-height: 140px;
    display: flex;
    flex-direction: column;
}

.hero-block:first-child {
    border-radius: 10px 0 0 10px;
}

.hero-block:last-child {
    border-radius: 0 10px 10px 0;
}

.hero-block-title {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: var(--text-muted);
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.hero-block-title svg {
    width: 14px;
    height: 14px;
    opacity: 0.7;
}

/* Hero Block A - Próxima Reposición */
.hero-runout-value {
    font-size: 36px;
    font-weight: 700;
    font-family: var(--font-mono, monospace);
    color: var(--text-primary);
    line-height: 1;
    margin-bottom: 8px;
}

.hero-runout-value.critical {
    color: var(--color-danger, #ef5350);
}

.hero-runout-value.warning {
    color: var(--color-warning, #ffa726);
}

.hero-runout-value.ok {
    color: var(--color-success, #00c853);
}

.hero-runout-asset {
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 4px;
}

.hero-runout-level {
    font-size: 12px;
    color: var(--text-muted);
    margin-bottom: 12px;
}

.hero-runout-link {
    font-size: 12px;
    color: var(--brand-primary, #0066cc);
    text-decoration: none;
    cursor: pointer;
    margin-top: auto;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.hero-runout-link:hover {
    text-decoration: underline;
}

.hero-no-risk {
    display: flex;
    flex-direction: column;
    justify-content: center;
    flex: 1;
}

.hero-no-risk-text {
    font-size: 16px;
    font-weight: 500;
    color: var(--color-success, #00c853);
    margin-bottom: 8px;
}

.hero-no-risk-sub {
    font-size: 13px;
    color: var(--text-muted);
}

/* Hero Block B - Riesgo Operativo */
.hero-risk-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    flex: 1;
}

.hero-risk-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 6px 10px;
    border-radius: 6px;
    font-size: 13px;
    background: var(--bg-tertiary, #1a2142);
}

.hero-risk-item.highlight {
    background: var(--color-danger-bg, rgba(239, 83, 80, 0.15));
    border: 1px solid var(--color-danger-border, rgba(239, 83, 80, 0.3));
}

.hero-risk-item.highlight-warning {
    background: var(--color-warning-bg, rgba(255, 167, 38, 0.15));
    border: 1px solid var(--color-warning-border, rgba(255, 167, 38, 0.3));
}

.hero-risk-label {
    color: var(--text-secondary);
}

.hero-risk-badge {
    font-weight: 600;
    font-family: var(--font-mono, monospace);
    min-width: 24px;
    text-align: right;
}

.hero-risk-badge.critical { color: var(--color-danger, #ef5350); }
.hero-risk-badge.warning { color: var(--color-warning, #ffa726); }
.hero-risk-badge.info { color: var(--color-info, #42a5f5); }
.hero-risk-badge.muted { color: var(--text-muted); }

/* Hero Block C - Salud del Sistema */
.hero-health-grid {
    display: flex;
    flex-direction: column;
    gap: 12px;
    flex: 1;
}

.hero-health-main {
    display: flex;
    align-items: baseline;
    gap: 8px;
}

.hero-health-value {
    font-size: 42px;
    font-weight: 700;
    font-family: var(--font-mono, monospace);
    line-height: 1;
}

.hero-health-value.excellent { color: var(--color-success, #00c853); }
.hero-health-value.good { color: var(--color-info, #42a5f5); }
.hero-health-value.warning { color: var(--color-warning, #ffa726); }
.hero-health-value.critical { color: var(--color-danger, #ef5350); }

.hero-health-label {
    font-size: 14px;
    color: var(--text-muted);
}

.hero-health-stats {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-top: auto;
}

.hero-health-stat {
    display: flex;
    justify-content: space-between;
    font-size: 13px;
}

.hero-health-stat-label {
    color: var(--text-muted);
}

.hero-health-stat-value {
    font-weight: 500;
    color: var(--text-secondary);
    font-family: var(--font-mono, monospace);
}

/* ═══ ASSETS TABLE SECTION ═══ */
.assets-section {
    background: var(--bg-secondary, #141b3d);
    border-radius: 10px;
    border: 1px solid var(--border-color, rgba(255,255,255,0.1));
    overflow: hidden;
}

.assets-section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-color, rgba(255,255,255,0.1));
    flex-wrap: wrap;
    gap: 12px;
}

.assets-section-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
}

.assets-filters {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.filter-chip {
    padding: 6px 14px;
    background: var(--bg-tertiary, #1a2142);
    border: 1px solid transparent;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 500;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.15s ease;
}

.filter-chip:hover {
    background: var(--bg-elevated, #1f2749);
    color: var(--text-primary);
}

.filter-chip.active {
    background: var(--brand-primary, #0066cc);
    color: white;
    border-color: var(--brand-primary, #0066cc);
}

.filter-chip[data-filter="critical"].active {
    background: var(--color-danger, #ef5350);
    border-color: var(--color-danger, #ef5350);
}

.filter-chip[data-filter="warning"].active {
    background: var(--color-warning, #ffa726);
    border-color: var(--color-warning, #ffa726);
    color: #000;
}

.filter-chip[data-filter="offline"].active {
    background: var(--text-muted);
    border-color: var(--text-muted);
}

.assets-search {
    padding: 8px 12px;
    background: var(--bg-tertiary, #1a2142);
    border: 1px solid var(--border-color, rgba(255,255,255,0.1));
    border-radius: 6px;
    color: var(--text-primary);
    font-size: 13px;
    width: 200px;
}

.assets-search:focus {
    outline: none;
    border-color: var(--brand-primary, #0066cc);
}

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

/* Assets Table */
.assets-table-wrapper {
    overflow-x: auto;
}

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

.assets-table thead {
    background: var(--bg-tertiary, #1a2142);
}

.assets-table th {
    padding: 12px 16px;
    text-align: left;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border-color, rgba(255,255,255,0.1));
    white-space: nowrap;
}

.assets-table tbody tr {
    cursor: pointer;
    transition: background 0.15s ease;
}

.assets-table tbody tr:hover {
    background: var(--bg-hover, rgba(255,255,255,0.03));
}

.assets-table tbody tr:focus {
    outline: 2px solid var(--brand-primary, #0066cc);
    outline-offset: -2px;
}

.assets-table td {
    padding: 14px 16px;
    font-size: 13px;
    color: var(--text-primary);
    border-bottom: 1px solid var(--border-color, rgba(255,255,255,0.05));
    vertical-align: middle;
}

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

/* Asset name cell */
.asset-name-cell {
    display: flex;
    align-items: center;
    gap: 10px;
}

.asset-icon {
    width: 32px;
    height: 32px;
    border-radius: 6px;
    background: var(--bg-tertiary, #1a2142);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.asset-icon svg {
    width: 18px;
    height: 18px;
    color: var(--text-muted);
}

.asset-name {
    font-weight: 500;
}

.asset-id {
    font-size: 11px;
    color: var(--text-muted);
    font-family: var(--font-mono, monospace);
}

/* Level bar in cell */
.level-cell {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 120px;
}

.level-bar-container {
    flex: 1;
    height: 6px;
    background: var(--bg-tertiary, #1a2142);
    border-radius: 3px;
    overflow: hidden;
    min-width: 60px;
}

.level-bar {
    height: 100%;
    border-radius: 3px;
    transition: width 0.3s ease;
}

.level-bar.ok { background: var(--color-success, #00c853); }
.level-bar.warning { background: var(--color-warning, #ffa726); }
.level-bar.critical { background: var(--color-danger, #ef5350); }
.level-bar.offline { background: var(--text-muted); }

.level-pct {
    font-family: var(--font-mono, monospace);
    font-weight: 500;
    min-width: 36px;
    text-align: right;
}

/* Volume cell */
.volume-cell {
    font-family: var(--font-mono, monospace);
    color: var(--text-secondary);
}

/* Autonomy cell */
.autonomy-cell {
    font-family: var(--font-mono, monospace);
    font-weight: 600;
}

.autonomy-cell.critical { color: var(--color-danger, #ef5350); }
.autonomy-cell.warning { color: var(--color-warning, #ffa726); }
.autonomy-cell.ok { color: var(--text-primary); }

/* Status badge */
.status-badge-v4 {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.status-badge-v4.ok {
    background: var(--color-success-bg, rgba(0,200,83,0.15));
    color: var(--color-success, #00c853);
}

.status-badge-v4.warning {
    background: var(--color-warning-bg, rgba(255,167,38,0.15));
    color: var(--color-warning, #ffa726);
}

.status-badge-v4.critical {
    background: var(--color-danger-bg, rgba(239,83,80,0.15));
    color: var(--color-danger, #ef5350);
}

.status-badge-v4.offline {
    background: rgba(148,163,184,0.15);
    color: var(--text-muted);
}

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

/* Last seen cell */
.lastseen-cell {
    font-size: 12px;
    color: var(--text-muted);
}

.lastseen-cell.stale {
    color: var(--color-warning, #ffa726);
}

/* Empty state */
.assets-empty {
    padding: 48px 24px;
    text-align: center;
    color: var(--text-muted);
}

.assets-empty svg {
    width: 48px;
    height: 48px;
    margin-bottom: 12px;
    opacity: 0.5;
}

.assets-empty-text {
    font-size: 14px;
}

/* ═══ EVENTS FOOTER ═══ */
.events-section {
    background: var(--bg-secondary, #141b3d);
    border-radius: 10px;
    border: 1px solid var(--border-color, rgba(255,255,255,0.1));
    overflow: hidden;
}

.events-section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 20px;
    border-bottom: 1px solid var(--border-color, rgba(255,255,255,0.1));
}

.events-section-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
    display: flex;
    align-items: center;
    gap: 8px;
}

.events-section-link {
    font-size: 12px;
    color: var(--brand-primary, #0066cc);
    text-decoration: none;
}

.events-section-link:hover {
    text-decoration: underline;
}

.events-list {
    display: flex;
    flex-direction: column;
}

.event-item {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 12px 20px;
    border-bottom: 1px solid var(--border-color, rgba(255,255,255,0.05));
    cursor: pointer;
    transition: background 0.15s ease;
}

.event-item:last-child {
    border-bottom: none;
}

.event-item:hover {
    background: var(--bg-hover, rgba(255,255,255,0.03));
}

.event-type-badge {
    padding: 4px 10px;
    border-radius: 4px;
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    white-space: nowrap;
    flex-shrink: 0;
}

.event-type-badge.anomaly {
    background: var(--color-danger-bg, rgba(239,83,80,0.15));
    color: var(--color-danger, #ef5350);
}

.event-type-badge.refill {
    background: var(--color-success-bg, rgba(0,200,83,0.15));
    color: var(--color-success, #00c853);
}

.event-type-badge.offline {
    background: rgba(148,163,184,0.15);
    color: var(--text-muted);
}

.event-type-badge.alert {
    background: var(--color-warning-bg, rgba(255,167,38,0.15));
    color: var(--color-warning, #ffa726);
}

.event-info {
    flex: 1;
    min-width: 0;
}

.event-asset {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.event-summary {
    font-size: 12px;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-top: 2px;
}

.event-time {
    font-size: 11px;
    color: var(--text-muted);
    white-space: nowrap;
    flex-shrink: 0;
}

.events-empty {
    padding: 32px 24px;
    text-align: center;
    color: var(--text-muted);
    font-size: 13px;
}

/* ═══ ASSET DETAIL PANEL (Side Modal) ═══ */
.asset-detail-panel {
    position: fixed;
    top: 0;
    right: -420px;
    width: 400px;
    max-width: 90vw;
    height: 100vh;
    background: var(--bg-secondary, #141b3d);
    border-left: 1px solid var(--border-color, rgba(255,255,255,0.1));
    z-index: 1050;
    transition: right 0.25s ease;
    display: flex;
    flex-direction: column;
    box-shadow: -10px 0 30px rgba(0,0,0,0.3);
}

.asset-detail-panel.open {
    right: 0;
}

.asset-detail-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.85);
    z-index: 1049;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.25s ease, visibility 0.25s ease;
}

.asset-detail-backdrop.open {
    opacity: 1;
    visibility: visible;
}

.asset-detail-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px;
    border-bottom: 1px solid var(--border-color, rgba(255,255,255,0.1));
}

.asset-detail-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
}

.asset-detail-close {
    width: 32px;
    height: 32px;
    border-radius: 6px;
    background: var(--bg-tertiary, #1a2142);
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s ease;
}

.asset-detail-close:hover {
    background: var(--bg-elevated, #1f2749);
    color: var(--text-primary);
}

.asset-detail-body {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
}

.asset-detail-section {
    margin-bottom: 24px;
}

.asset-detail-section-title {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    margin-bottom: 12px;
}

.asset-detail-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.asset-detail-item {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.asset-detail-item.full-width {
    grid-column: 1 / -1;
}

.asset-detail-label {
    font-size: 11px;
    color: var(--text-muted);
}

.asset-detail-value {
    font-size: 15px;
    font-weight: 500;
    color: var(--text-primary);
}

.asset-detail-value.mono {
    font-family: var(--font-mono, monospace);
}

.asset-detail-value.large {
    font-size: 28px;
    font-weight: 700;
}

.asset-detail-footer {
    padding: 16px 20px;
    border-top: 1px solid var(--border-color, rgba(255,255,255,0.1));
}

.asset-detail-link {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px;
    background: var(--brand-primary, #0066cc);
    border: none;
    border-radius: 8px;
    color: white;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    width: 100%;
    transition: background 0.15s ease;
}

.asset-detail-link:hover {
    background: var(--brand-primary-hover, #0052a3);
}

/* ═══ EVENT DETAIL MODAL ═══ */
.event-modal-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.6);
    z-index: 1059;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s ease, visibility 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.event-modal-backdrop.open {
    opacity: 1;
    visibility: visible;
}

.event-modal {
    background: var(--bg-secondary, #141b3d);
    border: 1px solid var(--border-color, rgba(255,255,255,0.1));
    border-radius: 12px;
    width: 100%;
    max-width: 480px;
    max-height: 80vh;
    overflow: hidden;
    transform: scale(0.95);
    transition: transform 0.2s ease;
}

.event-modal-backdrop.open .event-modal {
    transform: scale(1);
}

.event-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px;
    border-bottom: 1px solid var(--border-color, rgba(255,255,255,0.1));
}

.event-modal-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
}

.event-modal-close {
    width: 32px;
    height: 32px;
    border-radius: 6px;
    background: var(--bg-tertiary, #1a2142);
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.event-modal-close:hover {
    background: var(--bg-elevated, #1f2749);
    color: var(--text-primary);
}

.event-modal-body {
    padding: 20px;
    overflow-y: auto;
}

.event-modal-row {
    display: flex;
    justify-content: space-between;
    padding: 10px 0;
    border-bottom: 1px solid var(--border-color, rgba(255,255,255,0.05));
}

.event-modal-row:last-child {
    border-bottom: none;
}

.event-modal-label {
    font-size: 13px;
    color: var(--text-muted);
}

.event-modal-value {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-primary);
    text-align: right;
}

/* ═══ RESPONSIVE ═══ */
@media (max-width: 1024px) {
    .hero-strip {
        grid-template-columns: 1fr 1fr;
    }
    
    .hero-block:nth-child(3) {
        grid-column: 1 / -1;
        border-radius: 0 0 10px 10px;
    }
    
    .hero-block:first-child {
        border-radius: 10px 0 0 0;
    }
    
    .hero-block:nth-child(2) {
        border-radius: 0 10px 0 0;
    }
}

@media (max-width: 768px) {
    .dash-header {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .dash-header-right {
        width: 100%;
        justify-content: space-between;
    }
    
    .hero-strip {
        grid-template-columns: 1fr;
    }
    
    .hero-block,
    .hero-block:first-child,
    .hero-block:nth-child(2),
    .hero-block:nth-child(3) {
        border-radius: 0;
    }
    
    .hero-block:first-child {
        border-radius: 10px 10px 0 0;
    }
    
    .hero-block:last-child {
        border-radius: 0 0 10px 10px;
    }
    
    .assets-section-header {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .assets-filters {
        width: 100%;
    }
    
    .assets-search {
        width: 100%;
    }
    
    .assets-table th:nth-child(3),
    .assets-table td:nth-child(3),
    .assets-table th:nth-child(4),
    .assets-table td:nth-child(4) {
        display: none;
    }
    
    .asset-detail-panel {
        width: 100%;
        max-width: 100%;
        right: -100%;
    }
}

@media (max-width: 480px) {
    .filter-chip {
        padding: 5px 10px;
        font-size: 11px;
    }
    
    .hero-runout-value {
        font-size: 28px;
    }
    
    .hero-health-value {
        font-size: 32px;
    }
    
    .assets-table th:nth-child(5),
    .assets-table td:nth-child(5) {
        display: none;
    }
}

/* Sensor Type Badge */
.sensor-type-badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-left: 8px;
}

.sensor-type-badge.lorawan {
    background: rgba(139, 92, 246, 0.15);
    color: #a78bfa;
}

.text-warning {
    color: var(--color-warning, #f59e0b) !important;
}