/* WooCommerce Print Designer Styles */

/* Design Preview Section */
.wpd-design-preview {
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    padding: 15px;
    margin-bottom: 15px;
    background: #fff;
}

.wpd-design-preview .wpd-preview-header {
    margin-bottom: 10px;
    padding-bottom: 10px;
    border-bottom: 1px solid #e0e0e0;
}

.wpd-design-preview .wpd-preview-content {
    display: flex;
    align-items: center;
    gap: 15px;
    margin-bottom: 15px;
}

.wpd-preview-thumbnail {
    width: 80px;
    height: 80px;
    border: 1px solid #ddd;
    border-radius: 4px;
    overflow: hidden;
    flex-shrink: 0;
    background: #f9f9f9;
    display: flex;
    align-items: center;
    justify-content: center;
}

.wpd-preview-thumbnail img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.wpd-preview-thumbnail svg {
    color: #999;
}

.wpd-preview-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.wpd-preview-type {
    font-weight: 600;
    color: #2271b1;
    font-size: 14px;
}

.wpd-preview-filename {
    font-size: 13px;
    color: #666;
    word-break: break-all;
}

.wpd-preview-actions {
    display: flex;
    gap: 10px;
}

.wpd-preview-actions button {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    padding: 8px 15px;
}

.wpd-preview-actions button svg {
    flex-shrink: 0;
}

/* Cart Design Preview */
.woocommerce-cart .wpd-cart-design-preview,
.woocommerce-checkout .wpd-cart-design-preview {
    margin-top: 10px;
    padding: 10px;
    background: #f9f9f9;
    border-radius: 4px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.wpd-cart-thumbnail {
    width: 50px;
    height: 50px;
    border: 1px solid #ddd;
    border-radius: 4px;
    overflow: hidden;
    flex-shrink: 0;
    background: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
}

.wpd-cart-thumbnail img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.wpd-cart-thumbnail svg {
    color: #999;
    width: 24px;
    height: 24px;
}

.wpd-cart-info {
    flex: 1;
    font-size: 13px;
}

.wpd-cart-info strong {
    display: block;
    margin-bottom: 3px;
    color: #2271b1;
}

.wpd-cart-actions {
    display: flex;
    gap: 5px;
}

.wpd-cart-actions a {
    padding: 5px 10px;
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 3px;
    text-decoration: none;
    font-size: 12px;
    color: #333;
    transition: all 0.3s ease;
}

.wpd-cart-actions a:hover {
    background: #f0f0f0;
    border-color: #999;
}

.wpd-cart-actions a.delete {
    color: #b32d2e;
}

.wpd-cart-actions a.delete:hover {
    background: #b32d2e;
    color: #fff;
    border-color: #b32d2e;
}

/* Modal Base Styles */
.wpd-modal {
    display: none;
    position: fixed;
    z-index: 999999;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0, 0, 0, 0.7);
}

