/* ================================================================
   NOR PUMPS APP — Estilo unificado V1
   Basado en identidad corporativa de https://norpumps.com
   ================================================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800;900&family=Space+Grotesk:wght@400;500;600;700&display=swap');

/* ---- Variables de diseño NOR ---- */
:root {
    /* Paleta principal — teal NOR */
    --primary:       #1f7c85;
    --primary-hover: #176269;
    --primary-light: #e8f4f5;
    --primary-glow:  #0ea5c0;
    --primary-dark:  #0a3d42;

    /* Superficies */
    --bg:            #f8fafb;
    --surface:       #ffffff;
    --card:          #ffffff;
    --card-hover:    #f0f6f7;

    /* Texto */
    --text:          #0f172a;
    --text-secondary:#475569;
    --text-muted:    #94a3b8;
    --on-primary:    #ffffff;

    /* Estados */
    --success:       #16a34a;
    --warning:       #d97706;
    --danger:        #dc2626;
    --info:          #0284c7;

    /* Bordes */
    --border:        #e2e8f0;
    --border-light:  #f1f5f9;
    --border-focus:  #1f7c85;

    /* Sombras */
    --shadow-sm:     0 1px 2px rgba(0,0,0,0.04);
    --shadow:        0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
    --shadow-md:     0 4px 6px rgba(0,0,0,0.05), 0 2px 4px rgba(0,0,0,0.04);
    --shadow-lg:     0 10px 15px rgba(0,0,0,0.06), 0 4px 6px rgba(0,0,0,0.04);
    --shadow-xl:     0 20px 25px rgba(0,0,0,0.08), 0 8px 10px rgba(0,0,0,0.05);

    /* Radios */
    --radius-sm:     8px;
    --radius:        12px;
    --radius-lg:     16px;
    --radius-xl:     20px;
    --radius-full:   9999px;

    /* Transiciones */
    --transition:    200ms ease;
    --transition-slow: 300ms ease;

    /* Tipografía */
    --font-heading:  'Space Grotesk', 'Inter', system-ui, sans-serif;
    --font-body:     'Inter', system-ui, sans-serif;
    --font-mono:     'SF Mono', 'Fira Code', 'Consolas', monospace;
}

/* ---- Reset y Base ---- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
    font-family: var(--font-body);
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ---- Header NOR unificado ---- */
.nor-header {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: 12px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    position: sticky;
    top: 0;
    z-index: 100;
    backdrop-filter: blur(12px);
    background: rgba(255,255,255,0.92);
}
.nor-header-logo {
    height: 32px;
    width: auto;
}
.nor-header-title {
    font-family: var(--font-heading);
    font-weight: 700;
    font-size: 1rem;
    color: var(--primary-dark);
    letter-spacing: -0.3px;
}
.nor-header-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

/* ---- Footer NOR ---- */
.nor-footer {
    background: var(--primary-dark);
    color: rgba(255,255,255,0.7);
    text-align: center;
    padding: 20px 24px;
    font-size: 0.75rem;
    letter-spacing: 0.5px;
    margin-top: auto;
}
.nor-footer strong { color: #fff; font-weight: 700; }

/* ---- Contenedor principal ---- */
.nor-container {
    width: 100%;
    max-width: 1400px;
    margin: 0 auto;
    padding: 24px;
    flex: 1;
}

/* ---- Tarjetas (cards) genéricas ---- */
.wcard, .card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 20px;
    box-shadow: var(--shadow-sm);
    transition: box-shadow var(--transition), border-color var(--transition);
}
.wcard:hover { box-shadow: var(--shadow); border-color: #cbd5e0; }
.wcard-head {
    font-family: var(--font-heading);
    font-weight: 600;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-secondary);
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 8px;
}
.wcard-head .material-symbols-outlined {
    font-size: 18px;
    color: var(--primary);
}
.wcard-body { flex: 1; }
.wcard-grow { display: flex; flex-direction: column; }

/* ---- Grids ---- */
.tech-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 20px;
    margin-bottom: 24px;
}
.pumps-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

/* ---- Tablas RAW ---- */
.raw-table { width: 100%; font-size: 11px; border-collapse: collapse; }
.raw-table td {
    padding: 5px 8px;
    border-bottom: 1px solid var(--border-light);
    color: var(--text-secondary);
}
.raw-table td:last-child {
    color: var(--text);
    font-family: var(--font-mono);
    font-size: 10.5px;
    text-align: right;
}
.raw-table tr:last-child td { border-bottom: none; }
.raw-table .mono { font-family: var(--font-mono); }
.raw-table .editable-cell {
    cursor: pointer;
    transition: background var(--transition);
    border-radius: 4px;
}
.raw-table .editable-cell:hover { background: var(--primary-light); }

