/**
 * Custom Printful Product Editor Styles
 * Scope A: Three-column layout (Layers | Canvas | Controls)
 */

/* Main Editor Container */
#editor-container.custom-printful-editor-container {
    width: 100%;
    min-height: 600px;
    background: #f5f5f5;
    border: 1px solid #ddd;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

/* Three-column layout (with top panel: main area is Canvas | Controls) */
.cppe-layout-three-col .editor-layout {
    display: flex;
    flex-direction: row;
    min-height: 500px;
}

/* Top bar: horizontal customization panel (Layers) */
.cppe-layout-top-panel .editor-top-bar {
    display: flex;
    flex-direction: row;
    width: 100%;
    background: #fff;
    border-bottom: 1px solid #ddd;
    flex-shrink: 0;
}

.cppe-layout-top-panel .editor-top-bar .editor-layers-panel {
    width: 100%;
    min-width: 0;
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    gap: 0;
    border-right: none;
    padding: 0;
}

.cppe-layout-top-panel .editor-top-bar .editor-panel-title {
    padding: 10px 14px;
    margin: 0;
    border-bottom: none;
    border-right: 1px solid #eee;
    flex-shrink: 0;
}

/* Toolbar row inside top bar: text options + actions in one row */
.editor-layers-toolbar {
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px;
    padding: 8px 14px;
    border-bottom: none;
}

.cppe-layout-top-panel .editor-top-bar .editor-layers-text-options {
    padding: 0;
    border-bottom: none;
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
}

.cppe-layout-top-panel .editor-top-bar .editor-layers-text-colors {
    margin-bottom: 0;
}

.cppe-layout-top-panel .editor-top-bar .editor-layers-text-row,
.cppe-layout-top-panel .editor-top-bar .editor-layers-primary-row {
    margin: 0;
}

.editor-layers-primary-row {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    align-items: center;
}

.editor-layers-primary-row .editor-layers-font-dropdown {
    min-width: 120px;
}

.editor-layers-label-inline {
    display: inline-flex;
    align-items: center;
    margin: 0;
}

.editor-layers-primary-row .editor-select:hover,
.editor-layers-primary-row .editor-layers-font-trigger:hover {
    border-color: #bbb;
}

.editor-layers-primary-row .editor-select:focus,
.editor-layers-primary-row .editor-layers-font-trigger:focus {
    outline: none;
    border-color: #8b5cf6;
}

.cppe-layout-top-panel .editor-top-bar .editor-layers-actions {
    padding: 0;
    border-bottom: none;
}

/* Layers list in top bar: horizontal scrollable strip */
.cppe-layout-top-panel .editor-top-bar .editor-layers-list {
    flex: 1;
    min-height: 0;
    min-width: 120px;
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    overflow-x: auto;
    overflow-y: hidden;
}

.cppe-layout-top-panel .editor-top-bar .editor-layer-item {
    flex: 0 0 auto;
    margin-bottom: 0;
    min-width: 100px;
}

.cppe-layout-top-panel .editor-top-bar .editor-layers-font-dropdown {
    min-width: 120px;
}

/* Under editor: all placement images with labels */
.editor-images-thumbnails {
    padding: 14px 16px;
    background: #fff;
    border-top: 1px solid #ddd;
}

.editor-images-thumbnails-title {
    margin: 0 0 10px;
    font-size: 13px;
    font-weight: 600;
    color: #333;
}

.editor-images-thumbnails-list {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    align-items: flex-start;
}

.editor-images-thumb-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}

.editor-images-thumb-img-wrap {
    position: relative;
    display: block;
    width: 80px;
    height: 80px;
    flex-shrink: 0;
}

.editor-images-thumb-img {
    display: block;
    width: 80px;
    height: 80px;
    object-fit: contain;
    background: #f5f5f5;
    border-radius: 4px;
    border: 1px solid #e0e0e0;
}

