/* ─────────────────────────────────────────────────────────────
   CRM — Estilos unificados del módulo (single source of truth).
   Todas las páginas /crm/* consumen este archivo.
   Tokens del sistema de diseño: --ic-* (definidos en app.css).
   ───────────────────────────────────────────────────────────── */

/* ── Tarjeta genérica del CRM (listas en móvil) ─────────────── */
.crm-card {
    border: 1px solid var(--ic-border);
    border-radius: var(--ic-radius-md);
    padding: 12px 14px;
    margin-bottom: 8px;
    background: var(--ic-surface);
    cursor: pointer;
    transition: opacity .12s, border-color .15s;
}
.crm-card:hover { border-color: rgba(148, 163, 184, 0.22); }
.crm-card:active { opacity: .7; }

/* ── Paper genérico de formularios CRM ──────────────────────── */
.crm-form-paper {
    max-width: 680px;
    border: 1px solid var(--ic-border);
    border-radius: var(--ic-radius-md);
    background: var(--ic-surface);
}

/* ── Pipeline (Kanban) ──────────────────────────────────────── */
.crm-kanban {
    display: flex;
    gap: 16px;
    overflow-x: auto;
    padding-bottom: 20px;
    min-height: 500px;
    -webkit-overflow-scrolling: touch;
}
.crm-kanban__column {
    min-width: 260px;
    max-width: 300px;
    background: var(--ic-surface-2);
    border-radius: var(--ic-radius-md);
    padding: 12px;
    flex-shrink: 0;
}
.crm-kanban__col-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
    gap: 8px;
}
.crm-kanban__card {
    background: var(--ic-surface);
    border: 1px solid var(--ic-border);
    border-radius: var(--ic-radius-sm);
    padding: 12px;
    margin-bottom: 8px;
    cursor: pointer;
    box-shadow: var(--ic-shadow-sm);
    transition: box-shadow .15s, border-color .15s;
}
.crm-kanban__card:hover {
    border-color: rgba(148, 163, 184, 0.22);
    box-shadow: var(--ic-shadow);
}
.crm-kanban__card-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 8px;
    gap: 8px;
}
.crm-kanban__card-actions {
    display: flex;
    gap: 4px;
    margin-top: 6px;
}
.crm-kanban__card-actions .mud-icon-button {
    min-width: 36px;
    min-height: 36px;
}

/* El bloque del Inbox (.crm-inbox__*, .crm-only-mobile) vive ahora en crm-inbox.css,
   con prefijo ib-. Ver docs/design-substrate.md. */

/* ── Móvil / tablet (alineado a MudBlazor SmAndDown ≤ 959.98px) */
@media (max-width: 959.98px) {
    .crm-form-paper { max-width: 100%; }
    .crm-kanban     { min-height: auto; }
}

/* ── Utilidades compartidas ─────────────────────────────────── */
.crm-truncate {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    min-width: 0;
}
/* Chip xs estandarizado (reemplaza min-width:20px;height:20px;font-size:11px etc.) */
.crm-chip-xs.mud-chip {
    height: 20px;
    min-width: 20px;
    padding: 0 8px;
    font-size: 0.6875rem;
}

/* ─────────────────────────────────────────────────────────────
   Shell del CRM (app dentro de la app — estilo WhatsApp Web)
   Sustituye .crm-subnav. Vive dentro de CrmLayout, sin tocar
   el MudAppBar global ni el bottom-nav del MainLayout.
   ───────────────────────────────────────────────────────────── */

/* ── Header slim sticky ─────────────────────────────────────── */
.crm-app-header {
    position: sticky;
    top: 0;
    z-index: var(--ic-page-header-z, 30);
    display: flex;
    align-items: center;
    gap: 8px;
    min-height: 52px;
    padding: 6px 12px;
    /* Antes full-bleed cuadrada (margin 0 -16px + border-bottom). Ahora barra
       redondeada alineada al mismo grid que las tarjetas del diseño general. */
    margin: 0 0 10px;
    border-radius: var(--ic-radius-lg, 16px);
    background: var(--ic-page-header-bg, rgba(26, 29, 39, 0.92));
    backdrop-filter: var(--ic-page-header-blur, blur(12px));
    -webkit-backdrop-filter: var(--ic-page-header-blur, blur(12px));
    border: 1px solid var(--ic-page-header-border, var(--ic-border));
    box-shadow: var(--ic-page-header-shadow, 0 1px 0 0 rgba(255,255,255,.04));
}
.crm-app-header__title {
    margin: 0;
    font-family: var(--ic-font);
    font-size: var(--ic-page-header-title-size, 1.0625rem);
    font-weight: var(--ic-page-header-title-weight, 600);
    color: var(--ic-text);
    flex: 0 1 auto;
}
.crm-app-header__back.mud-icon-button,
.crm-app-header__menu-btn.mud-icon-button {
    min-width: 44px;
    min-height: 44px;
    color: var(--ic-text);
}
.crm-app-header__menu-btn.is-active {
    color: var(--ic-nav-accent, var(--ic-primary));
    background: var(--ic-nav-active-bg, rgba(var(--lc-accent-rgb),0.16));
}

