.ld-customizer-preview {
    width: 100%;
    height: auto;

    aspect-ratio: 1/1;

    background-position: center;
    background-size: contain;
    background-repeat: no-repeat;

    position: relative;

    background-color: #eceeec;

    transition: background-color 0.3s ease, background-image 0.3s ease;

    z-index: 10;
}

.ld-customizer-preview.has-background-image {
    background-color: transparent;
}

.ld-customizer-thumbnail {
    width: auto;
    height: auto;

    aspect-ratio: 1/1;

    background-color: #eceeec;

    margin: 10px;

    transition: background-color 0.3s ease;
}

.ld-customizer-thumbnail.has-image {
    background-color: transparent;
}

.ld-customizer-thumbnail>img {
    width: 100%;
    max-width: 100px;
    height: auto;
    aspect-ratio: 1/1;

    margin: 0;

    object-fit: contain;
    opacity: 1;

    transition: opacity 0.3s ease;
}

.ld-customizer-thumbnail>img[src=""],
.ld-customizer-thumbnail>img:not([src]),
.ld-customizer-thumbnail>img[src="#"] {
    opacity: 0;
}

/* Canvas-based text overlay styles */
.ld-customizer-text-overlay {
    /* Remove default button styling */
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    border: none;
    background: transparent;
    padding: 0;
    margin: 0;
    cursor: pointer;

    /* Ensure proper positioning */
    position: absolute;
    display: block;
    overflow: hidden;

    /* Smooth transitions */
    transition: opacity 0.2s ease;
}

.ld-customizer-text-overlay:hover {
    opacity: 0.8;
}

.ld-customizer-text-overlay-canvas {
    /* Ensure canvas renders crisp text */
    image-rendering: -webkit-optimize-contrast;
    image-rendering: -moz-crisp-edges;
    image-rendering: crisp-edges;
    image-rendering: pixelated;

    /* Smooth transitions for resize operations */
    transition: width 0.1s ease-out, height 0.1s ease-out;

    /* Ensure proper display */
    display: block;
    width: 100%;
    height: 100%;

    /* Prevent text selection on canvas */
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
}

/* Ensure preview containers support canvas overlays */
.ld-customizer-preview,
.ld-customizer-mobile-preview {
    /* Ensure stacking context for canvas elements */
    position: relative;
    z-index: 1;
}

/* High DPI display optimizations */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 2dppx) {
    .ld-customizer-text-overlay-canvas {
        /* Ensure crisp rendering on high DPI displays */
        image-rendering: -webkit-optimize-contrast;
    }
}

/* Debug mode - show canvas boundaries */
.ld-customizer-debug .ld-customizer-text-overlay-canvas {
    border: 1px dashed rgba(255, 0, 0, 0.3);
    background-color: rgba(255, 255, 0, 0.1);
}

/* Loading states for text overlays */
.ld-customizer-text-overlay.loading {
    opacity: 0.5;
    pointer-events: none;
}

.ld-customizer-text-overlay.loading .ld-customizer-text-overlay-canvas {
    filter: blur(1px);
}

.ld-customizer-text-overlay {
    appearance: none;
    background-color: transparent;
    background: none;
    text-transform: none;
    letter-spacing: normal;
    display: block;
    padding: 0;
    margin: 0;
    border: 0;
    border-radius: 0;
    outline: 0;
    box-shadow: none;
    transition: all 0.2s ease;
}

.ld-customizer-text-overlay:hover {
    background-color: transparent;
    border: none;
}

.ld-customizer-fieldset-wrapper {
    counter-reset: fieldset-counter;
}

.ld-customizer-fieldset-wrapper fieldset {
    padding: 0;
    margin: 0;

    border: 1px solid #bed0d3;

    margin-bottom: 24px;

    display: flex;
    align-items: flex-start;
    justify-content: flex-start;
    flex-flow: column nowrap;
    gap: 0;
}

.ld-customizer-fieldset-wrapper fieldset.hidden {
    display: none;
}

