/* Porter Hub — vista unificada en tiempo real
   Layout: 2/3 izquierda (mesas arriba + pedidos abajo), 1/3 derecha (historial + feed). */

#hub-section {
    --hub-gap: 12px;
    --hub-radius: 14px;
    --hub-bg-card: rgba(20, 22, 30, 0.78);
    --hub-bg-card-hover: rgba(28, 32, 44, 0.85);
    --hub-border: rgba(255, 255, 255, 0.06);
    --hub-border-strong: rgba(255, 255, 255, 0.12);
    --hub-accent: #ffb020;
    --hub-accent-glow: rgba(255, 176, 32, 0.35);
    --hub-text: #e8eaed;
    --hub-text-dim: #8b8e95;
    --hub-text-faint: #5b5e65;
    --hub-green: #34d058;
    --hub-blue: #4aa3ff;
    --hub-purple: #b072ff;
    --hub-yellow: #ffb020;
    --hub-red: #ff5a5f;
    padding: 12px 16px;
    color: var(--hub-text);
    height: calc(100vh - var(--hub-top-offset, 96px));
    box-sizing: border-box;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

#content-hub.tab-content { padding: 0; height: 100%; overflow: hidden; }

.hub-grid {
    display: grid;
    grid-template-columns: minmax(0, 2fr) minmax(260px, 0.95fr);
    grid-template-rows: minmax(0, 1.05fr) minmax(0, 1fr);
    gap: var(--hub-gap);
    flex: 1;
    min-height: 0;
}

.hub-panel {
    background: var(--hub-bg-card);
    border: 1px solid var(--hub-border);
    border-radius: var(--hub-radius);
    backdrop-filter: blur(10px);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
    transition: border-color 0.2s;
}
.hub-panel:hover { border-color: var(--hub-border-strong); }

.hub-panel.col-mesas { grid-column: 1; grid-row: 1; }
.hub-panel.col-pedidos { grid-column: 1; grid-row: 2; }
.hub-panel.col-side { grid-column: 2; grid-row: 1 / span 2; }

.hub-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    border-bottom: 1px solid var(--hub-border);
    flex-shrink: 0;
}
.hub-panel-title {
    font-size: 0.78rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--hub-text-dim);
    display: flex;
    align-items: center;
    gap: 8px;
}
.hub-panel-title .pulse-dot {
    width: 6px; height: 6px;
    border-radius: 50%;
    background: var(--hub-green);
    box-shadow: 0 0 0 0 var(--hub-green);
    animation: hub-pulse-soft 2s infinite;
}
@keyframes hub-pulse-soft {
    0% { box-shadow: 0 0 0 0 rgba(52, 208, 88, 0.5); }
    70% { box-shadow: 0 0 0 6px rgba(52, 208, 88, 0); }
    100% { box-shadow: 0 0 0 0 rgba(52, 208, 88, 0); }
}
.hub-panel-meta {
    font-size: 0.72rem;
    color: var(--hub-text-faint);
}
.hub-panel-body { flex: 1; overflow: auto; padding: 12px; }
.hub-panel-body::-webkit-scrollbar { width: 6px; }
.hub-panel-body::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.08); border-radius: 3px; }

