/* Variables CSS (Paleta de Colores Base - Se ajustará con el logo) */
:root {
    --primary-theme: #e0a800; /* Amarillo mostaza */
    --primary-theme-hover: #c69500;
    --car-red: #D32F2F; /* Rojo bomberil para carros */
    --car-red-hover: #B71C1C;
    --dark-bg: #121212; /* Gris muy oscuro casi negro */
    --dark-card: #1E1E1E; /* Gris oscuro para tarjetas */
    --text-main: #FFFFFF;
    --text-muted: #B0BEC5;
    
    --success: #388E3C;
    --warning: #FBC02D;
    --danger: #D32F2F;
    
    --border-radius: 12px;
    --transition: 0.3s ease;
}

body.light-theme {
    --dark-bg: #F0F2F5;
    --dark-card: #FFFFFF;
    --text-main: #212121;
    --text-muted: #607D8B;
}

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

body.light-theme .car-toggle-ui {
    border-color: #CFD8DC;
}

body.light-theme .main-header {
    background: #FFFFFF;
    border-bottom: 3px solid var(--primary-theme);
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

body.light-theme .form-group input, 
body.light-theme .form-group select,
body.light-theme #inventory-filter {
    background-color: #FFFFFF !important;
    border: 1px solid #CFD8DC !important;
    color: #212121 !important;
}

body.light-theme .category-card,
body.light-theme .form-container,
body.light-theme .modal-content {
    border: 1px solid #E0E0E0;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
}

body.light-theme .inventory-list-item {
    border-top: 1px solid #E0E0E0;
    border-right: 1px solid #E0E0E0;
    border-bottom: 1px solid #E0E0E0;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
}

body.light-theme .btn-secondary {
    border: 1px solid #90A4AE;
    color: #212121;
}

body.light-theme .btn-edit, 
body.light-theme .btn-delete,
body.light-theme .btn-log {
    background: #F5F5F5;
    border: 1px solid #E0E0E0;
}

body.light-theme .btn-delete:hover { background: rgba(255, 82, 82, 0.1); }
body.light-theme .btn-edit:hover { background: rgba(0, 0, 0, 0.05); }
body.light-theme .btn-log:hover { background: rgba(156, 39, 176, 0.1); }

.hidden {
    display: none !important;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', 'Roboto', sans-serif;
    background-color: var(--dark-bg);
    color: var(--text-main);
    line-height: 1.6;
}

/* Header */
.main-header {
    background: linear-gradient(135deg, var(--dark-bg) 0%, var(--dark-card) 100%);
    border-bottom: 3px solid var(--primary-theme);
    padding: 2rem 1rem;
    text-align: center;
    box-shadow: 0 4px 6px rgba(0,0,0,0.3);
    position: relative;
}

.btn-back-global {
    position: absolute;
    top: 20px;
    left: 15px;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: var(--text-main);
    padding: 8px 15px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: var(--transition);
    z-index: 100;
    text-decoration: none;
}

.btn-back-global:hover {
    background: rgba(255, 255, 255, 0.1);
}

.logo-container {
    width: 80px;
    height: 80px;
    margin: 0 auto 1rem;
    background-color: #FFFFFF; /* Fondo blanco para el logo sin fondo */
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid var(--primary-theme);
    overflow: hidden;
}

.logo-container img, #header-logo {
    width: 90%;
    height: 90%;
    object-fit: contain;
    display: none; /* Hide by default to prevent flashing wrong logo */
}

.logo-placeholder i {
    font-size: 2rem;
    color: var(--primary-theme);
}

.main-header h1 {
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: 1px;
}

.subtitle {
    color: var(--text-muted);
    font-size: 0.9rem;
}

/* Header Actions & Dropdown */
.header-actions {
    position: absolute;
    top: 2rem;
    left: 2rem;
    z-index: 100;
}

.settings-btn {
    background: transparent;
    border: none;
    color: var(--text-main);
    font-size: 1.5rem;
    cursor: pointer;
    transition: var(--transition);
}

