/* ═══════════════════════════════════════════════════════════════
   Horse Colour Addon — Sales App
   Remove: this file + horse-colour-addon.js + svg/horse-coloring-template.svg + horse-outline.png
           + overlay HTML in index.html + script/link tags
           + ws-horse-colour-btn logic in workshop-tab-functions.js
═══════════════════════════════════════════════════════════════ */

/* ── Large centred modal (backdrop + dialog) ─────────────── */
#horse-colour-overlay {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 10900;
    background: rgba(0, 0, 0, 0.45);
    align-items: center;
    justify-content: center;
    padding: 24px;
    box-sizing: border-box;
}
#horse-colour-overlay.open {
    display: flex;
}
.hc-overlay-dialog {
    width: min(1400px, 96vw);
    height: min(900px, 92vh);
    max-height: 92vh;
    background: #f0f2f5;
    border: 2px solid #111;
    border-radius: 10px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.35);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    flex-shrink: 0;
}

/* ── Overlay header bar ──────────────────────────────────── */
.hc-overlay-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 14px;
    background: #fff;
    border-bottom: 2px solid #111;
    flex-shrink: 0;
    min-height: 52px;
}
.hc-overlay-title {
    font-size: 15px;
    font-weight: 800;
    letter-spacing: .04em;
    text-transform: uppercase;
    color: #111;
    flex-shrink: 0;
}
.hc-overlay-order-info {
    display: flex;
    flex-direction: column;
    gap: 1px;
    flex: 1;
    min-width: 0;
    overflow: hidden;
}
#hc-header-order-label {
    font-size: 13px;
    font-weight: 700;
    color: #1a56db;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
