/* ============================================================================
   TANDA H1 :: tanda-h1-manodock - estilos premium para la barra unificada
   ============================================================================
   Variables CSS para personalización rápida.
   Mobile-first con safe-area-inset.
   ============================================================================ */

:root {
    --mdock-bg:        rgba(12, 14, 18, 0.9);
    --mdock-bg-solid:  #0f1116;
    --mdock-border:    rgba(255, 255, 255, 0.10);
    --mdock-fg:        #f5f5f7;
    --mdock-muted:     rgba(245, 245, 247, 0.55);
    --mdock-accent:    #c8102e;
    --mdock-critical:  #c8102e;
    --mdock-success:   #16a34a;
    --mdock-radius:    22px;
    --mdock-shadow:    0 8px 32px rgba(0, 0, 0, 0.45),
                       0 2px 8px rgba(0, 0, 0, 0.25),
                       inset 0 1px 0 rgba(255, 255, 255, 0.06);
    --mdock-blur:      18px;
    --mdock-z:         1030;            /* < modal Bootstrap (1050) */
    --mdock-z-update:  1040;            /* update FAB un poco más alto */
    --mdock-z-panel:   1055;            /* panel modal arriba de todo */
}

/* ============================================================================
   ROOT WRAPPER
   ============================================================================ */
.mdock-root {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: var(--mdock-z);
}
.mdock-root > * { pointer-events: auto; }

/* ============================================================================
   BARRA INFERIOR - estado Open
   ============================================================================ */
.mdock-bar {
    position: fixed;
    left: 50%;
    bottom: calc(16px + env(safe-area-inset-bottom, 0px));
    transform: translateX(-50%);
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 6px 10px;
    max-width: min(720px, calc(100vw - 32px));
    background: var(--mdock-bg);
    backdrop-filter: saturate(160%) blur(var(--mdock-blur));
    -webkit-backdrop-filter: saturate(160%) blur(var(--mdock-blur));
    border: 1px solid var(--mdock-border);
    border-radius: var(--mdock-radius);
    box-shadow: var(--mdock-shadow);
    color: var(--mdock-fg);
    animation: mdock-slide-up .35s cubic-bezier(.2, .9, .25, 1);
    overflow-x: auto;
    overflow-y: hidden;
    scrollbar-width: none;
}
.mdock-bar::-webkit-scrollbar { display: none; }

@keyframes mdock-slide-up {
    from { transform: translate(-50%, 24px); opacity: 0; }
    to   { transform: translate(-50%, 0);    opacity: 1; }
}

/* ============================================================================
   ITEMS DEL DOCK
   ============================================================================ */
.mdock-item {
    position: relative;
    flex: 0 0 auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    min-width: 56px;
    padding: 8px 10px;
    background: transparent;
    border: none;
    border-radius: 12px;
    color: var(--mdock-fg);
    font-family: inherit;
    cursor: pointer;
    transition: background-color .15s ease, transform .15s ease;
    -webkit-tap-highlight-color: transparent;
}
.mdock-item:hover {
    background: rgba(225, 29, 58, 0.12);
}
.mdock-item:hover .mdock-lbl { color: #f4f6fa; }
.mdock-item:active {
    transform: scale(0.94);
}
.mdock-ico {
    font-size: 22px;
    line-height: 1;
    filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.4));
}
.mdock-lbl {
    font-size: 9.5px;
    font-weight: 700;
    letter-spacing: 0.06em;
    color: var(--mdock-muted);
    text-transform: uppercase;
    white-space: nowrap;
    transition: color .15s ease;
}

/* Badge numérica */
.mdock-badge {
    position: absolute;
    top: 2px;
    right: 4px;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    background: var(--mdock-critical);
    color: #fff;
    font-size: 10px;
    font-weight: 800;
    border-radius: 9px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 0 0 2px var(--mdock-bg-solid);
    animation: mdock-badge-pop .25s ease-out;
}
@keyframes mdock-badge-pop {
    from { transform: scale(0); }
    to   { transform: scale(1); }
}

