/* =====================================================================
   Personalizador de sudaderas JHK
   Vista: application/views/paginas/personalizar_sudaderas_jhk.php
   Lógica: assets/js/personalizar-sudaderas-jhk.js
   ===================================================================== */

#jhk-personalizador * { box-sizing: border-box; }

/* ===== App shell: hero + editor pinned to the viewport on desktop, zero page scroll ===== */
html:has(#jhk-app-shell),
body:has(#jhk-app-shell) {
    height: 100%;
    overflow: hidden;
}

body:has(#jhk-app-shell) {
    display: flex;
    flex-direction: column;
}

/* Everything above the shell (topbar, header) keeps its natural height and never grows */
body:has(#jhk-app-shell) > #all,
body:has(#jhk-app-shell) > *:not(#jhk-app-shell) {
    flex: 0 0 auto;
}

body:has(#jhk-app-shell) footer.main-footer { display: none; }

#jhk-app-shell {
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    min-height: 0;
    overflow: hidden;
}

#jhk-mini-header {
    flex: 0 0 auto;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 8px;
    background: #fff;
    border-bottom: 1px solid #eee;
}
#jhk-mini-header img { display: block; height: 32px; width: auto; }

.jhk-xmas-hero {
    flex: 0 0 auto;
    background: linear-gradient(135deg, #b71c1c 0%, #7a1414 60%, #1b5e20 100%);
    color: #fff;
    text-align: center;
    padding: 0.6rem 1rem;
}
.jhk-xmas-hero h1 { color: #fff; font-size: 1.05rem; margin: 0 0 0.15rem; }
.jhk-xmas-hero p { color: #f5f5f5; max-width: 640px; margin: 0 auto; font-size: 0.78rem; display: none; }
.jhk-xmas-hero .price-note { display: inline-block; margin: 0 8px; font-size: 0.75rem; color: #e0e0e0; }

#jhk-personalizador {
    font-family: Arial, sans-serif;
    background-color: #f4f4f4;
    padding: 8px 8px 64px;
    flex: 1 1 auto;
    min-height: 0;
}

/* Sizes read by resizeCanvasDisplay() in the JS; overridden per breakpoint at the end of the file */
#editor-container {
    --side-panel-w: 110px;
    --side-panel-w-expanded: 320px;
    --editor-max-w: 1600px;
    display: grid;
    grid-template-columns: 1fr 110px;
    grid-template-rows: 1fr;
    background-color: white;
    box-shadow: 0 0 10px rgba(0,0,0,0.1);
    width: 96%;
    max-width: 1600px;
    margin: 0 auto;
    border-radius: 4px;
    height: 100%;
    min-height: 0;
}

/* View selector: centered inside the top toolbar */
#views {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    gap: 8px;
}

.view-toggle {
    display: flex;
    background: #f0f0f0;
    border-radius: 20px;
    padding: 3px;
    gap: 2px;
}

.view-toggle-btn.view-thumb-btn {
    position: relative;
    flex-direction: row;
    align-items: center;
    justify-content: center;
    width: auto;
    border: none;
    border-radius: 18px;
    padding: 6px 14px;
    background: transparent;
    color: #666;
    font-size: 12px;
    font-weight: bold;
    white-space: nowrap;
    transition: background-color 0.2s, color 0.2s;
}

.view-toggle-btn.view-thumb-btn:hover:not(.active) {
    border-color: transparent;
    color: #333;
}

.view-toggle-btn.view-thumb-btn.active {
    background: #e67e22;
    border-color: transparent;
    color: #fff;
}

.view-thumb-btn {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    border: 2px solid transparent;
    border-radius: 6px;
    padding: 4px;
    background: white;
    cursor: pointer;
    width: 100%;
    transition: border-color 0.2s;
}

.view-thumb-btn.hidden-view {
    display: none;
}

.upsell-badge {
    display: none;
    position: absolute;
    top: -9px;
    right: -6px;
    height: 16px;
    padding: 0 5px;
    border-radius: 8px;
    background: #e74c3c;
    color: white;
    font-size: 9.5px;
    font-weight: bold;
    line-height: 1;
    align-items: center;
    justify-content: center;
    box-shadow: 0 1px 3px rgba(0,0,0,0.3);
    pointer-events: none;
    z-index: 2;
}

.upsell-badge.visible {
    display: flex;
}

.view-thumb-btn.active {
    border-color: #00a8cc;
}

.view-thumb-btn:hover:not(.active) {
    border-color: #ccc;
}

.view-thumb-btn img {
    width: 68px;
    height: 68px;
    object-fit: contain;
}

.view-thumb-btn .vt-label {
    font-size: 11px;
    color: #444;
    margin-top: 3px;
    text-align: center;
}

#canvas-caption { display: none; }

/* ===== CENTER: Canvas ===== */
#canvas-area {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 6px;
    height: 100%;
    min-height: 0;
    overflow: hidden;
}

/* Toolbar above the canvas: view selector, centred.
   (visibility, not display, hides it while zoomed: the toolbar keeps its height and the canvas doesn't jump) */
#top-toolbar {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    padding: 6px 10px;
    margin-bottom: 6px;
    background: #f7f7f7;
    border-radius: 4px;
    border: 1px solid #eee;
}