.editor-images-thumb-printarea {
    position: absolute;
    top: 0;
    left: 0;
    box-sizing: border-box;
    border: 2px dashed rgba(139, 92, 246, 0.9);
    pointer-events: none;
}

.editor-images-thumb-label {
    font-size: 11px;
    font-weight: 500;
    color: #555;
    text-align: center;
    max-width: 90px;
    word-break: break-word;
}

.editor-images-thumb-category {
    width: 100%;
    font-size: 12px;
    font-weight: 600;
    color: #8b5cf6;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin: 12px 0 8px;
    padding: 6px 0;
    border-bottom: 2px solid #e0e0e0;
    flex-basis: 100%;
}

.editor-images-thumb-category:first-child {
    margin-top: 0;
}

/* Side panels */
.editor-panel {
    background: #fff;
    border-right: 1px solid #ddd;
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
}

.editor-panel:last-of-type {
    border-right: none;
    border-left: 1px solid #ddd;
}

.editor-panel-title {
    margin: 0;
    padding: 12px 14px;
    font-size: 14px;
    font-weight: 600;
    color: #333;
    border-bottom: 1px solid #eee;
}

/* Left: Layers Panel */
.editor-layers-panel {
    width: 220px;
    min-width: 180px;
}

/* Layers panel: text options (colors, font, style, size) */
.editor-layers-text-options {
    padding: 10px 14px;
    border-bottom: 1px solid #eee;
}
.editor-layers-text-colors {
    display: flex;
    gap: 10px;
    margin-bottom: 10px;
    align-items: center;
}
.editor-layers-color-label {
    display: inline-flex;
    align-items: center;
    cursor: pointer;
}
.editor-layers-color-sr {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    border: 0;
}
.editor-layers-color {
    width: 32px;
    height: 28px;
    padding: 2px;
    border: 2px solid #555;
    border-radius: 4px;
    cursor: pointer;
    background: #fff;
    outline: 1px solid #333;
    box-sizing: border-box;
}
.editor-layers-color:hover {
    border-color: #8b5cf6;
    outline-color: #8b5cf6;
}
/* Background checkbox + color in same row */
.editor-layers-bg-wrap {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}
.editor-layers-bg-use {
    width: 16px;
    height: 16px;
    margin: 0;
    cursor: pointer;
    flex-shrink: 0;
}
.editor-layers-bg-label {
    font-size: 11px;
    color: #555;
    flex-shrink: 0;
}