/* Item de Update (color naranja persistente) */
.mdock-item-update .mdock-ico {
    animation: mdock-spin-soft 6s linear infinite;
}
.mdock-item-update {
    background: linear-gradient(135deg, rgba(200, 16, 46, 0.18), rgba(200, 16, 46, 0.12));
}
.mdock-item-update:hover {
    background: linear-gradient(135deg, rgba(200, 16, 46, 0.32), rgba(200, 16, 46, 0.22));
}
@keyframes mdock-spin-soft {
    0%, 80% { transform: rotate(0deg); }
    100%    { transform: rotate(360deg); }
}

/* Separador + minimizar */
.mdock-sep {
    width: 1px;
    height: 24px;
    background: var(--mdock-border);
    margin: 0 4px;
    flex: 0 0 auto;
}
.mdock-min-btn {
    flex: 0 0 auto;
    width: 32px;
    height: 32px;
    padding: 0;
    background: transparent;
    border: none;
    border-radius: 8px;
    color: var(--mdock-muted);
    cursor: pointer;
    transition: background-color .15s ease, color .15s ease;
}
.mdock-min-btn:hover {
    background: rgba(255, 255, 255, 0.07);
    color: var(--mdock-fg);
}
.mdock-min-ico {
    font-size: 16px;
    line-height: 1;
    display: inline-block;
    transform: translateY(-1px);
}

/* ============================================================================
   PILL MINIMIZADA
   ============================================================================ */
