/**
 * EpdProductDesigner Designer Styles
 *
 * @package EpdProductDesigner
 * @license GPL-2.0-or-later
 */

/* ==========================================================================
   TRANSITIONS: Hide designer until Fabric.js is ready, then fade in
   ========================================================================== */

.epdesigner-designer-wrapper:not([data-bundle-index]):not(.epdesigner-ready),
.epdesigner-bundle-wrapper:not(.epdesigner-ready) {
    opacity: 0;
}

.epdesigner-designer-wrapper:not([data-bundle-index]),
.epdesigner-bundle-wrapper {
    transition: opacity 0.3s ease-out;
}

/* ==========================================================================
   BASE: Main Wrapper & Canvas
   ========================================================================== */

.epdesigner-designer-wrapper {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    max-width: 100%;
    margin: 0 auto;
    padding: 20px 0;
}

.epdesigner-canvas-wrapper {
    flex: 1 1 calc(50% - 10px);
    min-width: 300px;
}

.epdesigner-canvas-wrapper h3 {
    margin: 0 0 15px 0;
    font-size: 1.3em;
    color: #333;
}

.epdesigner-change-product {
    margin: 0 0 10px 0;
}

.epdesigner-change-product a {
    color: #0073aa;
    text-decoration: none;
    font-size: 14px;
}

.epdesigner-change-product a:hover {
    text-decoration: underline;
}

.epdesigner-canvas-container {
    position: relative;
    background: #f5f5f5;
    border: 1px solid #ddd;
    border-radius: 4px;
}

.epdesigner-canvas-container .canvas-container {
    margin: 0;
}

.epdesigner-canvas-container canvas {
    display: block;
}

/* ==========================================================================
   BASE: Controls Section
   ========================================================================== */

.epdesigner-controls-wrapper {
    flex: 1 1 calc(50% - 10px);
    min-width: 300px;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

/* ==========================================================================
   OPTIONAL: Control Reordering (Two-columns & Stacked layouts only)
   
   To reorder controls, add this to your custom CSS and adjust the numbers:
   
   .epdesigner-tool-color { order: 1; }
   .epdesigner-tool-area { order: 2; }
   .epdesigner-tool-image { order: 3; }
   .epdesigner-tool-text { order: 4; }
   .epdesigner-tool-actions { order: 5; }
   .epdesigner-cf7-form-wrapper { order: 6; }
   
   Lower numbers appear first. Does NOT work with Compact layout.
   ========================================================================== */

.epdesigner-control-group {
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 4px;
    padding: 15px;
    box-sizing: border-box;
}

/* Control ordering - NOT applied by default to preserve natural HTML order.
   Users can enable reordering via custom CSS - see comment in .epdesigner-controls-wrapper above. */

.epdesigner-control-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: #333;
    font-size: 14px;
}

.epdesigner-control-group input[type="text"],
.epdesigner-control-group input[type="email"],
.epdesigner-control-group select,
.epdesigner-control-group textarea {
    width: 100%;
    padding: 10px;
    border: 1px solid #ccc;
    border-radius: 3px;
    font-size: 14px;
    box-sizing: border-box;
}

.epdesigner-control-group input[type="color"] {
    width: 50px;
    height: 36px;
    padding: 2px;
    border: 1px solid #ccc;
    border-radius: 3px;
    cursor: pointer;
}

.epdesigner-control-group textarea {
    min-height: 80px;
    resize: vertical;
}

.epdesigner-control-group small {
    display: block;
    margin-top: 5px;
    color: #666;
    font-size: 12px;
}

/* ==========================================================================
   BASE: Tools Row (wrapper for image + text + actions)
   ========================================================================== */

.epdesigner-tools-row {
    display: contents; /* Default: children flow normally */
}

/* ==========================================================================
   BASE: Text Style Options
   ========================================================================== */

.epdesigner-text-options {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 10px;
    align-items: flex-end;
}

.epdesigner-text-option-font {
    flex: 1 1 120px;
    min-width: 100px;
}

.epdesigner-text-option-font label {
    display: block;
    margin-bottom: 5px;
}

.epdesigner-text-option-font select {
    width: 100%;
    height: 36px;
    padding: 0 8px;
    border: 1px solid #ccc;
    border-radius: 3px;
    background: #f5f5f5;
    font-size: 14px;
}

.epdesigner-text-option-color {
    flex: 0 0 auto;
}

.epdesigner-text-option-color label {
    display: block;
    margin-bottom: 5px;
}

.epdesigner-text-option-color input[type="color"] {
    width: 36px;
    height: 36px;
    padding: 2px;
    border: 1px solid #ccc;
    border-radius: 3px;
    cursor: pointer;
    background: #f5f5f5;
    vertical-align: middle;
}

.epdesigner-text-option-color input[type="color"]::-webkit-color-swatch-wrapper {
    padding: 2px;
}

.epdesigner-text-option-color input[type="color"]::-webkit-color-swatch {
    border: none;
    border-radius: 2px;
}

.epdesigner-text-option-style {
    flex: 0 0 auto;
}

.epdesigner-text-option-style label {
    display: block;
    margin-bottom: 5px;
}

.epdesigner-style-buttons {
    display: flex;
    gap: 4px;
}

.epdesigner-style-btn {
    width: 36px;
    height: 36px;
    padding: 0;
    margin: 0;
    background: #f5f5f5;
    border: 1px solid #ccc;
    border-radius: 3px;
    cursor: pointer;
    font-size: 14px;
    line-height: 1;
    color: #333;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s ease;
}

.epdesigner-style-btn:hover {
    background: #e0e0e0;
    border-color: #999;
}