/* Hidden while zoomed. !important + children: Bootstrap's global ".visible" utility (used by the
   upsell badges) forces visibility:visible and would otherwise keep the "+5€" badge on screen. */
#views.is-hidden,
#views.is-hidden * { visibility: hidden !important; }

/* Floating tools (zoom, undo, redo): a column next to the print zone's top-left corner (positioned by JS) */
.canvas-float-tools {
    position: absolute;
    top: 8px;
    left: 8px;
    z-index: 20;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.canvas-float-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    padding: 0;
    border: none;
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 2px 6px rgba(0,0,0,0.3);
    cursor: pointer;
    transition: transform 0.1s, background-color 0.15s, opacity 0.15s;
}

.canvas-float-btn:hover:not(:disabled) { transform: scale(1.08); }

.canvas-float-btn:disabled {
    opacity: 0.45;
    cursor: default;
    box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

.canvas-float-btn svg {
    width: 22px;
    height: 22px;
    fill: none;
    stroke: #00a8cc;
    stroke-width: 2.4;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.canvas-float-btn:disabled svg { stroke: #888; }

/* Zoomed in: blue zoom button, the "+" becomes a "-" */
#toggle-zoom-btn.is-zoomed { background: #00a8cc; }
#toggle-zoom-btn.is-zoomed svg { stroke: #fff; }
#toggle-zoom-btn.is-zoomed .zoom-plus-bar { display: none; }

#canvas-wrapper {
    position: relative;
    display: block;
    line-height: 0;
    flex: 1 1 auto;
    min-height: 0;
}

#tshirt-canvas {
    display: block;
    background-color: #fff;
    cursor: default;
}

#canvas-status {
    position: absolute;
    top: 8px;
    left: 8px;
    z-index: 10;
    background: rgba(255,255,255,0.85);
    border-radius: 4px;
    padding: 6px 8px;
    width: 130px;
    display:none;
}

#canvas-status #debug-info {
    margin: 0;
}

/* ===== RIGHT: Tools panel ===== */
#tools-panel {
    border-left: 1px solid #eee;
    padding: 12px 8px;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    min-height: 0;
    overflow: hidden;
}

/* Top block: add-object tools + selected-object editor, natural height, own scroll if needed */
#tools-panel-top {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    flex: 0 1 auto;
    min-height: 0;
    overflow-y: auto;
}

/* Middle block: pure spacer, grows/shrinks to push the layers list to the bottom */
#tools-panel-spacer {
    flex: 1 1 auto;
    min-height: 8px;
}

/* Bottom block: layers list, pinned to the bottom of the right column */
#tools-panel-bottom {
    flex: 0 0 auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    max-height: 45%;
    overflow-y: auto;
}

#add-object-tools {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    width: 100%;
}

.tool-icon-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    border: 1px solid #e5e5e5;
    border-radius: 6px;
    padding: 8px 4px;
    background: white;
    width: 90px;
    min-height: 72px;
    cursor: pointer;
    transition: background-color 0.15s;
    gap: 5px;
}

.tool-icon-btn:hover { background-color: #f7f7f7; }
label.tool-icon-btn { cursor: pointer; }

.t-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 28px;
}

.t-label {
    font-size: 11px;
    color: #333;
    text-align: center;
    line-height: 1.2;
}

/* Line icons (same style for the three "add" buttons) */
.t-icon svg {
    width: 26px;
    height: 26px;
    fill: none;
    stroke: #00a8cc;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}
.tool-icon-btn:hover .t-icon svg { stroke: #0090b0; }

#upload-image-btn,
#cart-form { display: none; }

.view-thumb-btn img.is-mirrored { transform: scaleX(-1); }

/* Layers + text tools */
#tools { width: 100%; }

#uploaded-files-preview {
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.uploaded-file-item {
    display: flex;
    align-items: center;
    padding: 3px 4px;
    border: 1px solid #ddd;
    border-radius: 3px;
    cursor: pointer;
    background: #fafafa;
    transition: border-color 0.2s;
}

.uploaded-file-item:hover {
    border-color: #00a8cc !important;
    background-color: #e6f7fb;
}

.item-preview {
    width: 22px;
    height: 22px;
    margin-right: 5px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
}

.item-info {
    flex-grow: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-size: 10px;
}

.item-remove-btn {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    margin-left: 4px;
    border: none;
    border-radius: 50%;
    background: #e74c3c;
    color: #fff;
    font-size: 12px;
    line-height: 1;
    cursor: pointer;
    padding: 0;
}

.item-remove-btn:hover { background: #c0392b; }

#text-tools {
    width: 100%;
    padding-top: 8px;
    border-top: 1px solid #eee;
}

.tool-section span {
    font-size: 11px;
    margin-bottom: 6px;
    color: #555;
}

#text-tools .tool-section span {
    color: inherit;
}

.text-tools-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin: -8px -8px 10px;
    padding: 10px 10px 10px 12px;
    background-color: #00a8cc;
    border-radius: 4px 4px 0 0;
}

