/* /modules/inventory/css/ninja_main.css
   Ninja module styles. Every selector is prefixed with `ninja-` because module
   stylesheets are loaded globally on every page. */

.ninja-cut-root {
    --ninja-accent: var(--apple-accent-color, #6c63ff);
    --ninja-cut: #3b82f6;
    --ninja-stock: #16a34a;
    --ninja-splice: #f59e0b;
    --ninja-reusable: rgba(22, 163, 74, 0.18);
    --ninja-waste: rgba(128, 128, 128, 0.22);
    --ninja-surface: rgba(128, 128, 128, 0.06);
    --ninja-border: rgba(128, 128, 128, 0.18);
    padding-bottom: 120px; /* room for the pet */
}

.ninja-cut-hidden { display: none !important; }

/* ---------- Header & cards ---------- */
.ninja-cut-title-icon {
    width: 44px;
    height: 44px;
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3rem;
    color: #fff;
    background: linear-gradient(135deg, var(--ninja-accent), #1f2937);
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.18);
}

.ninja-cut-btn-primary {
    background: var(--ninja-accent);
    color: #fff;
    border: none;
    box-shadow: 0 0 10px var(--button-glow, rgba(108, 99, 255, 0.35));
}
.ninja-cut-btn-primary:hover,
.ninja-cut-btn-primary:focus { color: #fff; filter: brightness(1.08); }

.ninja-cut-card { border-radius: 1rem; overflow: hidden; }

.ninja-cut-card-header {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.85rem 1.25rem;
    border-bottom: 1px solid var(--ninja-border);
    background: var(--ninja-surface);
}

.ninja-cut-card-icon {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    color: var(--ninja-accent);
    background: rgba(128, 128, 128, 0.12);
}
.ninja-cut-icon-success { color: var(--ninja-stock); }

.ninja-cut-label {
    display: block;
    margin-bottom: 0.3rem;
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--bs-secondary-color);
}
.ninja-cut-label i { color: var(--ninja-accent); margin-right: 0.2rem; }

/* ---------- Tabs ---------- */
.ninja-cut-tab {
    display: inline-flex;
    align-items: center;
    padding: 0.3rem 0.75rem;
    font-size: 0.85rem;
    border-radius: 999px !important;
    color: var(--bs-body-color);
    background: var(--ninja-surface);
    border: 1px solid var(--ninja-border);
}
.ninja-cut-tab.active,
.ninja-cut-tab.active:hover {
    color: #fff;
    background: var(--ninja-accent);
    border-color: var(--ninja-accent);
}
.ninja-cut-tab-count {
    font-size: 0.7rem;
    background: rgba(128, 128, 128, 0.2);
    color: inherit;
}


/* ---------- Tables & chips ---------- */
.ninja-cut-table { --bs-table-bg: transparent; }
.ninja-cut-table th {
    white-space: nowrap;
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: var(--bs-secondary-color);
    border-bottom-color: var(--ninja-border);
}
.ninja-cut-table input { min-width: 80px; }

.ninja-cut-empty {
    padding: 0.75rem;
    text-align: center;
    border: 1px dashed var(--ninja-border);
    border-radius: 0.75rem;
}

.ninja-cut-badge-muted { background: rgba(128, 128, 128, 0.15); color: var(--bs-secondary-color); }
.ninja-cut-badge-success { background: rgba(22, 163, 74, 0.15); color: var(--ninja-stock); }

.ninja-cut-chip {
    display: inline-block;
    padding: 0.15rem 0.55rem;
    margin: 0 0.15rem 0.2rem 0;
    font-size: 0.78rem;
    border-radius: 999px;
    background: rgba(59, 130, 246, 0.1);
    border: 1px solid rgba(59, 130, 246, 0.25);
}
.ninja-cut-chip-splice { background: rgba(245, 158, 11, 0.12); border-color: rgba(245, 158, 11, 0.35); }
.ninja-cut-chip-warn { background: rgba(220, 38, 38, 0.1); border-color: rgba(220, 38, 38, 0.3); }
.ninja-cut-chip-stock { background: rgba(22, 163, 74, 0.1); border-color: rgba(22, 163, 74, 0.3); }

.ninja-cut-profile-pill {
    display: inline-flex;
    align-items: center;
    padding: 0.3rem 0.85rem;
    border-radius: 999px;
    font-weight: 700;
    font-size: 0.85rem;
    color: #fff;
    background: var(--ninja-accent);
}

/* ---------- KPIs ---------- */
.ninja-cut-kpi {
    height: 100%;
    padding: 1rem;
    text-align: center;
    border-radius: 1rem;
    background: var(--ninja-surface);
    border: 1px solid var(--ninja-border);
    border-top: 3px solid var(--ninja-accent);
}
.ninja-cut-kpi-good { border-top-color: var(--ninja-stock); }
.ninja-cut-kpi-bad { border-top-color: #dc2626; }
.ninja-cut-kpi-icon {
    width: 36px;
    height: 36px;
    margin: 0 auto 0.4rem;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--ninja-accent);
    background: rgba(128, 128, 128, 0.12);
}
.ninja-cut-kpi-label {
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--bs-secondary-color);
}
.ninja-cut-kpi-value { font-size: 1.6rem; font-weight: 800; line-height: 1.3; }
.ninja-cut-kpi-value small { font-size: 0.9rem; font-weight: 500; color: var(--bs-secondary-color); }
.ninja-cut-kpi-sub {
    margin-top: 0.35rem;
    padding-top: 0.4rem;
    font-size: 0.74rem;
    color: var(--bs-secondary-color);
    border-top: 1px solid var(--ninja-border);
}