.epdesigner-style-btn:focus-visible {
    outline: 2px solid #0073aa;
    outline-offset: 2px;
}

.epdesigner-style-btn.active {
    background: #0073aa;
    border-color: #0073aa;
    color: #fff;
}

.epdesigner-style-btn strong {
    font-weight: 700;
}

.epdesigner-style-btn em {
    font-style: italic;
}

/* Font colors row (restricted colors) */
.epdesigner-font-colors-row {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid #eee;
}

.epdesigner-font-colors-row > label {
    font-size: 13px;
    color: #333;
    white-space: nowrap;
}

.epdesigner-font-color-swatches {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.epdesigner-font-color-swatch {
    width: 28px;
    height: 28px;
    border-radius: 4px;
    border: 2px solid #ddd;
    cursor: pointer;
    padding: 0;
    position: relative;
    transition: all 0.15s ease;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.epdesigner-font-color-swatch:hover {
    transform: scale(1.1);
    border-color: #999;
}

.epdesigner-font-color-swatch.active {
    border-color: #0073aa;
    box-shadow: 0 0 0 2px #0073aa;
}

.epdesigner-font-color-swatch:focus {
    outline: none;
    box-shadow: 0 0 0 2px #0073aa;
}

.epdesigner-font-color-swatch.active::after {
    content: '✓';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 12px;
    font-weight: bold;
    color: #fff;
    text-shadow: 0 1px 1px rgba(0, 0, 0, 0.5);
}

.epdesigner-font-color-swatch.active.light-color::after {
    color: #333;
    text-shadow: none;
}

/* ==========================================================================
   BASE: Image Upload Button
   ========================================================================== */

/* Visually hidden file input (sr-only pattern) */
.epdesigner-tool-image {
    position: relative;
    overflow: clip; /* clip prevents programmatic scroll-into-view on focus */
    display: flex;
    gap: 8px;
}

.epdesigner-upload-input {
    position: absolute;
    top: 0;
    left: 0;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.epdesigner-tool-image .epdesigner-upload-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    gap: 4px;
    padding: 12px 20px;
    margin-bottom: 0;
    background: #f5f5f5;
    border: 2px dashed #ccc;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.2s ease, border-color 0.2s ease, color 0.2s ease;
    color: #666;
    flex: 1 1 0;
    min-width: 0;
    box-sizing: border-box;
}

.epdesigner-tool-image .epdesigner-upload-btn:hover {
    background: #e8f4fc;
    border-color: #0073aa;
    color: #0073aa;
}

.epdesigner-tool-image .epdesigner-upload-btn.epdesigner-uploading {
    pointer-events: none;
    position: relative;
}

.epdesigner-tool-image .epdesigner-upload-btn.epdesigner-uploading > * {
    visibility: hidden;
}

.epdesigner-tool-image .epdesigner-upload-btn.epdesigner-uploading::after {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    width: 24px;
    height: 24px;
    margin-top: -15px;
    margin-left: -15px;
    border: 3px solid #ddd;
    border-top-color: #0073aa;
    border-radius: 50%;
    animation: epdesigner-spin 0.7s linear infinite;
}

.epdesigner-upload-icon {
    display: flex;
    align-items: center;
    justify-content: center;
}

.epdesigner-upload-icon svg {
    width: 28px;
    height: 28px;
}

.epdesigner-upload-text {
    font-size: 12px;
    font-weight: 500;
}

.epdesigner-upload-hint {
    font-size: 9px;
    color: #767676;
    font-weight: 400;
}

/* ==========================================================================
   BASE: Image Library Button
   ========================================================================== */

.epdesigner-library-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    gap: 4px;
    padding: 12px 20px;
    margin-bottom: 0;
    background: #f5f5f5;
    border: 2px dashed #ccc;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.2s ease, border-color 0.2s ease, color 0.2s ease;
    color: #666;
    flex: 1 1 0;
    min-width: 0;
    box-sizing: border-box;
    font-family: inherit;
    font-size: inherit;
}

.epdesigner-library-btn:hover {
    background: #e8f4fc;
    border-color: #0073aa;
    color: #0073aa;
}

.epdesigner-library-btn:focus-visible {
    outline: 2px solid #0073aa;
    outline-offset: 2px;
}

.epdesigner-library-icon {
    display: flex;
    align-items: center;
    justify-content: center;
}

.epdesigner-library-icon svg {
    width: 28px;
    height: 28px;
}

.epdesigner-library-text {
    font-size: 12px;
    font-weight: 500;
}

/* ==========================================================================
   BASE: Image Library Modal
   ========================================================================== */

.epdesigner-library-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 100000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.epdesigner-library-modal-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
}

.epdesigner-library-modal-content {
    position: relative;
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.2);
    max-width: 600px;
    width: 90%;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

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

.epdesigner-library-modal-header h3 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
    color: #1d2327;
}

.epdesigner-library-modal-close {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: #666;
    padding: 0;
    line-height: 1;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
}

.epdesigner-library-modal-close:hover {
    color: #1d2327;
    background: #f0f0f0;
}

.epdesigner-library-modal-close:focus-visible {
    outline: 2px solid #0073aa;
    outline-offset: 2px;
}

.epdesigner-library-modal .epdesigner-library-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    gap: 12px;
    padding: 20px;
    overflow-y: auto;
}

.epdesigner-library-item {
    aspect-ratio: 1;
    border: 2px solid #ddd;
    border-radius: 8px;
    overflow: hidden;
    cursor: pointer;
    background: #f5f5f5;
    padding: 0;
    transition: border-color 0.2s ease, transform 0.15s ease;
}