.wpd-modal-content {
    background-color: #fefefe;
    margin: 5% auto;
    padding: 30px;
    border-radius: 8px;
    width: 90%;
    max-width: 800px;
    position: relative;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

.wpd-fullscreen .wpd-modal-content {
    margin: 0;
    padding: 0;
    width: 100%;
    max-width: 100%;
    height: 100vh;
    border-radius: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.wpd-close {
    color: #d63638;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    line-height: 20px;
    transition: color 0.2s ease;
    padding: 0;
    margin: 0;
}

.wpd-close:hover,
.wpd-close:focus {
    color: #b32d2e;
}

/* Design Options */
.wpd-design-options {
    display: flex;
    gap: 20px;
    margin-top: 30px;
    flex-wrap: wrap;
}

.wpd-option-card {
    flex: 1;
    min-width: 250px;
    padding: 30px 20px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    background: #fff;
}

.wpd-option-card:hover {
    border-color: #2271b1;
    box-shadow: 0 4px 12px rgba(34, 113, 177, 0.1);
    transform: translateY(-2px);
}

.wpd-option-icon {
    color: #2271b1;
    margin-bottom: 15px;
}

.wpd-option-card h3 {
    margin: 15px 0;
    font-size: 20px;
    font-weight: 600;
}

.wpd-option-card ul {
    list-style: none;
    padding: 0;
    margin: 15px 0 0 0;
    text-align: left;
}

.wpd-option-card li {
    padding: 5px 0;
    color: #666;
    position: relative;
    padding-left: 20px;
}

.wpd-option-card li:before {
    content: "−";
    position: absolute;
    left: 0;
}

/* Upload Modal */
.wpd-upload-area {
    margin-top: 20px;
}

.wpd-dropzone {
    border: 2px dashed #ccc;
    border-radius: 8px;
    padding: 60px 20px;
    text-align: center;
    transition: all 0.3s ease;
}

.wpd-dropzone.wpd-dragover {
    border-color: #2271b1;
    background-color: #f0f8ff;
}

.wpd-dropzone svg {
    color: #999;
    margin-bottom: 20px;
}

.wpd-dropzone p {
    margin: 10px 0;
    color: #666;
}

.wpd-dropzone .wpd-or {
    color: #999;
    font-size: 14px;
}

.wpd-file-info {
    font-size: 12px;
    color: #999;
}

.wpd-upload-preview {
    text-align: center;
    padding: 20px;
}

.wpd-upload-preview img {
    max-width: 100%;
    max-height: 400px;
    margin-bottom: 15px;
    border-radius: 4px;
}

.wpd-modal-actions {
    margin-top: 30px;
    display: flex;
    gap: 10px;
    justify-content: flex-end;
}

/* Editor Styles */
.wpd-editor-header {
    background: #fff;
    padding: 10px 20px;
    border-bottom: 1px solid #ddd;
    display: flex;
    flex-direction: column;
    gap: 8px;
    flex-shrink: 0;
}

.wpd-editor-header-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.wpd-editor-header h2 {
    margin: 0;
    font-size: 20px;
    font-weight: 600;
    color: #2271b1;
}

.wpd-editor-actions {
    display: flex;
    gap: 6px;
    align-items: center;
}

.wpd-editor-actions .button {
    padding: 6px 12px;
    font-size: 13px;
    height: 32px;
    min-height: 32px;
    max-height: 32px;
    display: flex;
    align-items: center;
    gap: 4px;
    line-height: 1;
    border-radius: 4px;
    white-space: nowrap;
}

.wpd-editor-actions .button svg {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
}

.wpd-editor-actions .button .wpd-btn-text {
    display: inline;
}

/* Delete button - red themed */
.wpd-delete-btn {
    background: #fee;
    border-color: #d63638;
    color: #d63638;
}

.wpd-delete-btn:hover {
    background: #d63638;
    color: #fff;
    border-color: #d63638;
}

/* ===== COLOR BAR ===== */
.wpd-color-bar {
    background: #fff;
    border-bottom: 1px solid #ddd;
    padding: 6px 10px;
    display: flex;
    align-items: center;
    position: relative;
    z-index: 60;
    min-height: 44px;
    height: 44px;
    max-height: 44px;
    flex-shrink: 0;
    gap: 6px;
    /* Always visible, even when empty */
}

/* Scrollable swatch container */
.wpd-color-bar-scroll {
    flex: 1;
    overflow-x: auto;
    overflow-y: hidden;
    min-width: 0;
    /* hide scrollbar on desktop, keep functional */
    scrollbar-width: thin;
    scrollbar-color: #ccc transparent;
}
.wpd-color-bar-scroll::-webkit-scrollbar {
    height: 3px;
}
.wpd-color-bar-scroll::-webkit-scrollbar-thumb {
    background: #ccc;
    border-radius: 2px;
}

.wpd-color-bar-swatches {
    display: flex;
    gap: 6px;
    align-items: center;
    flex-wrap: nowrap;
    padding-bottom: 2px; /* room for scrollbar */
}

/* Group / Copy icon buttons in color bar */
.wpd-color-bar-btn {
    width: 34px;
    height: 34px;
    border: 1.5px solid #ddd;
    border-radius: 7px;
    background: #f9f9f9;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    padding: 0;
    color: #444;
    transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.wpd-color-bar-btn:hover {
    background: #e8f4fc;
    border-color: #2271b1;
    color: #2271b1;
}
.wpd-color-bar-btn.wpd-active {
    background: #2271b1;
    border-color: #2271b1;
    color: #fff;
}

/* Paste-color button shows a small colored dot to indicate what color is ready to paste */
#wpd-paste-color-btn {
    position: relative;
}
#wpd-paste-color-btn .wpd-paste-dot {
    position: absolute;
    top: 4px;
    right: 4px;
    width: 7px;
    height: 7px;
    border-radius: 50%;
    border: 1.5px solid rgba(255,255,255,0.8);
    pointer-events: none;
}

.wpd-color-bar-divider {
    width: 1px;
    height: 24px;
    background: #e0e0e0;
    flex-shrink: 0;
}

.wpd-color-swatch {
    width: 32px;
    height: 32px;
    border-radius: 6px;
    cursor: pointer;
    border: 2px solid #e0e0e0;
    transition: transform 0.15s, border-color 0.15s;
    position: relative;
    flex-shrink: 0;
}

.wpd-color-swatch:hover {
    transform: scale(1.1);
    border-color: #2271b1;
}

.wpd-color-swatch.active {
    border-color: #2271b1;
    box-shadow: 0 0 0 2px rgba(34,113,177,0.3);
}

.wpd-color-swatch-wrap {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1px;
}

.wpd-color-swatch-label {
    font-size: 9px;
    color: #666;
    text-align: center;
    line-height: 1;
}

/* Palette dropdown */
.wpd-color-palette-dropdown {
    position: absolute;
    top: 100%;
    left: 10px;
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 10px;
    box-shadow: 0 8px 30px rgba(0,0,0,0.18);
    padding: 16px;
    z-index: 100;
    min-width: 280px;
    max-width: 340px;
}

.wpd-palette-section {
    margin-bottom: 14px;
}

.wpd-palette-section:last-child {
    margin-bottom: 0;
}

.wpd-palette-title {
    font-size: 11px;
    font-weight: 700;
    color: #333;
    letter-spacing: 0.5px;
    margin-bottom: 8px;
}

.wpd-palette-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 6px;
}

.wpd-palette-color {
    width: 100%;
    aspect-ratio: 1;
    border-radius: 6px;
    cursor: pointer;
    transition: transform 0.15s;
    min-width: 40px;
}

.wpd-palette-color:hover {
    transform: scale(1.12);
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}

.wpd-palette-add {
    width: 100%;
    aspect-ratio: 1;
    border-radius: 6px;
    border: 2px dashed #ccc;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    color: #999;
    cursor: pointer;
    transition: border-color 0.2s, color 0.2s;
    min-width: 40px;
}

.wpd-palette-add:hover {
    border-color: #2271b1;
    color: #2271b1;
}