/* ─── KPIs strip (sobre el grid) ─── */
.hub-kpis {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: var(--hub-gap);
    margin-bottom: var(--hub-gap);
    flex-shrink: 0;
}
.hub-kpi {
    background: var(--hub-bg-card);
    border: 1px solid var(--hub-border);
    border-radius: 10px;
    padding: 8px 12px;
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.hub-kpi-label {
    font-size: 0.66rem;
    color: var(--hub-text-dim);
    text-transform: uppercase;
    letter-spacing: 0.06em;
}
.hub-kpi-value {
    font-size: 1.35rem;
    font-weight: 700;
    color: var(--hub-text);
    line-height: 1.1;
    font-variant-numeric: tabular-nums;
}
.hub-kpi-sub {
    font-size: 0.66rem;
    color: var(--hub-text-faint);
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

/* ─── Pisos ─── */
.hub-pisos { display: flex; flex-direction: column; gap: 10px; }
.hub-piso { display: flex; flex-direction: column; gap: 6px; }
.hub-piso-header {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    padding: 0 2px;
}
.hub-piso-name {
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--hub-text-dim);
}
.hub-piso-count {
    font-size: 0.7rem;
    color: var(--hub-text-faint);
    font-variant-numeric: tabular-nums;
}

/* ─── Mesas grid ─── */
.hub-mesas-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(64px, 1fr));
    gap: 8px;
}
.hub-mesa {
    aspect-ratio: 1 / 1;
    border-radius: 9px;
    background: rgba(255,255,255,0.02);
    border: 1.5px solid var(--hub-border);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    position: relative;
    transition: transform 0.12s, border-color 0.18s, background 0.18s;
    user-select: none;
    padding: 4px;
    box-sizing: border-box;
}
.hub-mesa:hover { transform: translateY(-1px); background: rgba(255,255,255,0.04); }
.hub-mesa-numero {
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--hub-text);
    line-height: 1;
}
.hub-mesa-total {
    font-size: 0.62rem;
    color: var(--hub-text-dim);
    margin-top: 3px;
    font-variant-numeric: tabular-nums;
    font-weight: 600;
}
.hub-mesa[data-estado="libre"] { border-color: rgba(52, 208, 88, 0.25); }
.hub-mesa[data-estado="libre"] .hub-mesa-numero { color: rgba(232, 234, 237, 0.45); }
.hub-mesa[data-estado="ocupada"] { border-color: var(--hub-blue); background: rgba(74, 163, 255, 0.08); }
.hub-mesa[data-estado="ocupada"] .hub-mesa-total { color: var(--hub-blue); }
.hub-mesa[data-estado="reservada"] { border-color: var(--hub-purple); background: rgba(176, 114, 255, 0.08); }
.hub-mesa[data-estado="cuenta"] { border-color: var(--hub-yellow); background: rgba(255, 176, 32, 0.1); }
.hub-mesa[data-estado="cuenta"] .hub-mesa-total { color: var(--hub-yellow); }
.hub-mesa.flash { animation: hub-flash 0.6s ease; }
@keyframes hub-flash {
    0% { box-shadow: 0 0 0 0 var(--hub-accent-glow); }
    50% { box-shadow: 0 0 0 6px var(--hub-accent-glow); }
    100% { box-shadow: 0 0 0 0 transparent; }
}

/* ─── Pedidos kanban mini (4 cols) ─── */
.hub-pedidos-cols {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 8px;
    height: 100%;
}
.hub-pedidos-col {
    display: flex;
    flex-direction: column;
    background: rgba(0,0,0,0.18);
    border-radius: 10px;
    border: 1px solid var(--hub-border);
    overflow: hidden;
    min-height: 0;
}
.hub-pedidos-col-header {
    padding: 8px 10px;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--hub-border);
    flex-shrink: 0;
}
.hub-pedidos-col[data-estado="PENDIENTE"] .hub-pedidos-col-header { color: var(--hub-yellow); }
.hub-pedidos-col[data-estado="EN_PREPARACION"] .hub-pedidos-col-header { color: var(--hub-blue); }
.hub-pedidos-col[data-estado="EN_CAMINO"] .hub-pedidos-col-header { color: var(--hub-purple); }
.hub-pedidos-col[data-estado="ENTREGADO"] .hub-pedidos-col-header { color: var(--hub-green); }
.hub-pedidos-col-count {
    background: rgba(255,255,255,0.06);
    border-radius: 999px;
    padding: 1px 7px;
    font-size: 0.68rem;
    color: var(--hub-text);
}
.hub-pedidos-col-list {
    flex: 1;
    overflow-y: auto;
    padding: 6px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.hub-pedidos-col-list::-webkit-scrollbar { width: 4px; }
.hub-pedidos-col-list::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.08); border-radius: 2px; }