.epdesigner-library-item:hover {
    border-color: #0073aa;
    transform: scale(1.03);
}

.epdesigner-library-item:focus-visible {
    outline: 2px solid #0073aa;
    outline-offset: 2px;
}

.epdesigner-library-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

/* ==========================================================================
   BASE: Color Swatches (Product Colors)
   ========================================================================== */

.epdesigner-color-selector {
    padding-bottom: 10px;
}

.epdesigner-color-swatches {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 8px;
}

/* Mask selector row with color picker */
.epdesigner-mask-selector-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 5px;
}

.epdesigner-mask-selector-row select {
    flex: 1;
}

.epdesigner-mask-selector-row input[type="color"] {
    width: 36px;
    height: 32px;
    padding: 2px;
    border: 2px solid #ddd;
    border-radius: 4px;
    cursor: pointer;
    background: #fff;
}

.epdesigner-mask-selector-row input[type="color"]:hover {
    border-color: #0073aa;
}

.epdesigner-btn-small {
    padding: 4px 8px;
    font-size: 12px;
    line-height: 1;
    min-width: auto;
}

.epdesigner-btn-small .dashicons {
    font-size: 16px;
    width: 16px;
    height: 16px;
    line-height: 16px;
}

.epdesigner-clear-mask-color {
    background: #f0f0f0;
    border-color: #ddd;
    color: #666;
}

.epdesigner-clear-mask-color::before {
    content: '×';
    font-size: 18px;
    font-weight: bold;
    line-height: 1;
}

.epdesigner-clear-mask-color:hover {
    background: #e0e0e0;
    color: #333;
}

.epdesigner-clear-mask-color:focus-visible {
    outline: 2px solid #0073aa;
    outline-offset: 2px;
}

/* Product color picker (free picker mode) */
.epdesigner-product-color-picker {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 8px;
}

.epdesigner-product-color-picker input[type="color"] {
    width: 60px;
    height: 36px;
    padding: 2px;
    border: 2px solid #ddd;
    border-radius: 6px;
    cursor: pointer;
    background: #fff;
}

.epdesigner-product-color-picker input[type="color"]:hover {
    border-color: #0073aa;
}

.epdesigner-product-color-picker .epdesigner-reset-product-color {
    padding: 6px 12px;
    font-size: 13px;
}

.epdesigner-color-swatch {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: 3px solid #ddd;
    cursor: pointer;
    padding: 0;
    position: relative;
    transition: all 0.15s ease;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.15);
}

.epdesigner-color-swatch:hover {
    transform: scale(1.1);
    border-color: #999;
}

.epdesigner-color-swatch.active {
    border-color: #0073aa;
    box-shadow: 0 0 0 2px #fff, 0 0 0 4px #0073aa;
}

.epdesigner-color-swatch:focus {
    outline: none;
    box-shadow: 0 0 0 2px #fff, 0 0 0 4px #0073aa;
}

.epdesigner-color-swatch.active::after {
    content: '✓';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 16px;
    font-weight: bold;
    color: #fff;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
}

.epdesigner-color-swatch.active.light-color::after {
    color: #333;
    text-shadow: none;
}

/* ==========================================================================
   BASE: Buttons
   ========================================================================== */

.epdesigner-btn {
    display: inline-block;
    padding: 10px 20px;
    background: #0073aa;
    color: #fff;
    border: none;
    border-radius: 3px;
    cursor: pointer;
    font-size: 14px;
    text-align: center;
    text-decoration: none;
    transition: background-color 0.2s ease;
}

.epdesigner-btn:hover {
    background: #005177;
    color: #fff;
}

.epdesigner-btn:focus {
    outline: 2px solid #0073aa;
    outline-offset: 2px;
}

.epdesigner-btn-secondary {
    background: #f0f0f0;
    color: #333;
}

.epdesigner-btn-secondary:hover {
    background: #ddd;
    color: #333;
}

.epdesigner-btn-group {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

#epdesigner-add-text {
    margin-top: 10px;
}

/* ==========================================================================
   BASE: Product Selector & Messages
   ========================================================================== */

.epdesigner-product-selector {
    max-width: 400px;
    margin: 20px auto;
    text-align: center;
}

.epdesigner-product-selector label {
    display: block;
    margin-bottom: 10px;
    font-weight: 600;
}

.epdesigner-product-selector .epdesigner-select {
    width: 100%;
    padding: 12px;
    font-size: 16px;
    border: 1px solid #ccc;
    border-radius: 4px;
}

.epdesigner-error {
    background: #fef0f0;
    border: 1px solid #f5c6cb;
    color: #721c24;
    padding: 15px;
    border-radius: 4px;
    text-align: center;
}

.epdesigner-success {
    background: #d4edda;
    border: 1px solid #c3e6cb;
    color: #155724;
    padding: 15px;
    border-radius: 4px;
    text-align: center;
}

.epdesigner-notice {
    background: #fff3cd;
    border: 1px solid #ffc107;
    color: #856404;
    padding: 15px;
    border-radius: 4px;
    text-align: center;
}


/* ==========================================================================
   BASE: Loading State
   ========================================================================== */

.epdesigner-loading {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
}

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

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

/* ==========================================================================
   BASE: Layer Toolbar (Floating)
   ========================================================================== */

.epdesigner-layer-toolbar {
    position: absolute;
    z-index: 50;
    display: flex;
    gap: 4px;
    background: rgba(255, 255, 255, 0.95);
    border: 1px solid #ccc;
    border-radius: 4px;
    padding: 4px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    pointer-events: auto;
}