.wpd-editor-body {
    display: flex;
    flex: 1;
    min-height: 0;
    background: #f5f5f5;
    overflow: hidden;
}

.wpd-editor-sidebar {
    width: 80px;
    background: #2c3e50;
    display: flex;
    flex-direction: column;
    padding: 10px 0;
    flex-shrink: 0;
}

.wpd-tool {
    padding: 15px;
    text-align: center;
    cursor: pointer;
    color: #ecf0f1;
    transition: all 0.3s ease;
    border-left: 3px solid transparent;
}

.wpd-tool:hover {
    background: #34495e;
}

.wpd-tool.active {
    background: #34495e;
    border-left-color: #3498db;
}

.wpd-tool svg {
    display: block;
    margin: 0 auto 5px;
}

.wpd-tool span {
    font-size: 11px;
    display: block;
}

.wpd-editor-main {
    flex: 1;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding: 10px 15px 20px 15px;
    overflow: auto;
    min-height: 0;
}

.wpd-canvas-area {
    display: inline-flex;
    flex-direction: column;
    align-items: center;
}

.wpd-canvas-wrapper {
    position: relative;
    background: #fff;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    display: inline-block;
    overflow: visible;
}

/* Rotation angle tooltip */
.wpd-angle-tooltip {
    position: absolute;
    background: rgba(0,0,0,0.8);
    color: #fff;
    font-size: 12px;
    font-weight: 600;
    padding: 3px 8px;
    border-radius: 4px;
    pointer-events: none;
    z-index: 30;
    white-space: nowrap;
    transform: translateX(-50%);
    display: none;
}

/* Ensure fabric.js container doesn't add extra size */
.wpd-canvas-wrapper .canvas-container {
    display: block !important;
}

#wpd-canvas {
    display: block;
}

/* Canvas Toolbar - flows under canvas with gap */
.wpd-canvas-toolbar {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 3px;
    background: rgba(0, 0, 0, 0.75);
    padding: 4px 10px;
    border-radius: 6px;
    margin-top: 8px;
    width: 100%;
    box-sizing: border-box;
    flex-wrap: wrap;
}

/* Side Switcher for double-sided products */
.wpd-side-switcher {
    display: flex;
    gap: 2px;
    background: rgba(0, 0, 0, 0.5);
    border-radius: 4px;
    padding: 2px;
    margin-right: 4px;
}

.wpd-side-btn {
    padding: 4px 12px;
    font-size: 12px;
    font-weight: 500;
    border: none;
    background: transparent;
    color: #ccc;
    cursor: pointer;
    border-radius: 3px;
    transition: all 0.2s;
    white-space: nowrap;
}

.wpd-side-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
}

.wpd-side-btn.active {
    background: #2271b1;
    color: #fff;
}

.wpd-toolbar-btn {
    width: 28px;
    height: 28px;
    border: none;
    background: transparent;
    color: #fff;
    font-size: 16px;
    font-weight: bold;
    cursor: pointer;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    line-height: 1;
}

.wpd-toolbar-btn:hover {
    background: rgba(255, 255, 255, 0.2);
}

.wpd-toolbar-btn svg {
    display: block;
}

.wpd-toolbar-label {
    color: #fff;
    font-size: 11px;
    min-width: 32px;
    text-align: center;
    user-select: none;
}

.wpd-toolbar-divider {
    width: 1px;
    height: 18px;
    background: rgba(255,255,255,0.3);
    margin: 0 2px;
}

.wpd-layer-btn {
    position: relative;
}

/* Rulers */
.wpd-ruler {
    position: absolute;
    background: #f5f5f5;
    border: 1px solid #ccc;
    z-index: 10;
    box-sizing: border-box;
}

.wpd-ruler-horizontal {
    top: 0;
    height: 35px;
}

.wpd-ruler-vertical {
    left: 0;
    width: 35px;
}

.wpd-ruler-mark {
    position: absolute;
    background: #666;
}

.wpd-ruler-horizontal .wpd-ruler-mark {
    width: 1px;
    bottom: 0;
}

.wpd-ruler-horizontal .wpd-ruler-mark-major {
    height: 12px;
    background: #333;
}

.wpd-ruler-horizontal .wpd-ruler-mark-major span {
    position: absolute;
    top: 2px;
    left: 2px;
    font-size: 10px;
    color: #333;
    font-weight: 600;
}

.wpd-ruler-horizontal .wpd-ruler-mark-medium {
    height: 8px;
}

.wpd-ruler-horizontal .wpd-ruler-mark-minor {
    height: 5px;
}

.wpd-ruler-vertical .wpd-ruler-mark {
    height: 1px;
    right: 0;
}

.wpd-ruler-vertical .wpd-ruler-mark-major {
    width: 12px;
    background: #333;
}

.wpd-ruler-vertical .wpd-ruler-mark-major span {
    position: absolute;
    left: 2px;
    top: 2px;
    font-size: 10px;
    color: #333;
    font-weight: 600;
    writing-mode: vertical-rl;
    text-orientation: mixed;
}

.wpd-ruler-vertical .wpd-ruler-mark-medium {
    width: 8px;
}

.wpd-ruler-vertical .wpd-ruler-mark-minor {
    width: 5px;
}

.wpd-canvas-info {
    position: absolute;
    bottom: 10px;
    right: 10px;
    background: rgba(0, 0, 0, 0.7);
    color: #fff;
    padding: 5px 10px;
    border-radius: 4px;
    font-size: 12px;
}