.text-tools-header span {
    margin-bottom: 0;
    color: #fff;
    font-size: 13px;
    font-weight: bold;
}

#open-object-tools-btn {
    display: flex;
    align-items: center;
    gap: 4px;
    width: auto;
    border: none;
    border-radius: 20px;
    background-color: #00a8cc;
    color: #fff;
    font-size: 12px;
    font-weight: bold;
    padding: 8px 16px;
    cursor: pointer;
    position: absolute;
    z-index: 30;
    box-shadow: 0 2px 8px rgba(0,0,0,0.25);
    transform: translateX(-50%);
}

#open-object-tools-btn:hover { background-color: #0090b0; }

#open-object-tools-btn .edit-pencil-icon {
    font-size: 16px;
    line-height: 1;
}

.text-row {
    margin-bottom: 8px;
}

.text-row label {
    display: block;
    font-size: 10px;
    color: #777;
    margin-bottom: 3px;
}

.hidden-native-color {
    position: absolute;
    width: 1px;
    height: 1px;
    opacity: 0;
    pointer-events: none;
}

.color-grid {
    display: grid;
    grid-template-columns: repeat(9, 1fr);
    gap: 6px;
}

.color-grid-swatch {
    width: 100%;
    aspect-ratio: 1;
    border-radius: 50%;
    border: 2px solid rgba(0,0,0,0.08);
    cursor: pointer;
    padding: 0;
    transition: border-color 0.15s, transform 0.1s;
}

.color-grid-swatch:hover { transform: scale(1.08); }