.epdesigner-layer-btn {
    width: 28px;
    height: 28px;
    padding: 0;
    margin: 0;
    background: #f5f5f5;
    border: 1px solid #ddd;
    border-radius: 3px;
    cursor: pointer;
    font-size: 12px;
    line-height: 1;
    color: #333;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s ease;
}

.epdesigner-layer-btn:hover {
    background: #0073aa;
    border-color: #0073aa;
    color: #fff;
}

.epdesigner-layer-btn:active {
    transform: scale(0.95);
}

.epdesigner-layer-btn:focus-visible {
    outline: 2px solid #0073aa;
    outline-offset: 2px;
}

/* ==========================================================================
   BASE: Mask Selector & Form Styles
   ========================================================================== */

.epdesigner-mask-tabs {
    display: flex;
    gap: 5px;
    margin-bottom: 10px;
}

.epdesigner-mask-tab {
    padding: 8px 15px;
    background: #f0f0f0;
    border: 1px solid #ddd;
    border-radius: 3px;
    cursor: pointer;
    font-size: 13px;
    transition: all 0.2s ease;
}

.epdesigner-mask-tab:hover {
    background: #e0e0e0;
}

.epdesigner-mask-tab.active {
    background: #0073aa;
    color: #fff;
    border-color: #0073aa;
}

.epdesigner-form-row {
    margin-bottom: 15px;
}

.epdesigner-form-row:last-child {
    margin-bottom: 0;
}

.epdesigner-required {
    color: #d63638;
}

.epdesigner-hp-field {
    position: absolute;
    left: -9999px;
    top: -9999px;
}

/* ==========================================================================
   LAYOUT: Stacked (epdesigner-form-below)
   ========================================================================== */

.epdesigner-form-below {
    flex-direction: column;
}

.epdesigner-form-below .epdesigner-canvas-wrapper,
.epdesigner-form-below .epdesigner-controls-wrapper {
    flex: 0 0 auto;
    width: 100%;
    min-width: 0;
}

/* ==========================================================================
   LAYOUT: Two Columns (epdesigner-form-beside) - Default
   ========================================================================== */

/* Text controls in one row: TEXT | FONT | BOLD | ITALIC | COLOR | ADD TEXT */
.epdesigner-form-beside .epdesigner-tool-text {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 8px;
}

.epdesigner-form-beside .epdesigner-tool-text > label {
    display: none;
}

.epdesigner-form-beside .epdesigner-tool-text > input[type="text"] {
    flex: 1 1 120px;
    min-width: 100px;
    height: 36px;
    margin: 0;
}

.epdesigner-form-beside .epdesigner-text-options {
    flex: 0 0 auto;
    display: flex;
    flex-wrap: nowrap;
    gap: 8px;
    margin-top: 0;
    align-items: flex-end;
}

.epdesigner-form-beside .epdesigner-text-option-font,
.epdesigner-form-beside .epdesigner-text-option-color,
.epdesigner-form-beside .epdesigner-text-option-style {
    flex: 0 0 auto;
}

.epdesigner-form-beside .epdesigner-text-option-font {
    min-width: 90px;
    flex: 0 0 auto;
}

.epdesigner-form-beside .epdesigner-text-option-font label,
.epdesigner-form-beside .epdesigner-text-option-color label,
.epdesigner-form-beside .epdesigner-text-option-style label {
    display: none;
}

/* Add Text button stays on first row */
.epdesigner-form-beside .epdesigner-tool-text #epdesigner-add-text {
    flex: 0 0 auto;
    margin-top: 0;
}

/* Font colors row - shares second row with Add Text button */
.epdesigner-form-beside .epdesigner-font-colors-row {
    flex: 1 0 auto;
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid #eee;
}

.epdesigner-form-beside .epdesigner-font-colors-row > label {
    display: inline-block;
    font-size: 12px;
    white-space: nowrap;
}

/* When restricted colors exist, Add Text stays on same row, pushed right */
.epdesigner-form-beside .epdesigner-tool-text:has(.epdesigner-font-colors-row) #epdesigner-add-text {
    flex: 0 0 auto;
    margin-top: 8px;
    margin-left: auto;
}

/* Upload button in beside layout */
.epdesigner-form-beside .epdesigner-upload-btn {
    width: 100%;
    padding: 15px 20px;
    box-sizing: border-box;
}

/* ==========================================================================
   LAYOUT: Compact (epdesigner-form-compact)
   ========================================================================== */

.epdesigner-form-compact {
    display: flex;
    flex-wrap: nowrap;
    align-items: flex-start;
    gap: 15px;
}

.epdesigner-form-compact .epdesigner-canvas-wrapper {
    flex: 1 1 50%;
    min-width: 300px;
}

.epdesigner-form-compact .epdesigner-controls-wrapper {
    flex: 1 1 50%;
    min-width: 280px;
    gap: 8px;
}

.epdesigner-form-compact .epdesigner-control-group {
    padding: 10px;
}

/* Compact layout: tools-row creates own flex context
   This overrides display:contents and uses its own internal layout */
.epdesigner-form-compact .epdesigner-tools-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: flex-start;
}

/* Compact upload button - stays on first row */
.epdesigner-form-compact .epdesigner-tool-image.epdesigner-control-group {
    flex: 0 0 auto;
    padding: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    order: 0;
}

.epdesigner-form-compact .epdesigner-tool-image.epdesigner-control-group label {
    margin-bottom: 0;
}

.epdesigner-form-compact .epdesigner-upload-btn {
    width: 40px;
    height: 40px;
    padding: 0;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 40px;
}