.wpd-editor-toolpanel {
    width: 280px;
    background: #fff;
    border-left: 1px solid #ddd;
    padding: 15px;
    overflow-y: auto;
    overflow-x: hidden;
    scrollbar-gutter: stable;
}

.wpd-panel {
    display: none;
}

.wpd-panel h3 {
    margin-top: 0;
    margin-bottom: 15px;
    font-size: 17px;
}

.wpd-panel h4 {
    margin-top: 15px;
    margin-bottom: 10px;
    font-size: 14px;
    color: #666;
}

.wpd-input {
    width: 100%;
    padding: 8px;
    margin-bottom: 15px;
    border: 1px solid #ddd;
    border-radius: 4px;
    box-sizing: border-box;
}

/* Make the font dropdown taller so previewed names are legible */
select#font-family {
    height: 38px;
    font-size: 14px;
    cursor: pointer;
}

/* Each option renders in its own font – works in Chrome/Edge/Android.
   Firefox on macOS ignores font-family on <option> (browser limitation). */
select#font-family option {
    font-size: 15px;
    padding: 4px 0;
}

/* optgroup labels stay in the UI font */
select#font-family optgroup {
    font-family: inherit;
    font-style: normal;
    font-size: 11px;
    color: #888;
    letter-spacing: 0.04em;
}

.wpd-input:focus {
    outline: none;
    border-color: #2271b1;
}

.wpd-panel label {
    display: block;
    margin-bottom: 5px;
    font-weight: 600;
    font-size: 13px;
}

.wpd-style-buttons,
.wpd-align-buttons {
    display: flex;
    gap: 5px;
    margin-bottom: 15px;
}

.wpd-style-btn,
.wpd-align-btn {
    flex: 1;
    padding: 8px;
    background: #f0f0f0;
    border: 1px solid #ddd;
    border-radius: 4px;
    cursor: pointer;
    font-weight: bold;
    color: #1e1e1e;
    transition: all 0.3s ease;
}

.wpd-style-btn:hover,
.wpd-align-btn:hover {
    background: #e0e0e0;
    color: #1e1e1e;
}

.wpd-style-btn.active,
.wpd-align-btn.active {
    background: #2271b1;
    color: #fff;
    border-color: #2271b1;
}

/* ─── Tool panel sections now use the same wpd-props-section system ─── */

/* All wpd-panel children use section layout - remove old h3/h4 margin overrides */
.wpd-panel h3, .wpd-panel h4 { display: none; }