/* Custom colour: rainbow ring with "+"; once a custom colour is picked, its centre shows it */
.color-grid-custom {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    background: conic-gradient(#ff0000, #ffff00, #00ff00, #00ffff, #0000ff, #ff00ff, #ff0000);
    color: #fff;
    font-weight: bold;
    font-size: 15px;
    line-height: 1;
}

.color-grid-custom::before {
    content: '';
    position: absolute;
    inset: 22%;
    border-radius: 50%;
    background: var(--custom-color, transparent);
}

.color-grid-custom span {
    position: relative;
    text-shadow: 0 0 3px rgba(0,0,0,0.6);
}

.color-grid-swatch.active {
    border-color: #00a8cc;
    box-shadow: 0 0 0 1px #00a8cc;
}

.position-btn {
    display: flex;
    align-items: center;
    gap: 4px;
    border: none;
    background: none;
    cursor: pointer;
    color: #e67e22;
    font-size: 11px;
    line-height: 1.2;
    padding: 3px 2px;
    white-space: nowrap;
}

.position-btn:hover { color: #c8650f; }
.position-btn:disabled { color: #ccc; cursor: default; }

.position-btn .pos-icon {
    font-size: 15px;
    line-height: 1;
}

.tool-input {
    padding: 4px;
    width: 100%;
    border: 1px solid #ccc;
    border-radius: 3px;
    font-size: 11px;
}

.icon-btn-group {
    display: flex;
    gap: 4px;
}

.icon-toggle-btn {
    flex: 1;
    padding: 5px 0;
    border: 1px solid #ccc;
    background: white;
    color: #333;
    border-radius: 3px;
    font-size: 11px;
    cursor: pointer;
}

.icon-toggle-btn:hover {
    border-color: #999;
}

.icon-toggle-btn.active {
    background-color: #f39c12;
    border-color: #f39c12;
    color: white;
}

.tool-button {
    padding: 4px 8px;
    margin: 2px 1px;
    border: none;
    cursor: pointer;
    background-color: #3498db;
    color: white;
    border-radius: 3px;
    font-weight: bold;
    font-size: 12px;
}

/* Delete (left) + Continue (right), half width each */
.object-actions {
    display: flex;
    gap: 8px;
    margin-top: 5px;
}

.object-actions .tool-button {
    flex: 1 1 0;
    margin: 0;
    font-size: 11px;
    padding: 8px 5px;
    border-radius: 4px;
}

#delete-object-btn { background-color: #e74c3c; }
#delete-object-btn:hover { background-color: #c0392b; }
#duplicate-object-btn { background-color: #6c757d; }
#duplicate-object-btn:hover { background-color: #5a6268; }
#continue-object-btn { background-color: #00a8cc; }
#continue-object-btn:hover { background-color: #0090b0; }

/* ===== Object editor: text input + accordion (one section open at a time) ===== */
.font-family-native { display: none; }

/* Show each section/row only for the selected object type (#text-tools[data-kind] is set by the JS) */
#text-tools[data-kind="text"]    [data-for]:not([data-for~="text"]),
#text-tools[data-kind="image"]   [data-for]:not([data-for~="image"]),
#text-tools[data-kind="clipart"] [data-for]:not([data-for~="clipart"]) { display: none; }

.tool-accordion {
    border: 1px solid #e5e5e5;
    border-radius: 6px;
    overflow: hidden;
}

.acc-item + .acc-item { border-top: 1px solid #e5e5e5; }

.acc-header {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 10px 12px;
    border: none;
    background: #fafafa;
    cursor: pointer;
    text-align: left;
}

.acc-header:hover { background: #f2f2f2; }

#text-tools .acc-header span { margin-bottom: 0; }

#text-tools .acc-title {
    font-size: 13px;
    font-weight: bold;
    color: #333;
}

#text-tools .acc-value {
    flex: 1 1 auto;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 6px;
    min-width: 0;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    font-size: 13px;
    color: #666;
}

#text-tools #font-picker-current { display: block; text-align: right; font-size: 17px; color: #222; overflow: hidden; text-overflow: ellipsis; }

.acc-color-dot {
    flex: 0 0 auto;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    border: 1px solid rgba(0,0,0,0.2);
}

.acc-color-dot.is-empty { display: none; }

/* Border width slider ("Borde" section) */
.stroke-width-row {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 12px;
}

#text-tools .stroke-width-row label {
    flex: 0 0 auto;
    margin: 0;
    font-size: 12px;
    font-weight: bold;
    color: #555;
}

.stroke-width-row input[type="range"] {
    flex: 1 1 auto;
    min-width: 0;
    accent-color: #00a8cc;
}

.stroke-width-value {
    flex: 0 0 28px;
    text-align: right;
    font-size: 12px;
    color: #555;
}

#text-tools .acc-caret {
    flex: 0 0 auto;
    font-size: 12px;
    color: #888;
    transition: transform 0.15s;
}

.acc-item.open .acc-caret { transform: rotate(180deg); }
.acc-item.open .acc-header { background: #e6f7fb; }

.acc-body {
    display: none;
    padding: 10px 12px;
    background: #fff;
}

.acc-item.open .acc-body { display: block; }

/* Font list, shown inline inside the "Fuente" section */
.font-picker-list {
    max-height: 168px;
    overflow-y: auto;
    margin: 0 0 8px;
    padding: 0;
    list-style: none;
    border: 1px solid #eee;
    border-radius: 4px;
}

.font-picker-option {
    padding: 7px 10px;
    font-size: 17px;
    line-height: 1.2;
    color: #222;
    cursor: pointer;
}

.font-picker-option:hover { background: #e6f7fb; }

.font-picker-option.active {
    background: #00a8cc;
    color: #fff;
}

#debug-info {
    font-size: 12px;
    line-height: 1.4;
    color: #2c3e50;
    text-align: center;
    width: 100%;
}

.color-swatch-btn.pending { border-color: #f39c12; }

#select-color-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    width: 100%;
    padding: 6px 10px;
    background: #00a8cc;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 11px;
    font-weight: bold;
    white-space: nowrap;
}

#select-color-btn:hover { background: #0090b0; }

/* Position controls group, inside the object editor panel (#text-tools) */
#position-controls {
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    justify-content: space-between;
    gap: 4px;
}

#position-controls .position-btn { flex-direction: column; gap: 1px; padding: 4px 2px; flex: 1 1 0; }
#position-controls .position-btn span:last-child { display: block; font-size: 9px; }

.color-swatch-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    border: 2px solid #ddd;
    border-radius: 6px;
    padding: 6px 4px;
    cursor: pointer;
    background: white;
    transition: border-color 0.2s;
}