.epdesigner-form-compact .epdesigner-upload-icon {
    display: flex;
    align-items: center;
    justify-content: center;
}

.epdesigner-form-compact .epdesigner-upload-icon svg {
    width: 20px;
    height: 20px;
}

.epdesigner-form-compact .epdesigner-upload-text,
.epdesigner-form-compact .epdesigner-upload-hint {
    display: none;
}

/* Compact: library button as icon button next to upload */
.epdesigner-form-compact .epdesigner-library-btn {
    width: 40px;
    height: 40px;
    padding: 0;
    margin-bottom: 0;
    border-radius: 4px;
    flex: 0 0 40px;
}

.epdesigner-form-compact .epdesigner-library-icon svg {
    width: 20px;
    height: 20px;
}

.epdesigner-form-compact .epdesigner-library-text {
    display: none;
}

/* Text controls inline - shares row with image */
.epdesigner-form-compact .epdesigner-tool-text {
    flex: 1 1 0;
    min-width: 200px;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    order: 1;
}

.epdesigner-form-compact .epdesigner-tool-text > label {
    display: none;
}

.epdesigner-form-compact .epdesigner-tool-text > input[type="text"] {
    flex: 1 1 100px;
    min-width: 80px;
    height: 34px;
    padding: 6px 10px;
    font-size: 13px;
}

.epdesigner-form-compact .epdesigner-text-options {
    display: flex;
    flex-wrap: nowrap;
    gap: 4px;
    margin-top: 0;
    align-items: center;
}

.epdesigner-form-compact .epdesigner-text-option-font,
.epdesigner-form-compact .epdesigner-text-option-color,
.epdesigner-form-compact .epdesigner-text-option-style {
    flex: 0 0 auto;
}

.epdesigner-form-compact .epdesigner-text-option-font {
    min-width: 90px;
    max-width: 120px;
}

.epdesigner-form-compact .epdesigner-text-option-font label,
.epdesigner-form-compact .epdesigner-text-option-color label,
.epdesigner-form-compact .epdesigner-text-option-style label {
    display: none;
}

.epdesigner-form-compact .epdesigner-text-option-font select {
    height: 34px;
    padding: 0 6px;
    font-size: 12px;
}

.epdesigner-form-compact .epdesigner-text-option-color input[type="color"] {
    width: 34px;
    height: 34px;
}

.epdesigner-form-compact .epdesigner-style-btn {
    width: 34px;
    height: 34px;
}

.epdesigner-form-compact .epdesigner-tool-text #epdesigner-add-text {
    margin-top: 0;
    padding: 6px 12px;
    height: 34px;
    font-size: 12px;
    white-space: nowrap;
}

/* Font colors row - shares second row with Add Text button */
.epdesigner-form-compact .epdesigner-font-colors-row {
    flex: 1 0 auto;
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 4px;
    padding-top: 6px;
    border-top: 1px solid #eee;
}

.epdesigner-form-compact .epdesigner-font-colors-row > label {
    font-size: 11px;
    white-space: nowrap;
}

.epdesigner-form-compact .epdesigner-font-color-swatch {
    width: 24px;
    height: 24px;
}

/* When restricted colors exist, Add Text stays on same row, pushed right */
.epdesigner-form-compact .epdesigner-tool-text:has(.epdesigner-font-colors-row) #epdesigner-add-text {
    flex: 0 0 auto;
    margin-top: 4px;
    margin-left: auto;
}

/* Actions: full width below tools */
.epdesigner-form-compact .epdesigner-canvas-actions {
    flex: 0 0 100%;
    padding: 8px;
    order: 2;
}

.epdesigner-form-compact .epdesigner-canvas-actions .epdesigner-btn-group {
    gap: 6px;
}

.epdesigner-form-compact .epdesigner-canvas-actions .epdesigner-btn {
    padding: 6px 10px;
    font-size: 12px;
}

/* Smaller elements */
.epdesigner-form-compact .epdesigner-color-selector {
    padding: 10px;
}

.epdesigner-form-compact .epdesigner-color-selector > label {
    font-size: 12px;
    margin-bottom: 6px;
}

.epdesigner-form-compact .epdesigner-color-swatches {
    gap: 6px;
    margin-top: 6px;
}

.epdesigner-form-compact .epdesigner-color-swatch {
    width: 30px;
    height: 30px;
}

.epdesigner-form-compact .epdesigner-control-group > label[for="epdesigner-mask-select"] {
    font-size: 12px;
    margin-bottom: 4px;
}

.epdesigner-form-compact #epdesigner-mask-select {
    padding: 6px 8px;
    font-size: 13px;
}

/* ==========================================================================
   RESPONSIVE: General
   ========================================================================== */

@media (max-width: 1024px) {
    .epdesigner-designer-wrapper {
        flex-direction: column;
        padding: 10px 0;
    }

    .epdesigner-canvas-wrapper,
    .epdesigner-controls-wrapper {
        flex: 1 1 100%;
        min-width: 0;
    }
}

@media (max-width: 900px) {
    /* Compact falls back to stacked */
    .epdesigner-form-compact {
        flex-wrap: wrap;
    }
    
    .epdesigner-form-compact .epdesigner-canvas-wrapper,
    .epdesigner-form-compact .epdesigner-controls-wrapper {
        flex: 1 1 100%;
        max-width: 100%;
    }
}

