/* ==========================================================================
   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; }
}