.color-swatch-btn:hover { border-color: #aaa; }

.color-swatch-btn.active { border-color: #00a8cc; }

.swatch-circle {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: 1px solid #ccc;
}

.swatch-label {
    font-size: 10px;
    color: #333;
}

/* ===== Size / quantity "calculator" modal ===== */
.size-modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 1000;
    align-items: center;
    justify-content: center;
}

.size-modal-overlay.open { display: flex; }

.size-modal {
    background: #fff;
    border-radius: 8px;
    width: 360px;
    max-width: 92vw;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.size-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 18px;
    border-bottom: 1px solid #eee;
}

.size-modal-header span {
    margin: 0;
    font-size: 16px;
    color: #222;
}

.size-modal-close-btn {
    border: none;
    background: none;
    font-size: 20px;
    line-height: 1;
    cursor: pointer;
    color: #555;
    padding: 0;
}

.size-modal-close-btn:hover { color: #111; }

.size-modal-body {
    padding: 16px 18px;
    overflow-y: auto;
}

.size-modal-notice {
    display: flex;
    gap: 6px;
    background: #eef7fb;
    border: 1px solid #cdeaf5;
    color: #2c6178;
    font-size: 11.5px;
    line-height: 1.4;
    border-radius: 6px;
    padding: 8px 10px;
    margin: 0 0 14px;
}

.size-modal-hint {
    font-size: 11px;
    color: #888;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin: 0 0 12px;
}

.size-modal-footer {
    padding: 14px 18px;
    border-top: 1px solid #eee;
}

.size-modal-confirm-btn {
    width: 100%;
    padding: 12px;
    border: 1px solid #00a8cc;
    background: #fff;
    color: #00a8cc;
    border-radius: 4px;
    font-weight: bold;
    cursor: pointer;
    font-size: 13px;
}

.size-modal-confirm-btn.ready { background: #00a8cc; color: #fff; }
.size-modal-confirm-btn:disabled { opacity: 0.5; cursor: default; }

/* ===== Pantalla previa: elegir talla y color ===== */
#jhk-size-color-gate {
    position: fixed;
    inset: 0;
    z-index: 2000;
    background: #f4f4f4;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
}

#jhk-size-color-gate.gate-closed { display: none; }

.gate-mini-header {
    flex: 0 0 auto;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 8px;
    background: #fff;
    border-bottom: 1px solid #eee;
}
.gate-mini-header img { display: block; height: 32px; width: auto; }

.gate-body {
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 24px 16px;
    text-align: center;
    width: 96%;
    max-width: 480px;
    margin: 16px auto;
    background: #fff;
    box-shadow: 0 0 10px rgba(0,0,0,0.1);
    border-radius: 4px;
}

.gate-body-inner {
    width: 100%;
    max-width: 480px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.gate-title {
    font-size: 1.15rem;
    color: #222;
    margin: 4px 0 16px;
}

.gate-garment-img {
    max-width: 260px;
    width: 100%;
    margin: 0 auto 16px;
    display: block;
    object-fit: contain;
}

.gate-step-label {
    font-size: 13px;
    font-weight: bold;
    color: #00a8cc;
    margin: 0 0 12px;
}

.gate-color-list {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 10px;
    margin-bottom: 20px;
    max-width: 420px;
}

.gate-size-row {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 8px;
    max-width: 420px;
}

.gate-size-btn {
    padding: 10px 16px;
    border: 2px solid #ddd;
    border-radius: 6px;
    background: #fff;
    font-weight: bold;
    font-size: 13px;
    color: #333;
    cursor: pointer;
    transition: border-color 0.2s, background-color 0.2s, color 0.2s;
}

.gate-size-btn:hover { border-color: #aaa; }

.gate-size-btn.active {
    border-color: #00a8cc;
    background: #00a8cc;
    color: #fff;
}

.gate-footer-strip {
    background: #e67e22;
    color: #fff;
    text-align: center;
    padding: 8px 16px;
    border-radius: 20px;
    font-weight: bold;
    font-size: 12px;
    margin: 0 0 16px;
}

.gate-cta-bar {
    flex: 0 0 auto;
    position: sticky;
    bottom: 0;
    background: #fff;
    padding: 14px 18px;
    border-top: 1px solid #eee;
    width: 96%;
    max-width: 480px;
    margin: 0 auto;
}

/* ===== Templates modal ===== */
.templates-modal { width: 480px; }

.templates-grid {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.templates-group-title {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: #888;
    margin: 0 0 8px;
}

.templates-grid-inner {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
}

.template-item-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    border: 2px solid #eee;
    border-radius: 8px;
    padding: 6px;
    background: #fff;
    cursor: pointer;
    transition: border-color 0.2s;
}

.template-item-btn:hover { border-color: #00a8cc; }

.template-item-btn img {
    width: 100%;
    aspect-ratio: 1 / 1;
    object-fit: contain;
    background: #f7f7f7;
    border-radius: 4px;
}

.template-item-btn .template-label {
    font-size: 10.5px;
    color: #444;
    text-align: center;
}

.templates-empty {
    grid-column: 1 / -1;
    font-size: 12px;
    color: #999;
    text-align: center;
    padding: 20px 0;
}

/* ===== Low-resolution image notice (non-blocking toast) ===== */
#low-res-toast {
    display: none;
    position: absolute;
    top: 52px;
    right: 8px;
    max-width: calc(100% - 16px);
    width: 300px;
    background: #fff3cd;
    border: 2px solid #f0b400;
    color: #5c4400;
    border-radius: 8px;
    padding: 10px 12px;
    box-shadow: 0 4px 14px rgba(0,0,0,0.25);
    z-index: 30;
    align-items: flex-start;
    gap: 8px;
    font-size: 12.5px;
    font-weight: 500;
    line-height: 1.4;
}

#low-res-toast.visible { display: flex; }

#low-res-toast .lrt-icon {
    font-size: 16px;
    line-height: 1;
    flex: 0 0 auto;
}

#low-res-toast .lrt-text { flex: 1 1 auto; }

#low-res-toast .lrt-close {
    border: none;
    background: none;
    cursor: pointer;
    color: #6b4f00;
    font-size: 15px;
    line-height: 1;
    padding: 0;
    flex: 0 0 auto;
}

#low-res-toast .lrt-close:hover { color: #402f00; }

/* Sticky bottom CTA bar: always visible, desktop and mobile */
#mobile-cta-bar {
    display: flex;
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    align-items: center;
    justify-content: center;
    gap: 10px;
    width: 96%;
    max-width: 1600px;
    margin: 0 auto;
    padding: 10px 14px;
    background: #fff;
    border-top: 1px solid #eee;
    box-shadow: 0 -2px 10px rgba(0,0,0,0.08);
    z-index: 55;
    transition: bottom 0.15s ease;
}

#mobile-cta-bar #price-info { font-weight: bold; }

#mobile-cta-bar #select-color-btn { flex: 0 0 auto; width: auto; }

#mobile-cta-bar #save-design-btn {
    flex: 1 1 auto;
    max-width: 220px;
    padding: 10px 14px;
    border: none;
    background-color: #28a745;
    color: #fff;
    border-radius: 6px;
    font-size: 13px;
    font-weight: bold;
    cursor: pointer;
}