@media (max-width: 768px) {
    .epdesigner-designer-wrapper {
        gap: 15px;
        padding: 10px;
    }

    .epdesigner-canvas-wrapper {
        min-width: 0;
        width: 100%;
    }

    .epdesigner-canvas-container {
        max-width: 100%;
        overflow-x: auto;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }

    .epdesigner-controls-wrapper {
        min-width: 0;
        width: 100%;
        gap: 5px;
    }

    .epdesigner-control-group {
        padding: 12px;
    }

    /* Keep buttons normal size, only stack button groups */
    .epdesigner-btn-group {
        flex-direction: column;
    }

    .epdesigner-btn-group .epdesigner-btn {
        width: 100%;
    }

    /* Stack text controls */
    .epdesigner-form-beside .epdesigner-tool-text {
        flex-direction: column;
        align-items: stretch;
    }
    
    .epdesigner-form-beside .epdesigner-tool-text > input[type="text"] {
        flex: 1 1 auto;
        width: 100%;
    }
    
    .epdesigner-form-beside .epdesigner-text-options {
        flex-wrap: wrap;
    }
    
    .epdesigner-form-beside .epdesigner-text-option-font {
        flex: 1 1 100%;
    }

    /* Modal: near full-screen on mobile */
    .epdesigner-library-modal-content {
        width: 95%;
        max-height: 85vh;
    }

    .epdesigner-library-modal .epdesigner-library-grid {
        grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
        gap: 8px;
        padding: 12px;
    }
}

@media (max-width: 480px) {
    .epdesigner-designer-wrapper {
        padding: 5px;
        gap: 10px;
    }

    .epdesigner-canvas-wrapper h3 {
        font-size: 1.1em;
        margin-bottom: 10px;
    }

    .epdesigner-control-group {
        padding: 10px;
    }

    .epdesigner-control-group label {
        font-size: 13px;
    }

    .epdesigner-control-group input,
    .epdesigner-control-group select,
    .epdesigner-control-group textarea {
        font-size: 16px;
        padding: 10px;
    }
}

/* Touch device improvements - minimal enlargements */
@media (hover: none) and (pointer: coarse) {
    .epdesigner-control-group input,
    .epdesigner-control-group textarea {
        font-size: 16px; /* Prevent iOS zoom */
    }

    .epdesigner-control-group select {
        font-size: 16px; /* Prevent iOS zoom */
    }

    .epdesigner-layer-btn {
        width: 36px;
        height: 36px;
        font-size: 14px;
    }
}

/* ==========================================================================
   MOBILE TABS (when epdesigner-mobile-tabs class is present)
   ========================================================================== */

/* Hide tabs by default */
.epdesigner-tool-tabs {
    display: none;
}

