/**
 * nra.css — Estilos PWA Móvil: Control Mensual NRM (Formulario)
 * @version 4.0 — Scroll vertical + horizontal con overflow: auto
 */
:root {
    --nrm-primary: #0d6efd;
    --nrm-primary-dark: #0d47a1;
    --nrm-success: #198754;
    --nrm-warning: #e65c00;
    --nrm-danger: #dc3545;
    --nrm-info: #0dcaf0;
    --nrm-bg: #f8f9fa;
    --nrm-card-radius: 14px;
    --nrm-shadow: 0 3px 12px rgba(0, 0, 0, 0.09);
    --nrm-header-h: 52px;
    --nrm-status-h: 28px;
    --nrm-tabs-h: 50px;
    --nrm-top-offset: calc(
        var(--nrm-header-h) + var(--nrm-status-h) + var(--nrm-tabs-h)
    );
}

*,
*::before,
*::after {
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

body {
    margin: 0;
    padding: 0;
    background: var(--nrm-bg);
    font-family:
        -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial,
        sans-serif;
    overflow-x: hidden;
}

/* Header fijo */
.nrm-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1040;
    height: var(--nrm-header-h);
    background: linear-gradient(90deg, #0d47a1 0%, #1565c0 50%, #0d6efd 100%);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 12px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
}
.nrm-header-title {
    font-size: 0.92rem;
    font-weight: 700;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
    text-align: center;
}
.nrm-header-badge {
    font-size: 0.7rem;
    padding: 3px 9px;
    border-radius: 20px;
    background: rgba(255, 255, 255, 0.18);
    border: 1px solid rgba(255, 255, 255, 0.35);
    white-space: nowrap;
    cursor: default;
}

/* Barra de estado */
.nrm-status-bar {
    position: fixed;
    top: var(--nrm-header-h);
    left: 0;
    right: 0;
    z-index: 1039;
    height: var(--nrm-status-h);
    background: #fff;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 14px;
    font-size: 0.72rem;
    color: #4a6085;
    border-bottom: 1px solid #dee2e6;
}

/* Tabs */
.nrm-tabs {
    position: fixed;
    top: calc(var(--nrm-header-h) + var(--nrm-status-h));
    left: 0;
    right: 0;
    z-index: 1038;
    height: var(--nrm-tabs-h);
    background: #fff;
    border-bottom: 1px solid #dee2e6;
}
.nrm-tabs .nav-tabs {
    flex-wrap: nowrap;
    overflow-x: auto;
    overflow-y: hidden;
    scrollbar-width: none;
    -ms-overflow-style: none;
    border: none;
    padding: 0 6px;
    height: 100%;
    display: flex;
    align-items: stretch;
}
.nrm-tabs .nav-tabs::-webkit-scrollbar {
    display: none;
}
.nrm-tabs .nav-link {
    border: none;
    border-bottom: 3px solid transparent;
    padding: 8px 5px;
    font-size: 0.77rem;
    font-weight: 600;
    color: #6c757d;
    white-space: nowrap;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    height: 100%;
}
.nrm-tabs .nav-link i {
    font-size: 1.1rem;
}
.nrm-tabs .nav-link.active {
    color: var(--nrm-primary);
    border-bottom-color: var(--nrm-primary);
    background: transparent;
}
.tab-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 17px;
    height: 17px;
    border-radius: 9px;
    background: var(--nrm-primary);
    color: #fff;
    font-size: 0.62rem;
    font-weight: 700;
    padding: 0 5px;
    margin-left: 3px;
}

/* ===== CONTENEDOR PRINCIPAL: AMBOS SCROLLS ===== */
.nrm-wrapper {
    overflow: auto; /* scroll vertical + horizontal */
    margin-top: var(--nrm-top-offset);
    margin-bottom: 0;
    padding: 14px 12px 80px 12px;
    min-height: calc(100vh - var(--nrm-top-offset));
    background: var(--nrm-bg);
    -webkit-overflow-scrolling: touch; /* suavizado en iOS */
}

/* Tablas anchas: fuerzan scroll horizontal en el wrapper */
.nrm-tbl-presiones,
.nrm-tbl-checklist {
    min-width: 680px;
    width: max-content;
    white-space: nowrap;
    border-collapse: collapse;
    margin-bottom: 0;
}
.nrm-tbl-presiones th,
.nrm-tbl-presiones td,
.nrm-tbl-checklist th,
.nrm-tbl-checklist td {
    white-space: nowrap;
    vertical-align: middle;
}
.nrm-tbl-checklist {
    min-width: 500px;
}

