:root {
    --glass-bg: rgba(255, 255, 255, 0.55);
    --glass-border: 1px solid rgba(255, 255, 255, 0.5);
    --blur-amount: 25px;
    --primary-ios: #007AFF;
    --danger-ios: #FF3B30;
    --success-ios: #34C759;
    --text-main: #1d1d1f;
}

body {
    background-color: #f0f2f5;
    background-image: url('fondo.png');
    background-size: cover;
    background-position: center;
    background-attachment: fixed;
    font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", sans-serif;
    color: var(--text-main);
    min-height: 100vh;
}

/* CLASES PARA MINIATURAS DE LOGS */
.log-thumb-modal {
    width: 40px;
    height: 40px;
    object-fit: cover;
    border-radius: 6px;
    border: 1px solid #ddd;
}
.log-thumb-mini {
    width: 24px;
    height: 24px;
    object-fit: cover;
    border-radius: 4px;
    border: 1px solid rgba(0,0,0,0.1);
}

.glass-card {
    background: var(--glass-bg);
    backdrop-filter: blur(var(--blur-amount)) saturate(180%);
    -webkit-backdrop-filter: blur(var(--blur-amount)) saturate(180%);
    border-radius: 28px;
    border: var(--glass-border);
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1);
    position: relative;
    overflow: hidden;
}

.dev-card {
    cursor: pointer;
    transition: transform 0.3s;
    z-index: 1;
}

.dev-card:hover {
    transform: translateY(-3px);
    background: rgba(255, 255, 255, 0.65);
}

/* Indicador de arrastre */
.drag-handle {
    cursor: grab;
    color: #aaa;
    padding: 10px;
    margin: -10px -10px 0 0;
    transition: color 0.2s;
}

.drag-handle:active {
    cursor: grabbing;
    color: #555;
}

.sortable-ghost {
    opacity: 0.4;
    background: #eee;
}

.card-background {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
    pointer-events: none;
    overflow: hidden;
    display: flex;
    align-items: flex-end;
    justify-content: center;
}

.bg-log-list {
    list-style: none;
    padding: 0;
    margin: 0;
    width: 100%;
    padding: 20px 20px 60px 20px;
    opacity: 0.5;
    font-size: 0.8rem;
    font-weight: 500;
    color: #333;
    text-shadow: 0 1px 0 rgba(255, 255, 255, 0.8);
}

.bg-log-list li {
    border-bottom: 1px solid rgba(0, 0, 0, 0.1);
    padding: 6px 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.card-content {
    position: relative;
    z-index: 2;
    width: 100%;
}

/* --- ESTILOS VIDEO WALL --- */
#devices-grid.video-wall .device-item {
    transition: all 0.3s ease;
    padding: 5px !important;
}

#devices-grid.video-wall .glass-card {
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
    backdrop-filter: none !important;
    border-radius: 0 !important;
    padding: 0 !important;
}

#devices-grid.video-wall .glass-card:hover {
    transform: none !important;
    background: transparent !important;
}

#devices-grid.video-wall .card-content {
    padding: 0 !important;
}

#devices-grid.video-wall .info-section,
#devices-grid.video-wall .control-section,
#devices-grid.video-wall .card-background,
#devices-grid.video-wall .hint-text {
    display: none !important;
}

#devices-grid.video-wall .cam-container {
    border-radius: 4px !important;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.5) !important;
    margin: 0 !important;
    width: 100% !important;
    height: 100% !important;
}

/* ------------------------- */

.btn-ios {
    border-radius: 20px;
    font-weight: 600;
    padding: 12px 24px;
    border: none;
    transition: all 0.2s ease;
}

.btn-ios:active {
    transform: scale(0.97);
}

.input-glass {
    background: rgba(255, 255, 255, 0.4);
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 16px;
    padding: 10px 14px;
    font-size: 0.9rem;
}

.navbar-blur {
    background: rgba(255, 255, 255, 0.65) !important;
    backdrop-filter: blur(20px);
    border-bottom: 1px solid rgba(255, 255, 255, 0.4);
}