.editor-layers-text-row {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}
/* Custom font dropdown: trigger looks like a select */
.editor-layers-font-dropdown {
    position: relative;
    flex: 1;
    min-width: 0;
}
.editor-layers-font-trigger {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 6px;
    font-size: 13px;
    padding: 6px 8px;
    border-radius: 4px;
    border: 1px solid #ddd;
    background: #fff;
    cursor: pointer;
    text-align: left;
}
.editor-layers-font-trigger:hover {
    border-color: #bbb;
}
.editor-layers-font-trigger[aria-expanded="true"] {
    border-color: #8b5cf6;
    outline: none;
}
.editor-layers-font-trigger-text {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.editor-layers-font-arrow {
    flex-shrink: 0;
    color: #666;
    font-size: 10px;
}
.editor-layers-font-list {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    margin: 2px 0 0;
    padding: 4px 0;
    max-height: 220px;
    overflow-y: auto;
    list-style: none;
    background: #fff;
    color: #222;
    border: 1px solid #ddd;
    border-radius: 4px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    z-index: 100;
    display: none;
}
.editor-layers-font-dropdown.is-open .editor-layers-font-list {
    display: block;
}
.editor-layers-font-list li {
    padding: 6px 10px;
    font-size: 13px;
    cursor: pointer;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: #222;
}
.editor-layers-font-list li:hover {
    background: #f0f0f0;
    color: #222;
}
.editor-layers-font-list li.selected {
    background: #ede9fe;
    color: #5b21b6;
}
.editor-layers-font-select {
    flex: 1;
    min-width: 0;
    font-size: 13px;
    padding: 6px 8px;
    border-radius: 4px;
    border: 1px solid #ddd;
    background: #fff;
}
.editor-layers-style-select,
.editor-layers-size-select {
    width: 72px;
    flex-shrink: 0;
    font-size: 13px;
    padding: 6px 8px;
    border-radius: 4px;
    border: 1px solid #ddd;
    background: #fff;
}
.editor-layers-text-row .editor-select:hover {
    border-color: #bbb;
}
.editor-layers-text-row .editor-select:focus {
    outline: none;
    border-color: #8b5cf6;
}
.editor-btn-icon {
    padding: 6px 10px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.editor-btn-icon .editor-icon-text {
    display: block;
}

.editor-layers-actions {
    display: flex;
    gap: 8px;
    padding: 10px 14px;
    border-bottom: 1px solid #eee;
}

.editor-layers-list {
    flex: 1;
    overflow-y: auto;
    padding: 8px;
    min-height: 120px;
}

.editor-layers-empty {
    margin: 0;
    padding: 12px;
    font-size: 13px;
    color: #999;
    text-align: center;
}

.editor-layer-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    margin-bottom: 4px;
    border-radius: 4px;
    cursor: pointer;
    background: #f9f9f9;
    border: 1px solid transparent;
}

.editor-layer-item:hover {
    background: #f0f0f0;
}

.editor-layer-item.active {
    background: #ede9fe;
    border-color: #8b5cf6;
}

.editor-layer-item .layer-icon {
    flex-shrink: 0;
    font-size: 16px;
}

.editor-layer-item .layer-label {
    flex: 1;
    font-size: 13px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.editor-layer-item .layer-actions {
    display: flex;
    gap: 2px;
}

.editor-layer-item .layer-btn {
    width: 28px;
    height: 28px;
    padding: 0;
    border: none;
    background: transparent;
    cursor: pointer;
    border-radius: 4px;
    font-size: 12px;
    color: #666;
}

.editor-layer-item .layer-btn:hover {
    background: #e5e5e5;
    color: #333;
}

.editor-layer-item .layer-btn.hidden {
    opacity: 0.4;
}

/* Center: Canvas column - min-height so flex never collapses to 0 */
.editor-center {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    min-height: 1100px;
}

.editor-center .custom-printful-editor-toolbar {
    flex-shrink: 0;
}

.editor-center .custom-printful-editor-canvas-wrapper {
    flex: 1;
    min-height: 1000px;
    position: sticky;
    top: 55px;
    align-self: stretch;
}

/* Right: Controls Panel */
.editor-controls-panel {
    width: 520px;
    min-width: 440px;
}

.editor-controls-tabs {
    display: flex;
    border-bottom: 1px solid #eee;
}

.editor-controls-tabs .editor-tab {
    flex: 1;
    padding: 10px 12px;
    border: none;
    background: #f5f5f5;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    color: #666;
}

.editor-controls-tabs .editor-tab:hover {
    background: #eee;
    color: #333;
}

.editor-controls-tabs .editor-tab.active {
    background: #fff;
    color: #8b5cf6;
    border-bottom: 2px solid #8b5cf6;
    margin-bottom: -1px;
}

.editor-controls-body {
    padding: 14px;
    overflow-y: auto;
    display: none;
}

.editor-controls-body.active {
    display: block;
}

.editor-product-summary p {
    margin: 0 0 10px;
    font-size: 13px;
    color: #555;
}

.editor-product-summary .editor-product-name span,
.editor-product-summary .editor-product-color span,
.editor-product-summary .editor-product-size span {
    font-weight: 500;
    color: #333;
}

/* Object tab: ensure text is visible (overrides theme/global white text) */
#editor-controls-object {
    color: #333;
    background: #fff;
}

#editor-controls-object .editor-control-input,
#editor-controls-object .editor-select,
#editor-controls-object .editor-input,
#editor-controls-object option {
    color: #333;
    background: #fff;
    border-color: #ccc;
}