.settings-btn:hover {
    color: var(--primary-theme);
    transform: rotate(45deg);
}

.dropdown-menu {
    position: absolute;
    top: 100%;
    left: 0;
    margin-top: 10px;
    background-color: var(--dark-card);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 8px;
    min-width: 200px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.5);
    display: flex;
    flex-direction: column;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all 0.3s ease;
}

.dropdown-menu.active {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.dropdown-item {
    padding: 12px 20px;
    color: var(--text-main);
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 15px;
    transition: background 0.2s;
    font-size: 0.95rem;
    white-space: nowrap;
}

.dropdown-item:hover {
    background-color: rgba(255,255,255,0.05);
    color: var(--primary-theme);
}

.dropdown-item i {
    width: 20px;
    text-align: center;
}

body.light-theme .dropdown-menu {
    background-color: #FFFFFF;
    border: 1px solid #E0E0E0;
    box-shadow: 0 4px 15px rgba(0,0,0,0.1);
}

body.light-theme .dropdown-item {
    color: #212121;
}

body.light-theme .dropdown-item:hover {
    background-color: #F5F5F5;
}

body.light-theme .settings-btn {
    color: #212121;
}

/* Container & Sections */
.container {
    padding: 1.5rem 1rem;
    max-width: 800px;
    margin: 0 auto;
}

.view-section {
    display: none;
    animation: fadeIn 0.4s ease-out;
}

.view-section.active {
    display: block;
}

.section-title {
    font-size: 1.2rem;
    margin-bottom: 1.5rem;
    text-align: center;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1px;
}

/* Dashboard Cards */
.category-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 1rem;
}

.category-card {
    background-color: var(--dark-card);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: var(--border-radius);
    padding: 1.5rem 1rem;
    text-align: center;
    cursor: pointer;
    transition: var(--transition);
    color: var(--text-main);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    position: relative;
    overflow: hidden;
    min-height: 120px;
}

.category-card:hover, .category-card:active {
    transform: translateY(-5px);
    box-shadow: 0 8px 15px rgba(224, 168, 0, 0.2);
    border-color: var(--primary-theme);
}

.category-card i {
    font-size: 2.5rem;
    z-index: 2;
}

.icon-red { color: var(--car-red); }
.icon-gray { color: var(--text-muted); }

.category-card h3 {
    font-size: 1rem;
    font-weight: 800;
    z-index: 2;
    text-shadow: 0 2px 4px rgba(0,0,0,0.8);
}

.img-card {
    background-size: cover;
    background-position: center;
}

.img-card::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background: linear-gradient(to top, rgba(0,0,0,0.9) 0%, rgba(0,0,0,0.4) 100%);
    z-index: 1;
}

.img-card:hover::before {
    background: linear-gradient(to top, rgba(211,47,47,0.8) 0%, rgba(0,0,0,0.5) 100%);
}

/* Inventory View */
.inventory-header {
    display: flex;
    align-items: center;
    margin-bottom: 1.5rem;
    gap: 1rem;
}

.inventory-header h2 {
    font-size: 1.3rem;
    flex-grow: 1;
}

/* Buttons */
button {
    font-family: inherit;
    border: none;
    outline: none;
    cursor: pointer;
    border-radius: 8px;
    transition: var(--transition);
}

