/* ═══════════════════════════════════════════════════════════
   NETSENSE IOT - SITES V2
   Tabla estilo SaaS industrial
   ════════════════════════════════════════════════════════════ */

/* ═══ CONTAINER ═══ */
.sites-v2 {
    display: flex;
    flex-direction: column;
    gap: 20px;
    padding: 0;
}

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

.sites-header-left {
    display: flex;
    align-items: baseline;
    gap: 16px;
}

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

.sites-subtitle {
    font-size: 13px;
    color: var(--text-muted);
}

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

.hero-card {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background: var(--bg-secondary, #111827);
}

.hero-card.has-alerts {
    background: rgba(239, 68, 68, 0.08);
}

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

.hero-card-icon svg {
    width: 18px;
    height: 18px;
    stroke: var(--text-secondary);
}

.hero-card.has-alerts .hero-card-icon {
    background: rgba(239, 68, 68, 0.15);
}

.hero-card.has-alerts .hero-card-icon svg {
    stroke: #ef4444;
}

.hero-card-content {
    display: flex;
    flex-direction: column;
    gap: 0;
}

.hero-card-value {
    font-size: 22px;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.1;
}

.hero-card.has-alerts .hero-card-value {
    color: #ef4444;
}

.hero-card-label {
    font-size: 11px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

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

.sites-table-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));
}

.sites-table-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
}

.sites-table-wrapper {
    overflow-x: auto;
}

/* ═══ TABLE ═══ */
.sites-table {
    width: 100%;
    border-collapse: collapse;
}

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

.sites-table th {
    padding: 10px 16px;
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 1px solid var(--border-color, rgba(255, 255, 255, 0.1));
}

.sites-table th.col-site {
    text-align: left;
    padding-left: 20px;
}

.sites-table th.col-assets,
.sites-table th.col-alerts,
.sites-table th.col-status {
    text-align: center;
}

.sites-table th.col-reading {
    text-align: right;
}

/* ═══ TABLE ROWS ═══ */
.sites-table tbody tr {
    cursor: pointer;
    transition: background 0.15s ease;
    border-left: 3px solid transparent;
}

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

.sites-table tbody tr:not(:last-child) {
    border-bottom: 1px solid var(--border-color, rgba(255, 255, 255, 0.05));
}

.sites-table tbody tr.critical-row {
    border-left-color: #ef4444;
    background: rgba(239, 68, 68, 0.04);
}

.sites-table tbody tr.critical-row:hover {
    background: rgba(239, 68, 68, 0.08);
}

.sites-table tbody tr.warning-row {
    border-left-color: #f59e0b;
}

.sites-table td {
    padding: 12px 16px;
    font-size: 13px;
    color: var(--text-primary);
    vertical-align: middle;
    height: 44px;
}

/* Column: Site */
.sites-table td.col-site {
    padding-left: 20px;
}

.site-cell {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.site-cell-name {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
}

.site-cell-id {
    font-size: 11px;
    color: var(--text-muted);
}

/* Column: Assets */
.sites-table td.col-assets {
    text-align: center;
    font-family: 'JetBrains Mono', monospace;
    font-size: 14px;
    font-weight: 500;
}

/* Column: Alerts */
.sites-table td.col-alerts {
    text-align: center;
}

.alerts-cell {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 28px;
    padding: 2px 8px;
    border-radius: 4px;
    font-family: 'JetBrains Mono', monospace;
    font-size: 13px;
    font-weight: 600;
}

.alerts-cell.has-alerts {
    background: rgba(245, 158, 11, 0.15);
    color: #f59e0b;
}

.alerts-cell.no-alerts {
    color: var(--text-muted);
}

/* Column: Last Reading */
.sites-table td.col-reading {
    text-align: right;
    font-size: 12px;
    color: var(--text-secondary);
}

/* Column: Status */
.sites-table td.col-status {
    text-align: center;
}

/* ═══ EMPTY STATE ═══ */
.sites-table-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 48px 20px;
    color: var(--text-muted);
}

.sites-table-empty svg {
    width: 40px;
    height: 40px;
    margin-bottom: 12px;
    stroke: var(--text-muted);
}

.sites-table-empty span {
    font-size: 13px;
}

.sites-table-empty.hidden {
    display: none;
}

/* ═══ MAP SECTION ═══ */
.sites-map-section {
    margin-top: 4px;
}

.sites-map-card {
    background: var(--bg-secondary, #111827);
    border: 1px solid var(--border-color, rgba(255, 255, 255, 0.1));
    border-radius: 10px;
    overflow: hidden;
}

.sites-map-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-color);
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
}

.sites-map-header svg {
    width: 16px;
    height: 16px;
    stroke: var(--text-secondary);
}

.sites-map-container {
    height: 280px;
    width: 100%;
}

/* Leaflet overrides for dark theme */
.sites-map-container .leaflet-control-zoom {
    border: none !important;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3) !important;
}

