/* ==========================================================================
   NMSolutions CRM - estilos globales
   Complementa el tema material de Radzen (misma base que NMSolutions.eCommerce).
   ========================================================================== */

:root {
    --nms-brand: #0a66c2;
    --nms-brand-dark: #07437f;
    --nms-surface: #f8fafc;
    --nms-line: #e5e7eb;
    --nms-muted: #6b7280;
    --nms-ok: #18794e;     --nms-ok-soft: #e6f4ec;
    --nms-warn: #a35a00;   --nms-warn-soft: #fff3e0;
    --nms-bad: #c0362c;    --nms-bad-soft: #fdecea;
    --nms-info: #0a66c2;   --nms-info-soft: #e8f1fb;
    --nms-violet: #6b3fb8; --nms-violet-soft: #f1ebfb;
    --nms-teal: #0e6e74;   --nms-teal-soft: #e7f6f7;
}

html, body {
    margin: 0;
    padding: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background: var(--nms-surface);
}

/* FocusOnNavigate pone el foco en el h1 de cada pagina: sin recuadro */
h1:focus, h1:focus-visible { outline: none; }

#blazor-error-ui {
    background: #fffbea;
    color: #7a4f01;
    border-top: 1px solid #f5c518;
    bottom: 0;
    box-shadow: 0 -1px 2px rgba(0,0,0,.1);
    display: none;
    left: 0;
    padding: .75rem 1.25rem;
    position: fixed;
    width: 100%;
    z-index: 1000;
}
#blazor-error-ui .dismiss { cursor: pointer; position: absolute; right: 1rem; top: .75rem; }

/* ==========================================================================
   Header (igual que eCommerce)
   ========================================================================== */
.nms-header {
    background: linear-gradient(135deg, var(--nms-brand) 0%, var(--nms-brand-dark) 100%) !important;
    color: #fff !important;
    box-shadow: 0 2px 6px rgba(0, 0, 0, .12);
}
.nms-header,
.nms-header .nms-header-title,
.nms-header .rz-text,
.nms-header .rzi,
.nms-header .rz-icon,
.nms-header .rz-button,
.nms-header .rz-sidebar-toggle,
.nms-header .rz-profile-menu,
.nms-header .rz-profile-menu > * {
    color: #fff !important;
}
.nms-header .rz-button:hover,
.nms-header .rz-sidebar-toggle:hover { background: rgba(255, 255, 255, .12) !important; }

.nms-header-company-logo {
    height: 34px;
    max-width: 220px;
    object-fit: contain;
    background: #fff;
    border-radius: 4px;
    padding: 2px 6px;
}

/* Boton "Ejecutar envio ahora" (mismo estilo que el boton de carrito del eCommerce) */
.nms-run-btn {
    display: inline-flex;
    align-items: center;
    gap: .5rem;
    background: rgba(255, 255, 255, .14);
    color: #fff;
    border: 1px solid rgba(255, 255, 255, .25);
    border-radius: 999px;
    padding: .4rem .9rem;
    cursor: pointer;
    font-size: .92rem;
    font-weight: 600;
    line-height: 1;
    transition: background .15s ease, transform .15s ease;
}
.nms-run-btn:hover { background: rgba(255, 255, 255, .24); transform: translateY(-1px); }
.nms-run-btn:disabled { opacity: .6; cursor: default; transform: none; }
.nms-run-btn .rzi, .nms-run-btn .rz-icon { font-size: 1.15rem; color: #fff; }

.nms-profile-menu,
.nms-profile-menu .rz-profile-menu-button,
.nms-profile-label {
    display: inline-flex;
    align-items: center;
    gap: .4rem;
    background: transparent !important;
}

.nms-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 1rem;
}

/* ==========================================================================
   Utilidades
   ========================================================================== */