.btn-icon {
    background: transparent;
    color: var(--text-muted);
    font-size: 1rem;
    padding: 0.5rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.btn-icon:hover { color: var(--text-main); }

.btn-primary {
    background-color: var(--primary-theme);
    color: #111;
    padding: 0.8rem 1.5rem;
    font-size: 1rem;
    font-weight: 800;
    width: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 0.5rem;
}

.btn-primary:hover { background-color: var(--primary-theme-hover); }

.btn-success { background-color: var(--success); color: white; padding: 0.8rem 1.5rem; font-weight: bold; flex: 1; }
.btn-secondary { background-color: transparent; color: var(--text-main); border: 1px solid rgba(255,255,255,0.2); padding: 0.8rem 1.5rem; flex: 1; }

.btn-floating {
    position: fixed;
    bottom: 25px;
    right: 25px;
    background-color: var(--primary-theme);
    color: #111;
    width: 55px;
    height: 55px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    box-shadow: 0 4px 15px rgba(0,0,0,0.5);
    z-index: 900;
    opacity: 1;
    transition: opacity 0.3s, transform 0.3s, background-color 0.3s;
}
.btn-floating:hover {
    transform: translateY(-5px);
    background-color: var(--primary-theme-hover);
}
.btn-floating.hidden {
    opacity: 0;
    pointer-events: none;
}

.form-actions {
    display: flex;
    gap: 1rem;
    margin-top: 1.5rem;
}

/* Forms */
.form-container {
    background-color: var(--dark-card);
    padding: 1.5rem;
    border-radius: var(--border-radius);
    margin-top: 1rem;
    margin-bottom: 1.5rem;
    border: 1px solid rgba(255,255,255,0.1);
}

.form-container h3 {
    margin-bottom: 1rem;
    font-size: 1.1rem;
    color: var(--primary-theme);
}

.form-container.hidden {
    display: none;
}

.form-group {
    margin-bottom: 1rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-size: 0.9rem;
    color: var(--text-muted);
}

.form-group input, .form-group select {
    width: 100%;
    padding: 0.8rem;
    border-radius: 8px;
    border: 1px solid rgba(255,255,255,0.2);
    background-color: var(--dark-bg);
    color: var(--text-main);
    font-size: 1rem;
    font-family: inherit;
}

.form-group input:focus, .form-group select:focus {
    border-color: var(--primary-theme);
    outline: none;
}

/* Modals */
.modal-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.85);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    backdrop-filter: blur(5px);
}
.modal-overlay.hidden { display: none; }
.modal-content {
    background: var(--dark-card);
    padding: 20px 25px;
    border-radius: 12px;
    border: 1px solid rgba(255,255,255,0.1);
    max-width: 400px;
    width: 90%;
    text-align: center;
    box-shadow: 0 10px 40px rgba(0,0,0,0.8);
    animation: fadeIn 0.2s ease-out;
}
.modal-content h3 { color: var(--primary-theme); margin-bottom: 15px; font-size: 1.3rem; }
.modal-content p { color: var(--text-main); font-size: 0.95rem; margin-bottom: 25px; line-height: 1.5; white-space: pre-wrap; }
.modal-actions { display: flex; gap: 10px; }

/* List */
.inventory-list {
    list-style: none;
    margin-top: 1rem;
}

.inventory-list-item {
    background-color: var(--dark-card);
    padding: 1rem;
    border-radius: 8px;
    margin-bottom: 0.8rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-left: 4px solid var(--text-muted);
}