/* ---- Botones ---- */
.btn-primary {
    background: var(--primary);
    color: var(--on-primary);
    border: none;
    padding: 8px 20px;
    border-radius: var(--radius-sm);
    font-weight: 600;
    font-size: 0.85rem;
    cursor: pointer;
    transition: background var(--transition), transform var(--transition);
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-family: var(--font-body);
}
.btn-primary:hover { background: var(--primary-hover); transform: translateY(-1px); }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }
.btn-primary:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }

.btn-c {
    background: var(--surface);
    color: var(--text-secondary);
    border: 1px solid var(--border);
    padding: 8px 16px;
    border-radius: var(--radius-sm);
    font-weight: 500;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all var(--transition);
    font-family: var(--font-body);
}
.btn-c:hover { background: var(--bg); color: var(--text); }

.btn-maint-toggle {
    background: var(--bg);
    border: 1px solid var(--border);
    color: var(--text-secondary);
    padding: 6px 12px;
    border-radius: var(--radius-sm);
    font-size: 0.72rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition);
    display: flex;
    align-items: center;
    gap: 4px;
    width: 100%;
    justify-content: center;
    font-family: var(--font-body);
}
.btn-maint-toggle:hover { background: var(--primary-light); border-color: var(--primary); color: var(--primary); }
.btn-maint-toggle.active {
    background: var(--primary-light);
    border-color: var(--primary);
    color: var(--primary);
    font-weight: 700;
}

/* ---- Badges ---- */
.badge {
    font-family: var(--font-body);
    font-size: 0.68rem;
    font-weight: 700;
    padding: 3px 9px;
    border-radius: 16px;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}
