/* ─────────────────────────────────────────────────────────────────────────
   KS Spinning Mills — shared UI components.
   Mounted after shared.css and mobile.css from base.html so it can override
   either when needed. Every rule below is media-query-aware: nothing is
   desktop-only.
   ───────────────────────────────────────────────────────────────────────── */


/* ── STATUS PILLS ──────────────────────────────────────────────────────── */

.pill {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.18rem 0.55rem;
    border-radius: 999px;
    font-family: var(--font-mono);
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.6px;
    text-transform: uppercase;
    line-height: 1.4;
    white-space: nowrap;
    border: 1px solid transparent;
}
.pill-done    { background: rgba(32,114,37,0.12);   color: #207225; border-color: rgba(32,114,37,0.25); }
.pill-pending { background: rgba(210,153,34,0.15);  color: #8a6914; border-color: rgba(210,153,34,0.30); }
.pill-warn    { background: rgba(229,83,75,0.12);   color: #b03a30; border-color: rgba(229,83,75,0.30); }
.pill-info    { background: rgba(34,45,53,0.07);    color: #2e3b45; border-color: rgba(34,45,53,0.15); }
.pill-active  { background: var(--ks-lime);         color: #fff;     border-color: #5fa033; }

/* For pills that contain just an icon (✓, !, ✗) */
.pill-icon { padding: 0.18rem 0.45rem; min-width: 24px; justify-content: center; }


/* ── ACTION-BUTTON TIERS ───────────────────────────────────────────────── */
/* These layer on top of Bootstrap's .btn so existing markup stays valid. */

.btn-primary-action,
.btn-secondary-action,
.btn-destructive {
    border: 2px solid transparent;
    border-radius: 8px;
    font-family: var(--font-mono);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 0.7rem 1.1rem;
    min-height: 48px;
    transition: transform 0.08s, box-shadow 0.15s, background 0.15s, color 0.15s;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
}

.btn-primary-action {
    background: var(--ks-lime);
    color: #16221c;
    border-color: #5fa033;
    box-shadow: 0 2px 8px rgba(129,215,66,0.35);
}
.btn-primary-action:hover:not(:disabled) {
    background: #72c436;
    box-shadow: 0 4px 14px rgba(129,215,66,0.45);
    color: #16221c;
}
.btn-primary-action:active:not(:disabled) { transform: scale(0.98); }

.btn-secondary-action {
    background: transparent;
    color: var(--ks-lime-dark);
    border-color: var(--ks-lime);
}
.btn-secondary-action:hover:not(:disabled) {
    background: rgba(129,215,66,0.10);
    color: var(--ks-lime-dark);
}

.btn-destructive {
    background: transparent;
    color: var(--ks-danger);
    border-color: var(--ks-danger);
}
.btn-destructive:hover:not(:disabled) {
    background: var(--ks-danger);
    color: #fff;
}

.btn-primary-action:disabled,
.btn-secondary-action:disabled,
.btn-destructive:disabled {
    opacity: 0.45;
    cursor: not-allowed;
    box-shadow: none;
    transform: none;
}

/* Block-level (full width) variant — useful as the sticky bottom action on phones */
.btn-block {
    display: flex;
    width: 100%;
}

/* Tiny inline-action variant for table rows / list rows */
.btn-inline {
    min-height: 32px;
    padding: 0.25rem 0.6rem;
    font-size: 0.75rem;
    border-radius: 6px;
}


/* ── INLINE ICONS ──────────────────────────────────────────────────────── */
/* Used inside button labels and nav items to balance emoji rendering. */

.icon {
    display: inline-block;
    font-size: 1.05em;
    line-height: 1;
    vertical-align: -1px;
    margin-right: 0.1em;
}
.icon-only {
    /* Larger when standing alone (e.g. on small screens where the text wraps below) */
    font-size: 1.3em;
    vertical-align: middle;
}


/* ── EMPTY STATES + HINTS ──────────────────────────────────────────────── */

.hint-empty {
    font-size: 0.85rem;
    font-style: italic;
    color: var(--ks-text-light);
    padding: 0.6rem 0.8rem;
    border-radius: 6px;
    background: rgba(34,45,53,0.04);
    border-left: 3px solid var(--ks-text-light);
    margin: 0.4rem 0;
}
.list-footer {
    font-size: 0.72rem;
    color: var(--ks-text-light);
    text-align: right;
    padding: 0.4rem 0.2rem 0;
    font-family: var(--font-mono);
    letter-spacing: 0.4px;
}


/* ── STATE-DRIVEN LIST CARDS (QC bill lines, lot picker, dispatch DN) ─── */

.state-card {
    border: 2px solid #d0d5da;
    border-radius: 10px;
    background: #fff;
    padding: 0.7rem 0.85rem;
    margin-bottom: 0.55rem;
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s, box-shadow 0.15s, transform 0.05s;
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}
.state-card:hover { box-shadow: 0 4px 12px rgba(0,0,0,0.07); border-color: #b8bfc6; }
.state-card:active { transform: scale(0.99); }

.state-card[data-state="idle"]    { /* default white card; no override needed */ }

.state-card[data-state="active"] {
    border-color: var(--ks-lime);
    background: linear-gradient(180deg, rgba(129,215,66,0.10) 0%, rgba(129,215,66,0.04) 100%);
    box-shadow: 0 4px 14px rgba(129,215,66,0.20);
}
.state-card[data-state="active"] .state-card-title { font-weight: 700; color: var(--ks-navy); }

.state-card[data-state="done"] {
    border-color: rgba(32,114,37,0.25);
    background: rgba(129,215,66,0.05);
    cursor: default;
    pointer-events: none;
}
.state-card[data-state="done"] .state-card-title { color: #6c7a83; text-decoration: line-through; }

.state-card-title {
    font-size: 0.95rem;
    color: var(--ks-navy);
    font-weight: 600;
}
.state-card-meta {
    font-family: var(--font-mono);
    font-size: 0.74rem;
    color: var(--ks-text-light);
}


/* ── PIPELINE STEP INDICATOR ───────────────────────────────────────────── */

ol.pipeline {
    list-style: none;
    padding: 0;
    margin: 0 0 1rem;
    display: flex;
    counter-reset: pipe-step;
    gap: 0;
    background: #fff;
    border: 1px solid var(--ks-border);
    border-radius: 10px;
    overflow: hidden;
    box-shadow: var(--shadow-sm);
}
ol.pipeline > li {
    counter-increment: pipe-step;
    flex: 1;
    padding: 0.7rem 0.5rem;
    text-align: center;
    font-family: var(--font-mono);
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--ks-text-light);
    background: #fff;
    border-right: 1px solid var(--ks-border);
    position: relative;
    line-height: 1.2;
}
ol.pipeline > li:last-child { border-right: 0; }
ol.pipeline > li::before {
    content: counter(pipe-step);
    display: inline-block;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: var(--ks-border);
    color: var(--ks-text-light);
    font-family: var(--font-mono);
    font-weight: 700;
    line-height: 22px;
    margin-right: 0.4rem;
    font-size: 0.78rem;
}

/* Steps up to and including the current one */
ol.pipeline[data-step="1"] > li:nth-child(-n+1),
ol.pipeline[data-step="2"] > li:nth-child(-n+2),
ol.pipeline[data-step="3"] > li:nth-child(-n+3),
ol.pipeline[data-step="4"] > li:nth-child(-n+4) {
    color: var(--ks-navy);
    background: rgba(129,215,66,0.08);
}
ol.pipeline[data-step="1"] > li:nth-child(-n+1)::before,
ol.pipeline[data-step="2"] > li:nth-child(-n+2)::before,
ol.pipeline[data-step="3"] > li:nth-child(-n+3)::before,
ol.pipeline[data-step="4"] > li:nth-child(-n+4)::before {
    background: var(--ks-lime);
    color: #16221c;
}

/* Highlight the current step extra */
ol.pipeline[data-step="1"] > li:nth-child(1),
ol.pipeline[data-step="2"] > li:nth-child(2),
ol.pipeline[data-step="3"] > li:nth-child(3),
ol.pipeline[data-step="4"] > li:nth-child(4) {
    background: rgba(129,215,66,0.18);
    color: var(--ks-lime-dark);
}


/* ── MOBILE TWEAKS ─────────────────────────────────────────────────────── */

@media (max-width: 768px) {
    .btn-primary-action,
    .btn-secondary-action,
    .btn-destructive {
        font-size: 0.95rem;
        padding: 0.7rem 0.9rem;
    }
    .pill { font-size: 0.66rem; padding: 0.16rem 0.45rem; }

    /* Pipeline collapses to a tighter row with smaller text */
    ol.pipeline > li { padding: 0.55rem 0.3rem; font-size: 0.65rem; letter-spacing: 0.3px; }
    ol.pipeline > li::before { width: 18px; height: 18px; line-height: 18px; font-size: 0.7rem; margin-right: 0.25rem; }

    .state-card { padding: 0.6rem 0.7rem; }
    .state-card-title { font-size: 0.9rem; }
}

@media (max-width: 420px) {
    /* Tiny screens: pipeline labels go super-compact (number-only beneath) */
    ol.pipeline > li { font-size: 0.6rem; }
    ol.pipeline > li::before { display: block; margin: 0 auto 0.25rem; }

    .btn-primary-action,
    .btn-secondary-action,
    .btn-destructive { font-size: 0.9rem; padding: 0.65rem 0.7rem; }
}


/* ── DESKTOP (≥769 px) ─────────────────────────────────────────────────── */

@media (min-width: 769px) {
    /* Slightly larger pipeline on desktop */
    ol.pipeline > li { font-size: 0.78rem; padding: 0.85rem 0.5rem; }
    ol.pipeline > li::before { width: 26px; height: 26px; line-height: 26px; font-size: 0.85rem; }
}


/* ── BILINGUAL SUB-LABEL (next to h5 headings) ─────────────────────────── */
.heading-sub { font-weight: 400; color: var(--ks-text-light); }