.mdock-pill {
    position: fixed;
    right: 16px;
    bottom: calc(16px + env(safe-area-inset-bottom, 0px));
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 12px;
    background: var(--mdock-bg);
    backdrop-filter: saturate(160%) blur(var(--mdock-blur));
    -webkit-backdrop-filter: saturate(160%) blur(var(--mdock-blur));
    border: 1px solid var(--mdock-border);
    border-radius: 999px;
    box-shadow: var(--mdock-shadow);
    color: var(--mdock-fg);
    font-family: inherit;
    cursor: pointer;
    transition: transform .15s ease, box-shadow .15s ease;
    animation: mdock-pill-in .3s cubic-bezier(.2, .9, .25, 1);
}
.mdock-pill:hover { transform: translateY(-2px); }
.mdock-pill:active { transform: scale(0.96); }
@keyframes mdock-pill-in {
    from { opacity: 0; transform: translateY(20px) scale(0.85); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}
.mdock-pill-icons {
    display: inline-flex;
    gap: 4px;
    font-size: 16px;
    line-height: 1;
}
.mdock-pill-icons span {
    display: inline-block;
    transform: scale(0.85);
    filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.4));
}
.mdock-pill-badge {
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    background: var(--mdock-critical);
    color: #fff;
    font-size: 11px;
    font-weight: 800;
    border-radius: 9px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.mdock-pill-up {
    font-size: 11px;
    color: var(--mdock-muted);
    margin-left: 2px;
}

/* ============================================================================
   UPDATE FAB URGENTE (esquina sup-derecha)
   ============================================================================ */
.mdock-update-fab {
    position: fixed;
    top: calc(16px + env(safe-area-inset-top, 0px));
    right: 16px;
    z-index: var(--mdock-z-update);
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 18px;
    background: linear-gradient(135deg, #e63148, #8f0a20);
    color: #fff;
    border: 2px solid rgba(255, 255, 255, 0.18);
    border-radius: 999px;
    font-family: inherit;
    font-size: 13px;
    font-weight: 800;
    letter-spacing: 0.04em;
    box-shadow:
        0 8px 24px rgba(200, 16, 46, 0.45),
        0 0 0 0 rgba(200, 16, 46, 0.7);
    cursor: pointer;
    transition: transform .15s ease, box-shadow .25s ease;
}
.mdock-update-fab:hover {
    transform: scale(1.04);
    box-shadow:
        0 12px 32px rgba(200, 16, 46, 0.55),
        0 0 0 8px rgba(200, 16, 46, 0.18);
}
.mdock-update-pulso {
    animation: mdock-pulse-ring 1.4s cubic-bezier(.4, 0, .6, 1) infinite;
}
@keyframes mdock-pulse-ring {
    0%   { box-shadow: 0 8px 24px rgba(200, 16, 46, 0.45), 0 0 0 0 rgba(200, 16, 46, 0.7); }
    70%  { box-shadow: 0 8px 24px rgba(200, 16, 46, 0.45), 0 0 0 18px rgba(200, 16, 46, 0); }
    100% { box-shadow: 0 8px 24px rgba(200, 16, 46, 0.45), 0 0 0 0 rgba(200, 16, 46, 0); }
}
.mdock-update-critica {
    background: linear-gradient(135deg, #c8102e, #8f0a20);
    animation: mdock-shake-soft .9s ease-in-out infinite;
}
@keyframes mdock-shake-soft {
    0%, 100% { transform: rotate(0deg); }
    25%      { transform: rotate(-1.2deg); }
    75%      { transform: rotate(1.2deg); }
}
.mdock-uf-icon {
    font-size: 16px;
    animation: mdock-spin-soft 4s linear infinite;
}
.mdock-uf-text { white-space: nowrap; }
.mdock-uf-badge {
    background: #fff;
    color: #c8102e;
    font-size: 11px;
    font-weight: 900;
    padding: 1px 6px;
    border-radius: 8px;
    margin-left: 2px;
}

/* ============================================================================
   V4.52 :: tanda-v452-update-real - FAB MÁS visible + mini btn auxiliar
   "Casi molesto pero no bloqueante" - el botón pulsa, brilla y vibra suavemente
   pero NUNCA cubre contenido importante ni intercepta clicks de la operativa.
   ============================================================================ */
.mdock-update-fab-v452 {
    /* heightened presence: borde más grueso, sombra multi-capa */
    border: 2.5px solid rgba(255, 255, 255, 0.28) !important;
    padding: 12px 22px !important;
    font-size: 14px !important;
    box-shadow:
        0 10px 32px rgba(200, 16, 46, 0.55),
        0 0 0 0 rgba(200, 16, 46, 0.7),
        inset 0 1px 0 rgba(255, 255, 255, 0.30) !important;
    /* siempre tiene un breathing pulse de fondo, aunque no esté en _updatePulso */
    animation: mdock-v452-breathe 2.6s cubic-bezier(.4, 0, .6, 1) infinite !important;
}
@keyframes mdock-v452-breathe {
    0%, 100% {
        transform: scale(1);
        box-shadow:
            0 10px 32px rgba(200, 16, 46, 0.55),
            0 0 0 0 rgba(200, 16, 46, 0.5),
            inset 0 1px 0 rgba(255, 255, 255, 0.30);
    }
    50% {
        transform: scale(1.04);
        box-shadow:
            0 14px 40px rgba(200, 16, 46, 0.70),
            0 0 0 12px rgba(200, 16, 46, 0),
            inset 0 1px 0 rgba(255, 255, 255, 0.40);
    }
}
/* Cuando _updatePulso (cada 5s del componente) se activa, ENCIMA del breathe
   le metemos un pulse-ring agresivo */
.mdock-update-fab-v452.mdock-update-pulso {
    animation:
        mdock-v452-breathe 2.6s cubic-bezier(.4, 0, .6, 1) infinite,
        mdock-v452-shake 0.6s cubic-bezier(.36,.07,.19,.97) !important;
}
@keyframes mdock-v452-shake {
    0%, 100% { transform: translateX(0) scale(1); }
    25%      { transform: translateX(-2px) scale(1.04); }
    75%      { transform: translateX(2px) scale(1.04); }
}

/* Mini botón auxiliar (📋) para abrir panel de novedades sin recargar */
.mdock-update-fab-mini {
    position: fixed;
    top: calc(16px + env(safe-area-inset-top, 0px));
    right: 175px;
    z-index: var(--mdock-z-update);
    width: 36px; height: 36px;
    background: rgba(20, 23, 29, 0.85);
    color: #fff;
    border: 1.5px solid rgba(200, 16, 46, 0.55);
    border-radius: 50%;
    cursor: pointer;
    font-size: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.35);
    backdrop-filter: blur(8px);
    transition: all 0.18s ease;
}
.mdock-update-fab-mini:hover {
    background: rgba(200, 16, 46, 0.20);
    transform: scale(1.10);
    border-color: #e63148;
}
@media (max-width: 700px) {
    .mdock-update-fab-mini { right: 145px; }
}

/* ============================================================================
   PANEL DE NOVEDADES + UPDATE (modal centrado)
   ============================================================================ */
.mdock-panel-bg {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: var(--mdock-z-panel);
    animation: mdock-fade .2s ease;
}
.mdock-panel {
    position: fixed;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    z-index: calc(var(--mdock-z-panel) + 1);
    width: min(560px, calc(100vw - 24px));
    max-height: min(80vh, 720px);
    background: #fff;
    color: #1a1a24;
    border-radius: 18px;
    box-shadow: 0 24px 64px rgba(0, 0, 0, 0.4);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: mdock-modal-in .25s cubic-bezier(.2, .9, .25, 1);
}
.mdock-panel-critica {
    border: 3px solid #c8102e;
    box-shadow: 0 24px 64px rgba(200, 16, 46, 0.3);
}
@keyframes mdock-fade {
    from { opacity: 0; }
    to   { opacity: 1; }
}
@keyframes mdock-modal-in {
    from { opacity: 0; transform: translate(-50%, -45%) scale(0.96); }
    to   { opacity: 1; transform: translate(-50%, -50%) scale(1); }
}

.mdock-panel-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    padding: 18px 20px 12px;
    border-bottom: 1px solid #ececec;
}
.mdock-panel-tit {
    font-size: 17px;
    font-weight: 800;
    line-height: 1.25;
}
.mdock-panel-sub {
    font-size: 12px;
    color: #6b7280;
    margin-top: 4px;
}
.mdock-panel-flag {
    background: #c8102e;
    color: #fff;
    font-size: 10px;
    font-weight: 900;
    padding: 2px 6px;
    border-radius: 4px;
    margin-left: 6px;
    letter-spacing: .04em;
}
.mdock-panel-close {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    border: none;
    background: #f3f4f6;
    color: #4b5563;
    font-size: 16px;
    cursor: pointer;
    transition: background-color .15s ease, color .15s ease;
    flex: 0 0 auto;
}
.mdock-panel-close:hover { background: #e5e7eb; color: #111827; }

.mdock-panel-body {
    flex: 1;
    overflow-y: auto;
    padding: 12px 20px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.mdock-loading, .mdock-empty {
    text-align: center;
    color: #6b7280;
    font-size: 14px;
    padding: 24px 0;
}

.mdock-card {
    border: 1px solid #ececec;
    border-radius: 12px;
    padding: 12px 14px;
    background: #fafafa;
}
.mdock-card-tit {
    font-weight: 700;
    font-size: 14px;
    color: #111827;
}
.mdock-card-sum {
    font-size: 13px;
    color: #4b5563;
    margin-top: 4px;
    line-height: 1.4;
}
.mdock-card-meta {
    display: flex;
    gap: 6px;
    font-size: 11px;
    color: #6b7280;
    margin-top: 6px;
    flex-wrap: wrap;
}
.mdock-card-flag {
    background: #c8102e;
    color: #fff;
    font-size: 10px;
    font-weight: 900;
    padding: 2px 6px;
    border-radius: 4px;
    margin-left: 6px;
}
.mdock-card-critica { border-color: #fecaca; background: #fef2f2; }
.mdock-card-importante { border-color: #fde68a; background: #fffbeb; }

.mdock-panel-actions {
    display: flex;
    gap: 8px;
    padding: 14px 20px 18px;
    border-top: 1px solid #ececec;
    flex-wrap: wrap;
}
.mdock-btn {
    flex: 1;
    min-height: 42px;
    padding: 0 16px;
    border-radius: 10px;
    border: none;
    font-family: inherit;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
    transition: filter .15s ease, transform .15s ease;
    white-space: nowrap;
}
.mdock-btn:active:not(:disabled) { transform: scale(0.97); }
.mdock-btn:disabled { opacity: 0.6; cursor: not-allowed; }
.mdock-btn-primary {
    background: linear-gradient(135deg, #e63148, #8f0a20);
    color: #fff;
    flex: 2;
}
.mdock-btn-primary:hover:not(:disabled) { filter: brightness(1.1); }
.mdock-btn-secondary {
    background: #f3f4f6;
    color: #111827;
    flex: 1;
}
.mdock-btn-secondary:hover:not(:disabled) { background: #e5e7eb; }
.mdock-btn-silenciar {
    background: transparent;
    color: #6b7280;
    border: 1px solid #d1d5db;
    flex: 1;
}
.mdock-btn-silenciar:hover:not(:disabled) {
    background: #f9fafb;
    color: #111827;
}

/* ============================================================================
   ESTADO HIDDEN - en /ventas/nueva (POS fullscreen)
   ============================================================================ */
.mdock-state-hidden .mdock-bar,
.mdock-state-hidden .mdock-pill {
    display: none !important;
}
/* Update FAB sigue visible incluso en POS - es importante saber que hay update */

/* ============================================================================
   RESPONSIVE - mobile (< 768px)
   ============================================================================ */
@media (max-width: 767px) {
    .mdock-bar {
        left: 8px;
        right: 8px;
        max-width: none;
        transform: none;
        bottom: calc(8px + env(safe-area-inset-bottom, 0px));
        padding: 4px 6px;
        gap: 2px;
    }
    @keyframes mdock-slide-up {
        from { transform: translateY(24px); opacity: 0; }
        to   { transform: translateY(0);    opacity: 1; }
    }
    .mdock-item {
        min-width: 48px;
        padding: 6px 6px;
    }
    .mdock-ico { font-size: 20px; }
    .mdock-lbl { font-size: 9px; }
    .mdock-sep { display: none; }
    .mdock-update-fab {
        top: calc(8px + env(safe-area-inset-top, 0px));
        right: 8px;
        padding: 8px 14px;
        font-size: 12px;
    }
    .mdock-uf-text { display: none; }
    .mdock-pill {
        right: 8px;
        bottom: calc(8px + env(safe-area-inset-bottom, 0px));
    }
    .mdock-panel {
        width: calc(100vw - 16px);
        max-height: 90vh;
        border-radius: 16px;
    }
    .mdock-panel-actions {
        flex-direction: column;
    }
    .mdock-btn { flex: 1 1 auto; }
}

/* ============================================================================
   COMPATIBILIDAD: posicionar AntipanicoBoton + bug-reporter para que no choquen
   ============================================================================ */

/* Antipánico: izquierda, separado del dock, z-index máximo (es crítico) */
body .ap-btn-flotante {
    bottom: calc(22px + env(safe-area-inset-bottom, 0px)) !important;
    left: 22px !important;
    right: auto !important;
    z-index: 1041 !important;
}
@media (max-width: 767px) {
    body .ap-btn-flotante {
        bottom: 84px !important; /* arriba del dock en mobile */
        left: 8px !important;
    }
}

/* Bug reporter (ladybug): ahora abre desde el dock, ocultar su botón propio */
.mb-bug-fab {
    display: none !important;
}

/* Buscador flotante TANDA 81 → ocultar (ya está en NavMenu y tiene Ctrl+K) */
.busc-flotante {
    display: none !important;
}

/* ============================================================================
   tanda-flotantes-en-barra :: CONSOLIDAR TODO en el dock central.
   El dock ya abre Chat (window._chatDockRef.JsTogglePanel) y Manolín
   (window._manolinDotnetRef.JsToggleChatExterno) por referencia .NET directa,
   NO clickeando estos lanzadores. Por eso la burbuja de chat (esquina inf-der)
   y la mascota toro flotante son redundantes y ensucian la pantalla → se ocultan.
   Los PANELES siguen funcionando (se abren desde el dock). El Antipánico NO se
   toca: es control de seguridad y debe quedar SIEMPRE visible.
   ============================================================================ */
.chd-burbuja { display: none !important; }          /* burbuja flotante de chat */
.manolin-egg, .manolin-pet { display: none !important; } /* huevito + mascota toro flotante */
.mp-fab { display: none !important; }               /* Manolin Pro FAB legacy (si existiera) */

/* Cuando dock minimizado, dejar más espacio horizontal a Antipánico */
body[data-mdock-state="mini"] .ap-btn-flotante {
    /* sin cambios, queda igual */
}

/* En POS fullscreen, dock está hidden pero Antipánico sigue */
.mdock-state-hidden ~ * .ap-btn-flotante,
body .mdock-state-hidden + * .ap-btn-flotante {
    /* siempre visible, no tocar */
}