/* Contenedores de tablas: sin scroll propio (delegado al wrapper) */
.table-responsive {
    overflow: visible !important;
    width: 100%;
}

/* Barras de scroll personalizadas (opcional, solo estética) */
.nrm-wrapper::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}
.nrm-wrapper::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 3px;
}
.nrm-wrapper::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 3px;
}
.nrm-wrapper::-webkit-scrollbar-thumb:hover {
    background: #555;
}
.nrm-wrapper {
    scrollbar-width: thin;
    scrollbar-color: #888 #f1f1f1;
}

/* Cards y formularios */
.nrm-card {
    background: #fff;
    border-radius: var(--nrm-card-radius);
    box-shadow: var(--nrm-shadow);
    margin-bottom: 14px;
    overflow: visible;
    border: 1px solid rgba(0, 0, 0, 0.04);
}
.nrm-card-header {
    padding: 11px 16px;
    font-weight: 700;
    font-size: 0.83rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.nrm-card-body {
    overflow: visible;
    padding: 14px 16px;
}
.nrm-card-body.p-0 {
    padding: 0;
}

.form-group {
    margin-bottom: 14px;
}
.form-group label {
    display: block;
    font-size: 0.76rem;
    font-weight: 700;
    color: #4a5568;
    margin-bottom: 5px;
    text-transform: uppercase;
    letter-spacing: 0.4px;
}
.form-control {
    font-size: 0.87rem;
    border-radius: 9px;
    border: 1.5px solid #d0dae8;
    padding: 9px 12px;
    background: #fff;
    width: 100%;
    height: 45px;
}
.form-control:focus {
    border-color: var(--nrm-primary);
    box-shadow: 0 0 0 3px rgba(13, 110, 253, 0.12);
    outline: none;
}
input[type='number'] {
    -moz-appearance: textfield;
    appearance: textfield;
}
input[type='number']::-webkit-outer-spin-button,
input[type='number']::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

/* Tabla de equipos (lista de dispensadores/compresores) */
.table-equipo {
    font-size: 0.85rem;
    margin-bottom: 0;
}
.table-equipo thead th {
    background: var(--nrm-primary-dark);
    color: #fff;
    font-weight: 700;
    font-size: 0.72rem;
    padding: 8px 10px;
    text-transform: uppercase;
}
.table-equipo tbody td {
    vertical-align: middle;
    padding: 7px 10px;
    font-size: 0.78rem;
}
.table-equipo tbody tr:nth-child(even) {
    background: #f8fafd;
}
.table-equipo tbody tr:hover {
    background: #ebf2ff;
}

/* Toggle elegante */
.toggle-elegante-container {
    text-align: center;
}
.toggle-switch-elegante {
    display: inline-block;
    width: 48px;
    height: 48px;
    border-radius: 24px;
    background: #e9ecef;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}
.toggle-switch-elegante.disabled {
    opacity: 0.5;
    cursor: not-allowed;
}
.toggle-switch-elegante.enabled {
    background: #d4edda;
}
.toggle-switch-elegante.active {
    background: #28a745;
    box-shadow: 0 0 0 3px rgba(40, 167, 69, 0.3);
}
.toggle-knob {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    color: #495057;
}
.toggle-switch-elegante.active .toggle-knob {
    color: #fff;
}

/* Barra de acciones inferior */
.nrm-action-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    display: flex;
    gap: 8px;
    padding: 10px;
    background: #f8f9fa;
    border-top: 1px solid #dee2e6;
    z-index: 1050;
}
.nrm-action-bar .btn {
    flex: 1;
    font-size: 1rem;
    padding: 12px 0;
    border-radius: 10px;
    font-weight: 600;
}
.nrm-action-bar .btn:active {
    transform: scale(0.97);
}

/* Spinner */
.nrm-spinner {
    display: inline-block;
    width: 17px;
    height: 17px;
    border: 2.5px solid rgba(255, 255, 255, 0.4);
    border-top-color: #fff;
    border-radius: 50%;
    animation: nrm-spin 0.7s linear infinite;
}
@keyframes nrm-spin {
    to {
        transform: rotate(360deg);
    }
}

/* Estado vacío */
.empty-state {
    text-align: center;
    padding: 36px 20px;
    color: #b0bec5;
}
.empty-state i {
    font-size: 2.8rem;
    margin-bottom: 12px;
    display: block;
}

/* Responsive */
@media (max-width: 360px) {
    .nrm-tabs .nav-link {
        padding: 0 10px;
        font-size: 0.72rem;
    }
    .nrm-action-bar .btn {
        font-size: 0.85rem;
        padding: 10px 0;
    }
}