/* ---------- Visual bars ---------- */
.ninja-cut-legend { display: flex; flex-wrap: wrap; gap: 0.9rem; font-size: 0.78rem; color: var(--bs-secondary-color); }
.ninja-cut-dot {
    display: inline-block;
    width: 12px;
    height: 12px;
    margin-right: 0.25rem;
    border-radius: 3px;
    vertical-align: -1px;
}

.ninja-cut-bar-row { margin-bottom: 0.9rem; }
.ninja-cut-bar-head {
    display: flex;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 0.25rem;
    margin-bottom: 0.25rem;
    font-size: 0.83rem;
}
.ninja-cut-mult {
    display: inline-block;
    margin-left: 0.3rem;
    padding: 0 0.5rem;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 700;
    color: #fff;
    background: var(--ninja-accent);
}

.ninja-cut-bar {
    display: flex;
    height: 30px;
    overflow: hidden;
    border-radius: 8px;
    background: var(--ninja-waste);
    border: 1px solid var(--ninja-border);
}
.ninja-cut-seg {
    flex-basis: 0;
    min-width: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 4px;
    overflow: hidden;
    white-space: nowrap;
    font-size: 0.72rem;
    font-weight: 600;
    border-right: 2px solid var(--bs-body-bg);
    animation: ninja-cut-seg-in 0.45s ease-out both;
}
.ninja-cut-seg:last-child { border-right: none; }
.ninja-cut-seg-cut { background: var(--ninja-cut); color: #fff; }
.ninja-cut-seg-stock { background: var(--ninja-stock); color: #fff; }
.ninja-cut-seg-splice { background: var(--ninja-splice); color: #1f2937; }
.ninja-cut-seg-reusable {
    color: var(--ninja-stock);
    background: repeating-linear-gradient(45deg, var(--ninja-reusable), var(--ninja-reusable) 6px, transparent 6px, transparent 12px);
}
.ninja-cut-seg-waste { background: var(--ninja-waste); color: var(--bs-secondary-color); }

@keyframes ninja-cut-seg-in {
    from { transform: scaleX(0); transform-origin: left; opacity: 0; }
    to { transform: scaleX(1); transform-origin: left; opacity: 1; }
}

.ninja-cut-splices {
    padding: 0.75rem 1rem;
    border-radius: 0.75rem;
    background: rgba(245, 158, 11, 0.06);
    border: 1px solid rgba(245, 158, 11, 0.25);
}

/* ---------- History ---------- */
@media (min-width: 1200px) {
    .ninja-cut-history-card { position: sticky; top: 1rem; }
    .ninja-cut-history-list { max-height: calc(100vh - 220px); overflow-y: auto; }
}
.ninja-cut-history-item {
    padding: 0.65rem 0.75rem;
    margin-bottom: 0.5rem;
    cursor: pointer;
    border-radius: 0.75rem;
    border: 1px solid var(--ninja-border);
    background: var(--ninja-surface);
    transition: border-color 0.15s ease, transform 0.15s ease;
}
.ninja-cut-history-item:hover { border-color: var(--ninja-accent); transform: translateY(-1px); }
.ninja-cut-history-item.active { border-color: var(--ninja-accent); box-shadow: inset 3px 0 0 var(--ninja-accent); }
.ninja-cut-history-item .ninja-cut-chip { font-size: 0.7rem; padding: 0.05rem 0.45rem; }

/* =====================================================================
   Ninja Pet
   ===================================================================== */
.ninja-pet-stage {
    position: fixed;
    right: 24px;
    bottom: 18px;
    width: 96px;
    height: 110px;
    z-index: 1060;
    pointer-events: none;
}

.ninja-pet {
    position: absolute;
    left: 0;
    bottom: 0;
    width: 96px;
    height: 110px;
    cursor: pointer;
    pointer-events: auto;
    user-select: none;
    transition: transform 1.6s ease-in-out;
    filter: drop-shadow(0 6px 8px rgba(0, 0, 0, 0.25));
}
.ninja-pet svg { width: 100%; height: 100%; overflow: visible; }
.ninja-pet-body { transform-origin: 50px 100px; animation: ninja-pet-breathe 3.2s ease-in-out infinite; }
.ninja-pet-flip .ninja-pet-inner { transform: scaleX(-1); }
.ninja-pet-inner { transform-origin: center; transition: transform 0.2s, opacity 0.25s; width: 100%; height: 100%; }
/* right-click: gone for a moment */
.ninja-pet-away .ninja-pet-inner { opacity: 0; transform: scale(0.3); }

.ninja-pet-eye { transform-box: fill-box; transform-origin: center; animation: ninja-pet-blink 4.5s infinite; }
.ninja-pet-band-tail { transform-box: fill-box; transform-origin: left center; animation: ninja-pet-band 0.9s ease-in-out infinite alternate; }

.ninja-pet-sleep .ninja-pet-eye { animation: none; transform: scaleY(0.12); }
.ninja-pet-sleep .ninja-pet-body { animation-duration: 4.5s; }

.ninja-pet-jump .ninja-pet-body { animation: ninja-pet-jump 0.7s cubic-bezier(.3,1.6,.5,1); }
.ninja-pet-flip-trick .ninja-pet-body { animation: ninja-pet-backflip 0.9s ease-in-out; }
.ninja-pet-shake .ninja-pet-body { animation: ninja-pet-shake 0.5s ease-in-out 2; }
.ninja-pet-slash .ninja-pet-sword { animation: ninja-pet-slash 0.5s ease-in-out 2; }
.ninja-pet-sword { transform-box: fill-box; transform-origin: 10% 90%; }
.ninja-pet-vanish svg { animation: ninja-pet-vanish 1.4s ease-in-out; }

.ninja-pet-bubble {
    position: absolute;
    right: 70px;
    bottom: 100px;
    max-width: 230px;
    width: max-content;
    padding: 0.45rem 0.75rem;
    font-size: 0.8rem;
    line-height: 1.3;
    border-radius: 14px 14px 2px 14px;
    color: var(--bs-body-color);
    background: var(--bs-body-bg);
    border: 1px solid var(--ninja-border, rgba(128,128,128,.25));
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.18);
    opacity: 0;
    transform: translateY(6px) scale(0.95);
    transition: opacity 0.25s ease, transform 0.25s ease;
    pointer-events: none;
}
.ninja-pet-bubble.ninja-pet-show { opacity: 1; transform: none; }

.ninja-pet-shuriken {
    position: fixed;
    z-index: 1061;
    width: 26px;
    height: 26px;
    pointer-events: none;
    color: #64748b;
    animation: ninja-pet-spin 0.35s linear infinite;
}
.ninja-pet-zzz {
    position: absolute;
    right: 8px;
    top: -6px;
    font-weight: 800;
    color: var(--bs-secondary-color);
    animation: ninja-pet-zzz 2.4s ease-in-out infinite;
    pointer-events: none;
}
.ninja-pet-smoke {
    position: absolute;
    left: 50%;
    bottom: 10px;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: rgba(148, 163, 184, 0.7);
    pointer-events: none;
    animation: ninja-pet-smoke 0.9s ease-out forwards;
}
.ninja-pet-confetti {
    position: fixed;
    z-index: 1061;
    width: 8px;
    height: 12px;
    border-radius: 2px;
    pointer-events: none;
}

/* constant idle stance: breathing + gentle sway so the pet is never frozen */
@keyframes ninja-pet-breathe {
    0%, 100% { transform: translateY(0) rotate(0) scaleY(1); }
    25% { transform: translateY(-3px) rotate(-3deg) scaleY(1.03); }
    50% { transform: translateY(0) rotate(0) scaleY(1); }
    75% { transform: translateY(-3px) rotate(3deg) scaleY(1.03); }
}
@keyframes ninja-pet-blink { 0%, 92%, 100% { transform: scaleY(1); } 95% { transform: scaleY(0.1); } }
@keyframes ninja-pet-band { from { transform: rotate(-8deg); } to { transform: rotate(10deg); } }
@keyframes ninja-pet-jump { 0% { transform: translateY(0); } 40% { transform: translateY(-46px); } 100% { transform: translateY(0); } }
@keyframes ninja-pet-backflip {
    0% { transform: translateY(0) rotate(0); }
    45% { transform: translateY(-55px) rotate(-200deg); }
    100% { transform: translateY(0) rotate(-360deg); }
}
@keyframes ninja-pet-shake { 0%, 100% { transform: rotate(0); } 25% { transform: rotate(-9deg); } 75% { transform: rotate(9deg); } }
@keyframes ninja-pet-slash { 0%, 100% { transform: rotate(0); } 50% { transform: rotate(-110deg); } }
@keyframes ninja-pet-vanish { 0%, 100% { opacity: 1; transform: scale(1); } 30%, 70% { opacity: 0; transform: scale(0.2); } }
@keyframes ninja-pet-spin { to { transform: rotate(360deg); } }
@keyframes ninja-pet-zzz { 0% { opacity: 0; transform: translate(0, 0) scale(0.7); } 50% { opacity: 1; } 100% { opacity: 0; transform: translate(12px, -22px) scale(1.2); } }
@keyframes ninja-pet-smoke { to { opacity: 0; transform: translate(var(--ninja-dx, 0), -30px) scale(3); } }

/* ---------- Idle scenes ---------- */
.ninja-pet-leg-l, .ninja-pet-leg-r, .ninja-pet-arm-l, .ninja-pet-arm-r {
    transform-box: fill-box;
    transform-origin: top center;
}
.ninja-pet-eyes { transition: transform 0.2s ease; }
.ninja-pet-head { transform-box: fill-box; transform-origin: bottom center; transition: transform 0.25s ease; }

/* walking: alternating legs + body bob */
.ninja-pet-walking .ninja-pet-leg-l { animation: ninja-pet-step 0.28s ease-in-out infinite alternate; }
.ninja-pet-walking .ninja-pet-leg-r { animation: ninja-pet-step 0.28s ease-in-out infinite alternate-reverse; }
.ninja-pet-walking .ninja-pet-arm-l { animation: ninja-pet-swing 0.28s ease-in-out infinite alternate; }
.ninja-pet-walking .ninja-pet-arm-r { animation: ninja-pet-swing 0.28s ease-in-out infinite alternate-reverse; }
.ninja-pet-walking .ninja-pet-body { animation: ninja-pet-bob 0.28s ease-in-out infinite alternate; }

/* sneaking: crouched, slow tiptoe */
.ninja-pet-sneaking .ninja-pet-body { animation: ninja-pet-sneak 0.55s ease-in-out infinite alternate; }
.ninja-pet-sneaking .ninja-pet-leg-l { animation: ninja-pet-step 0.55s ease-in-out infinite alternate; }
.ninja-pet-sneaking .ninja-pet-leg-r { animation: ninja-pet-step 0.55s ease-in-out infinite alternate-reverse; }

/* peeking from the screen edge */
.ninja-pet-peek svg { transform: rotate(-22deg); transform-origin: 50% 100%; transition: transform 0.3s ease; }
.ninja-pet-peek .ninja-pet-head { transform: rotate(-10deg); }

/* looking around */
.ninja-pet-glance-l .ninja-pet-eyes { transform: translateX(-3px); }
.ninja-pet-glance-r .ninja-pet-eyes { transform: translateX(3px); }

.ninja-pet-hop .ninja-pet-body { animation: ninja-pet-hop 0.5s ease-out; }
.ninja-pet-stretch .ninja-pet-body { animation: ninja-pet-stretch 1.4s ease-in-out; }
.ninja-pet-stretch .ninja-pet-arm-l { animation: ninja-pet-arm-up-l 1.4s ease-in-out; }
.ninja-pet-stretch .ninja-pet-arm-r { animation: ninja-pet-arm-up-r 1.4s ease-in-out; }
.ninja-pet-windy .ninja-pet-band-tail { animation-duration: 0.18s; }

.ninja-pet-meditate .ninja-pet-body { animation: ninja-pet-float 1.4s ease-in-out infinite alternate; }
.ninja-pet-meditate .ninja-pet-eye { animation: none; transform: scaleY(0.15); }
.ninja-pet-meditate .ninja-pet-shadow { animation: ninja-pet-shadow-shrink 1.4s ease-in-out infinite alternate; }

.ninja-pet-wave .ninja-pet-arm-r { animation: ninja-pet-wave 0.3s ease-in-out infinite alternate; }
.ninja-pet-dance .ninja-pet-body { animation: ninja-pet-dance 0.32s ease-in-out infinite alternate; }
.ninja-pet-dance .ninja-pet-arm-l { animation: ninja-pet-arm-up-l 0.64s ease-in-out infinite; }
.ninja-pet-dance .ninja-pet-arm-r { animation: ninja-pet-arm-up-r 0.64s ease-in-out infinite 0.32s; }
.ninja-pet-drop svg { animation: ninja-pet-drop 1.7s ease-in; }

.ninja-pet-shadow { transform-box: fill-box; transform-origin: center; }

.ninja-pet-orbit {
    position: absolute;
    left: 38px;
    top: -18px;
    width: 18px;
    height: 18px;
    color: #64748b;
    pointer-events: none;
    animation: ninja-pet-orbit 0.9s linear infinite;
}
.ninja-pet-orbit svg { width: 100%; height: 100%; animation: ninja-pet-spin 0.3s linear infinite; }

@keyframes ninja-pet-step { from { transform: translateY(0); } to { transform: translateY(-5px); } }
@keyframes ninja-pet-swing { from { transform: rotate(-18deg); } to { transform: rotate(18deg); } }
@keyframes ninja-pet-bob { from { transform: translateY(0); } to { transform: translateY(-3px); } }
@keyframes ninja-pet-sneak { from { transform: translateY(6px) rotate(-5deg) scaleY(0.94); } to { transform: translateY(4px) rotate(3deg) scaleY(0.94); } }
@keyframes ninja-pet-hop { 0%, 100% { transform: translateY(0) scale(1); } 20% { transform: translateY(2px) scale(1.06, 0.92); } 55% { transform: translateY(-16px) scale(0.96, 1.05); } }
@keyframes ninja-pet-stretch { 0%, 100% { transform: scale(1); } 45%, 65% { transform: scale(0.92, 1.12); } }
@keyframes ninja-pet-arm-up-l { 0%, 100% { transform: rotate(0); } 50% { transform: rotate(150deg); } }
@keyframes ninja-pet-arm-up-r { 0%, 100% { transform: rotate(0); } 50% { transform: rotate(-150deg); } }
@keyframes ninja-pet-float { from { transform: translateY(-4px); } to { transform: translateY(-16px); } }
@keyframes ninja-pet-shadow-shrink { from { transform: scale(0.9); opacity: 0.9; } to { transform: scale(0.6); opacity: 0.5; } }
@keyframes ninja-pet-wave { from { transform: rotate(-125deg); } to { transform: rotate(-165deg); } }
@keyframes ninja-pet-dance { from { transform: rotate(-10deg) translateY(0); } to { transform: rotate(10deg) translateY(-6px); } }
@keyframes ninja-pet-drop {
    0% { transform: translateY(0); opacity: 1; }
    20% { transform: translateY(-500px); opacity: 0; }
    55% { transform: translateY(-500px); opacity: 0; }
    56% { opacity: 1; }
    80% { transform: translateY(0) scale(1); }
    88% { transform: translateY(0) scale(1.12, 0.86); }
    100% { transform: translateY(0) scale(1); }
}
@keyframes ninja-pet-orbit {
    from { transform: rotate(0deg) translateX(26px) rotate(0deg); }
    to { transform: rotate(360deg) translateX(26px) rotate(-360deg); }
}

@media (max-width: 576px) {
    .ninja-pet-stage { transform: scale(0.75); transform-origin: bottom right; right: 8px; bottom: 8px; }
}

@media (prefers-reduced-motion: reduce) {
    .ninja-pet-body, .ninja-pet-eye, .ninja-pet-band-tail, .ninja-cut-seg,
    .ninja-pet-leg-l, .ninja-pet-leg-r, .ninja-pet-arm-l, .ninja-pet-arm-r, .ninja-pet-shadow { animation: none !important; }
    .ninja-pet { transition: none; }
}

@media print {
    .ninja-pet-stage { display: none !important; }
}

/* =====================================================================
   Fullscreen tool modal (Quick Tools). The core modals.css forces a top margin,
   rounded corners and overflow:visible on every modal, so override it here.
   ===================================================================== */
#ninjaCutModal .modal-dialog {
    margin: 0 !important;
    width: 100vw;
    max-width: none;
    height: 100vh;
    height: 100dvh;
}
#ninjaCutModal .modal-content {
    height: 100%;
    border: 0 !important;
    border-radius: 0 !important;
    box-shadow: none !important;
    overflow: hidden !important;
    background: var(--bs-body-bg) !important;
    background-color: var(--bs-body-bg) !important;
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
}
#ninjaCutModal .modal-header { flex: 0 0 auto; }
#ninjaCutModal .modal-body {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
}