@media (max-width: 768px) {
    

    /* Show tabs when enabled */
    .epdesigner-mobile-tabs .epdesigner-tool-tabs {
        display: flex;
        width: 100%;
        margin-bottom: 10px;
        border-radius: 8px;
        overflow-x: auto;
        overflow-y: hidden;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        -ms-overflow-style: none;
        border: 1px solid #ddd;
    }

    .epdesigner-mobile-tabs .epdesigner-tool-tabs::-webkit-scrollbar {
        display: none;
    }

    .epdesigner-tool-tab {
        flex: 1 0 auto;
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 4px;
        padding: 10px 8px;
        border: none;
        border-right: 1px solid #ddd;
        background: #f5f5f5;
        color: #666;
        font-size: 12px;
        font-weight: 500;
        white-space: nowrap;
        cursor: pointer;
        transition: all 0.2s ease;
    }

    

    .epdesigner-tool-tab:last-child {
        border-right: none;
    }

    .epdesigner-tool-tab.active {
        background: #0073aa;
        color: #fff;
    }

    .epdesigner-tool-tab:focus-visible {
        outline: 2px solid #0073aa;
        outline-offset: 2px;
    }

    .epdesigner-tool-tab svg {
        flex-shrink: 0;
        width: 16px;
        height: 16px;
    }

    /* Reorder: tools first, then colors */
    .epdesigner-mobile-tabs .epdesigner-controls-wrapper {
        display: flex;
        flex-direction: column;
    }

    .epdesigner-mobile-tabs .epdesigner-tools-row {
        order: 1;
        display: flex !important;
        flex-direction: column;
    }

    .epdesigner-mobile-tabs .epdesigner-color-selector {
        order: 2;
    }

    .epdesigner-mobile-tabs .epdesigner-cf7-form-wrapper,
    .epdesigner-mobile-tabs #epdesigner-designer-form {
        order: 3;
    }

    /* Hide panels by default */
    .epdesigner-mobile-tabs .epdesigner-tool-area,
    .epdesigner-mobile-tabs .epdesigner-tool-color,
    .epdesigner-mobile-tabs .epdesigner-tool-image,
    .epdesigner-mobile-tabs .epdesigner-tool-text,
    .epdesigner-mobile-tabs .epdesigner-tool-actions {
        display: none !important;
    }

    /* Show active panel - Area */
    .epdesigner-mobile-tabs .epdesigner-tool-area.epdesigner-tab-active {
        display: block !important;
        width: 100%;
        padding: 15px;
        background: #f9f9f9;
        border-radius: 4px;
    }

    .epdesigner-mobile-tabs .epdesigner-tool-area.epdesigner-tab-active label {
        display: block;
        margin-bottom: 8px;
        font-weight: 500;
    }

    .epdesigner-mobile-tabs .epdesigner-tool-area.epdesigner-tab-active .epdesigner-mask-selector-row {
        display: flex;
        gap: 8px;
        align-items: center;
    }

    .epdesigner-mobile-tabs .epdesigner-tool-area.epdesigner-tab-active select {
        flex: 1;
        height: 40px;
        font-size: 16px;
    }

    /* Show active panel - Color */
    .epdesigner-mobile-tabs .epdesigner-tool-color.epdesigner-tab-active {
        display: block !important;
        width: 100%;
        padding: 15px;
        background: #f9f9f9;
        border-radius: 4px;
    }

    .epdesigner-mobile-tabs .epdesigner-tool-color.epdesigner-tab-active > label {
        display: block;
        margin-bottom: 10px;
        font-weight: 500;
    }

    .epdesigner-mobile-tabs .epdesigner-tool-color.epdesigner-tab-active .epdesigner-color-swatches {
        display: flex;
        flex-wrap: wrap;
        gap: 8px;
        justify-content: flex-start;
    }

    .epdesigner-mobile-tabs .epdesigner-tool-color.epdesigner-tab-active .epdesigner-color-swatch {
        width: 40px;
        height: 40px;
    }

    .epdesigner-mobile-tabs .epdesigner-tool-color.epdesigner-tab-active .epdesigner-product-color-picker {
        display: flex;
        gap: 10px;
        align-items: center;
    }

    .epdesigner-mobile-tabs .epdesigner-tool-color.epdesigner-tab-active .epdesigner-product-color-picker input[type="color"] {
        width: 50px;
        height: 40px;
    }

    /* Show active panel - Image */
    .epdesigner-mobile-tabs .epdesigner-tool-image.epdesigner-tab-active {
        display: flex !important;
        width: 100%;
        gap: 8px;
    }

    .epdesigner-mobile-tabs .epdesigner-tool-image.epdesigner-tab-active .epdesigner-upload-btn {
        height: auto;
        padding: 16px 12px;
        flex-direction: column;
        gap: 8px;
    }

    .epdesigner-mobile-tabs .epdesigner-tool-image.epdesigner-tab-active .epdesigner-upload-icon svg {
        width: 32px;
        height: 32px;
    }

    .epdesigner-mobile-tabs .epdesigner-tool-image.epdesigner-tab-active .epdesigner-upload-text,
    .epdesigner-mobile-tabs .epdesigner-tool-image.epdesigner-tab-active .epdesigner-upload-hint {
        display: block;
    }

    /* Mobile tab: library button side by side with upload */
    .epdesigner-mobile-tabs .epdesigner-tool-image.epdesigner-tab-active .epdesigner-library-btn {
        padding: 16px 12px;
    }

    /* Text Tab: TEXT input on row 1, FONT|BOLD|ITALIC|COLOR on row 2, RESTRICTED COLORS|ADD TEXT on row 3 */
    .epdesigner-mobile-tabs .epdesigner-tool-text.epdesigner-tab-active {
        display: flex !important;
        flex-wrap: wrap;
        gap: 10px;
        width: 100%;
    }

    .epdesigner-mobile-tabs .epdesigner-tool-text.epdesigner-tab-active > label {
        display: none;
    }

    /* Row 1: Text input - full width */
    .epdesigner-mobile-tabs .epdesigner-tool-text.epdesigner-tab-active > input[type="text"] {
        flex: 1 1 100%;
        width: 100%;
        height: 40px;
        font-size: 16px;
    }

    /* Row 2: FONT | BOLD | ITALIC | COLOR - all inline, full width */
    .epdesigner-mobile-tabs .epdesigner-tool-text.epdesigner-tab-active .epdesigner-text-options {
        flex: 1 1 100%;
        display: flex;
        flex-wrap: nowrap;
        gap: 8px;
        align-items: center;
    }

    .epdesigner-mobile-tabs .epdesigner-tool-text.epdesigner-tab-active .epdesigner-text-option-font {
        flex: 1 1 auto;
        min-width: 80px;
    }

    .epdesigner-mobile-tabs .epdesigner-tool-text.epdesigner-tab-active .epdesigner-text-option-font label,
    .epdesigner-mobile-tabs .epdesigner-tool-text.epdesigner-tab-active .epdesigner-text-option-color label,
    .epdesigner-mobile-tabs .epdesigner-tool-text.epdesigner-tab-active .epdesigner-text-option-style label {
        display: none;
    }

    .epdesigner-mobile-tabs .epdesigner-tool-text.epdesigner-tab-active .epdesigner-text-option-font select {
        width: 100%;
        height: 36px;
        font-size: 14px;
    }

    .epdesigner-mobile-tabs .epdesigner-tool-text.epdesigner-tab-active #epdesigner-color-picker {
        width: 36px;
        height: 36px;
    }

    .epdesigner-mobile-tabs .epdesigner-tool-text.epdesigner-tab-active .epdesigner-style-btn {
        width: 36px;
        height: 36px;
    }

    /* Row 3: RESTRICTED COLORS + ADD TEXT button on same row */
    .epdesigner-mobile-tabs .epdesigner-tool-text.epdesigner-tab-active .epdesigner-font-colors-row {
        flex: 1 1 auto;
        display: flex;
        align-items: center;
        gap: 10px;
        margin-top: 0;
        padding-top: 8px;
        border-top: 1px solid #eee;
    }

    .epdesigner-mobile-tabs .epdesigner-tool-text.epdesigner-tab-active .epdesigner-font-colors-row > label {
        display: block;
        font-size: 12px;
        white-space: nowrap;
    }

    /* Add Text button - full width when no restricted colors */
    .epdesigner-mobile-tabs .epdesigner-tool-text.epdesigner-tab-active #epdesigner-add-text {
        flex: 1 1 100%;
        margin-top: 0;
        padding: 10px 16px;
        font-size: 14px;
    }

    /* When restricted colors exist, Add Text shares row with them */
    .epdesigner-mobile-tabs .epdesigner-tool-text.epdesigner-tab-active:has(.epdesigner-font-colors-row) #epdesigner-add-text {
        flex: 0 0 auto;
        margin-left: auto;
    }

    .epdesigner-mobile-tabs .epdesigner-tool-actions.epdesigner-tab-active {
        display: block !important;
        width: 100%;
        padding: 10px;
    }

    .epdesigner-mobile-tabs .epdesigner-tool-actions.epdesigner-tab-active .epdesigner-btn-group {
        flex-direction: column;
        gap: 8px;
    }

    .epdesigner-mobile-tabs .epdesigner-tool-actions.epdesigner-tab-active .epdesigner-btn {
        width: 100%;
        padding: 10px 16px;
        font-size: 14px;
    }
}