#mobile-cta-bar #save-design-btn:disabled { background-color: #9bd6ac; cursor: default; }

/* ===== Responsive: tablet / mobile =====
   Layout order (top to bottom): canvas -> floating zoom pill (over canvas) ->
   status/price caption -> tool icons row -> views/color row -> sticky CTA bar. */
@media (max-width: 860px) {
    html:has(#jhk-app-shell),
    body:has(#jhk-app-shell) {
        height: auto;
        overflow: visible;
        display: block;
    }
    #jhk-app-shell { flex: none; height: auto; overflow: visible; }

    .jhk-xmas-hero { display: none; }

    #jhk-personalizador { padding: 6px 6px 78px; flex: none; }

    #editor-container {
        display: flex;
        flex-direction: column;
        width: 100%;
        margin: 8px auto 0;
        height: auto;
        box-shadow: none;
        background: transparent;
    }

    /* ===== 1) Canvas: dominant area, shown first ===== */
    #canvas-area {
        order: 1;
        flex: 0 0 auto;
        min-height: 0;
        padding: 4px;
        background: #fff;
        border-radius: 8px;
        box-shadow: 0 0 10px rgba(0,0,0,0.08);
    }

    /* Full-width toolbar above the canvas: view selector, undo/redo */
    #top-toolbar {
        gap: 6px 10px;
        padding: 6px 8px;
    }

    .position-btn .pos-icon { font-size: 14px; }

    .view-toggle-btn.view-thumb-btn { padding: 5px 10px; font-size: 11px; }

    #canvas-status { display: none; }


    #low-res-toast {
        top: auto;
        bottom: 8px;
        right: 8px;
        width: calc(100% - 16px);
    }

    /* ===== 2) Status / price caption under the canvas ===== */
    #canvas-caption {
        display: block;
        order: 2;
        flex: 0 0 auto;
        padding: 10px 6px 4px;
        text-align: center;
    }

    #canvas-caption #debug-info-mobile { font-size: 12px; line-height: 1.4; color: #2c3e50; margin: 0; }
    #canvas-caption #price-info-mobile { font-size: 15px; font-weight: bold; color: #b71c1c; margin: 4px 0 0; }

    /* ===== 3) Tool icons row ===== */
    #tools-panel {
        order: 3;
        flex: 0 0 auto;
        flex-direction: row;
        flex-wrap: wrap;
        border-left: none;
        border-top: 1px solid #eee;
        padding: 10px 4px;
        gap: 4px;
        overflow: visible;
    }

    /* The 3-block desktop layout collapses: these wrappers become transparent so their
       children (#add-object-tools, #text-tools, #tools) lay out
       directly as flex items of #tools-panel, following the "order" rules below. */
    #tools-panel-top,
    #tools-panel-spacer,
    #tools-panel-bottom {
        display: contents;
    }

    #add-object-tools {
        flex-direction: row;
        width: 100%;
        justify-content: space-around;
        gap: 4px;
    }

    .tool-icon-btn {
        width: auto;
        flex: 1 1 0;
        min-height: 52px;
        border: none;
        background: none;
    }
    .tool-icon-btn:hover { background: none; }

    /* Layers list moves under the tool icons, own full-width row, horizontal scroll */
    #tools {
        order: 4;
        width: 100%;
        flex: 0 0 auto;
        max-height: none;
        overflow: visible;
        border-left: none;
        border-top: 1px solid #eee;
        padding-left: 0;
        padding-top: 8px;
    }

    #uploaded-files-preview {
        flex-direction: row;
        overflow-x: auto;
        gap: 6px;
    }

    #uploaded-files-preview .uploaded-file-item {
        flex: 0 0 auto;
        width: auto;
        max-width: 190px;
    }

    .view-thumb-btn img { width: 38px; height: 38px; }
    .view-thumb-btn .vt-label { font-size: 9px; }

    /* ===== 6) Sticky bottom CTA bar: price + add to cart ===== */
    #mobile-cta-bar {
        display: flex;
    }

    /* Object editor becomes a bottom sheet so it never squeezes the layout */
    #text-tools {
        position: fixed;
        left: 0;
        right: 0;
        bottom: 0;
        width: 100%;
        max-height: 85vh;
        overflow-y: auto;
        background: #fff;
        box-shadow: 0 -4px 16px rgba(0,0,0,0.18);
        border-radius: 12px 12px 0 0;
        padding: 14px 16px;
        margin: 0;
        border-top: 1px solid #eee;
        z-index: 60;
    }

    .text-tools-header {
        margin: -14px -16px 10px;
        padding: 14px 16px;
        border-radius: 12px 12px 0 0;
    }

    #open-object-tools-btn {
        padding: 6px 8px;
        font-size: 11px;
    }

    #open-object-tools-btn .edit-pencil-icon { font-size: 14px; }

    /* Colours: a single row with the main colours + the custom one */
    .color-grid { gap: 5px; }
    .color-grid-swatch.is-extra { display: none; }
}