/* Primary action button inside a panel section */
.wpd-panel-action-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    width: 100%;
    padding: 9px 12px;
    background: #2271b1;
    color: #fff;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
    letter-spacing: .02em;
    transition: background .15s;
}
.wpd-panel-action-btn:hover { background: #1a5c96; }
.wpd-panel-action-btn:disabled { opacity: 0.5; cursor: not-allowed; }
.wpd-panel-action-btn:disabled:hover { background: #2271b1; }

/* Font selector inside panel - matches props select style */
.wpd-panel-select {
    width: 100%;
    padding: 6px 8px;
    border: 1px solid #e0e0e0;
    border-radius: 5px;
    background: #f7f7f7;
    color: #222;
    font-size: 13px;
    outline: none;
    cursor: pointer;
    box-sizing: border-box;
    transition: border-color .12s;
}
.wpd-panel-select:focus { border-color: #2271b1; }

/* B/I/U and align buttons — override wide-btn for these smaller uses */
#panel-text .wpd-prop-wide-btn {
    flex: 1;
    padding: 0 !important;
    font-size: 13px;
    font-weight: 700;
}

/* Shapes panel — shape grid sits directly inside wpd-props-section, no extra padding */
#panel-cliparts .wpd-props-section .wpd-shapes-grid {
    margin: 0;
}

/* Remove old add-text full-width override (now handled by .wpd-panel-action-btn) */


.wpd-note {
    padding: 15px;
    background: #f0f0f0;
    border-radius: 4px;
    font-size: 13px;
    color: #666;
    text-align: center;
}

/* Panel Toggle Button - hidden on desktop */
.wpd-panel-toggle {
    display: none;
}

/* Responsive Design */
@media (max-width: 768px) {
    .wpd-design-options {
        flex-direction: column;
    }
    
    .wpd-option-card {
        min-width: 100%;
    }
    
    .wpd-modal-content {
        width: 95%;
        margin: 2% auto;
        padding: 20px;
    }
    
    .wpd-editor-sidebar {
        width: 50px;
    }
    
    /* Keep tool labels visible on mobile too */
    .wpd-tool span {
        display: block;
        font-size: 9px;
    }
    
    .wpd-tool {
        padding: 10px 4px;
    }
    
    .wpd-tool svg {
        margin-bottom: 3px;
        width: 20px;
        height: 20px;
    }
    
    .wpd-editor-header {
        padding: 8px 12px;
        gap: 6px;
    }
    
    .wpd-editor-header h2 {
        font-size: 17px;
        font-weight: 600;
    }
    
    .wpd-editor-actions {
        gap: 4px;
        flex-wrap: nowrap;
        overflow-x: auto;
    }
    
    .wpd-editor-actions .button {
        padding: 5px 10px;
        font-size: 13px;
        height: 32px;
        min-height: 32px;
        max-height: 32px;
        flex: 0 0 auto;
    }

    .wpd-editor-actions .button svg {
        width: 15px;
        height: 15px;
    }

    /* Keep button text visible on mobile - we have enough space */
    .wpd-editor-actions .button span.wpd-btn-text {
        display: inline;
    }

    /* Editor body needs position relative for toggle button placement */
    .wpd-editor-body {
        position: relative;
    }
    
    /* Canvas area: minimal padding, align top on mobile */
    .wpd-editor-main {
        padding: 5px;
        align-items: flex-start;
        justify-content: center;
    }
    
    /* Toggle button: always visible on mobile, sits on right edge */
    .wpd-panel-toggle {
        display: flex;
        align-items: center;
        justify-content: center;
        position: absolute;
        right: 0;
        top: 12px;
        width: 28px;
        height: 44px;
        background: #2271b1;
        border: none;
        border-radius: 6px 0 0 6px;
        cursor: pointer;
        z-index: 100;
        padding: 0;
        color: #fff;
        box-shadow: -2px 1px 6px rgba(0,0,0,0.2);
        transition: right 0.3s ease;
    }
    
    .wpd-panel-toggle:hover,
    .wpd-panel-toggle:active {
        background: #1a5a8e;
    }
    
    .wpd-panel-toggle svg {
        transition: transform 0.3s ease;
        display: block;
    }
    
    /* When panel is open, move toggle button to left of panel and rotate arrow */
    .wpd-panel-toggle.wpd-toggle-active {
        right: 250px;
    }
    
    .wpd-panel-toggle.wpd-toggle-active svg {
        transform: rotate(0deg);
    }
    
    .wpd-panel-toggle:not(.wpd-toggle-active) svg {
        transform: rotate(180deg);
    }
    
    /* Toolpanel: HIDDEN by default on mobile via CSS - no JS needed */
    .wpd-editor-toolpanel {
        position: absolute;
        right: 0;
        top: 0;
        bottom: 0;
        width: 0;
        padding: 0;
        border-left: none;
        overflow: hidden;
        z-index: 50;
        background: #fff;
        transition: width 0.3s ease, padding 0.3s ease;
    }
    
    /* When panel is open */
    .wpd-editor-toolpanel.wpd-panel-open {
        width: 250px;
        padding: 20px;
        border-left: 1px solid #ddd;
        overflow-y: auto;
        overflow-x: hidden;
        box-shadow: -4px 0 15px rgba(0, 0, 0, 0.15);
    }
    
    /* Toolbar: bigger tap targets on mobile */
    .wpd-canvas-toolbar {
        padding: 5px 6px;
        gap: 2px;
    }
    
    .wpd-toolbar-btn {
        width: 32px;
        height: 32px;
        font-size: 18px;
    }
    
    /* Smaller rulers on mobile */
    .wpd-ruler-horizontal {
        height: 20px !important;
    }
    
    .wpd-ruler-vertical {
        width: 20px !important;
    }
    
    .wpd-ruler-horizontal .wpd-ruler-mark-major span,
    .wpd-ruler-vertical .wpd-ruler-mark-major span {
        font-size: 7px !important;
        font-weight: 500 !important;
    }
    
    .wpd-ruler-horizontal .wpd-ruler-mark-major {
        height: 10px !important;
    }
    
    .wpd-ruler-horizontal .wpd-ruler-mark-medium {
        height: 6px !important;
    }
    
    .wpd-ruler-horizontal .wpd-ruler-mark-minor {
        height: 4px !important;
    }
    
    .wpd-ruler-vertical .wpd-ruler-mark-major {
        width: 10px !important;
    }
    
    .wpd-ruler-vertical .wpd-ruler-mark-medium {
        width: 6px !important;
    }
    
    .wpd-ruler-vertical .wpd-ruler-mark-minor {
        width: 4px !important;
    }

    /* Stock photo thumbnails: fit sidebar on mobile */
    .wpd-stock-results {
        grid-template-columns: repeat(2, 1fr);
        gap: 4px;
        padding: 2px;
        max-height: 300px;
    }
    
    .wpd-stock-img {
        aspect-ratio: 1;
    }

    .wpd-stock-search {
        padding: 0 2px;
    }

    /* Color bar: mobile adjustments - handled in dedicated section */
    
    /* Shapes grid: fit sidebar on mobile */
    .wpd-shapes-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 4px;
    }

    /* Hide desktop resize handle on mobile */
    .wpd-resize-handle {
        display: none;
    }
}

/* Desktop: Resizable sidebar handle */
.wpd-editor-toolpanel {
    position: relative;
}

.wpd-resize-handle {
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 5px;
    cursor: col-resize;
    background: transparent;
    z-index: 10;
    transition: background 0.2s;
}

.wpd-resize-handle:hover,
.wpd-resize-handle.wpd-resizing {
    background: #2271b1;
}

/* Cart Edit Design button */
.wpd-cart-actions a.wpd-cart-edit-design {
    color: #2271b1;
}

.wpd-cart-actions a.wpd-cart-edit-design:hover {
    background: #2271b1;
    color: #fff;
    border-color: #2271b1;
}

/* Admin Styles */
.wpd-admin-section {
    margin: 20px 0;
}

/* Shapes Grid */
.wpd-shapes-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 4px;
    padding: 0;
    box-sizing: border-box;
    width: 100%;
    max-width: 100%;
    overflow: hidden;
}

.wpd-shape-btn {
    width: 100%;
    aspect-ratio: 1;
    border: 1px solid #ddd;
    background: #fafafa;
    border-radius: 4px;
    cursor: pointer;
    padding: 8px;
    box-sizing: border-box;
    min-width: 0;
    transition: border-color 0.2s, background 0.2s;
}