.icon-box {
    background: rgba(255, 255, 255, 0.7);
    border-radius: 50%;
    width: 56px;
    height: 56px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.8rem;
    border: 1px solid rgba(255, 255, 255, 0.8);
}

.mode-switch-container {
    background: rgba(0, 0, 0, 0.05);
    border-radius: 20px;
    padding: 4px;
    display: inline-flex;
    width: 100%;
}

.mode-radio {
    display: none;
}

.mode-label {
    flex: 1;
    text-align: center;
    padding: 8px;
    border-radius: 16px;
    cursor: pointer;
    font-weight: 600;
    color: #666;
}

.mode-radio:checked + .mode-label {
    background: #fff;
    color: #000;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

@keyframes alarmPulse {
    0% { box-shadow: 0 0 0 0 rgba(255, 59, 48, 0.7); }
    70% { box-shadow: 0 0 0 10px rgba(255, 59, 48, 0); }
    100% { box-shadow: 0 0 0 0 rgba(255, 59, 48, 0); }
}

.alarm-active {
    animation: alarmPulse 1.5s infinite;
    border: 2px solid #FF3B30 !important;
}

.card-switch-container {
    position: absolute;
    top: 20px;
    right: 20px;
    z-index: 10;
}

.form-switch .form-check-input {
    width: 3em;
    height: 1.5em;
    cursor: pointer;
}

.form-switch .form-check-input:checked {
    background-color: var(--success-ios);
    border-color: var(--success-ios);
}

.cam-container {
    width: 100%;
    border-radius: 16px;
    overflow: hidden;
    background: #000;
    position: relative;
    aspect-ratio: 16 / 9;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.cam-video {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.cam-snapshot-canvas {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    background: #222;
}

.cam-placeholder {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    color: rgba(255, 255, 255, 0.3);
    z-index: 0;
}

#fs-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: #000;
    z-index: 99999;
    display: none;
    align-items: center;
    justify-content: center;
    flex-direction: column;
}

#fs-video {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.btn-close-fs {
    position: absolute;
    top: 25px;
    right: 25px;
    width: 50px;
    height: 50px;
    background-color: rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    color: white;
    font-size: 1.5rem;
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 100002;
    backdrop-filter: blur(5px);
}

.fs-controls {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 15px;
    background: rgba(0, 0, 0, 0.6);
    padding: 10px 20px;
    border-radius: 30px;
    backdrop-filter: blur(10px);
    z-index: 100001;
}

.btn-fs-ctrl {
    color: white;
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    width: 45px;
    height: 45px;
    font-size: 1.2rem;
}

.btn-fs-ctrl:hover {
    background: rgba(255, 255, 255, 0.2);
}

#fs-history {
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    width: 320px;
    background: rgba(20, 20, 20, 0.95);
    backdrop-filter: blur(20px);
    z-index: 100001;
    transform: translateX(-100%);
    transition: transform 0.3s;
    padding: 20px;
    color: white;
    overflow-y: auto;
    border-right: 1px solid #333;
}

#fs-history.open {
    transform: translateX(0);
}

.hist-day-item {
    padding: 12px;
    border-bottom: 1px solid #333;
    cursor: pointer;
    display: flex;
    flex-direction: column;
}

.hist-day-item:hover {
    background: #333;
}

.hist-hour-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 6px;
    margin-top: 10px;
    display: none;
}

.hist-hour-btn {
    font-size: 0.75rem;
    padding: 6px 0;
    background: #444;
    border: none;
    color: #fff;
    border-radius: 6px;
    text-align: center;
    transition: 0.2s;
}

.hist-hour-btn:hover {
    background: var(--primary-ios);
}

.assoc-cam-wrapper {
    margin-bottom: 15px;
}

.assoc-cam-title {
    font-size: 0.8rem;
    font-weight: bold;
    color: #666;
    margin-bottom: 5px;
    margin-top: 10px;
}

.no-scrollbar::-webkit-scrollbar {
    display: none;
}