.badge-success { background: #f0fdf4; color: var(--success); border: 1px solid #bbf7d0; }
.badge-danger { background: #fef2f2; color: var(--danger); border: 1px solid #fecaca; }
.badge-warning { background: #fffbeb; color: var(--warning); border: 1px solid #fde68a; }

/* ---- Modales ---- */
.modal-bg {
    position: fixed;
    inset: 0;
    background: rgba(15,23,42,0.35);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}
.modal {
    background: var(--surface);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-xl);
    border: 1px solid var(--border);
    overflow: hidden;
    max-height: 90vh;
    overflow-y: auto;
}
.modal-top {
    padding: 24px 24px 12px;
    text-align: center;
}
.modal-top .iw {
    width: 44px; height: 44px;
    border-radius: var(--radius);
    display: flex; align-items: center; justify-content: center;
    margin: 0 auto 12px auto;
}
.modal-bot {
    padding: 16px 24px;
    background: var(--bg);
    border-top: 1px solid var(--border);
}
.modal-acts {
    display: flex;
    gap: 10px;
}
.modal-acts > * { flex: 1; }

/* ---- Selects e Inputs ---- */
select, input[type="text"], input[type="number"], input[type="password"] {
    font-family: var(--font-body);
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 8px 12px;
    font-size: 0.9rem;
    color: var(--text);
    background: var(--surface);
    transition: border-color var(--transition), box-shadow var(--transition);
    outline: none;
    width: 100%;
}
select:focus, input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(31,124,133,0.12);
}

/* ---- Secciones ---- */
.section-title {
    font-family: var(--font-heading);
    font-weight: 700;
    font-size: 1.1rem;
    color: var(--primary-dark);
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 10px;
    padding-bottom: 12px;
    border-bottom: 2px solid var(--primary-light);
}
.section-title .material-symbols-outlined { color: var(--primary); }

/* ---- Estado de bombas ---- */
.pump-status {
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 4px 10px;
    border-radius: var(--radius-full);
    display: inline-block;
    text-align: center;
    margin: 8px 0;
}
.pump-status.running { background: #f0fdf4; color: var(--success); }
.pump-status.sleep { background: #f8fafc; color: var(--text-muted); }
.pump-status.error { background: #fef2f2; color: var(--danger); }
.pump-status { background: var(--bg); color: var(--text-secondary); }

.pump-ring {
    width: 64px; height: 64px;
    border-radius: 50%;
    background: #e2e8f0;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 8px;
    font-weight: 700;
    font-size: 0.85rem;
    font-family: var(--font-mono);
    transition: background var(--transition);
}
.pump-ring.active { color: var(--primary-dark); }
.pump-label { font-size: 0.65rem; font-weight: 600; color: var(--text-muted); text-transform: uppercase; }
.pump-val { font-family: var(--font-mono); font-size: 0.9rem; font-weight: 700; color: var(--text); }
.pump-info { text-align: center; margin: 4px 0; }

/* ---- Login ---- */
.login-err {
    color: var(--danger);
    font-size: 0.82rem;
    background: #fef2f2;
    border: 1px solid #fecaca;
    border-radius: var(--radius-sm);
    padding: 8px 12px;
    margin-top: 8px;
}
.hidden { display: none !important; }

/* ---- Utilidades ---- */
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-primary { color: var(--primary); }
.text-muted { color: var(--text-muted); }
.text-danger { color: var(--danger); }
.font-bold { font-weight: 700; }
.font-mono { font-family: var(--font-mono); }
.animate-spin { animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.gap-2 { gap: 8px; }
.gap-4 { gap: 16px; }
.flex { display: flex; }
.flex-col { display: flex; flex-direction: column; }
.items-center { align-items: center; }
.justify-center { justify-content: center; }
.justify-between { justify-content: space-between; }
.w-full { width: 100%; }

/* ---- Responsive ---- */
@media (max-width: 768px) {
    .nor-container { padding: 16px; }
    .tech-grid { grid-template-columns: 1fr; }
    .pumps-grid { grid-template-columns: 1fr; }
    .nor-header { padding: 10px 16px; }
    .nor-header-title { font-size: 0.85rem; }
}

/* ---- Scrollbar elegante ---- */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #cbd5e0; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #94a3b8; }

/* ---- Toggle switch ---- */
.toggle-track {
    width: 44px; height: 24px;
    background: var(--border);
    border-radius: 12px;
    cursor: pointer;
    transition: background var(--transition);
    position: relative;
}
.toggle-track.auto { background: var(--success); }
.toggle-knob {
    width: 20px; height: 20px;
    background: #fff;
    border-radius: 50%;
    position: absolute;
    top: 2px;
    left: 2px;
    transition: transform var(--transition);
    box-shadow: var(--shadow-sm);
}
.toggle-track.auto .toggle-knob { transform: translateX(20px); }

/* ================================================================
   SOBREESCRITURAS de contraste — navbar y login sobre fondo claro
   ================================================================ */

/* Navbar: fondo sólido oscuro, sin degradado a blanco */
.navbar {
    background: var(--primary-dark) !important;
    color: #fff;
    padding: 0 24px;
    height: 58px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 46px; /* debajo del nor-header */
    z-index: 99;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}
.nav-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 800;
    font-size: 1.1rem;
    letter-spacing: -0.3px;
    color: #fff;
}
.nav-brand .material-symbols-outlined {
    font-size: 26px;
    color: var(--primary-glow);
}
.nav-user {
    display: flex;
    align-items: center;
    gap: 14px;
    font-size: .82rem;
    color: #fff;
}
.nav-user .email {
    opacity: 0.85;
    color: #fff;
}

/* Login: fondos limpios sin degradados que se vayan a blanco */
.login-wrap {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: var(--bg) !important;
}
.login-top {
    background: var(--primary-dark) !important;
    color: #fff;
    padding: 30px;
    text-align: center;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}
.login-top h3 { color: #fff; }
.login-top p { color: rgba(255,255,255,0.75); }

/* Botón logout */
.btn-out {
    background: rgba(255,255,255,0.15) !important;
    border: 1px solid rgba(255,255,255,0.25) !important;
    color: #fff !important;
    padding: 6px 14px;
    border-radius: 8px;
    cursor: pointer;
    font-size: .78rem;
    font-weight: 600;
    transition: .2s;
    display: flex;
    align-items: center;
    gap: 4px;
}
.btn-out:hover {
    background: rgba(255,255,255,0.25) !important;
}

/* Ícono de equipo en selector */
.eq-icon {
    width: 38px;
    height: 38px;
    border-radius: 9px;
    background: var(--primary-light);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--primary);
}

/* Responsive navbar */
@media (max-width: 768px) {
    .navbar { padding: 0 14px; height: 52px; top: 42px; }
    .nav-brand { font-size: .95rem; }
    .nav-user .email { display: none; }
}

/* ================================================================
   FIXES: degradado sutil, botón login, logo index
   ================================================================ */

/* Navbar: degradado sutil teal oscuro → teal (sin blanco) */
.navbar {
    background: linear-gradient(135deg, var(--primary-dark) 0%, var(--primary) 100%) !important;
}
/* Sobreescribir el gradiente viejo del login-wrap también */
.login-wrap {
    background: linear-gradient(160deg, #e8f4f8 0%, var(--surface) 50%, #f0f6f9 100%) !important;
}

/* Botón login: hover con color oscuro, no primary-light (que es casi blanco) */
.btn-login {
    background: var(--primary) !important;
    color: #fff !important;
}
.btn-login:hover {
    background: var(--primary-hover) !important;
}

/* Logo en header: tamaño controlado, nunca ocupa todo el ancho */
.nor-header-logo {
    height: 32px;
    width: auto;
    max-width: 180px;
    object-fit: contain;
}

/* Logo en index (página principal): tamaño aún más controlado */
.index-page .nor-header-logo,
.nor-header-logo {
    max-height: 36px;
    max-width: 200px;
}

/* Asegurar que img no explote en index */
.nor-header a img {
    max-width: 200px;
    height: auto;
}

/* ================================================================
   FIXES: degradado sutil, botón login, logo index
   ================================================================ */

/* Navbar: degradado sutil teal oscuro -> teal (sin blanco) */
.navbar {
    background: linear-gradient(135deg, var(--primary-dark) 0%, var(--primary) 100%) !important;
}

/* Login wrap: degradado suave, sin tintes púrpura */
.login-wrap {
    background: linear-gradient(160deg, #e8f4f8 0%, var(--surface) 50%, #f0f6f9 100%) !important;
}

/* Botón login: hover corregido (primary-light es casi blanco -> usar primary-hover) */
.btn-login {
    background: var(--primary) !important;
    color: #fff !important;
}
.btn-login:hover {
    background: var(--primary-hover) !important;
    color: #fff !important;
}

/* Logo en header: tamaño controlado, no explota en index */
.nor-header-logo {
    height: 32px !important;
    width: auto !important;
    max-width: 180px !important;
    object-fit: contain;
}
.nor-header a img {
    max-width: 200px !important;
    height: auto !important;
}

/* ======= FIXES FINALES V2 ======= */

/* 1. Logo: forzar tamaño máximo en TODOS los contextos */
.nor-header-logo,
.nor-header a img,
.nor-header img {
    height: 32px !important;
    width: auto !important;
    max-width: 200px !important;
    display: inline-block !important;
}

/* 2. Botón login: asegurar contraste incluso si el viejo CSS lo sobreescribe */
.btn-login,
button.btn-login,
.log-card .btn-login,
.log-card-foot .btn-login {
    background: var(--primary) !important;
    color: #ffffff !important;
    border: none !important;
}
.btn-login:hover,
button.btn-login:hover {
    background: var(--primary-dark) !important;
    color: #ffffff !important;
}

/* 3. Gradiente sutil en TODAS las páginas de login (admin, dist, dashboard) */
.login-wrap,
.log-card {
    background: linear-gradient(160deg, #e8f4f8 0%, #ffffff 50%, #f0f6f9 100%) !important;
}
.log-card {
    border: 1px solid var(--border) !important;
    box-shadow: var(--shadow-md) !important;
}

/* 4. Cabecera de login cards */
.login-top,
.log-card-top {
    background: linear-gradient(135deg, var(--primary-dark) 0%, var(--primary) 100%) !important;
    color: #fff !important;
}
.login-top h2, .login-top h3, .log-card-top h2, .log-card-top h3 {
    color: #fff !important;
}

/* ======= FIX .fg (form group) backgrounds ======= */
.fg {
    background: transparent !important;
}
.fg label {
    color: var(--text-secondary) !important;
    font-weight: 600;
}
.fg input {
    background: var(--surface) !important;
    color: var(--text) !important;
    border: 1.5px solid var(--border) !important;
}

/* ======= Asegurar que botones de formulario hereden ======= */
form .btn-login,
#loginForm .btn-login {
    background: var(--primary) !important;
    color: #fff !important;
}
form .btn-login:hover,
#loginForm .btn-login:hover {
    background: var(--primary-dark) !important;
}

/* ======= BOTÓN LOGIN DISTRIBUIDORES — forzado absoluto ======= */
#loginForm .btn-login,
#loginForm button.btn-login,
#btnLoginSubmit,
button#btnLoginSubmit,
#loginView .btn-login,
form .btn-login {
    background: #1f7c85 !important;
    color: #ffffff !important;
    border: none !important;
    padding: 11px !important;
    border-radius: 10px !important;
    font-size: .88rem !important;
    font-weight: 700 !important;
    cursor: pointer !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 6px !important;
    width: 100% !important;
}
#loginForm .btn-login:hover,
#btnLoginSubmit:hover {
    background: #0a3d42 !important;
    color: #fff !important;
}

/* ======= Asegurar que el contenedor del formulario no ponga fondo blanco ======= */
#loginView,
#loginView .log-card,
#loginView .card {
    background: transparent !important;
}

/* ======= BOTÓN CAMBIAR CONTRASEÑA (btn-back en navbar) ======= */
.btn-back,
#btnChangePass,
button.btn-back {
    background: rgba(255,255,255,0.18) !important;
    border: 1px solid rgba(255,255,255,0.3) !important;
    color: #ffffff !important;
    padding: 5px 12px !important;
    border-radius: 8px !important;
    font-size: .78rem !important;
    font-weight: 600 !important;
    cursor: pointer !important;
    transition: .2s !important;
    display: flex !important;
    align-items: center !important;
    gap: 4px !important;
}
.btn-back:hover,
#btnChangePass:hover {
    background: rgba(255,255,255,0.30) !important;
    color: #fff !important;
}

/* Asegurar el span del icono dentro */
.btn-back .material-symbols-outlined {
    color: #fff !important;
}