.nms-muted { color: var(--nms-muted); font-size: .85rem; }
.nms-sub { display: block; color: var(--nms-muted); font-size: .78rem; margin-top: 1px; }
.nms-text-bad { color: var(--nms-bad); font-size: .85rem; }
.nms-text-warn { color: var(--nms-warn); font-size: .85rem; }
.nms-empty { padding: 1.5rem; text-align: center; color: var(--nms-muted); }
.nms-grow { flex: 1; }
.nms-click { cursor: pointer; }
.nms-click:hover { background: #f5f8fc; }
.nms-link { background: none; border: 0; color: #9ec2ff; cursor: pointer; font: inherit; padding: 0; text-decoration: underline; }
code { background: #eef1f5; border-radius: 4px; padding: 1px 5px; font-size: .82rem; }
code.nms-ph { background: var(--nms-warn-soft); color: var(--nms-warn); margin-right: 4px; }

/* Pastillas de estado */
.nms-pill {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: .76rem;
    font-weight: 600;
    padding: 2px 9px;
    border-radius: 999px;
    white-space: nowrap;
    background: #eef0f4;
    color: #5b6577;
}
.nms-pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .8; }
.nms-pill-info { background: var(--nms-info-soft); color: var(--nms-info); }
.nms-pill-violet { background: var(--nms-violet-soft); color: var(--nms-violet); }
.nms-pill-warn { background: var(--nms-warn-soft); color: var(--nms-warn); }
.nms-pill-ok { background: var(--nms-ok-soft); color: var(--nms-ok); }
.nms-pill-bad { background: var(--nms-bad-soft); color: var(--nms-bad); }
.nms-pill-teal { background: var(--nms-teal-soft); color: var(--nms-teal); }

/* Avance de la secuencia */
.nms-steps { display: inline-flex; gap: 3px; vertical-align: middle; }
.nms-steps i { width: 16px; height: 6px; border-radius: 3px; background: var(--nms-line); }
.nms-steps i.on { background: var(--nms-brand); }
.nms-steps-txt { color: var(--nms-muted); font-size: .78rem; margin-left: 4px; }

/* ==========================================================================
   Panel
   ========================================================================== */
.nms-kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 1rem; }
.nms-kpi {
    background: #fff;
    border: 1px solid var(--nms-line);
    border-radius: 10px;
    padding: 1rem 1.1rem;
    box-shadow: 0 1px 2px rgba(16, 24, 40, .05);
}
.nms-kpi .lbl { font-size: .8rem; color: var(--nms-muted); font-weight: 500; }
.nms-kpi .val { font-size: 1.9rem; font-weight: 650; margin-top: 4px; letter-spacing: -.5px; font-variant-numeric: tabular-nums; }
.nms-kpi .sub { font-size: .8rem; color: var(--nms-muted); margin-top: 2px; }
.nms-kpi-accent { border-color: #f0d48a; background: #fffbf0; }

.nms-funnel { display: flex; flex-direction: column; gap: .7rem; }
.nms-funnel-row { display: grid; grid-template-columns: 130px 1fr 60px; gap: .75rem; align-items: center; font-size: .9rem; }
.nms-funnel-row b { text-align: right; font-variant-numeric: tabular-nums; }
.nms-bar { height: 12px; background: #eef1f5; border-radius: 6px; overflow: hidden; }
.nms-bar > i { display: block; height: 100%; background: var(--nms-brand); border-radius: 6px; min-width: 2px; }
.nms-bar > i.warn { background: #d98a1c; }
.nms-bar > i.bad { background: var(--nms-bad); }

.nms-bars { display: flex; align-items: flex-end; gap: 6px; height: 140px; padding-top: 8px; }
.nms-bars .b { flex: 1; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; height: 100%; }
.nms-bars .b i { width: 100%; max-width: 26px; background: var(--nms-brand); border-radius: 4px 4px 0 0; min-height: 2px; }
.nms-bars .b i.e { background: var(--nms-bad); border-radius: 4px 4px 0 0; }
.nms-bars .b i.e + i { border-radius: 0; }
.nms-bars .b small { font-size: .65rem; color: var(--nms-muted); margin-top: 4px; }
.nms-legend { display: flex; gap: 1rem; font-size: .78rem; color: var(--nms-muted); margin-top: .5rem; }
.nms-legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; background: var(--nms-brand); }
.nms-legend i.e { background: var(--nms-bad); }

.nms-table { width: 100%; border-collapse: collapse; }
.nms-table td { padding: .5rem .4rem; border-bottom: 1px solid #f0f2f5; vertical-align: middle; }

/* Linea de tiempo (respuestas / historial) */
.nms-timeline { display: flex; flex-direction: column; }
.nms-tl { display: grid; grid-template-columns: 26px 1fr; gap: .7rem; padding: .65rem .25rem; border-bottom: 1px solid #f0f2f5; border-radius: 6px; }
.nms-tl:last-child { border-bottom: 0; }
.nms-tl-dot { width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; background: #eef0f4; color: #5b6577; }
.nms-tl-dot .rzi, .nms-tl-dot .rz-icon { font-size: 15px; }
.nms-tl-dot.out { background: var(--nms-info-soft); color: var(--nms-info); }
.nms-tl-dot.in { background: var(--nms-warn-soft); color: var(--nms-warn); }
.nms-tl-dot.bad { background: var(--nms-bad-soft); color: var(--nms-bad); }
.nms-tl-meta { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; font-size: .8rem; color: var(--nms-muted); }
.nms-tl-meta b { color: #1f2937; font-size: .9rem; }
.nms-tl-txt { margin-top: 3px; white-space: pre-wrap; word-break: break-word; font-size: .9rem; }

/* ==========================================================================
   Contactos
   ========================================================================== */
.nms-selbar {
    position: sticky;
    top: 0;
    z-index: 5;
    display: flex;
    gap: .5rem;
    align-items: center;
    flex-wrap: wrap;
    background: #0f1d33;
    color: #fff;
    padding: .5rem .75rem;
    border-radius: 10px;
}
.nms-selbar .rz-button { color: #fff !important; border-color: rgba(255,255,255,.3) !important; }
.nms-selbar .rz-button:hover { background: rgba(255,255,255,.12) !important; }

/* ==========================================================================
   Importar
   ========================================================================== */
.nms-drop {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: .35rem;
    border: 2px dashed #c8d2e2;
    border-radius: 12px;
    padding: 2.5rem 1rem;
    text-align: center;
    background: #fbfcfe;
    cursor: pointer;
    transition: .15s;
}
.nms-drop:hover { border-color: var(--nms-brand); background: var(--nms-info-soft); }
.nms-drop.busy { opacity: .7; cursor: progress; }
.nms-drop .rzi, .nms-drop .rz-icon { font-size: 2.6rem; color: var(--nms-brand); }
.nms-drop b { font-size: 1rem; }
/* El InputFile cubre toda la zona: permite clic y arrastrar-soltar */
.nms-drop input[type=file] { position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; height: 100%; }

.nms-map-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: .75rem; }
.nms-map-grid .rz-form-field { width: 100%; }

.nms-stats { display: flex; gap: .6rem; flex-wrap: wrap; }
.nms-stat { background: #eef1f5; border-radius: 8px; padding: .5rem .8rem; font-size: .85rem; }
.nms-stat b { font-size: 1.25rem; display: block; font-variant-numeric: tabular-nums; }
.nms-stat.ok b { color: var(--nms-ok); }
.nms-stat.bad b { color: var(--nms-bad); }
.nms-stat.warn b { color: var(--nms-warn); }

.nms-row-err > td { background: #fff7f6 !important; }
.nms-row-warn > td { background: #fffcf3 !important; }

/* ==========================================================================
   Plantillas
   ========================================================================== */
.nms-code textarea, textarea.nms-code {
    font-family: Consolas, "Cascadia Mono", monospace !important;
    font-size: 12px !important;
    line-height: 1.45 !important;
}
.nms-preview { width: 100%; height: 640px; border: 1px solid var(--nms-line); border-radius: 8px; background: #fff; }

/* ==========================================================================
   Login (igual que eCommerce)
   ========================================================================== */
.nms-login-wrapper {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #0a66c2 0%, #1b3c6b 100%);
    padding: 1.5rem;
}
.nms-login-card {
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0,0,0,.15);
    padding: 2rem;
    width: 100%;
    max-width: 420px;
}
.nms-login-brand { text-align: center; margin-bottom: 1.5rem; }
.nms-login-brand img { max-width: 200px; height: auto; }
.nms-login-app { margin-top: .5rem; font-weight: 700; letter-spacing: .12em; color: var(--nms-brand); font-size: .85rem; }
.nms-login-form .rz-textbox,
.nms-login-form .nms-login-input {
    width: 100%;
    padding: .65rem .75rem;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 1rem;
    box-sizing: border-box;
    background: #fff;
}
.nms-login-form .nms-login-input:focus {
    outline: none;
    border-color: var(--nms-brand, #3b82f6);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, .15);
}
.nms-label {
    display: block;
    font-size: .75rem;
    font-weight: 700;
    letter-spacing: .04em;
    color: #4b5563;
    margin-bottom: .35rem;
}
.nms-login-row { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: .5rem; }
.nms-checkbox-inline { display: inline-flex; align-items: center; gap: .35rem; font-size: .9rem; color: #374151; }
.nms-login-btn { width: 100%; justify-content: center; margin-top: .5rem; }
.nms-login-footer { margin-top: 1.5rem; color: rgba(255,255,255,.85); font-size: .85rem; }
.nms-login-footer a { color: inherit; text-decoration: underline; }

@media (max-width: 640px) {
    .nms-funnel-row { grid-template-columns: 95px 1fr 44px; }
}

/* ---------- Formulario publico de alta ---------- */
.nms-public-card { max-width: 640px; }
.nms-public-card h1 { font-size: 1.35rem; margin: 0 0 .35rem 0; text-align: center; }
.nms-public-card .nms-public-sub { text-align: center; color: #555; margin: 0 0 1.25rem 0; line-height: 1.5; }
.nms-public-ok { text-align: center; padding: 1rem 0; }
.nms-public-ok .material-icons, .nms-public-ok .rzi { font-size: 3rem !important; color: var(--nms-ok, #2e7d32); }


/* ==========================================================================
   Layout con menu superior (sin barra lateral)
   ========================================================================== */
.nms-shell { min-height: 100vh; display: flex; flex-direction: column; }

.nms-top {
    position: sticky; top: 0; z-index: 50;
    background: #fff;
    border-bottom: 1px solid var(--nms-line);
    box-shadow: 0 1px 2px rgba(16, 24, 40, .04);
}
.nms-top-row {
    display: flex; align-items: center; gap: 1.25rem;
    height: 60px; padding: 0 1.5rem;
    max-width: 1600px; margin: 0 auto;
}

.nms-brand { display: flex; align-items: center; gap: .65rem; text-decoration: none; flex-shrink: 0; }
.nms-brand img { height: 30px; width: auto; display: block; }
.nms-brand-app {
    font-size: .72rem; font-weight: 700; letter-spacing: .14em; text-transform: uppercase;
    color: var(--nms-brand); padding-left: .65rem; border-left: 1px solid var(--nms-line); line-height: 1.6;
}

/* --- navegacion --- */
.nms-nav { display: flex; align-items: stretch; height: 100%; gap: .15rem; flex: 1; min-width: 0; }
.nms-nav-link {
    position: relative; display: inline-flex; align-items: center; gap: .45rem;
    height: 100%; padding: 0 .8rem; border: 0; background: none; cursor: pointer;
    font: inherit; font-size: .9rem; font-weight: 500; color: #475467; text-decoration: none; white-space: nowrap;
    transition: color .15s ease;
}
.nms-nav-link .rzi, .nms-nav-link .rz-icon { font-size: 1.15rem; color: #98a2b3; transition: color .15s ease; }
.nms-nav-link:hover { color: #101828; }
.nms-nav-link:hover .rzi { color: #667085; }
.nms-nav-link::after {
    content: ""; position: absolute; left: .8rem; right: .8rem; bottom: -1px; height: 2px;
    border-radius: 2px 2px 0 0; background: transparent; transition: background .15s ease;
}
.nms-nav-link.active, .nms-nav-group.active > .nms-nav-link { color: var(--nms-brand); }
.nms-nav-link.active .rzi, .nms-nav-group.active > .nms-nav-link .rzi { color: var(--nms-brand); }
.nms-nav-link.active::after, .nms-nav-group.active > .nms-nav-link::after { background: var(--nms-brand); }
.nms-caret { font-size: 1rem !important; margin-left: -.2rem; transition: transform .15s ease; }
.nms-nav-group.open .nms-caret { transform: rotate(180deg); }

.nms-badge {
    min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px;
    display: inline-flex; align-items: center; justify-content: center;
    font-size: .7rem; font-weight: 600; line-height: 1;
    background: #eef2f6; color: #475467;
}
.nms-badge.warn { background: var(--nms-warn-soft); color: var(--nms-warn); }
.nms-badge.ok { background: var(--nms-ok-soft); color: var(--nms-ok); }

/* --- desplegables --- */
.nms-nav-group { position: relative; display: flex; align-items: stretch; }
.nms-nav-menu {
    display: none; position: absolute; top: calc(100% + 6px); left: 0; z-index: 60;
    min-width: 260px; padding: .35rem;
    background: #fff; border: 1px solid var(--nms-line); border-radius: 10px;
    box-shadow: 0 12px 32px -8px rgba(16, 24, 40, .18), 0 4px 8px -4px rgba(16, 24, 40, .06);
}
.nms-nav-menu-right { left: auto; right: 0; min-width: 200px; }
.nms-nav-group.open > .nms-nav-menu { display: block; animation: nmsMenu .12s ease-out; }
@keyframes nmsMenu { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }
.nms-nav-menu-head { padding: .5rem .65rem .4rem; font-size: .78rem; color: var(--nms-muted); border-bottom: 1px solid var(--nms-line); margin-bottom: .3rem; }

.nms-nav-item {
    display: flex; align-items: center; gap: .7rem;
    padding: .55rem .65rem; border-radius: 7px;
    color: #344054; text-decoration: none; font-size: .9rem; font-weight: 500;
}
.nms-nav-item .rzi, .nms-nav-item .rz-icon { font-size: 1.15rem; color: #98a2b3; }
.nms-nav-item small { display: block; font-size: .75rem; font-weight: 400; color: var(--nms-muted); margin-top: 1px; }
.nms-nav-item > span:not(.nms-badge) { flex: 1; }
.nms-nav-item:hover { background: #f5f7fa; color: #101828; }
.nms-nav-item.active { background: var(--nms-info-soft); color: var(--nms-brand); }
.nms-nav-item.active .rzi { color: var(--nms-brand); }

/* --- acciones de la derecha --- */
.nms-top-actions { display: flex; align-items: center; gap: .5rem; margin-left: auto; flex-shrink: 0; height: 100%; }
.nms-btn-run {
    display: inline-flex; align-items: center; gap: .4rem;
    height: 34px; padding: 0 .85rem; border-radius: 8px; cursor: pointer;
    border: 1px solid #d0d5dd; background: #fff; color: #344054;
    font: inherit; font-size: .85rem; font-weight: 500;
    box-shadow: 0 1px 2px rgba(16, 24, 40, .05);
    transition: border-color .15s ease, background .15s ease, color .15s ease;
}
.nms-btn-run .rzi, .nms-btn-run .rz-icon { font-size: 1rem; color: var(--nms-brand); }
.nms-btn-run:hover { border-color: var(--nms-brand); color: var(--nms-brand); background: #f8fbff; }
.nms-btn-run:disabled { opacity: .6; cursor: default; }

.nms-user { height: 100%; align-items: center; }
.nms-user-btn {
    display: inline-flex; align-items: center; gap: .5rem; height: 40px; padding: 0 .4rem 0 .25rem;
    border: 0; background: none; border-radius: 8px; cursor: pointer; font: inherit; color: #344054;
}
.nms-user-btn:hover { background: #f5f7fa; }
.nms-user-btn .nms-caret { color: #98a2b3; }
.nms-avatar {
    width: 30px; height: 30px; border-radius: 50%;
    display: inline-flex; align-items: center; justify-content: center;
    background: var(--nms-info-soft); color: var(--nms-brand); font-size: .75rem; font-weight: 700; letter-spacing: .02em;
}
.nms-user-name { font-size: .85rem; font-weight: 500; max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nms-user .nms-nav-menu { top: calc(100% - 4px); }

.nms-burger { display: none; border: 0; background: none; padding: .35rem; border-radius: 8px; cursor: pointer; color: #344054; }
.nms-burger:hover { background: #f5f7fa; }
.nms-burger .rzi { font-size: 1.5rem; }

.nms-mobile-nav { display: none; }
.nms-backdrop { position: fixed; inset: 0; z-index: 40; background: transparent; }

/* --- contenido --- */
.nms-main { flex: 1; width: 100%; max-width: 1600px; margin: 0 auto; padding: 1.75rem 1.5rem 2rem; box-sizing: border-box; }
.nms-shell > .nms-footer {
    padding: 1rem 1.5rem; border-top: 1px solid var(--nms-line); background: #fff;
    color: var(--nms-muted); font-size: .8rem;
}

/* --- pantallas medianas: solo iconos en los items con contador --- */
@media (max-width: 1280px) {
    .nms-user-name { display: none; }
    .nms-nav-link { padding: 0 .6rem; }
    .nms-nav-link::after { left: .6rem; right: .6rem; }
}
@media (max-width: 1100px) {
    .nms-btn-run span { display: none; }
    .nms-btn-run { padding: 0 .55rem; }
}

/* --- celular / tablet: menu hamburguesa --- */
@media (max-width: 960px) {
    .nms-nav { display: none; }
    .nms-burger { display: inline-flex; }
    .nms-top-row { padding: 0 1rem; gap: .75rem; }
    .nms-brand img { height: 26px; }
    .nms-mobile-nav {
        display: block; position: relative; z-index: 55;
        padding: .5rem .75rem 1rem; border-top: 1px solid var(--nms-line); background: #fff;
        max-height: calc(100vh - 60px); overflow-y: auto;
    }
    .nms-mobile-sep { padding: .75rem .65rem .25rem; font-size: .7rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: #98a2b3; }
    .nms-main { padding: 1.25rem 1rem 1.5rem; }
}

/* Registrar contacto entrante */
.nms-entrante-row { display: flex; align-items: center; gap: .6rem; padding: .5rem .6rem; border-radius: 7px; cursor: pointer; flex-wrap: wrap; }
.nms-entrante-row:hover { background: #f5f7fa; }
.nms-entrante-row.sel { background: var(--nms-info-soft); }
.nms-entrante-row input { margin: 0; accent-color: var(--nms-brand); }
.nms-entrante-main { flex: 1; min-width: 200px; display: flex; flex-direction: column; }
.nms-entrante-main .nms-muted { font-size: .8rem; }
.nms-input { width: 100%; box-sizing: border-box; padding: .6rem .75rem; border: 1px solid #d0d5dd; border-radius: 6px; font: inherit; font-size: .95rem; }
.nms-input:focus { outline: none; border-color: var(--nms-brand); box-shadow: 0 0 0 3px rgba(10, 102, 194, .12); }