@media (max-width: 480px) {
    /* Shorter font list so the open panel never covers the print zone */
    .font-picker-list { max-height: 118px; }

    .tool-icon-btn { min-height: 48px; padding: 6px 2px; }
    .t-label { font-size: 10px; }

    #canvas-caption #price-info-mobile { font-size: 14px; }
    #canvas-caption #debug-info-mobile { font-size: 11px; }

    #mobile-cta-bar { flex-wrap: wrap; }
    #mobile-cta-bar #select-color-btn { font-size: 10.5px; padding: 8px 8px; }
    #mobile-cta-bar #price-info { font-size: 13px; }
    #mobile-cta-bar #save-design-btn { font-size: 12px; padding: 9px 10px; }
}

/* ===== Desktop with little height (laptops, tablets in landscape) =====
   Compact header so the vertical space goes to the canvas. */
@media (min-width: 861px) and (max-height: 820px) {
    #jhk-mini-header { padding: 4px; }
    #jhk-mini-header img { height: 28px; }

    .jhk-xmas-hero { padding: 0.35rem 1rem; }
    .jhk-xmas-hero h1 { font-size: 0.95rem; margin: 0; }
    .jhk-xmas-hero .price-note { font-size: 0.7rem; }

    #jhk-personalizador { padding-top: 4px; }
    #top-toolbar { padding: 4px 8px; margin-bottom: 4px; }
}