/* ==========================================================================
   PRODUCT GRID (Visual Selector)
   ========================================================================== */

.epdesigner-product-grid {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px 0;
}

.epdesigner-product-grid .epdesigner-grid-title {
    margin: 0 0 20px 0;
    font-size: 1.4em;
    color: #333;
    text-align: center;
}

.epdesigner-grid-items {
    display: grid;
    gap: 20px;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
}

.epdesigner-grid-items[data-count="1"] {
    grid-template-columns: 1fr;
    max-width: 400px;
    margin: 0 auto;
}

.epdesigner-grid-items[data-count="2"] {
    grid-template-columns: repeat(2, 1fr);
    max-width: 600px;
    margin: 0 auto;
}

.epdesigner-grid-items[data-count="3"] {
    grid-template-columns: repeat(3, 1fr);
    max-width: 800px;
    margin: 0 auto;
}

.epdesigner-grid-items[data-count="4"] {
    grid-template-columns: repeat(4, 1fr);
}

.epdesigner-grid-item {
    display: block;
    text-decoration: none;
    background: #fff;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    overflow: hidden;
    transition: all 0.2s ease;
    text-align: center;
}

.epdesigner-grid-item:hover {
    border-color: #0073aa;
    box-shadow: 0 4px 12px rgba(0, 115, 170, 0.2);
    transform: translateY(-2px);
}

.epdesigner-grid-item:focus {
    outline: none;
    border-color: #0073aa;
    box-shadow: 0 0 0 3px rgba(0, 115, 170, 0.3);
}

.epdesigner-grid-image {
    width: 100%;
    aspect-ratio: 1 / 1;
    overflow: hidden;
    background: #f9f9f9;
    display: flex;
    align-items: center;
    justify-content: center;
}

.epdesigner-grid-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.2s ease;
}

.epdesigner-grid-item:hover .epdesigner-grid-image img {
    transform: scale(1.05);
}

.epdesigner-grid-item .epdesigner-grid-title {
    padding: 12px 10px;
    font-size: 14px;
    font-weight: 600;
    color: #333;
    background: #fff;
    border-top: 1px solid #eee;
    margin: 0;
    text-align: center;
}

.epdesigner-grid-item:hover .epdesigner-grid-title {
    color: #0073aa;
}

.epdesigner-grid-item .epdesigner-grid-excerpt {
    padding: 0 10px 12px;
    font-size: 12px;
    color: #666;
    background: #fff;
    margin: 0;
    text-align: center;
    line-height: 1.4;
}

@media (max-width: 768px) {
    .epdesigner-grid-items[data-count="2"],
    .epdesigner-grid-items[data-count="3"],
    .epdesigner-grid-items[data-count="4"] {
        grid-template-columns: repeat(2, 1fr);
        max-width: none;
    }
}

@media (max-width: 480px) {
    .epdesigner-grid-items[data-count="2"],
    .epdesigner-grid-items[data-count="3"],
    .epdesigner-grid-items[data-count="4"] {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 600px) {
    .epdesigner-grid-items {
        grid-template-columns: repeat(2, 1fr);
        gap: 12px;
    }
    
    .epdesigner-grid-item .epdesigner-grid-title {
        padding: 10px 8px;
        font-size: 13px;
    }
    
    .epdesigner-grid-item .epdesigner-grid-excerpt {
        padding: 0 8px 10px;
        font-size: 11px;
    }
}

@media (max-width: 400px) {
    .epdesigner-grid-items {
        grid-template-columns: 1fr;
    }
}



/* ==========================================================================
   Notice Messages
   ========================================================================== */

.epdesigner-notice-container {
    width: 100%;
    margin-bottom: 15px;
}

.epdesigner-notice {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 12px 15px;
    border-radius: 4px;
    margin-bottom: 10px;
    font-size: 14px;
    line-height: 1.5;
    animation: epdesigner-notice-fadeIn 0.3s ease;
}

@keyframes epdesigner-notice-fadeIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.epdesigner-notice-info {
    background-color: #e7f3ff;
    border: 1px solid #b3d7ff;
    color: #0066cc;
}

.epdesigner-notice-warning {
    background-color: #fff8e6;
    border: 1px solid #ffd666;
    color: #996600;
}

.epdesigner-notice-error {
    background-color: #ffe6e6;
    border: 1px solid #ff9999;
    color: #cc0000;
}

.epdesigner-notice-text {
    flex: 1;
}

.epdesigner-notice-close {
    background: none;
    border: none;
    font-size: 20px;
    line-height: 1;
    cursor: pointer;
    opacity: 0.6;
    padding: 0;
    margin: -2px -5px 0 0;
    color: inherit;
}

.epdesigner-notice-close:hover {
    opacity: 1;
}

.epdesigner-notice-close:focus-visible {
    outline: 2px solid #0073aa;
    outline-offset: 2px;
}