/* Object tab: top = Object layers, bottom = Object properties */
.editor-controls-object-inner {
    display: flex;
    flex-direction: column;
    gap: 0;
    min-height: 0;
}

.editor-object-tab-section {
    flex: 0 0 auto;
    min-height: 0;
}

.editor-object-layers-section {
    border-bottom: 1px solid #eee;
    padding-bottom: 12px;
    margin-bottom: 12px;
}

.editor-object-section-title {
    margin: 0 0 8px;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.02em;
    color: #666;
}

#editor-controls-object .editor-object-section-title {
    color: #555;
}

.editor-object-list {
    min-width: 0;
    overflow-y: auto;
    padding: 4px 0 0;
    max-height: 200px;
}

.editor-object-properties-section {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
}

.editor-object-list-empty {
    margin: 0;
    padding: 12px 0;
    font-size: 13px;
    color: #666;
    text-align: center;
}

.editor-object-list-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    margin-bottom: 4px;
    border-radius: 4px;
    cursor: pointer;
    background: #f5f5f5;
    border: 1px solid transparent;
    color: #333;
}

.editor-object-list-item:hover {
    background: #eee;
    color: #222;
}

.editor-object-list-item.active {
    background: #ede9fe;
    border-color: #8b5cf6;
    color: #5b21b6;
}

.editor-object-list-item .editor-object-list-icon {
    flex-shrink: 0;
    font-size: 16px;
}

.editor-object-list-item .editor-object-list-label {
    flex: 1;
    min-width: 0;
    font-size: 13px;
    color: inherit;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.editor-object-list-actions {
    display: flex;
    gap: 2px;
    flex-shrink: 0;
}

.editor-object-list-item .layer-btn {
    width: 26px;
    height: 26px;
    padding: 0;
    border: none;
    background: transparent;
    cursor: pointer;
    border-radius: 4px;
    font-size: 12px;
    color: #333;
}

.editor-object-list-item .layer-btn:hover {
    background: #e5e5e5;
    color: #222;
}

.editor-object-placeholder {
    font-size: 13px;
    color: #666;
    padding: 10px 0;
}

.editor-object-fields label {
    display: block;
    margin-bottom: 12px;
    font-size: 12px;
    color: #333;
}

.editor-object-fields .editor-control-input {
    margin-top: 4px;
    width: 100%;
    box-sizing: border-box;
}

#editor-controls-object #control-opacity-value {
    color: #333;
    margin-left: 6px;
}

.editor-btn-sm {
    padding: 6px 12px;
    font-size: 12px;
}

/* Toolbar */
#editor-toolbar.custom-printful-editor-toolbar {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    background: #ffffff;
    border-bottom: 1px solid #ddd;
    flex-wrap: wrap;
}

.editor-toolbar-group {
    display: flex;
    gap: 8px;
    align-items: center;
}

.editor-btn {
    padding: 8px 16px;
    background: #0073aa;
    color: #ffffff;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: background-color 0.2s ease;
    white-space: nowrap;
}

.editor-btn:hover {
    background: #005a87;
}

.editor-btn:active {
    background: #004a6f;
}

.editor-btn:disabled {
    background: #ccc;
    cursor: not-allowed;
    opacity: 0.7;
}