/* ===== Large screens (>= 1600px) ===== */
@media (min-width: 1600px) {
    #editor-container {
        --side-panel-w: 140px;
        --side-panel-w-expanded: 360px;
        --editor-max-w: 2000px;
        max-width: var(--editor-max-w);
    }

    #jhk-personalizador { padding-bottom: 82px; }

    #jhk-mini-header img,
    .gate-mini-header img { height: 38px; }
    .jhk-xmas-hero h1 { font-size: 1.25rem; }
    .jhk-xmas-hero .price-note { font-size: 0.85rem; }

    /* Toolbar */
    #top-toolbar { padding: 8px 14px; }
    .canvas-float-btn { width: 42px; height: 42px; }
    .canvas-float-btn svg { width: 26px; height: 26px; }
    .view-toggle-btn.view-thumb-btn { padding: 8px 20px; font-size: 14px; }
    .upsell-badge { height: 18px; padding: 0 6px; border-radius: 9px; font-size: 11px; }

    /* Tools panel */
    .tool-icon-btn { width: 120px; min-height: 92px; }
    .t-icon { height: 36px; }
    .t-icon svg { width: 32px; height: 32px; }
    .t-label { font-size: 13px; }
    .item-preview { width: 28px; height: 28px; font-size: 15px; }
    .item-info { font-size: 12px; }

    /* Object editor */
    .text-tools-header span { font-size: 15px; }
    .text-row label { font-size: 12px; }
    .tool-input { font-size: 13px; padding: 6px; }
    .icon-toggle-btn { font-size: 13px; padding: 7px 0; }
    .position-btn { font-size: 13px; }
    #position-controls .position-btn span:last-child { font-size: 11px; }
    .object-actions .tool-button { font-size: 13px; padding: 9px 6px; }
    #text-tools .acc-title, #text-tools .acc-value { font-size: 14px; }
    .font-picker-option { font-size: 18px; }

    /* CTA bar */
    #mobile-cta-bar { padding: 12px 18px; }
    #select-color-btn { font-size: 13px; padding: 10px 16px; }
    #mobile-cta-bar #save-design-btn { max-width: 300px; font-size: 15px; padding: 12px 18px; }

    /* Size / colour gate */
    .gate-title { font-size: 1.5rem; }
    .gate-garment-img { max-width: 360px; }
    .gate-step-label { font-size: 15px; }
    .gate-color-list,
    .gate-size-row { max-width: 520px; gap: 12px; }
    .swatch-circle { width: 34px; height: 34px; }
    .swatch-label { font-size: 12px; }
    .gate-size-btn { font-size: 15px; padding: 12px 22px; }
    .size-modal-confirm-btn { font-size: 15px; padding: 14px; }
}

/* ===== Extra-large screens (>= 2200px: 1440p, 4K) ===== */
@media (min-width: 2200px) {
    #editor-container {
        --side-panel-w: 180px;
        --side-panel-w-expanded: 420px;
        --editor-max-w: 2600px;
    }

    #jhk-personalizador { padding-bottom: 100px; }

    #jhk-mini-header img,
    .gate-mini-header img { height: 46px; }
    .jhk-xmas-hero { padding: 0.8rem 1rem; }
    .jhk-xmas-hero h1 { font-size: 1.6rem; }
    .jhk-xmas-hero .price-note { font-size: 1rem; }

    /* Toolbar */
    #top-toolbar { padding: 10px 18px; }
    .canvas-float-tools { gap: 10px; }
    .canvas-float-btn { width: 52px; height: 52px; }
    .canvas-float-btn svg { width: 32px; height: 32px; }
    .view-toggle { border-radius: 26px; }
    .view-toggle-btn.view-thumb-btn { padding: 10px 26px; font-size: 18px; border-radius: 24px; }
    .upsell-badge { height: 22px; padding: 0 8px; border-radius: 11px; font-size: 13px; top: -11px; }

    /* Tools panel */
    .tool-icon-btn { width: 150px; min-height: 116px; border-radius: 8px; }
    .t-icon { height: 44px; }
    .t-icon svg { width: 40px; height: 40px; }
    .t-label { font-size: 16px; }
    .uploaded-file-item { padding: 6px; }
    .item-preview { width: 34px; height: 34px; font-size: 18px; }
    .item-info { font-size: 14px; }
    .item-remove-btn { width: 24px; height: 24px; font-size: 15px; }

    /* Object editor */
    .text-tools-header span { font-size: 18px; }
    .text-row label { font-size: 14px; }
    .tool-input { font-size: 15px; padding: 8px; }
    .icon-toggle-btn { font-size: 15px; padding: 9px 0; }
    .position-btn { font-size: 15px; }
    .position-btn .pos-icon { font-size: 20px; }
    #position-controls .position-btn span:last-child { font-size: 13px; }
    .object-actions .tool-button { font-size: 15px; padding: 11px 8px; }
    #text-tools .acc-title, #text-tools .acc-value { font-size: 16px; }
    .font-picker-option { font-size: 21px; }
    #open-object-tools-btn { font-size: 15px; padding: 10px 20px; }

    /* CTA bar */
    #mobile-cta-bar { padding: 14px 22px; gap: 14px; }
    #select-color-btn { font-size: 16px; padding: 12px 20px; }
    #mobile-cta-bar #save-design-btn { max-width: 380px; font-size: 19px; padding: 14px 24px; }

    /* Size / colour gate */
    .gate-title { font-size: 2rem; }
    .gate-garment-img { max-width: 480px; }
    .gate-step-label { font-size: 18px; }
    .gate-color-list,
    .gate-size-row { max-width: 640px; gap: 14px; }
    .color-swatch-btn { padding: 8px 6px; }
    .swatch-circle { width: 44px; height: 44px; }
    .swatch-label { font-size: 14px; }
    .gate-size-btn { font-size: 18px; padding: 14px 28px; }
    .size-modal-confirm-btn { font-size: 18px; padding: 16px; }
}