.ld-customizer-fieldset-wrapper fieldset>legend {
    display: block;
    position: relative;
    float: left;
    width: 100%;

    background-color: #63d8bf;
    color: #fff;

    padding: 12px;

    font-weight: 700;
}

.ld-customizer-fieldset-wrapper fieldset>legend::before {
    counter-increment: fieldset-counter;
    content: "Step " counter(fieldset-counter) ": ";
}

.ld-customizer-fieldset-wrapper fieldset>div {
    padding: 12px;
    margin: 0;
    width: 100%;

    display: flex;
    align-items: flex-start;
    justify-content: flex-start;
    flex-flow: column nowrap;
    gap: 12px;
}

.ld-customizer-form-field {
    width: 100%;
    display: flex;
    align-items: stretch;
    justify-content: flex-start;
    flex-flow: column nowrap;
    gap: 6px;
}

.ld-customizer-form-field>select {
    appearance: none;
    border: 1px solid #bed0d3;
    border-radius: 0;
    background: #fff;
    color: #3a3939;
    display: block;
    padding: 14px 15px 9px;
    font-size: 14px;
    -webkit-box-sizing: border-box;
    -moz-box-sizing: border-box;
    box-sizing: border-box;
}

.ld-customizer-fieldset-wrapper fieldset>div.ld-customizer-label-design-inputs-wrapper {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    grid-auto-rows: auto;
    gap: 6px;

    width: 100%;
}

@media (max-width: 720px) {
    .ld-customizer-fieldset-wrapper fieldset>div.ld-customizer-label-design-inputs-wrapper {
        grid-template-columns: repeat(4, 1fr);
    }
}

.ld-customizer-label-design-input {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-flow: row nowrap;
    gap: 6px;
    padding: 6px;

    position: relative;

    width: 100%;
    height: auto;

    aspect-ratio: 1/1;
}

.ld-customizer-label-design-input>input {
    position: absolute;
    width: 0;
    height: 0;
    opacity: 0;
}

.ld-customizer-label-design-input>label {
    user-select: none;
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;

    color: transparent;

    cursor: pointer;

    border: 2px solid #bed0d3;

    transition: all 0.2s ease;
}

.ld-customizer-label-design-input>input:checked+label {
    border-color: #63d8bf;
}

/* Mobile Preview Styles */
.ld-customizer-mobile-preview-container {
    display: none !important;
    width: 100%;
    margin-top: 24px;
    margin-bottom: 24px;
    background-color: #fff;
    border: 1px solid #bed0d3;
    padding: 12px;
    border-radius: 4px;
}

.ld-customizer-mobile-preview-container.show {
    display: block !important;
}

.ld-customizer-mobile-preview-header {
    font-weight: 700;
    padding: 10px;
}

.ld-customizer-mobile-preview-header h3 {
    margin: 0;
    font-size: 16px;
    font-weight: 700;
    text-align: center;
}

.ld-customizer-mobile-preview-content {
    padding: 12px 0;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 200px;
}

.ld-customizer-mobile-preview {
    width: 100%;
    height: auto;
    aspect-ratio: 1/1;
    background-position: center;
    background-size: contain;
    background-repeat: no-repeat;
    position: relative;
    background-color: #eceeec;
    transition: background-color 0.3s ease, background-image 0.3s ease;
}

.ld-customizer-mobile-preview.has-background-image {
    background-color: transparent;
}

.ld-customizer-mobile-preview-wrapper {
  display: none;
}

/* Show mobile preview on mobile screens only when explicitly shown by JavaScript */
@media (max-width: 989px) {
    .ld-customizer-mobile-preview-container.show {
        display: block !important;
    }

    .ld-customizer-mobile-preview-wrapper {
      display: block
    };
}

/* Loading States */
.ld-customizer-loading {
    position: relative;
    pointer-events: none;
    opacity: 0.6;
}

.ld-customizer-fieldset-wrapper fieldset.ld-customizer-loading {
    opacity: 0.8;
}

.ld-customizer fieldset {
  transition: opacity 0.3s ease;
}