.editor-btn .spinner {
    display: inline-block;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.editor-btn.active {
    background: #8b5cf6;
    box-shadow: 0 0 0 2px rgba(139, 92, 246, 0.3);
}

.editor-btn.active:hover {
    background: #7c3aed;
}

/* Toolbar form elements */
.editor-select,
.editor-input {
    padding: 6px 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 13px;
    background: #ffffff;
    color: #333;
    min-width: 120px;
}

.editor-select:focus,
.editor-input:focus {
    outline: none;
    border-color: #0073aa;
    box-shadow: 0 0 0 2px rgba(0, 115, 170, 0.1);
}

/* Snap to grid toggle (editor-layers-actions) */
.editor-snap-label {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin: 0;
    padding: 4px 0;
    cursor: pointer;
    font-size: 13px;
    color: #333;
    user-select: none;
}
.editor-snap-label input[type="checkbox"] {
    margin: 0;
    cursor: pointer;
}
.editor-snap-text {
    white-space: nowrap;
}

/* Font select dropdown - each option in its own font */
.font-select option {
    font-family: inherit;
}

.font-select option[value="Arial"] { font-family: Arial, sans-serif; }
.font-select option[value="Helvetica"] { font-family: Helvetica, sans-serif; }
.font-select option[value="Times New Roman"] { font-family: "Times New Roman", serif; }
.font-select option[value="Courier New"] { font-family: "Courier New", monospace; }
.font-select option[value="Verdana"] { font-family: Verdana, sans-serif; }
.font-select option[value="Georgia"] { font-family: Georgia, serif; }
.font-select option[value="Palatino"] { font-family: Palatino, serif; }
.font-select option[value="Garamond"] { font-family: Garamond, serif; }
.font-select option[value="Bookman"] { font-family: Bookman, serif; }
.font-select option[value="Comic Sans MS"] { font-family: "Comic Sans MS", cursive; }
.font-select option[value="Trebuchet MS"] { font-family: "Trebuchet MS", sans-serif; }
.font-select option[value="Arial Black"] { font-family: "Arial Black", sans-serif; }
.font-select option[value="Impact"] { font-family: Impact, sans-serif; }
.font-select option[value="Lucida Console"] { font-family: "Lucida Console", monospace; }
.font-select option[value="Tahoma"] { font-family: Tahoma, sans-serif; }
.font-select option[value="Roboto"] { font-family: "Roboto", sans-serif; }
.font-select option[value="Open Sans"] { font-family: "Open Sans", sans-serif; }
.font-select option[value="Lato"] { font-family: "Lato", sans-serif; }
.font-select option[value="Montserrat"] { font-family: "Montserrat", sans-serif; }
.font-select option[value="Oswald"] { font-family: "Oswald", sans-serif; }
.font-select option[value="Raleway"] { font-family: "Raleway", sans-serif; }
.font-select option[value="Playfair Display"] { font-family: "Playfair Display", serif; }
.font-select option[value="Merriweather"] { font-family: "Merriweather", serif; }
.font-select option[value="Ubuntu"] { font-family: "Ubuntu", sans-serif; }
.font-select option[value="Poppins"] { font-family: "Poppins", sans-serif; }

.editor-input {
    width: 60px;
    min-width: 60px;
}

.editor-color-picker {
    width: 50px;
    height: 36px;
    padding: 2px;
    border: 1px solid #ddd;
    border-radius: 4px;
    cursor: pointer;
    background: #ffffff;
}

.editor-color-picker::-webkit-color-swatch-wrapper {
    padding: 0;
}

.editor-color-picker::-webkit-color-swatch {
    border: none;
    border-radius: 3px;
}

/* Canvas Wrapper – zoom window left, canvas center; top aligned, enlarged */
#editor-canvas-wrapper.custom-printful-editor-canvas-wrapper {
    flex: 1;
    display: flex;
    flex-direction: row;
    align-items: flex-start;
    justify-content: center;
    padding: 20px;
    background: #fafafa;
    overflow: auto;
    min-height: 1000px;
    position: relative;
    gap: 16px;
}

/* Zoom window – in Product tab at top; shows magnified area under cursor */
#editor-zoom-window.editor-zoom-window {
    flex-shrink: 0;
    width: 100%;
    max-width: 100%;
    padding: 10px 0 14px;
    margin-bottom: 12px;
    border-bottom: 1px solid #eee;
    background: transparent;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
}

#editor-zoom-window .editor-zoom-window-label {
    font-size: 12px;
    font-weight: 600;
    color: #555;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

#editor-zoom-window .editor-zoom-canvas {
    display: block;
    width: 100%;
    max-width: 100%;
    height: auto;
    aspect-ratio: 1 / 1;
    border: 1px solid #e0e0e0;
    border-radius: 4px;
    background: #f5f5f5;
    cursor: default;
}

