/* 1. VARIABLES Y CONFIGURACIÓN BASE */
:root {
    --on: #FFD700;
    --off: #444;
    --bg-page: #0a0a0a;
    --bg-section: #1c1c1c;
    --bg-card: #2a2a2a;
    --card-size: 75px;
    --glow: rgba(255, 215, 0, 0.3);
}

body {
    font-family: 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    background: var(--bg-page);
    color: white;
    margin: 0;
    padding: 10px;
    user-select: none;
    overflow-x: hidden;
}

/* 2. ESTRUCTURA DEL DASHBOARD */
#ui {
    column-count: 3;
    column-gap: 20px;
    width: 100%;
    max-width: 100vw;
    padding: 10px;
    box-sizing: border-box;
}

.section-block {
    break-inside: avoid;
    display: inline-block;
    width: 100%;
    background: var(--bg-section);
    border: 1px solid #333;
    border-radius: 15px;
    padding: 12px;
    margin-bottom: 20px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.5);
    box-sizing: border-box;
}

.section-header-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 2px solid var(--on);
    margin-bottom: 12px;
    padding-bottom: 6px;
}

.group-header {
    color: var(--on);
    font-size: 1rem;
    text-transform: uppercase;
    margin: 0;
    font-weight: bold;
    letter-spacing: 1px;
}

.header-badges { display: flex; gap: 6px; }

.internal-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(var(--card-size), 1fr));
    gap: 8px;
    width: 100%;
}

/* 3. ESTILOS DE TARJETAS (Específicos para el Dashboard) */
#ui .card, 
.global-badges-container .card,
.header-badges .card {
    background: var(--bg-card);
    width: var(--card-size);
    height: var(--card-size);
    border-radius: 10px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    border: 1px solid #444;
    box-sizing: border-box;
    transition: transform 0.1s, background 0.3s;
    overflow: hidden;
    color: white; /* Forzamos color para que no herede el de Bootstrap */
}

#ui .card.on,
.global-badges-container .card.on {
    border-color: var(--on);
    background: #443c00;
    box-shadow: 0 0 10px var(--glow);
}

/* Elementos internos de las tarjetas */
.card .icon-container {
    height: 38px;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
}

.card .icon-container svg {
    width: 32px;
    height: 32px;
    fill: #999;
    transition: fill 0.3s ease;
}

.card.on .icon-container svg {
    fill: var(--on) !important;
    filter: drop-shadow(0 0 3px var(--on));
}

.card .name {
    font-size: 0.55rem;
    color: #ccc;
    text-align: center;
    width: 90%;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-top: 4px;
    font-weight: 600;
}

.card .state-val {
    font-size: 0.55rem;
    color: var(--on);
    font-weight: bold;
    margin-top: 2px;
}

/* 4. VARIANTES DE TARJETAS (Header y Rows) */
.header-badges .card { 
    width: 40px !important; 
    height: 40px !important; 
    border-radius: 8px; 
    background: #333; 
}
.header-badges .icon-container { height: 26px; }
.header-badges .icon-container svg { width: 22px; height: 22px; }
.header-badges .name { display: none; }

.horizontal-row {
    grid-column: 1 / -1;
    display: flex;
    gap: 8px;
    margin: 4px 0;
    width: 100%;
}
.horizontal-row .card { flex: 1; height: var(--card-size); }

.global-badges-container {
    column-span: all;
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 25px;
    padding: 10px;
    width: 100%;
    box-sizing: border-box;
}

.global-badges-container .card {
    width: auto;
    min-width: 90px;
    height: 60px;
    border-radius: 8px;
    padding: 0 12px;
    flex-direction: row;
    gap: 8px;
    background: #222;
    border: 1px solid #444;
}

.global-badges-container .state-val { font-size: 0.8rem; margin: 0; white-space: nowrap; }
.global-badges-container .name { display: none; }

/* 5. ANIMACIONES */
@keyframes spin { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }

/* 6. RESPONSIVIDAD */
@media (max-width: 1024px) {
    #ui { column-count: 2; column-gap: 15px; }
}

@media (max-width: 600px) {
    :root { --card-size: 85px; }
    #ui { column-count: 1; padding: 5px; }
    .internal-grid { grid-template-columns: repeat(auto-fill, minmax(var(--card-size), 1fr)); }
    .global-badges-container .card { min-width: 80px; flex: 1 1 40%; }
}

/* 7. FIX CRÍTICO PARA EL MODAL DE BOOTSTRAP */
/* Esto asegura que el modal se vea bien aunque el dashboard sea oscuro */
.modal {
    color: #212529 !important; /* Texto oscuro para el modal blanco */
}
.modal-content {
    background-color: #ffffff !important;
    border-radius: 15px;
    border: none;
}
.modal-header {
    border-bottom: 1px solid #dee2e6;
}
.modal-body {
    padding: 20px;
    text-align: center;
}
/* Evita que las imágenes se desborden del popup */
.modal-body img {
    max-width: 100%;
    height: auto;
    border-radius: 8px;
}