.sites-map-container .leaflet-control-zoom a {
    background: var(--bg-secondary, #111827) !important;
    color: var(--text-primary) !important;
    border: 1px solid var(--border-color) !important;
}

.sites-map-container .leaflet-control-zoom a:hover {
    background: var(--bg-tertiary, #1a2142) !important;
}

/* ═══ SITE DETAIL PANEL ═══ */
.site-detail-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.75);
    z-index: 9998;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

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

.site-detail-panel {
    position: fixed;
    top: 0;
    right: 0;
    width: 400px;
    max-width: 100%;
    height: 100vh;
    background: var(--bg-secondary, #111827);
    border-left: 1px solid var(--border-color);
    z-index: 9999;
    display: flex;
    flex-direction: column;
    transform: translateX(100%);
    transition: transform 0.3s ease;
}

.site-detail-panel.open {
    transform: translateX(0);
}

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

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

.site-detail-close {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    color: var(--text-secondary);
    transition: all 0.2s ease;
}

.site-detail-close:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.site-detail-close svg {
    width: 18px;
    height: 18px;
}

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

.site-detail-footer {
    padding: 16px 20px;
    border-top: 1px solid var(--border-color);
}

.site-detail-footer .btn-primary {
    width: 100%;
    justify-content: center;
}

/* ═══ SITE DETAIL SECTIONS ═══ */
.site-detail-section {
    margin-bottom: 20px;
}

.site-detail-section:last-child {
    margin-bottom: 0;
}

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

.site-detail-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.site-detail-item {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.site-detail-label {
    font-size: 10px;
    color: var(--text-muted);
    text-transform: uppercase;
}

.site-detail-value {
    font-size: 13px;
    color: var(--text-primary);
}

.site-detail-value.mono {
    font-family: 'JetBrains Mono', monospace;
}

.site-detail-value.text-critical {
    color: #ef4444;
}

.site-detail-value.text-warning {
    color: #f59e0b;
}

/* ═══ FLUID LIST ═══ */
.site-detail-fluid-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.site-detail-fluid-card {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px;
    background: var(--bg-tertiary, #1a2142);
    border-radius: 6px;
}

.site-detail-fluid-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

.site-detail-fluid-info {
    flex: 1;
}

.site-detail-fluid-name {
    font-size: 12px;
    font-weight: 600;
}

.site-detail-fluid-stats {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 1px;
}

/* ═══ ASSETS LIST ═══ */
.site-detail-assets-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.site-detail-asset {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 10px;
    background: var(--bg-tertiary, #1a2142);
    border-radius: 6px;
}

.site-detail-asset-info {
    display: flex;
    align-items: center;
    gap: 6px;
}

.site-detail-asset-name {
    font-size: 12px;
    color: var(--text-primary);
}

.site-detail-asset-level {
    display: flex;
    align-items: center;
    gap: 6px;
}

.site-detail-asset-pct {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-primary);
    font-family: 'JetBrains Mono', monospace;
    min-width: 32px;
    text-align: right;
}

.site-detail-asset-bar {
    width: 50px;
    height: 5px;
    background: var(--bg-primary, #0d1321);
    border-radius: 3px;
    overflow: hidden;
}

.site-detail-asset-bar-fill {
    height: 100%;
    border-radius: 3px;
    transition: width 0.3s ease;
}

.site-detail-asset-bar-fill.ok {
    background: linear-gradient(90deg, #10b981, #34d399);
}

.site-detail-asset-bar-fill.warning {
    background: linear-gradient(90deg, #f59e0b, #fbbf24);
}

.site-detail-asset-bar-fill.critical {
    background: linear-gradient(90deg, #ef4444, #f87171);
}

.site-detail-empty {
    padding: 16px;
    text-align: center;
    color: var(--text-muted);
    font-size: 12px;
}

/* ═══ STATUS BADGE (reutilizar de dashboard) ═══ */
.status-badge-v4 {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.status-badge-v4.ok {
    background: rgba(16, 185, 129, 0.12);
    color: #10b981;
}

.status-badge-v4.warning {
    background: rgba(245, 158, 11, 0.12);
    color: #f59e0b;
}

.status-badge-v4.critical {
    background: rgba(239, 68, 68, 0.12);
    color: #ef4444;
}

.status-badge-v4.offline {
    background: rgba(100, 116, 139, 0.12);
    color: #64748b;
}

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

.status-badge-v4.ok .status-dot {
    background: #10b981;
}

.status-badge-v4.warning .status-dot {
    background: #f59e0b;
}

.status-badge-v4.critical .status-dot {
    background: #ef4444;
}

.status-badge-v4.offline .status-dot {
    background: #64748b;
}

/* ═══ STATUS DOT ═══ */
.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

.status-dot.ok {
    background: #10b981;
}

.status-dot.warning {
    background: #f59e0b;
}

.status-dot.critical {
    background: #ef4444;
}

.status-dot.offline {
    background: #64748b;
}

/* ═══ RESPONSIVE ═══ */
@media (max-width: 768px) {
    .sites-hero-strip {
        grid-template-columns: 1fr;
    }

    .site-detail-panel {
        width: 100%;
    }

    .sites-header-left {
        flex-direction: column;
        align-items: flex-start;
        gap: 4px;
    }

    .sites-map-container {
        height: 220px;
    }
}

/* ═══ LOADING ═══ */
.loading-placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px;
    color: var(--text-muted);
    font-size: 13px;
}

.hidden {
    display: none !important;
}