/* Canvas container: white background, no border. Top aligned. Fits expanded template. */
#editor-canvas-container.custom-printful-editor-canvas-container {
    position: relative;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    min-height: 1000px;
    width: 100%;
    min-width: 320px;
    background: #ffffff;
    border: none;
    box-shadow: none;
}

/* Fabric.js .canvas-container wrapper - no border, ensure visible and non-zero size */
#editor-canvas-container .canvas-container {
    position: relative;
    display: block;
    background: #ffffff;
    border: none;
    box-shadow: none;
    flex-shrink: 0;
    min-width: 960px;
    min-height: 960px;
    visibility: visible;
    opacity: 1;
}

/* Fabric lower/upper canvas - ensure visible; upper must be transparent so lower shows through */
#editor-canvas-container .canvas-container .lower-canvas,
#editor-canvas-container .canvas-container .upper-canvas,
#editor-canvas-container .canvas-container canvas {
    visibility: visible !important;
    opacity: 1 !important;
}
#editor-canvas-container .canvas-container .upper-canvas {
    background: transparent !important;
}

/* Canvas elements - no border, visible */
#editor-canvas-container .canvas-container canvas,
#editor-canvas.custom-printful-editor-canvas {
    border: none;
    border-radius: 0;
    background: #ffffff;
    box-shadow: none;
    cursor: crosshair;
    display: block;
}

/* Loading Spinner */
.editor-loading {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.9);
    z-index: 10;
}

.editor-loading-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #0073aa;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.editor-loading-text {
    margin-top: 12px;
    color: #666;
    font-size: 14px;
}

/* Responsive: top bar wraps; main layout stacks on small screens */
@media (max-width: 992px) {
    .cppe-layout-three-col .editor-layout {
        flex-wrap: wrap;
    }
    .cppe-layout-top-panel .editor-top-bar .editor-layers-panel {
        flex-direction: column;
        align-items: stretch;
    }
    .cppe-layout-top-panel .editor-top-bar .editor-panel-title {
        border-right: none;
        border-bottom: 1px solid #eee;
    }
    .editor-layers-toolbar {
        flex-direction: column;
        align-items: flex-start;
    }
    .editor-center {
        width: 100%;
    }
    .editor-controls-panel {
        width: 100%;
        max-height: 220px;
        border-left: none;
        border-top: 1px solid #ddd;
    }
}

@media (max-width: 768px) {
    #editor-container.custom-printful-editor-container {
        min-height: 400px;
    }
    .editor-layers-panel,
    .editor-controls-panel {
        min-width: 0;
    }
    #editor-canvas-wrapper.custom-printful-editor-canvas-wrapper {
        padding: 10px;
        min-height: 300px;
        position: relative;
        top: 0;
    }
    #editor-toolbar.custom-printful-editor-toolbar {
        padding: 8px 12px;
    }
    .editor-btn {
        padding: 6px 12px;
        font-size: 12px;
    }
}

/* Preview modal */
.editor-preview-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 100000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    box-sizing: border-box;
}

.editor-preview-modal-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    cursor: pointer;
}

.editor-preview-modal-content {
    position: relative;
    background: #fff;
    border-radius: 8px;
    padding: 16px;
    max-width: 95vw;
    max-height: 95vh;
    overflow: auto;
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.25);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
}

.editor-preview-modal-content img {
    max-width: 100%;
    height: auto;
    display: block;
}

.editor-preview-modal-close {
    flex-shrink: 0;
}