/* ── Drawer derecho del CRM ─────────────────────────────────── */
.crm-app-drawer .mud-drawer {
    background: var(--ic-surface);
    color: var(--ic-text);
}
.crm-app-drawer__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    border-bottom: 1px solid var(--ic-border);
    min-height: 56px;
}
.crm-app-drawer__title {
    font-weight: 700;
    letter-spacing: 0.01em;
}
.crm-app-drawer__search {
    padding: 10px 12px;
    border-bottom: 1px solid var(--ic-border);
}
.crm-app-drawer__list {
    overflow-y: auto;
    padding: 6px 0 16px;
    flex: 1;
    min-height: 0;
}
.crm-app-drawer__item {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 12px 16px;
    min-height: 48px;
    color: var(--ic-text);
    text-decoration: none;
    font-family: var(--ic-font);
    font-size: 0.9375rem;
    font-weight: 500;
    transition: background .12s ease, color .12s ease;
    -webkit-tap-highlight-color: transparent;
}
.crm-app-drawer__item .mud-icon-root {
    color: var(--ic-muted);
    transition: color .12s ease;
}
/* Contador de pendientes al final de la fila (cantidades de inventario por contar).
   Aparece sólo cuando hay algo que hacer y se apaga solo al terminar. */
.crm-app-drawer__badge {
    margin-left: auto;
    min-width: 22px;
    height: 22px;
    padding: 0 6px;
    border-radius: 999px;
    background: var(--lc-warn, #FFB74D);
    /* Tinta de MÁXIMO contraste contra el relleno, no color de texto: --ic-surface es
       #1A282E en oscuro (el mismo gris que estaba fijo aquí) y #FFFFFF en claro. Fijo daba
       3.02:1 sobre el ámbar oscuro del tema claro, y al calibrar --lc-warn para AA habría
       bajado a 2.36. */
    color: var(--ic-surface, #1A282E);
    font-size: 0.75rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.crm-app-drawer__item:hover {
    background: rgba(var(--lc-accent-rgb), 0.06);
    color: var(--ic-text);
}
.crm-app-drawer__item:hover .mud-icon-root { color: var(--ic-text); }
.crm-app-drawer__item.active {
    background: var(--ic-nav-active-bg, rgba(var(--lc-accent-rgb),0.16));
    color: var(--ic-nav-accent, var(--ic-primary));
    font-weight: 600;
}
.crm-app-drawer__item.active .mud-icon-root {
    color: var(--ic-nav-accent, var(--ic-primary));
}
.crm-app-drawer__empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 32px 16px;
    color: var(--ic-muted);
    text-align: center;
}
.crm-app-drawer__empty .mud-icon-root { color: var(--ic-muted); font-size: 40px; }

/* ── Grupos de secciones dentro del drawer ──────────────────── */
.crm-section-group { padding: 4px 0 8px; }
.crm-section-group + .crm-section-group {
    border-top: 1px solid var(--ic-border);
    padding-top: 8px;
}
.crm-section-group__label {
    padding: 12px 16px 6px;
    font-size: 0.6875rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--ic-muted);
}

/* ── Drawer del CRM en móvil: ancho cómodo en pantallas pequeñas ── */
@media (max-width: 359.98px) {
    .crm-app-drawer .mud-drawer {
        width: 100% !important;
    }
}

/* ─────────────────────────────────────────────────────────────
   Onboarding del CRM (clon visual de .mapa2-onboarding-*)
   ───────────────────────────────────────────────────────────── */
.crm-onboarding {
    position: fixed;
    inset: 0;
    z-index: 6500;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    background: rgba(0, 0, 0, 0.65);
    backdrop-filter: blur(8px);
    animation: crm-onboarding-fadein 0.2s ease;
}
@keyframes crm-onboarding-fadein {
    from { opacity: 0; }
    to   { opacity: 1; }
}
.crm-onboarding-card {
    position: relative;
    width: 100%;
    max-width: 380px;
    background: linear-gradient(180deg, rgba(var(--ic-surface-rgb), 0.98), rgba(var(--ic-bg-rgb), 0.98));
    border: 1px solid rgba(var(--lc-accent-rgb), 0.3);
    border-radius: 20px;
    box-shadow: 0 16px 48px rgba(0, 0, 0, 0.6);
    padding: 24px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    animation: crm-onboarding-slidein 0.3s cubic-bezier(0.32, 0.72, 0, 1);
}
@keyframes crm-onboarding-slidein {
    from { transform: translateY(20px); opacity: 0; }
    to   { transform: translateY(0);    opacity: 1; }
}
.crm-onboarding-skip {
    position: absolute;
    top: 12px;
    right: 12px;
    background: transparent;
    border: 0;
    color: var(--ic-muted);
    cursor: pointer;
    padding: 4px;
    border-radius: 50%;
}
.crm-onboarding-skip:hover { background: rgba(148, 163, 184, 0.1); color: var(--ic-text); }
.crm-onboarding-emoji {
    width: 72px;
    height: 72px;
    border-radius: 50%;
    background: var(--ic-brand-gradient);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 8px;
    box-shadow: 0 8px 20px rgba(var(--lc-accent-rgb), 0.45);
}
.crm-onboarding-emoji .mud-icon-root { color: var(--ic-on-primary) !important; font-size: 40px !important; }
.crm-onboarding-titulo {
    margin: 0;
    font-size: 1.25rem;
    font-weight: 800;
    color: var(--ic-text);
    text-align: center;
}
.crm-onboarding-desc {
    margin: 0;
    font-size: 0.9rem;
    line-height: 1.5;
    color: var(--ic-muted);
    text-align: center;
}
.crm-onboarding-dots {
    display: flex;
    gap: 6px;
    margin: 8px 0;
}
.crm-onboarding-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: rgba(148, 163, 184, 0.3);
    transition: width 0.2s, background 0.2s;
}
.crm-onboarding-dot.is-on {
    width: 24px;
    border-radius: 4px;
    background: var(--ic-nav-accent);
}
.crm-onboarding-actions {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 4px;
}