.no-scrollbar {
    -ms-overflow-style: none;
    scrollbar-width: none;
}

#loading-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    z-index: 100005;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(8px);
}

.loading-card {
    background: rgba(255, 255, 255, 0.9);
    border-radius: 20px;
    padding: 30px;
    text-align: center;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.3);
    max-width: 300px;
    width: 85%;
}

#cam-grid-controls {
    display: none;
    margin-left: 10px;
}

.btn-grid-ctrl {
    font-size: 0.8rem;
    padding: 4px 10px;
    border-radius: 8px;
    border: 1px solid #ddd;
    background: white;
    font-weight: bold;
    color: #555;
    transition: all 0.2s;
}

.btn-grid-ctrl:hover,
.btn-grid-ctrl.active {
    background: #007AFF;
    color: white;
    border-color: #007AFF;
}

.log-item {
    cursor: pointer;
    transition: background 0.2s;
}

.log-item:hover {
    background: rgba(0, 0, 0, 0.05);
}
/* =========================================
   CORRECCIONES PARA MÓVILES (Responsive)
   ========================================= */
@media (max-width: 576px) {
    /* 1. Ocultar el saludo "Hola Usuario" para dar espacio a los iconos */
    .header-left-col h6 {
        display: none !important;
    }

    /* 2. Hacer el logo de JAB un poco más pequeño */
    .header-left-col img {
        width: 28px !important;
        margin-right: 5px !important;
    }

    /* 3. Ajustar los botones de filtro (Todos, PIR, etc) para que sean compactos */
    #filter-container button {
        padding: 4px 10px !important;
        font-size: 0.75rem !important;
        white-space: nowrap; /* Evita que el texto baje */
    }

    /* 4. Asegurar que los botones derechos (+, Dashboard, Config) no se rompan */
    .navbar .d-flex.align-items-center:last-child > * {
        margin-left: 4px !important; /* Reducir margen entre botones */
    }

    .navbar .d-flex.align-items-center:last-child button,
    .navbar .d-flex.align-items-center:last-child a:not([href*="logout"]) {
        width: 32px !important;
        height: 32px !important;
    }

    /* 5. Ajustar botón Salir */
    .navbar a[href*="logout"] {
        padding: 4px 10px !important;
        font-size: 0.75rem !important;
    }
}
.play-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
    cursor: pointer;
    backdrop-filter: blur(2px);
    transition: opacity 0.2s ease;
}
.play-overlay:hover {
    background: rgba(0,0,0,0.6);
}
@media screen and (max-width: 960px) and (max-height: 500px) and (orientation: landscape) {

    /* 1. Ajustar el zoom general para que quepan más cosas */
    body {
        zoom: 0.8;
    }

    /* 2. Ocultar la barra de navegación superior para ganar espacio vertical */
    .navbar {
        padding: 0 !important;
        min-height: 40px !important;
    }

    /* Ocultar botones innecesarios en el Echo Show */
    .navbar a[href*="logout"],
    .navbar button[onclick*="Telegram"],
    .navbar a[href*="dashboard"] {
        display: none !important;
    }

    /* 3. Forzar Grid de 2 o 3 columnas siempre */
    .device-item {
        width: 33.33% !important; /* 3 dispositivos por fila */
        flex: 0 0 auto !important;
    }

    /* 4. Reducir tamaño de las tarjetas */
    .glass-card {
        border-radius: 12px !important;
        margin-bottom: 10px !important;
    }

    .card-content {
        padding: 10px !important;
    }

    .icon-box {
        width: 35px;
        height: 35px;
        font-size: 1.2rem;
    }

    h5.fw-bold {
        font-size: 1rem !important;
    }

    small {
        font-size: 0.7rem !important;
    }

    /* 5. Ajustar altura del contenedor de cámara para que no ocupe toda la pantalla */
    .cam-container {
        aspect-ratio: 16/7 !important; /* Más panorámico para ahorrar altura */
    }

    /* 6. Ocultar scrollbars feos del navegador Silk */
    ::-webkit-scrollbar {
        display: none;
    }
}