#hc-header-customer-label {
    font-size: 11px;
    color: #555;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.hc-overlay-actions {
    display: flex;
    gap: 8px;
    flex-shrink: 0;
    align-items: center;
}
.hc-save-order-btn {
    padding: 7px 16px;
    background: #15803d;
    color: #fff;
    border: none;
    border-radius: 5px;
    font-family: inherit;
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    transition: background .15s;
}
.hc-save-order-btn:hover { background: #166534; }
.hc-save-order-btn:disabled { opacity: .6; cursor: not-allowed; }
.hc-close-overlay-btn {
    padding: 6px 12px;
    background: #fff;
    border: 1.5px solid #999;
    border-radius: 5px;
    font-family: inherit;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    color: #333;
    transition: background .15s;
}
.hc-close-overlay-btn:hover { background: #f0f0f0; }
.hc-btn-spinner {
    display: inline-block;
    width: 12px; height: 12px;
    border: 2px solid rgba(255,255,255,.4);
    border-top-color: #fff;
    border-radius: 50%;
    animation: hc-spin .7s linear infinite;
    vertical-align: middle;
}
@keyframes hc-spin { to { transform: rotate(360deg); } }

/* ── Main body (sidebar + horse panel) ───────────────────── */
.hc-overlay-body {
    display: flex;
    flex: 1;
    gap: 10px;
    padding: 10px;
    min-height: 0;
    overflow: hidden;
}

/* ── Selections sidebar ──────────────────────────────────── */
.hc-selections-panel {
    background: #fff;
    border: 2px solid #111;
    border-radius: 8px;
    padding: 10px 8px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    width: 200px;
    flex-shrink: 0;
    overflow: hidden;
}
.hc-selections-panel h2 {
    color: #111;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .06em;
    margin: 0 0 2px;
}
.hc-preset-btn, .hc-print-btn, .hc-save-btn {
    width: 100%;
    padding: 6px 8px;
    background: #f5f5f5;
    border: 1.5px solid #666;
    border-radius: 4px;
    font-family: inherit;
    font-size: 11px;
    font-weight: 700;
    color: #111;
    cursor: pointer;
    text-align: left;
    display: flex;
    align-items: center;
    gap: 4px;
    transition: background .15s, border-color .15s;
}
.hc-preset-btn:hover, .hc-print-btn:hover, .hc-save-btn:hover {
    background: #ebebeb;
    border-color: #111;
}
.hc-current-preset-name {
    font-size: 10px;
    color: #666;
    font-style: italic;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    margin: 0;
}
.hc-part-list {
    display: flex;
    flex-direction: column;
    gap: 2px;
    overflow-y: auto;
    /* No flex:1 — let it size to content so buttons follow immediately */
}
.hc-sidebar-divider {
    border: none;
    border-top: 1.5px solid #ddd;
    margin: 4px 0;
    flex-shrink: 0;
}
.hc-part-row {
    display: flex;
    align-items: flex-start;
    gap: 6px;
    padding: 4px;
    border-radius: 4px;
    cursor: pointer;
    transition: background .12s;
}
.hc-part-row:hover { background: #f0f0f0; }
.hc-part-swatches { display: flex; gap: 2px; flex-shrink: 0; padding-top: 1px; }
.hc-part-swatch {
    width: 16px;
    height: 16px;
    border-radius: 3px;
    border: 1.5px solid #999;
}
.hc-part-row:hover .hc-part-swatch { border-color: #111; }
.hc-part-text { flex: 1; min-width: 0; line-height: 1.25; }
.hc-part-label { font-size: 11px; font-weight: 600; display: block; color: #111; }
.hc-part-horse { font-size: 9px; color: #333; display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hc-part-paint { font-size: 9px; color: #666; display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hc-part-num {
    font-size: 10px;
    font-weight: 700;
    color: #666;
    background: #f0f0f0;
    border-radius: 3px;
    padding: 1px 4px;
    flex-shrink: 0;
    margin-top: 1px;
}

/* ── Horse panel (right) ─────────────────────────────────── */
.hc-horse-panel {
    background: #fff;
    border: 2px solid #111;
    border-radius: 8px;
    padding: 10px;
    display: flex;
    flex-direction: column;
    flex: 1;
    min-width: 0;
    position: relative;
    overflow: hidden;
}
.hc-horse-panel-chrome {
    position: absolute;
    top: 10px;
    left: 10px;
    right: 10px;
    z-index: 2;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
    pointer-events: none;
}
.hc-horse-panel-label {
    background: #fff;
    border: 1.5px solid #111;
    border-radius: 4px;
    padding: 4px 8px;
    font-size: 10px;
    font-weight: 700;
    color: #111;
    letter-spacing: .05em;
    text-transform: uppercase;
}
.hc-horse-panel-job {
    align-self: center;
    background: #fff;
    border: 2.5px solid #1a56db;
    border-radius: 8px;
    padding: 9px 24px 8px;
    font-size: 28px;
    font-weight: 800;
    color: #1a56db;
    letter-spacing: .02em;
    line-height: 1.15;
    text-align: center;
    max-width: min(420px, calc(100% - 24px));
    pointer-events: none;
}
.hc-horse-stage {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    min-height: 0;
    padding: 60px 16px 16px;   /* top gap keeps chrome label clear */
    position: relative;
    overflow: hidden;
}
.hc-horse-live {
    position: relative;
    flex: 1;
    width: 100%;
    min-height: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}
#hc-preview-slot {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}
#hc-preview-slot svg,
#hc-horse-preview {
    max-width: 100%;
    max-height: 100%;
    width: auto;
    height: auto;
    display: block;
    object-fit: contain;
    margin: auto;
}

/* ── Board button: horse colour dropdown wrapper ─────────── */
.hc-horse-dropdown {
    position: relative;
    display: inline-flex;
    align-items: center;
}
/* Same footprint as .btn-burger (32×32) when Horse Colour is omitted */
.ws-board-actions .ws-horse-colour-spacer {
    display: inline-block;
    width: 32px;
    height: 32px;
    flex-shrink: 0;
    visibility: hidden;
    pointer-events: none;
}
.hc-horse-dropdown .row-actions-menu {
    min-width: 160px;
}
/* Delete Colour Config — red danger item */
.hc-menu-delete {
    color: #c0392b;
    border-top: 1px solid #f0d0cd;
    margin-top: 2px;
}
.hc-menu-delete:hover {
    background: #fff0ee;
    color: #96281b;
}

/* ── Board button visual states ──────────────────────────── */
.ws-board-actions .ws-horse-colour-btn {
    cursor: pointer;
    border-radius: 5px;
    border: 1.5px solid transparent;
    transition: border-color .15s, background .15s;
}

/* Saved — green shading: clear green border + green background */
.ws-board-actions .ws-horse-colour-btn.ws-horse-colour-done {
    border-color: #16a34a;
    background: #dcfce7;
}
.ws-board-actions .ws-horse-colour-btn.ws-horse-colour-done:hover {
    border-color: #15803d;
    background: #bbf7d0;
}
.ws-board-actions .ws-horse-colour-btn.ws-horse-colour-done .workshop-burger-icon {
    filter: none;
}

/* Not saved — warm sand shading: visible but clearly different from done */
.ws-board-actions .ws-horse-colour-btn.ws-horse-colour-pending {
    border-color: #d1c4a8;
    background: #faf7f0;
    opacity: 0.80;
}
.ws-board-actions .ws-horse-colour-btn.ws-horse-colour-pending:hover {
    border-color: #b5a48a;
    background: #f3ede0;
    opacity: 1;
}

/* ── Burger menu: Horse Colour label hint ────────────────── */
/* The default is-tick (green) and is-fail (red) marks are already correct;
   no colour overrides needed. Add a subtle label tint when saved. */
.row-actions-item-horse-colour .row-actions-item-label {
    font-weight: 600;
}

/* ── Guide modal (intro) ─────────────────────────────────── */
#hc-guide-modal-backdrop {
    position: fixed;
    inset: 0;
    z-index: 11100;
    background: rgba(0,0,0,.45);
    display: none;
    align-items: center;
    justify-content: center;
}
#hc-guide-modal-backdrop.open { display: flex; }
#hc-guide-modal-backdrop .hc-modal {
    background: #fff;
    border-radius: 8px;
    width: min(400px, 95vw);
    box-shadow: 0 8px 32px rgba(0,0,0,.25);
    overflow: hidden;
}

/* ── Picker, preset, save, save-order modals ─────────────── */
#hc-picker-modal-backdrop,
#hc-preset-modal-backdrop,
#hc-save-modal-backdrop,
#hc-save-order-modal-backdrop {
    position: fixed;
    inset: 0;
    z-index: 11200;
    background: rgba(0,0,0,.45);
    display: none;
    align-items: flex-start;
    justify-content: center;
    overflow-y: auto;
    padding: 40px 12px;
}
#hc-picker-modal-backdrop.open,
#hc-preset-modal-backdrop.open,
#hc-save-modal-backdrop.open,
#hc-save-order-modal-backdrop.open { display: flex; }

.hc-modal {
    background: #fff;
    border-radius: 8px;
    width: min(560px, 100%);
    box-shadow: 0 8px 32px rgba(0,0,0,.25);
    overflow: hidden;
    flex-shrink: 0;
}
.hc-modal-wide {
    width: min(680px, 100%);
}
.hc-modal-narrow {
    width: min(380px, 100%);
}
.hc-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    border-bottom: 1.5px solid #e5e7eb;
}
.hc-modal-header h3 {
    margin: 0;
    font-size: 14px;
    font-weight: 700;
    color: #111;
}
.hc-modal-header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}
.hc-modal-close {
    background: none;
    border: none;
    font-size: 16px;
    cursor: pointer;
    color: #555;
    padding: 2px 6px;
    border-radius: 4px;
    line-height: 1;
}
.hc-modal-close:hover { background: #f3f4f6; color: #111; }
.hc-modal-body {
    padding: 14px 16px;
    max-height: 70vh;
    overflow-y: auto;
}
.hc-modal-apply-btn {
    margin-top: 14px;
    width: 100%;
    padding: 9px;
    background: #1a56db;
    color: #fff;
    border: none;
    border-radius: 5px;
    font-family: inherit;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
}
.hc-modal-apply-btn:hover { background: #1e40af; }
.hc-modal-apply-btn-sm {
    padding: 5px 12px;
    background: #1a56db;
    color: #fff;
    border: none;
    border-radius: 4px;
    font-family: inherit;
    font-size: 11px;
    font-weight: 700;
    cursor: pointer;
}
.hc-modal-cancel-btn {
    padding: 8px 14px;
    background: #fff;
    border: 1.5px solid #999;
    border-radius: 5px;
    font-family: inherit;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    color: #333;
}
.hc-modal-cancel-btn:hover { background: #f3f4f6; }
.hc-modal-actions {
    display: flex;
    gap: 8px;
    margin-top: 14px;
    justify-content: flex-end;
}
.hc-confirm-msg {
    font-size: 13px;
    font-weight: 600;
    color: #111;
    margin: 0 0 6px;
}
.hc-confirm-hint {
    font-size: 12px;
    color: #555;
    margin: 0 0 2px;
    line-height: 1.4;
}

/* ── Colour picker internals ─────────────────────────────── */
.hc-picker-part-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
}
.hc-picker-part-swatch-large {
    width: 36px;
    height: 36px;
    border-radius: 6px;
    border: 2px solid #333;
    flex-shrink: 0;
}
.hc-picker-preview-text {
    font-size: 12px;
    color: #111;
    line-height: 1.35;
}
.hc-custom-colour-form { margin-bottom: 10px; }
.hc-custom-colour-fields {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    align-items: center;
    margin-top: 4px;
}
.hc-custom-colour-fields input {
    flex: 1;
    min-width: 110px;
    padding: 6px 8px;
    border: 1px solid #d1d5db;
    border-radius: 4px;
    font-size: 12px;
    font-family: inherit;
}

.hc-match-tile {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 6px 8px;
    background: #f9fafb;
    border: 1.5px solid #e5e7eb;
    border-radius: 5px;
    cursor: pointer;
    font-family: inherit;
    text-align: left;
    margin-bottom: 3px;
    transition: border-color .12s, background .12s;
}
.hc-match-tile:hover { background: #eff6ff; border-color: #93c5fd; }
.hc-match-tile.selected { background: #dbeafe; border-color: #1a56db; }
.hc-match-tile-swatches { display: flex; gap: 3px; flex-shrink: 0; }
.hc-match-tile-swatch { width: 20px; height: 20px; border-radius: 3px; border: 1px solid #999; }
.hc-match-tile-body { flex: 1; min-width: 0; }
.hc-match-tile-horse { font-size: 12px; font-weight: 700; color: #111; display: block; }
.hc-match-tile-paint { font-size: 11px; color: #1a56db; font-weight: 600; display: block; }
.hc-match-tile-meta  { font-size: 10px; color: #888; display: block; }

/* ── Preset modal internals ──────────────────────────────── */
.hc-preset-cat-label {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: #888;
    margin: 10px 0 4px;
}
.hc-preset-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 6px;
}
.hc-preset-tile-wrap { position: relative; }
.hc-preset-tile {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 6px 8px;
    background: #f9fafb;
    border: 1.5px solid #e5e7eb;
    border-radius: 5px;
    cursor: pointer;
    font-family: inherit;
    text-align: left;
    width: 110px;
    transition: border-color .12s, background .12s;
}
.hc-preset-tile:hover { background: #eff6ff; border-color: #93c5fd; }
.hc-preset-tile.selected { background: #dbeafe; border-color: #1a56db; }
.hc-preset-swatch-row {
    display: flex;
    gap: 1px;
    height: 12px;
    border-radius: 3px;
    overflow: hidden;
    border: 1px solid #ccc;
}
.hc-preset-swatch-seg { flex: 1; }
.hc-preset-tile-name { font-size: 10px; font-weight: 700; color: #111; }
.hc-preset-tile-paint { font-size: 9px; color: #666; }
.hc-preset-tile-delete {
    position: absolute;
    top: 2px;
    right: 2px;
    background: rgba(255,255,255,.85);
    border: 1px solid #ccc;
    border-radius: 3px;
    font-size: 12px;
    line-height: 1;
    padding: 1px 4px;
    cursor: pointer;
    color: #cc0000;
    display: none;
}
.hc-preset-tile-wrap:hover .hc-preset-tile-delete { display: block; }
.hc-saved-empty { font-size: 11px; color: #888; font-style: italic; margin: 0 0 8px; }

/* ── Save combination modal ──────────────────────────────── */
.hc-save-modal-field {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-bottom: 10px;
}
.hc-save-modal-field label {
    font-size: 12px;
    font-weight: 600;
    color: #374151;
}
.hc-save-modal-field input {
    padding: 7px 10px;
    border: 1.5px solid #d1d5db;
    border-radius: 5px;
    font-size: 13px;
    font-family: inherit;
}
.hc-save-modal-hint {
    font-size: 11px;
    color: #666;
    margin: 0 0 10px;
    line-height: 1.4;
}

/* ── Save order confirmation ─────────────────────────────── */
.hc-save-order-meta {
    font-size: 12px;
    color: #374151;
    margin: 0 0 10px;
    line-height: 1.6;
}
.hc-save-order-parts {
    list-style: none;
    margin: 0 0 12px;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.hc-save-order-parts li {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 11px;
}
.hc-save-order-swatch {
    width: 14px;
    height: 14px;
    border-radius: 3px;
    border: 1px solid #999;
    flex-shrink: 0;
}
.hc-save-order-part-label { font-weight: 600; min-width: 75px; }
.hc-save-order-part-paint { color: #555; }