.editor-preview-modal-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    padding: 24px;
}
.editor-preview-modal-loading p {
    margin: 0;
    color: #555;
}
.editor-preview-spinner {
    display: inline-block;
    width: 28px;
    height: 28px;
    border: 3px solid #e2e8f0;
    border-top-color: #2563eb;
    border-radius: 50%;
    animation: editor-preview-spin 0.7s linear infinite;
}
@keyframes editor-preview-spin {
    to { transform: rotate(360deg); }
}
.editor-preview-modal-error {
    padding: 24px;
    color: #b91c1c;
}
.editor-preview-modal-error p {
    margin: 0;
}
.editor-preview-modal-mockups {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 12px;
    padding: 12px 0;
}
.editor-preview-modal-mockups img {
    max-width: 100%;
    height: auto;
    border-radius: 6px;
    border: 1px solid #e2e8f0;
}
.editor-preview-mockup-item {
    margin: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
}
.editor-preview-mockup-label {
    margin: 6px 0 0;
    font-size: 12px;
    text-transform: capitalize;
    color: #64748b;
}

/* Success/Info Notifications */
.editor-notification {
    position: fixed;
    top: 20px;
    right: 20px;
    padding: 12px 20px;
    border-radius: 4px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    z-index: 10000;
    font-size: 14px;
    font-weight: 500;
    opacity: 0;
    transform: translateX(100%);
    transition: all 0.3s ease;
    max-width: 300px;
}

.editor-notification.show {
    opacity: 1;
    transform: translateX(0);
}

.editor-notification-success {
    background: #10b981;
    color: #ffffff;
    border-left: 4px solid #059669;
}

.editor-notification-info {
    background: #3b82f6;
    color: #ffffff;
    border-left: 4px solid #2563eb;
}

.editor-notification-warning {
    background: #f59e0b;
    color: #ffffff;
    border-left: 4px solid #d97706;
}

/* Product tab: Preview section and mockups (main image + thumbnails) */
.editor-product-preview-section { margin-top: 1rem; }
#editor-product-mockups { margin-top: 0.75rem; }
#editor-product-mockups-loading,
#editor-product-mockups-error { margin-bottom: 0.5rem; }
.editor-product-mockups-loading-text,
.editor-product-mockups-error-text { font-size: 0.9em; color: #666; }
#editor-product-mockups .editor-product-mockup-main-wrap { margin-bottom: 0.5rem; max-width: 100%; overflow: hidden; border-radius: 4px; background: #f5f5f5; }
#editor-product-mockups #editor-product-mockup-main {
    display: block;
    max-width: 100%;
    height: auto;
    min-height: 0;
    cursor: pointer;
}
#editor-product-mockups #editor-product-mockup-main:hover { opacity: 0.9; }
/* Thumbnails: force small size so they never expand to main image size */
#editor-product-mockups .editor-product-mockup-thumbnails { display: flex; flex-wrap: wrap; gap: 6px; align-items: flex-start; }
#editor-product-mockups .editor-product-mockup-thumb {
    padding: 0;
    border: 2px solid transparent;
    border-radius: 4px;
    cursor: pointer;
    background: #f0f0f0;
    flex: 0 0 56px;
    width: 56px;
    min-width: 56px;
    height: 56px;
    overflow: hidden;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
}
#editor-product-mockups .editor-product-mockup-thumb:hover { border-color: #ccc; }
#editor-product-mockups .editor-product-mockup-thumb.active { border-color: #0073aa; }
#editor-product-mockups .editor-product-mockup-thumb img {
    display: block;
    width: 56px !important;
    height: 56px !important;
    min-width: 56px !important;
    min-height: 56px !important;
    max-width: 56px !important;
    max-height: 56px !important;
    object-fit: cover;
}

/* Dark mode support (optional) */
@media (prefers-color-scheme: dark) {
    #editor-container.custom-printful-editor-container {
        background: #1a1a1a;
        border-color: #333;
    }
    
    #editor-toolbar.custom-printful-editor-toolbar {
        background: #2a2a2a;
        border-bottom-color: #333;
    }
    
    #editor-canvas-wrapper.custom-printful-editor-canvas-wrapper {
        background: #1f1f1f;
    }
    
    #editor-canvas.custom-printful-editor-canvas {
        background: #ffffff;
    }
}
