/* Shipment tags: the coloured chips, the tag bar at the top of the shipment dialog, and the
   condition builder on the tag screen. A tag's colour is a name from a fixed palette, so each
   name gets a shade that reads well in light and in dark. */

.s-tag-chip {
    --tag-fg: #1f2937;
    --tag-bg: #e5e7eb;
    --tag-border: #d1d5db;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 2px 9px;
    border: 1px solid var(--tag-border);
    border-radius: 999px;
    background: var(--tag-bg);
    color: var(--tag-fg);
    font-size: 12px;
    font-weight: 600;
    line-height: 1.5;
    white-space: nowrap;
}

.s-tag-chip.is-automatic { border-style: dashed; }
.s-tag-chip .fa-bolt { font-size: 10px; opacity: .8; }

.s-tag-swatch {
    display: inline-block;
    width: 12px;
    height: 12px;
    border-radius: 3px;
    vertical-align: -1px;
    background: var(--tag-bg);
    border: 1px solid var(--tag-border);
}

.tag-color-blue   { --tag-fg: #1e40af; --tag-bg: #dbeafe; --tag-border: #93c5fd; }
.tag-color-green  { --tag-fg: #166534; --tag-bg: #dcfce7; --tag-border: #86efac; }
.tag-color-orange { --tag-fg: #9a3412; --tag-bg: #ffedd5; --tag-border: #fdba74; }
.tag-color-red    { --tag-fg: #991b1b; --tag-bg: #fee2e2; --tag-border: #fca5a5; }
.tag-color-purple { --tag-fg: #6b21a8; --tag-bg: #f3e8ff; --tag-border: #d8b4fe; }
.tag-color-teal   { --tag-fg: #115e59; --tag-bg: #ccfbf1; --tag-border: #5eead4; }
.tag-color-pink   { --tag-fg: #9d174d; --tag-bg: #fce7f3; --tag-border: #f9a8d4; }
.tag-color-yellow { --tag-fg: #854d0e; --tag-bg: #fef9c3; --tag-border: #fde047; }
.tag-color-brown  { --tag-fg: #78350f; --tag-bg: #f5e6d3; --tag-border: #d6b48f; }
.tag-color-gray   { --tag-fg: #374151; --tag-bg: #f3f4f6; --tag-border: #d1d5db; }

[data-bs-theme="dark"] .tag-color-blue   { --tag-fg: #bfdbfe; --tag-bg: #1e3a8a66; --tag-border: #3b82f6; }
[data-bs-theme="dark"] .tag-color-green  { --tag-fg: #bbf7d0; --tag-bg: #14532d66; --tag-border: #22c55e; }
[data-bs-theme="dark"] .tag-color-orange { --tag-fg: #fed7aa; --tag-bg: #7c2d1266; --tag-border: #f97316; }
[data-bs-theme="dark"] .tag-color-red    { --tag-fg: #fecaca; --tag-bg: #7f1d1d66; --tag-border: #ef4444; }
[data-bs-theme="dark"] .tag-color-purple { --tag-fg: #e9d5ff; --tag-bg: #581c8766; --tag-border: #a855f7; }
[data-bs-theme="dark"] .tag-color-teal   { --tag-fg: #99f6e4; --tag-bg: #134e4a66; --tag-border: #14b8a6; }
[data-bs-theme="dark"] .tag-color-pink   { --tag-fg: #fbcfe8; --tag-bg: #83184366; --tag-border: #ec4899; }
[data-bs-theme="dark"] .tag-color-yellow { --tag-fg: #fef08a; --tag-bg: #713f1266; --tag-border: #eab308; }
[data-bs-theme="dark"] .tag-color-brown  { --tag-fg: #f5d0a9; --tag-bg: #78350f66; --tag-border: #b45309; }
[data-bs-theme="dark"] .tag-color-gray   { --tag-fg: #e5e7eb; --tag-bg: #37415166; --tag-border: #6b7280; }

/* ---- The colour picker on the tag screen: every colour as the chip it makes ---- */

.s-ShipmentTagColor {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 2px 0;
}

.s-ShipmentTagColor .s-tag-chip {
    font-family: inherit;
    cursor: pointer;
}

.s-ShipmentTagColor .s-tag-chip:hover { filter: brightness(.96); }

.s-ShipmentTagColor .s-tag-chip.is-chosen {
    border-width: 2px;
    border-color: var(--tag-fg);
    padding: 1px 8px;
}

.s-ShipmentTagColor .s-tag-chip .fa-check { font-size: 10px; }

/* ---- The tag bar at the top of the shipment dialog ---- */

.s-ShipmentTagBar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    margin-bottom: 6px;
    border: 1px solid var(--s-border-color, #dee2e6);
    border-radius: 8px;
    background: var(--s-panel-bg, #f8fafc);
}

.s-ShipmentTagBar[hidden] { display: none; }

.s-ShipmentTagBar .tag-bar-label {
    color: var(--s-text-muted-color, #6c757d);
    font-size: 12px;
    font-weight: 600;
    white-space: nowrap;
}

.s-ShipmentTagBar .tag-bar-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.s-ShipmentTagBar .tag-chip-remove {
    padding: 0 0 0 2px;
    border: 0;
    background: none;
    color: inherit;
    font-size: 14px;
    line-height: 1;
    opacity: .6;
    cursor: pointer;
}

.s-ShipmentTagBar .tag-chip-remove:hover { opacity: 1; }

.s-ShipmentTagBar .tag-bar-input {
    position: relative;
    flex: 0 1 220px;
    min-width: 160px;
}

.s-ShipmentTagBar .tag-bar-input input { height: 28px; border-radius: 999px; }

.s-ShipmentTagBar .tag-bar-menu {
    position: absolute;
    z-index: 1060;
    top: calc(100% + 4px);
    left: 0;
    min-width: 100%;
    max-height: 260px;
    overflow-y: auto;
    margin: 0;
    padding: 4px;
    list-style: none;
    border: 1px solid var(--s-border-color, #dee2e6);
    border-radius: 8px;
    background: var(--s-body-bg, #fff);
    box-shadow: 0 8px 24px rgba(0, 0, 0, .12);
}

.s-ShipmentTagBar .tag-bar-menu li {
    padding: 4px 8px;
    border-radius: 6px;
    cursor: pointer;
    white-space: nowrap;
}

.s-ShipmentTagBar .tag-bar-menu li.is-active,
.s-ShipmentTagBar .tag-bar-menu li:hover { background: var(--s-hover-bg, rgba(13, 110, 253, .08)); }

.s-ShipmentTagBar .tag-bar-create { color: var(--s-primary-color, #0d6efd); font-weight: 600; }

/* ---- The condition builder on the tag screen ---- */

.s-ShipmentTagConditions { width: 100%; }

/* Wide screens get a builder that still reads as sentences rather than a spread-out table. */
.s-ShipmentTagConditions .tag-cond { max-width: 1180px; }

.s-ShipmentTagConditions .tag-cond-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 12px;
}

.s-ShipmentTagConditions .tag-cond-intro {
    margin: 0;
    color: var(--s-text-muted-color, #6c757d);
    max-width: 720px;
}

.s-ShipmentTagConditions .tag-cond-count {
    padding: 2px 10px;
    border-radius: 999px;
    background: var(--s-panel-bg, #f1f5f9);
    font-size: 12px;
    font-weight: 600;
    white-space: nowrap;
}

.s-ShipmentTagConditions .tag-cond-count.is-full { color: #b45309; }

.s-ShipmentTagConditions .tag-cond-empty {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 20px;
    border: 1px dashed var(--s-border-color, #cbd5e1);
    border-radius: 10px;
    color: var(--s-text-muted-color, #6c757d);
}

.s-ShipmentTagConditions .tag-cond-group {
    padding: 10px 12px 6px;
    border: 1px solid var(--s-border-color, #dee2e6);
    border-left: 4px solid var(--s-primary-color, #0d6efd);
    border-radius: 10px;
    background: var(--s-body-bg, #fff);
}

.s-ShipmentTagConditions .tag-cond-group-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 6px;
    color: var(--s-text-muted-color, #6c757d);
    font-size: 11px;
    font-weight: 700;
    letter-spacing: .04em;
    text-transform: uppercase;
}

.s-ShipmentTagConditions .tag-cond-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 0;
}

.s-ShipmentTagConditions .tag-cond-row > .tag-cond-field { flex: 1.4 1 200px; min-width: 0; }
.s-ShipmentTagConditions .tag-cond-row > .tag-cond-operator { flex: 1 1 150px; min-width: 0; }
.s-ShipmentTagConditions .tag-cond-row > .tag-cond-value,
.s-ShipmentTagConditions .tag-cond-row > .tag-cond-novalue { flex: 1 1 150px; min-width: 0; }
.s-ShipmentTagConditions .tag-cond-row > .tag-cond-remove { flex: 0 0 28px; }

.s-ShipmentTagConditions .tag-cond-join {
    flex: 0 0 48px;
    color: var(--s-text-muted-color, #6c757d);
    font-size: 11px;
    font-weight: 700;
    text-align: right;
    text-transform: uppercase;
}

.s-ShipmentTagConditions .tag-cond-between {
    color: var(--s-text-muted-color, #6c757d);
    font-size: 12px;
}

.s-ShipmentTagConditions .tag-cond-icon {
    width: 28px;
    height: 28px;
    border: 0;
    border-radius: 6px;
    background: none;
    color: var(--s-text-muted-color, #6c757d);
    cursor: pointer;
}

.s-ShipmentTagConditions .tag-cond-icon:hover { background: rgba(220, 53, 69, .1); color: #dc3545; }

.s-ShipmentTagConditions .tag-cond-add { padding-left: 56px; }

.s-ShipmentTagConditions .tag-cond-or {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 8px 0;
    color: var(--s-text-muted-color, #6c757d);
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
}

.s-ShipmentTagConditions .tag-cond-or::before,
.s-ShipmentTagConditions .tag-cond-or::after {
    content: "";
    flex: 1;
    border-top: 1px dashed var(--s-border-color, #cbd5e1);
}

.s-ShipmentTagConditions .tag-cond-add-group { margin-top: 10px; }

@media (max-width: 767px) {
    .s-ShipmentTagConditions .tag-cond-row { flex-wrap: wrap; }
    .s-ShipmentTagConditions .tag-cond-row > * { flex-basis: 100%; }
    .s-ShipmentTagConditions .tag-cond-row > .tag-cond-remove { flex-basis: 28px; margin-left: auto; }
    .s-ShipmentTagConditions .tag-cond-join { text-align: left; }
    .s-ShipmentTagConditions .tag-cond-add { padding-left: 0; }
}