.wpd-shape-btn:hover {
    border-color: #2271b1;
    background: #e8f4fc;
}

.wpd-fill-type-btn,
.wpd-stroke-type-btn {
    color: #333;
    font-weight: 500;
    transition: all 0.2s;
}

.wpd-fill-type-btn.active,
.wpd-stroke-type-btn.active {
    background: #e8f4fc !important;
    border-color: #2271b1 !important;
    color: #1a5276;
}

.wpd-fill-type-btn:hover:not(.active),
.wpd-stroke-type-btn:hover:not(.active) {
    background: #f0f0f0 !important;
    border-color: #999 !important;
}

.wpd-shape-btn svg {
    width: 100%;
    height: 100%;
}

/* Stock Photo Search */
.wpd-full-btn {
    width: 100%;
    text-align: center;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    padding: 9px 12px;
    font-size: 13px;
    font-weight: 600;
    border-radius: 6px;
    box-sizing: border-box;
    cursor: pointer;
    letter-spacing: .02em;
}

.wpd-search-row {
    display: flex;
    gap: 4px;
    margin-bottom: 8px;
    align-items: stretch;
}

.wpd-search-row input {
    flex: 1;
    min-width: 0;
    height: 36px;
    box-sizing: border-box;
    padding: 6px 10px;
    font-size: 13px;
    border: 1px solid #ddd;
    border-radius: 4px;
    margin-bottom: 0;
}

.wpd-search-row .button {
    padding: 0 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    height: 36px;
    box-sizing: border-box;
    min-width: 36px;
}

.wpd-source-tabs {
    display: flex;
    gap: 4px;
    margin-bottom: 10px;
}

.wpd-source-tab {
    flex: 1;
    padding: 5px 4px;
    border: 1px solid #ddd;
    background: #f9f9f9;
    color: #333;
    cursor: pointer;
    font-size: 11px;
    border-radius: 4px;
    text-align: center;
    transition: all 0.2s;
}

.wpd-source-tab.active {
    background: #2271b1;
    color: #fff;
    border-color: #2271b1;
}

.wpd-source-tab:hover:not(.active) {
    background: #e8f4fc;
    border-color: #2271b1;
}

.wpd-stock-results {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 6px;
    max-height: 400px;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 4px;
}

.wpd-stock-img {
    width: 100%;
    aspect-ratio: 1;
    object-fit: cover;
    border-radius: 4px;
    cursor: pointer;
    border: 2px solid transparent;
    transition: border-color 0.2s, opacity 0.2s;
    display: block;
}

.wpd-stock-img:hover {
    border-color: #2271b1;
    opacity: 0.85;
}

.wpd-stock-credit {
    font-size: 9px;
    color: #999;
    text-align: center;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Button Overrides */
button:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* ===== LAYERS PANEL ===== */
.wpd-layers-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
    max-height: 380px;
    overflow-y: auto;
}

.wpd-layer-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 7px 10px;
    border: 1.5px solid #e0e0e0;
    border-radius: 6px;
    background: #fafafa;
    cursor: pointer;
    font-size: 12px;
    color: #333;
    user-select: none;
    transition: background 0.15s, border-color 0.15s;
}
.wpd-layer-item:hover {
    background: #e8f4fc;
    border-color: #2271b1;
}
.wpd-layer-item.wpd-layer-selected {
    background: #dceefb;
    border-color: #2271b1;
    color: #1a5276;
    font-weight: 600;
}
.wpd-layer-item .wpd-layer-thumb {
    width: 28px;
    height: 28px;
    border: 1px solid #ddd;
    border-radius: 4px;
    background: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    overflow: hidden;
}
.wpd-layer-item .wpd-layer-thumb svg {
    width: 16px;
    height: 16px;
}
.wpd-layer-item .wpd-layer-label {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.wpd-layer-item .wpd-layer-actions {
    display: flex;
    gap: 3px;
    opacity: 0;
    transition: opacity 0.15s;
}
.wpd-layer-item:hover .wpd-layer-actions,
.wpd-layer-item.wpd-layer-selected .wpd-layer-actions {
    opacity: 1;
}
.wpd-layer-action-btn {
    width: 20px;
    height: 20px;
    border: none;
    background: transparent;
    cursor: pointer;
    color: #666;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 3px;
    padding: 0;
}
.wpd-layer-action-btn:hover {
    background: #ddd;
    color: #222;
}
.wpd-layer-drag-handle {
    cursor: grab;
    color: #bbb;
    font-size: 14px;
    line-height: 1;
}

/* ===== MOBILE COLOR BAR ADJUSTMENTS ===== */
@media (max-width: 768px) {
    .wpd-color-bar {
        padding: 5px 8px;
        min-height: 38px;
        height: 38px;
        max-height: 38px;
        gap: 4px;
    }
    .wpd-color-bar-btn {
        width: 30px;
        height: 30px;
    }
    .wpd-color-swatch {
        width: 28px;
        height: 28px;
    }
    .wpd-color-palette-dropdown {
        left: 5px !important;
        right: 5px;
        min-width: auto;
        max-width: calc(100vw - 20px);
    }
}

/* ============================================================
   Custom SVG Shapes Section
   ============================================================ */

.wpd-custom-shapes-section {
    margin-top: 18px;
    border-top: 2px solid #e0e0e0;
    padding-top: 14px;
}

.wpd-custom-shapes-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 10px;
}