.hub-pedido-card {
    background: rgba(255,255,255,0.04);
    border: 1px solid var(--hub-border);
    border-radius: 8px;
    padding: 8px 10px;
    cursor: pointer;
    transition: background 0.15s, transform 0.12s, border-color 0.15s;
    animation: hub-slide-in 0.4s ease;
}
.hub-pedido-card:hover {
    background: rgba(255,255,255,0.07);
    border-color: var(--hub-border-strong);
    transform: translateY(-1px);
}
.hub-pedido-card-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 6px;
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--hub-text);
}
.hub-pedido-card-cliente {
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
    flex: 1; min-width: 0;
}
.hub-pedido-card-total {
    color: var(--hub-accent);
    font-variant-numeric: tabular-nums;
}
.hub-pedido-card-meta {
    display: flex;
    justify-content: space-between;
    margin-top: 4px;
    font-size: 0.66rem;
    color: var(--hub-text-faint);
}
.hub-pedido-card.fresh {
    border-color: var(--hub-accent);
    box-shadow: 0 0 0 0 var(--hub-accent-glow);
    animation: hub-fresh-pulse 1.6s ease 1, hub-slide-in 0.4s ease;
}
@keyframes hub-fresh-pulse {
    0% { box-shadow: 0 0 0 0 var(--hub-accent-glow); }
    60% { box-shadow: 0 0 0 8px transparent; }
    100% { box-shadow: 0 0 0 0 transparent; }
}
@keyframes hub-slide-in {
    from { opacity: 0; transform: translateY(-6px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ─── Side column: historial + feed ─── */
.hub-side {
    display: flex;
    flex-direction: column;
    height: 100%;
    min-height: 0;
}
.hub-side-section {
    display: flex;
    flex-direction: column;
    min-height: 0;
}
.hub-side-section.historial { flex: 1 1 50%; border-bottom: 1px solid var(--hub-border); }
.hub-side-section.feed { flex: 1 1 50%; }
.hub-side-section .hub-panel-body { padding: 10px 12px; }

.hub-side-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.hub-side-item {
    display: flex;
    gap: 10px;
    padding: 8px 10px;
    background: rgba(255,255,255,0.025);
    border: 1px solid transparent;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s;
    animation: hub-slide-in 0.35s ease;
}
.hub-side-item:hover {
    background: rgba(255,255,255,0.05);
    border-color: var(--hub-border);
}
.hub-side-item-icon {
    width: 28px; height: 28px;
    border-radius: 50%;
    background: rgba(255,255,255,0.05);
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
    font-size: 0.95rem;
}
.hub-side-item-body {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.hub-side-item-title {
    font-size: 0.82rem;
    color: var(--hub-text);
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.hub-side-item-meta {
    font-size: 0.7rem;
    color: var(--hub-text-faint);
    display: flex; gap: 8px;
}
.hub-side-item.fresh {
    background: rgba(255, 176, 32, 0.08);
    border-color: var(--hub-accent);
    animation: hub-fresh-glow 2s ease 1, hub-slide-in 0.35s ease;
}
@keyframes hub-fresh-glow {
    0% { box-shadow: inset 0 0 0 0 var(--hub-accent-glow); }
    50% { box-shadow: inset 0 0 18px 0 var(--hub-accent-glow); }
    100% { box-shadow: inset 0 0 0 0 transparent; }
}

.hub-empty {
    text-align: center;
    color: var(--hub-text-faint);
    font-size: 0.78rem;
    padding: 24px 12px;
}

/* RT status indicator (top right of header) */
#rt-status-dot {
    width: 8px; height: 8px;
    border-radius: 50%;
    display: inline-block;
    background: #888;
    margin-left: 6px;
    vertical-align: middle;
    transition: background 0.3s;
}
#rt-status-dot[data-status="connected"] { background: var(--hub-green); box-shadow: 0 0 6px rgba(52, 208, 88, 0.5); }
#rt-status-dot[data-status="connecting"] { background: var(--hub-yellow); animation: hub-pulse-soft 1.2s infinite; }
#rt-status-dot[data-status="offline"] { background: var(--hub-red); }

/* Tab del Hub: badge con conteo de feed */
#tab-hub .tab-icon { filter: drop-shadow(0 0 2px var(--hub-accent-glow)); }

/* Responsive: mobile/tablet */
@media (max-width: 1100px) {
    .hub-grid {
        grid-template-columns: 1fr;
        grid-template-rows: auto auto auto;
        height: auto;
    }
    .hub-panel.col-mesas { grid-column: 1; grid-row: 1; min-height: 280px; }
    .hub-panel.col-pedidos { grid-column: 1; grid-row: 2; min-height: 360px; }
    .hub-panel.col-side { grid-column: 1; grid-row: 3; min-height: 420px; }
    .hub-kpis { grid-template-columns: repeat(2, 1fr); }
    .hub-pedidos-cols { grid-template-columns: repeat(2, 1fr); grid-template-rows: repeat(2, 1fr); gap: 6px; }
}