.inventory-list-item.status-bueno { border-left-color: var(--success); }
.inventory-list-item.status-regular { border-left: 8px solid var(--warning); background: rgba(251, 192, 45, 0.08); }
.inventory-list-item.status-malo { border-left: 8px solid var(--danger); background: rgba(211, 47, 47, 0.08); }
.inventory-list-item.status-cargando { border-left: 8px solid #fbc02d; background: rgba(251, 192, 45, 0.08); } /* Amarillo para indicar carga eléctrica */

.item-details h4 {
    font-size: 1rem;
    margin-bottom: 0.2rem;
}

.item-details p {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.item-actions {
    display: flex;
    gap: 0.5rem;
}

.btn-edit, .btn-delete, .btn-log {
    background: rgba(255,255,255,0.1);
    color: var(--text-main);
    width: 35px;
    height: 35px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-delete { color: #ff5252; }
.btn-log { color: #ce93d8; }
.btn-delete:hover { background: rgba(255, 82, 82, 0.2); }
.btn-edit:hover { background: rgba(255,255,255,0.2); }
.btn-log:hover { background: rgba(156, 39, 176, 0.2); }

.loading-state {
    text-align: center;
    padding: 2rem;
    color: var(--text-muted);
}

/* Animations */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes pulse-yellow {
    0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(255, 235, 59, 0.7); }
    70% { transform: scale(1); box-shadow: 0 0 0 10px rgba(255, 235, 59, 0); }
    100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(255, 235, 59, 0); }
}

.badge-pulse {
    animation: pulse-yellow 2s infinite;
}

/* Fire Engine Diagram CSS */
.fire-engine-diagram {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    max-width: 260px; /* Más angosto para aspecto alargado */
    margin: 20px auto;
    background-color: transparent;
}

.fe-cab {
    width: 85%;
    height: 100px; /* Aumentado para que las divisiones de cabina sean más grandes */
    background-color: var(--car-red);
    border-radius: 30px 30px 0 0; /* Más redondeado arriba */
    border: 2px solid #fff;
    margin-bottom: 2px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    position: relative;
    transition: var(--transition);
}

.fe-cab:hover { background-color: var(--car-red-hover); box-shadow: 0 0 10px rgba(211,47,47,0.5); }
.fe-cab span { font-weight: bold; font-size: 0.85rem; }

/* Espejos */
.fe-cab::before, .fe-cab::after {
    content: '';
    position: absolute;
    width: 6px;
    height: 25px;
    background: #555;
    top: 20px;
    border-radius: 3px;
}
.fe-cab::before { left: -8px; transform: rotate(-10deg); }
.fe-cab::after { right: -8px; transform: rotate(10deg); }

/* Luces Azules de Emergencia (Balizas) */
.lightbar-rear {
    position: absolute;
    bottom: 2px;
    left: 10%;
    width: 80%;
    height: 5px;
    background-color: #0055ff;
    border-radius: 2px;
    z-index: 5;
    animation: flash-blue-1 0.3s infinite alternate;
}

.lightbar-mid {
    position: absolute;
    top: 50%;
    left: 10%;
    width: 80%;
    height: 5px;
    background-color: #0055ff;
    border-radius: 2px;
    z-index: 5;
    transform: translateY(-50%);
    animation: flash-blue-1 0.3s infinite alternate;
}

.lightbar-front-left, .lightbar-front-right {
    position: absolute;
    top: 8px;
    width: 18px;
    height: 8px;
    background-color: #0055ff;
    border-radius: 2px;
    z-index: 5;
}

[data-subcat] {
    position: relative;
}

.status-icon {
    position: absolute;
    top: 4px;
    right: 4px;
    font-size: 1rem;
    z-index: 10;
    pointer-events: none;
}


.lightbar-side-left, .lightbar-side-right {
    position: absolute;
    top: 40%;
    width: 6px;
    height: 18px;
    background-color: #0055ff;
    border-radius: 2px;
    z-index: 5;
}

.lightbar-front-left { left: 12px; animation: flash-blue-1 0.3s infinite alternate; }
.lightbar-front-right { right: 12px; animation: flash-blue-2 0.3s infinite alternate; }

.lightbar-side-left { left: 2px; animation: flash-blue-1 0.3s infinite alternate; }
.lightbar-side-right { right: 2px; animation: flash-blue-2 0.3s infinite alternate; }

@keyframes flash-blue-1 {
    0% { opacity: 0.3; box-shadow: none; }
    100% { opacity: 1; box-shadow: 0 0 10px #0055ff, 0 0 20px #0055ff; }
}

@keyframes flash-blue-2 {
    0% { opacity: 1; box-shadow: 0 0 10px #0055ff, 0 0 20px #0055ff; }
    100% { opacity: 0.3; box-shadow: none; }
}

.fe-body {
    width: 100%;
    display: flex;
    justify-content: space-between;
    background-color: #222;
    border: 2px solid #fff;
}

.fe-side {
    display: flex;
    flex-direction: column;
    width: 28%; /* Cortinas más angostas */
}

.fe-cortina {
    height: 110px; /* Cortinas más altas para alargar el camión */
    background-color: #3a3a3a;
    border: 1px solid #111;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.7rem;
    font-weight: bold;
    text-align: center;
    color: white;
    transition: var(--transition);
}

.fe-cortina:hover { background-color: var(--car-red); }

.fe-center {
    width: 44%;
    display: flex;
    flex-direction: column;
}

.fe-techo {
    height: 100%;
    background-color: #2a2a2a;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 0.8rem;
    transition: var(--transition);
    border-left: 1px solid #111;
    border-right: 1px solid #111;
}

.fe-techo:hover { background-color: var(--car-red); }

.fe-rear {
    width: 100%;
    height: 60px;
    background-color: var(--car-red);
    border-radius: 0 0 10px 10px;
    border: 2px solid #fff;
    border-top: none;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    font-size: 0.8rem;
    font-weight: bold;
    gap: 8px;
    transition: var(--transition);
}
.fe-rear:hover { background-color: var(--car-red-hover); box-shadow: 0 0 10px rgba(211,47,47,0.5); }

/* BX-7 Specific (Camiva) */
.bx7-side {
    display: flex;
    flex-direction: column;
    width: 32%; /* Un poco más ancho para acomodar la cajonera */
}

.bx7-compartment {
    display: flex;
    height: 130px; /* 2 divisiones, total 260px para hacerlo más largo */
    border: 1px solid #111;
    margin: 2px;
}

.bx7-side.left .bx7-compartment {
    flex-direction: row; /* Cajonera a la izquierda (afuera) */
}

.bx7-side.right .bx7-compartment {
    flex-direction: row-reverse; /* Cajonera a la derecha (afuera) */
}

.bx7-gabinete {
    width: 45%; /* Más ancho para evitar miss-click */
    background-color: #555; /* Más claro para diferenciar que está más abajo */
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.65rem;
    color: #ccc;
    cursor: pointer;
    transition: var(--transition);
    writing-mode: vertical-rl;
    text-align: center;
}

.bx7-cortina {
    width: 55%;
    background-color: #3a3a3a;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.7rem;
    color: white;
    cursor: pointer;
    transition: var(--transition);
    text-align: center;
    font-weight: bold;
}

.bx7-gabinete:hover, .bx7-cortina:hover {
    background-color: var(--car-red);
    color: white;
}

.bx7-cab {
    display: flex;
    width: 100%;
    height: 100%;
    flex-direction: column;
    border-radius: 28px 28px 0 0;
    overflow: hidden;
}

.bx7-cab-row {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.7rem;
    color: white;
    font-weight: bold;
    border-bottom: 1px solid rgba(255,255,255,0.2);
}

.bx7-cab-row:hover {
    background-color: var(--car-red-hover);
}

/* M-7 Specific (Magirus) */
.m7-tower {
    display: flex;
    flex-direction: column;
    width: 100%;
    height: 80px; /* Más alto para acomodar dos filas */
    background-color: #222;
    border-left: 2px solid #fff;
    border-right: 2px solid #fff;
}

.m7-tower-row {
    display: flex;
    width: 100%;
    flex: 1;
}

.m7-tower-side {
    width: 50%;
    background-color: #444;
    border: 1px solid #111;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.65rem;
    color: white;
    cursor: pointer;
    transition: var(--transition);
    font-weight: bold;
}

.m7-tower-center {
    width: 100%;
    background-color: #333;
    border: 1px solid #111;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.65rem;
    color: white;
    cursor: pointer;
    transition: var(--transition);
}

.m7-tower-side:hover, .m7-tower-center:hover {
    background-color: var(--car-red);
}

.m7-body {
    width: 100%;
    display: flex;
    justify-content: space-between;
    background-color: #1a1a1a;
    border: 2px solid #fff;
    border-top: none;
    border-bottom: none;
}

.m7-deck-side {
    display: flex;
    flex-direction: column;
    width: 25%;
}

.m7-inf-cortina {
    height: 95px; /* Más alto para alargar el carro */
    background-color: #555;
    border: 1px solid #111;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.65rem;
    color: #ccc;
    transition: var(--transition);
    text-align: center;
}

.m7-inf-cortina:hover {
    background-color: var(--car-red);
    color: white;
}

.m7-deck-center {
    width: 50%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: repeating-linear-gradient(45deg, #222, #222 10px, #2a2a2a 10px, #2a2a2a 20px);
    color: white;
    font-size: 0.8rem;
    cursor: pointer;
    transition: var(--transition);
    border-left: 1px solid #111;
    border-right: 1px solid #111;
}

.m7-deck-center:hover {
    background: var(--car-red);
}

.icon-white { color: white; }

/* Status Colors for Diagrams (Checklist) */
.status-verde {
    background: #2e7d32 !important; /* Verde éxito */
    color: white !important;
    border: 2px solid #111 !important;
    box-sizing: border-box !important;
}

.status-amarillo {
    background: #fbc02d !important; /* Amarillo advertencia */
    color: black !important;
    border: 2px solid #111 !important;
    box-sizing: border-box !important;
}
.status-amarillo .icon-white { color: black !important; }

.status-rojo {
    background: #c62828 !important; /* Rojo alerta */
    color: white !important;
    border: 2px solid #111 !important;
    box-sizing: border-box !important;
}

/* Indicador de herramienta defectuosa */
.has-defect {
    position: relative;
}

.has-defect::after {
    content: '\f071'; /* FontAwesome warning icon */
    font-family: 'Font Awesome 6 Free';
    font-weight: 900;
    position: absolute;
    top: 3px;
    right: 3px;
    color: #ff5252;
    background: rgba(255, 255, 255, 0.9);
    border-radius: 50%;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    box-shadow: 0 0 8px rgba(255, 82, 82, 0.8);
    z-index: 10;
    animation: pulse-defect 1.5s infinite;
}

@keyframes pulse-defect {
    0% { transform: scale(1); box-shadow: 0 0 0 0 rgba(255, 82, 82, 0.7); }
    70% { transform: scale(1.1); box-shadow: 0 0 0 6px rgba(255, 82, 82, 0); }
    100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(255, 82, 82, 0); }
}

/* Indicador de herramienta cargando batería */
.has-charging {
    position: relative;
}

.has-charging::before {
    content: '\f0e7'; /* FontAwesome bolt icon */
    font-family: 'Font Awesome 6 Free';
    font-weight: 900;
    position: absolute;
    top: 3px;
    right: 28px; /* Move slightly to the left so it doesn't overlap with defect */
    color: #fbc02d; /* Yellow */
    background: rgba(255, 255, 255, 0.9);
    border-radius: 50%;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    box-shadow: 0 0 8px rgba(251, 192, 45, 0.8);
    z-index: 10;
    animation: pulse-charging 1.5s infinite;
}

@keyframes pulse-charging {
    0% { transform: scale(1); box-shadow: 0 0 0 0 rgba(251, 192, 45, 0.7); }
    70% { transform: scale(1.1); box-shadow: 0 0 0 6px rgba(251, 192, 45, 0); }
    100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(251, 192, 45, 0); }
}

/* Leyenda de Estados */
.legend-container {
    background-color: var(--dark-card);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: var(--border-radius);
    padding: 1rem;
    margin-top: 2rem;
    margin-bottom: 1rem;
}

.legend-container h4 {
    text-align: center;
    color: var(--text-muted);
    font-size: 0.9rem;
    margin-bottom: 1rem;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.legend-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.85rem;
    color: var(--text-main);
}

.legend-color {
    width: 16px;
    height: 16px;
    border-radius: 4px;
    border: 1px solid #111;
}

.legend-icon {
    width: 16px;
    height: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255,255,255,0.9);
    border-radius: 50%;
    font-size: 9px;
}

/* Botones de Exportación Pequeños */
.btn-export {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 6px;
    padding: 0.4rem 0.6rem;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: var(--transition);
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-main);
    cursor: pointer;
}

.btn-export:hover {
    background: rgba(255, 255, 255, 0.15);
}

.btn-export-pdf { border-color: rgba(211, 47, 47, 0.5); }
.btn-export-pdf:hover {
    border-color: #d32f2f;
    box-shadow: 0 0 10px rgba(211, 47, 47, 0.4);
}

.btn-export-excel { border-color: rgba(46, 125, 50, 0.5); }
.btn-export-excel:hover {
    border-color: #2e7d32;
    box-shadow: 0 0 10px rgba(46, 125, 50, 0.4);
}

/* ==========================================================================
   Módulo de Control de Asistencias
   ========================================================================== */

.attendance-container {
    padding-bottom: 50px;
}

.tool-btn {
    background: var(--dark-bg);
    border: 1px solid rgba(255,255,255,0.1);
    color: var(--text-muted);
    padding: 8px 12px;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 600;
    font-size: 0.85rem;
    transition: var(--transition);
}

.tool-btn.active {
    box-shadow: 0 0 10px rgba(255,255,255,0.1);
}

.tool-btn.active.att-state-1 { background-color: #2e7d32; color: white; border-color: #4caf50; }
.tool-btn.active.att-state-2 { background-color: #1565c0; color: white; border-color: #2196f3; }
.tool-btn.active.att-state-3 { background-color: #f57f17; color: white; border-color: #ffeb3b; }
.tool-btn.active.att-state-4 { background-color: #6a1b9a; color: white; border-color: #ab47bc; }
.tool-btn.active.att-state-0 { background-color: #424242; color: white; border-color: #9e9e9e; }

.ff-btn {
    background: var(--dark-bg);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 8px;
    padding: 10px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: var(--transition);
    user-select: none;
    position: relative;
    overflow: hidden;
}

.ff-btn:active {
    transform: scale(0.95);
}

.ff-clave {
    font-size: 1.2rem;
    font-weight: bold;
    color: var(--text-main);
    margin-bottom: 2px;
}

.ff-nombre {
    font-size: 0.7rem;
    color: var(--text-muted);
    text-align: center;
    line-height: 1.1;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* Estados aplicados a los bomberos */
.ff-btn.state-1 { background-color: rgba(46, 125, 50, 0.2); border-color: #4caf50; }
.ff-btn.state-1 .ff-clave, .ff-btn.state-1 .ff-nombre { color: #81c784; }

.ff-btn.state-2 { background-color: rgba(21, 101, 192, 0.2); border-color: #2196f3; }
.ff-btn.state-2 .ff-clave, .ff-btn.state-2 .ff-nombre { color: #64b5f6; }

.ff-btn.state-3 { background-color: rgba(245, 127, 23, 0.2); border-color: #ffeb3b; }
.ff-btn.state-3 .ff-clave, .ff-btn.state-3 .ff-nombre { color: #fff59d; }

.ff-btn.state-4 { background-color: rgba(106, 27, 154, 0.2); border-color: #ab47bc; }
.ff-btn.state-4 .ff-clave, .ff-btn.state-4 .ff-nombre { color: #ce93d8; }

.ff-group-title {
    color: var(--primary-theme); 
    border-bottom: 1px solid rgba(255,255,255,0.1); 
    padding-bottom: 5px; 
    margin-bottom: 5px; 
    font-size: 1rem;
}
body.light-theme .ff-group-title {
    border-bottom: 1px solid #E0E0E0;
}

body.light-theme .ff-checkbox-box {
    border-color: #9e9e9e;
}

/* Lista / Matriz de Bomberos */
.firefighters-list {
    display: flex;
    flex-direction: column;
    gap: 2px; /* espaciado vertical súper apretado */
}

.ff-list-item {
    display: flex;
    align-items: center;
    background: transparent;
    border: none;
    padding: 2px 0;
    cursor: pointer;
    user-select: none;
    gap: 10px;
    overflow: hidden;
}

.ff-list-item:active {
    opacity: 0.7;
}

.ff-checkbox-box {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
    border: 1px solid #ccc;
    background-color: transparent;
    border-radius: 2px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.1s, border-color 0.1s;
}

.ff-list-info {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 5px;
    min-width: 0; /* needed for text-overflow to work in flex child */
}

.ff-list-clave {
    font-size: 0.85rem;
    color: var(--text-main);
    white-space: nowrap;
}

.ff-list-nombre {
    font-size: 0.85rem;
    color: var(--text-main);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Toggle Buttons para Carros */
.cars-toggle-group {
    display: flex;
    gap: 15px;
    flex-wrap: wrap;
    margin-top: 10px;
}

.car-toggle-btn {
    margin: 0;
    cursor: pointer;
}

.car-toggle-btn input[type="checkbox"] {
    display: none;
}

.car-toggle-ui {
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: var(--dark-bg);
    border: 2px solid rgba(255,255,255,0.2);
    border-radius: 8px;
    padding: 10px 20px;
    font-size: 1.1rem;
    font-weight: bold;
    color: var(--text-muted);
    transition: all 0.2s ease-in-out;
    min-width: 80px;
}

.car-toggle-btn input[type="checkbox"]:checked + .car-toggle-ui {
    background-color: #f44336; /* Rojo bomberos */
    border-color: #f44336;
    color: white;
    box-shadow: 0 4px 10px rgba(244, 67, 54, 0.4);
    transform: translateY(-2px);
}

/* Estados en la lista */
.ff-list-item.state-1 { background-color: rgba(46, 125, 50, 0.15); border-color: #4caf50; }
.ff-list-item.state-1 .ff-checkbox-box { background-color: #4caf50; border-color: #4caf50; }
.ff-list-item.state-1 .ff-checkbox-box::after { content: '\f00c'; font-family: 'Font Awesome 6 Free'; font-weight: 900; color: white; font-size: 12px; }

.ff-list-item.state-2 { background-color: rgba(21, 101, 192, 0.15); border-color: #2196f3; }
.ff-list-item.state-2 .ff-checkbox-box { background-color: #2196f3; border-color: #2196f3; }
.ff-list-item.state-2 .ff-checkbox-box::after { content: '\f00c'; font-family: 'Font Awesome 6 Free'; font-weight: 900; color: white; font-size: 12px; }

.ff-list-item.state-3 { background-color: rgba(245, 127, 23, 0.15); border-color: #ffeb3b; }
.ff-list-item.state-3 .ff-checkbox-box { background-color: #ffeb3b; border-color: #ffeb3b; }
.ff-list-item.state-3 .ff-checkbox-box::after { content: '\f00c'; font-family: 'Font Awesome 6 Free'; font-weight: 900; color: #333; font-size: 12px; }

.ff-list-item.state-4 { background-color: rgba(106, 27, 154, 0.15); border-color: #ab47bc; }
.ff-list-item.state-4 .ff-checkbox-box { background-color: #ab47bc; border-color: #ab47bc; }
.ff-list-item.state-4 .ff-checkbox-box::after { content: '\f00c'; font-family: 'Font Awesome 6 Free'; font-weight: 900; color: white; font-size: 12px; }

/* Paginación y Búsqueda Usuarios */
.pagination button {
    background-color: var(--dark-card);
    border: 1px solid rgba(255,255,255,0.1);
    color: var(--text-main);
    padding: 8px 12px;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
}
.pagination button:hover {
    background-color: rgba(255,255,255,0.05);
}
.pagination button.active {
    background-color: #fbc02d;
    color: #1a1a1a;
    border-color: #fbc02d;
    font-weight: bold;
}

/* Floating Action Button (Volver Arriba) */
.fab {
    position: fixed;
    bottom: 30px;
    right: 30px;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background-color: #fbc02d;
    color: #1a1a1a;
    border: none;
    box-shadow: 0 4px 15px rgba(0,0,0,0.5);
    font-size: 1.2rem;
    cursor: pointer;
    transition: all 0.3s ease;
    z-index: 1000;
    display: flex;
    justify-content: center;
    align-items: center;
}
.fab:hover {
    transform: translateY(-5px);
    box-shadow: 0 6px 20px rgba(0,0,0,0.6);
}
.fab.hidden {
    opacity: 0;
    visibility: hidden;
    transform: translateY(20px);
}