.wpd-custom-shapes-label {
    font-size: 13px;
    font-weight: 600;
    color: #1a1a1a;
    letter-spacing: 0.02em;
}

.wpd-custom-shapes-hint {
    font-size: 10px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: #fff;
    background: #2271b1;
    padding: 2px 7px;
    border-radius: 20px;
}

/* Same column layout as built-in grid (4-up) */
.wpd-custom-shapes-grid {
    grid-template-columns: repeat(4, 1fr);
}

/* Custom SVG buttons match .wpd-shape-btn exactly; SVG fills button */
.wpd-custom-svg-btn {
    position: relative;
}

.wpd-custom-svg-btn svg {
    width: 100% !important;
    height: 100% !important;
    display: block;
}

/* Loading spinner overlay */
.wpd-custom-svg-btn.wpd-custom-svg-loading {
    pointer-events: none;
    opacity: 0.6;
}

.wpd-custom-svg-btn.wpd-custom-svg-loading::after {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: 4px;
    background: rgba(255,255,255,0.6)
        url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 50 50' width='22' height='22'%3E%3Ccircle cx='25' cy='25' r='20' fill='none' stroke='%232271b1' stroke-width='5' stroke-dasharray='94 31'%3E%3CanimateTransform attributeName='transform' type='rotate' from='0 25 25' to='360 25 25' dur='0.7s' repeatCount='indefinite'/%3E%3C/circle%3E%3C/svg%3E")
        center / 22px 22px no-repeat;
}

/* ==============================================================
   Templates Panel
   ============================================================== */

/* 3-column grid — slightly wider cells than shapes so labels fit */
.wpd-templates-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 6px;
    padding: 0;
    box-sizing: border-box;
    width: 100%;
}

/* Individual template card button */
.wpd-template-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    width: 100%;
    border: 1px solid #ddd;
    background: #fafafa;
    border-radius: 6px;
    cursor: pointer;
    padding: 6px 4px;
    box-sizing: border-box;
    transition: border-color 0.2s, background 0.2s, box-shadow 0.2s;
    min-width: 0;
    position: relative;
}

.wpd-template-btn:hover {
    border-color: #2271b1;
    background: #e8f4fc;
    box-shadow: 0 2px 6px rgba(34,113,177,0.15);
}

/* Thumbnail area — fixed aspect ratio box */
.wpd-template-thumb {
    width: 100%;
    aspect-ratio: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    border-radius: 3px;
    background: #fff;
    border: 1px solid #eee;
}

/* SVG inside thumb fills the box */
.wpd-template-thumb > svg {
    width: 100% !important;
    height: 100% !important;
    display: block;
}

/* Raster thumbnail (PDF/AI Imagick output) */
.wpd-template-thumb img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
}

/* File-type icon (fallback when no Imagick thumbnail) */
.wpd-template-thumb > svg[viewBox="0 0 24 24"] {
    width: 40px !important;
    height: 40px !important;
}

/* Template name label */
.wpd-template-label {
    font-size: 10px;
    color: #444;
    text-align: center;
    line-height: 1.3;
    word-break: break-word;
    max-width: 100%;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* Loading spinner — same pattern as wpd-custom-svg-loading */
.wpd-template-btn.wpd-template-loading {
    pointer-events: none;
    opacity: 0.6;
}

.wpd-template-btn.wpd-template-loading::after {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: 6px;
    background: rgba(255,255,255,0.65)
        url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 50 50' width='22' height='22'%3E%3Ccircle cx='25' cy='25' r='20' fill='none' stroke='%232271b1' stroke-width='5' stroke-dasharray='94 31'%3E%3CanimateTransform attributeName='transform' type='rotate' from='0 25 25' to='360 25 25' dur='0.7s' repeatCount='indefinite'/%3E%3C/circle%3E%3C/svg%3E")
        center / 22px 22px no-repeat;
}

/* Empty-state message when no templates are present */
.wpd-templates-empty {
    padding: 10px 0 20px;
}

.wpd-templates-empty code {
    background: #f0f0f0;
    padding: 2px 5px;
    border-radius: 3px;
    font-size: 10px;
}

/* Mobile: drop to 2-column grid */
@media (max-width: 480px) {
    .wpd-templates-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}


/* =============================================
   RIGHT PROPERTIES PANEL
   ============================================= */

/* ── Sections (used in both toolpanel and merged-props) ── */
.wpd-props-section {
    padding: 10px 12px;
    border-bottom: 1px solid #f0f0f0;
}
.wpd-props-section:last-child { border-bottom: none; }

.wpd-props-section-label {
    font-size: 9.5px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .1em;
    color: #aaa;
    margin-bottom: 7px;
}

/* ── Two-column field rows (W/H, X/Y, angle/opacity) ── */
.wpd-props-row {
    display: flex;
    gap: 6px;
    margin-bottom: 5px;
}
.wpd-props-field {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 3px;
    background: #f5f5f5;
    border: 1px solid #e0e0e0;
    border-radius: 5px;
    padding: 4px 6px 4px 7px;
    min-width: 0;
    transition: border-color .12s;
}
.wpd-props-field:focus-within {
    border-color: #3b82f6;
    background: #f0f6ff;
}
.wpd-props-label {
    font-size: 10px;
    font-weight: 700;
    color: #bbb;
    white-space: nowrap;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    gap: 1px;
    line-height: 1;
    user-select: none;
}
.wpd-props-numfield {
    flex: 1;
    border: none;
    background: transparent;
    font-size: 12px;
    font-weight: 600;
    color: #1a1a1a;
    width: 0;
    min-width: 0;
    outline: none;
    text-align: right;
    padding: 0;
    -moz-appearance: textfield;
}
/* Hide native spin arrows — we use custom stepper buttons instead */
.wpd-props-numfield::-webkit-outer-spin-button,
.wpd-props-numfield::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }

/* ── Custom stepper (▲ / ▼) column beside each number field ── */
.wpd-num-stepper {
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    margin-left: 2px;
    gap: 1px;
}
.wpd-num-stepper button {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 14px;
    height: 10px;
    padding: 0;
    margin: 0;
    border: none;
    background: #e2e2e2;
    color: #555;
    cursor: pointer;
    font-size: 7px;
    line-height: 1;
    border-radius: 2px;
    transition: background .1s;
    -webkit-user-select: none;
    user-select: none;
}
.wpd-num-stepper button:hover { background: #ccc; }
.wpd-num-stepper button:active { background: #aaa; color: #fff; }
.wpd-props-unit {
    font-size: 10px;
    color: #ccc;
    flex-shrink: 0;
    font-weight: 500;
}

/* ── Icon button grid (align, etc.) ── */
.wpd-props-icon-row {
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
}
.wpd-prop-icon-btn {
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid #e0e0e0;
    border-radius: 5px;
    background: #f5f5f5;
    cursor: pointer;
    color: #555;
    transition: background .12s, border-color .12s, color .12s;
    flex-shrink: 0;
    padding: 0;
}
.wpd-prop-icon-btn svg {
    width: 15px;
    height: 15px;
    display: block;
}
.wpd-prop-icon-btn:hover {
    background: #eaf0fe;
    border-color: #93b4f7;
    color: #2563eb;
}
.wpd-prop-icon-btn.active {
    background: #2563eb;
    border-color: #2563eb;
    color: #fff;
}

/* Wide buttons (Flip H/V, Fit/Fill) */
.wpd-prop-wide-btn {
    width: auto !important;
    padding: 0 10px !important;
    gap: 5px;
    font-size: 11px;
    font-weight: 600;
    height: 30px;
}

/* ── Fill / Stroke mode selectors ── */
.wpd-prop-fill-mode,
.wpd-prop-stroke-mode {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    padding: 5px 4px 4px;
    flex: 1;
    border: 1.5px solid #e0e0e0;
    border-radius: 6px;
    background: #f7f7f7;
    cursor: pointer;
    color: #444;
    transition: background .12s, border-color .12s, box-shadow .12s;
    min-width: 0;
}
.wpd-prop-fill-mode svg,
.wpd-prop-stroke-mode svg {
    width: 22px;
    height: 22px;
    display: block;
    flex-shrink: 0;
}
.wpd-prop-fill-mode span,
.wpd-prop-stroke-mode span {
    font-size: 9.5px;
    font-weight: 600;
    color: #777;
    white-space: nowrap;
}
.wpd-prop-fill-mode:hover,
.wpd-prop-stroke-mode:hover {
    background: #eaf0fe;
    border-color: #93b4f7;
}
.wpd-prop-fill-mode.active,
.wpd-prop-stroke-mode.active {
    border-color: #2563eb;
    background: #eff6ff;
    box-shadow: 0 0 0 2px #2563eb30;
}
.wpd-prop-fill-mode.active span,
.wpd-prop-stroke-mode.active span {
    color: #2563eb;
}

/* ── Color picker row ── */
.wpd-prop-colorpick-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 7px;
}
.wpd-prop-swatch {
    width: 30px;
    height: 30px;
    border: 1.5px solid #ddd;
    border-radius: 5px;
    cursor: pointer;
    padding: 2px;
    background: #fff;
    flex-shrink: 0;
}
.wpd-prop-color-hex {
    font-size: 11px;
    font-weight: 600;
    color: #555;
    letter-spacing: .04em;
    text-transform: uppercase;
    flex: 1;
}

/* ── Gradient stop row ── */
.wpd-prop-grad-stops {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 6px;
}
.wpd-prop-grad-preview {
    flex: 1;
    height: 14px;
    border-radius: 4px;
    border: 1px solid #e0e0e0;
    background: linear-gradient(to right, #ff6b35, #4a90d9);
    pointer-events: none;
}

.wpd-props-select {
    width: 100%;
    font-size: 11px;
    padding: 5px 6px;
    border: 1px solid #e0e0e0;
    border-radius: 5px;
    background: #f7f7f7;
    color: #333;
    outline: none;
    margin-top: 4px;
}
.wpd-props-select:focus { border-color: #3b82f6; }

/* text-align active state */
.wpd-prop-textalign.active {
    background: #2563eb;
    border-color: #2563eb;
    color: #fff;
}

/* ── Merged Properties Block (inside toolpanel) ── */
#wpd-merged-props {
    border-top: 2px solid #e4e8ec;
    margin-top: 18px;
    padding-top: 0;
}

.wpd-merged-props-header {
    display: flex;
    align-items: center;
    gap: 7px;
    padding: 10px 12px 8px;
    background: #f0f4f8;
    border-bottom: 1px solid #dde3ea;
    position: sticky;
    top: 0;
    z-index: 2;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .09em;
    color: #5a6a7a;
}

.wpd-merged-props-header svg {
    flex-shrink: 0;
    opacity: 0.7;
}

/* Ensure sections inside merged props don't have unexpected last-child overrides */
#wpd-merged-props .wpd-props-section:last-child {
    border-bottom: none;
}