/* ── Detalle de oportunidad (od-) — rediseño F4 ─────────────────────────── */
.od-header .od-header__monto-row {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.od-header__monto {
    font-size: 1.75rem;
    font-weight: 800;
    color: var(--ic-text);
    letter-spacing: -0.02em;
}

/* Etapa como barra de progreso segmentada con nombres (tap = abrir sheet de mover) */
.od-stagebar {
    display: flex;
    gap: 4px;
    margin-top: 12px;
}

.od-stagebar__seg {
    flex: 1;
    min-height: 44px;
    border: none;
    border-radius: 8px;
    background: var(--ic-border);
    opacity: 0.45;
    cursor: pointer;
    padding: 4px 2px;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    -webkit-tap-highlight-color: transparent;
}

.od-stagebar__seg--on {
    background: var(--seg-color, var(--ic-nav-accent));
    opacity: 0.85;
}

.od-stagebar__seg--current {
    opacity: 1;
    outline: 2px solid var(--ic-surface);
    box-shadow: 0 0 0 2px var(--seg-color, var(--ic-nav-accent));
}

.od-stagebar__lbl {
    font-size: 0.625rem;
    font-weight: 700;
    /* Sobre el relleno del segmento, que siempre es un color de marca saturado. */
    color: var(--ic-on-primary);
    mix-blend-mode: normal;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
}

.od-stagebar__seg:not(.od-stagebar__seg--on) .od-stagebar__lbl {
    color: var(--ic-muted);
}

/* Siguiente paso destacado */
.od-next__row {
    display: flex;
    align-items: center;
    gap: 12px;
}

.od-next--missing {
    border-color: var(--mud-palette-warning, #FFB74D);
}

/* Action bar fija inferior (respeta el CrmBottomNav en móvil) */
.od-actionbar {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    justify-content: space-around;
    gap: 4px;
    padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
    background: var(--ic-surface);
    border-top: 1px solid var(--ic-border);
    z-index: 1190;
}

.od-actionbar .mud-button-root {
    min-height: 44px;
}

html[data-chrome="app"] .od-actionbar {
    bottom: var(--ic-bottom-nav-height);
    padding-bottom: 6px;
}

/* Filas de etapa en el sheet "Mover a…" */
.od-sheet-etapa {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    min-height: 48px;
    border: none;
    background: transparent;
    color: var(--ic-text);
    font-size: 1rem;
    padding: 8px 6px;
    border-radius: 10px;
    cursor: pointer;
    text-align: left;
    -webkit-tap-highlight-color: transparent;
}

.od-sheet-etapa:hover {
    background: var(--ic-interactive-hover);
}

.od-sheet-etapa--current {
    font-weight: 700;
}

.od-sheet-etapa__dot {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    flex-shrink: 0;
}

/* ── FAB extendido del pipeline móvil (con etiqueta de texto) ─────────────── */
.pl-fab-ext {
    position: fixed;
    right: 16px;
    bottom: calc(var(--ic-bottom-nav-height, 0px) + 16px);
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-height: 48px;
    padding: 0 18px;
    border: none;
    border-radius: 24px;
    background: var(--ic-brand-gradient, var(--ic-primary));
    color: var(--ic-on-primary);
    font-size: 0.9375rem;
    font-weight: 700;
    font-family: var(--ic-font);
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.35);
    cursor: pointer;
    z-index: 1190;
    -webkit-tap-highlight-color: transparent;
}

.pl-fab-ext:active {
    transform: scale(0.96);
}

html:not([data-chrome="app"]) .pl-fab-ext { display: none; }

/* ── Vista previa de campaña ──────────────────────────────────────────────
   Burbuja tipo WhatsApp con el mensaje ya resuelto. Va aquí y no en un
   bloque <style> del .razor porque esos bloques no tienen scope: un selector
   suelto restilaría los diálogos que la página abre. */
.cmp-preview {
    white-space: pre-wrap;
    padding: 12px 14px;
    border-radius: 12px;
    border: 1px solid var(--ic-border);
    background: var(--ic-surface-2);
    color: var(--ic-text);
    font-size: 14px;
    line-height: 1.5;
    max-width: 420px;
}
