#map-shortcode {
    display: flex;
    gap: 2em;
    max-width: 100%;
    width: 100%;
}
#canvas-master-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    aspect-ratio: 1 !important;
    max-height: 80vh;
    max-width: 40vw;
    height: 100%;
    width: 100%;
    background: #e8e8e8;
    position: relative;
}
#canvas-options {
    padding: .3em;
    max-width: 100%;
}
@media (min-width: 800px) {
    form.cart {
        margin-bottom: 0 !important;
        padding: 0 !important;
        height: 4em !important;
        position: absolute;
        bottom: 0;
        right: 0;
}
}
form.cart .price {
    margin: 0 !important;
}
.edit-link {
    display: none;
}
.entry-summary {
    position: relative;
}
@media (max-width: 800px) {
    /* Styles for screens smaller than 1000px */
    #map-shortcode {
        flex-wrap: wrap;
    }
    #canvas-master-wrapper {
        max-width: 100%;
    }
}
@media (min-width: 800px) {
    /* Styles for screens smaller than 1000px */
    #canvas-options {
        max-height: calc(40vw - 4em);
        overflow-y: scroll;
    }
}

#controls {
    position: absolute;
    bottom: 0;
    right: 0;
}
#frame {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    pointer-events: none;
    z-index: 10;
    scale: 1.1;
}
#frame .frame-image {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-repeat: no-repeat;
    background-position: center;
    background-size: contain;
    pointer-events: none;
}
#canvas-text-editor {
    min-width: 300px;
    display: flex;
    flex-wrap: wrap;
}
#canvas-text-editor label {
    width: 20%;
}
#canvas-text-editor div {
    width: 80%;
}
.has-frame #map-wrapper {
    scale: .85;
}
/* Define poster dimensions with responsive design */
.poster-size {
    margin: 0 auto; /* Center the container */
    position: relative;
    width: auto; /* Width adjusts based on aspect ratio */
    display: inline-block;
}
/* Map and Fabric.js layers are sized dynamically inside the container */
#map-container {
    width: 100% !important;
    height: 100% !important;
    mix-blend-mode: multiply;
    transition: all 0.3s ease;
}

#map,
#fabric-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}
.canvas-container {
    pointer-events: none;
}
.canvas-container, .canvas-container .upper-canvas, .canvas-container .lower-canvas {
    max-width: 100%;
    max-height: 100%;
}
.fabric-interactive {
    pointer-events: auto; /* Enable interaction for Fabric.js objects */
}
.maplibregl-control-container {
    display: none;
}
#map-wrapper {
    position: relative;
    background-image: url('/wp-content/plugins/fabric-map-plugin/assets/texture.jpg'); /* Replace with your texture URL */
    background-size: cover;
    background-repeat: no-repeat;
    background-position: center;
    scale: .9;
}
#map-container {
    mix-blend-mode: multiply;
}
#search-container {
    margin: 10px 0;
    display: flex;
    gap: 5px;
    position: relative;
    z-index: 999;
}
#search-suggestions {
    list-style: none;
    margin: 0;
    position: absolute;
    top: 100%;
    background: white;
    border: solid lightgrey;
    border-top: none;
    width: 100%;
}
#search-suggestions:empty {
    display: none !important;
}
#search-suggestions li {
    text-wrap: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    cursor: pointer;
    padding: .5em;
}
#search-suggestions li:hover {
    background: lightgrey;
}
#search-input {
    flex: 1;
    padding: 10px;
    font-size: 16px;
    border: 1px solid #ccc;
    border-radius: 5px;
}
#search-button {
    padding: 10px 15px;
    background-color: #0078ff;
    color: white;
    font-size: 16px;
    border: none;
    border-radius: 5px;
    cursor: pointer;
}
#search-button:hover {
    background-color: #0056cc;
}
#sizing-bars {
    position: absolute;
    pointer-events: none;
    top: 0;
    height: 100%;
    width: 100%;
}

#horizontal-bar {
    border-left: solid;
    border-right: solid;
    display: flex;
    gap: 1em;
    align-items: center;
    height: 1em;
    position: absolute;
    bottom: -1em;
    padding-top: 1em;
    left: 50%;
    transform: translateX(-50%);
    width: 100%; /* Initial width, will be updated dynamically */
}
#horizontal-bar:before, #horizontal-bar:after {
    content: '';
    height: 1px;
    width: 100%;
    background: #6d6d6d;
}
#canvas-master-wrapper .dashicons-image-rotate-left {
    rotate: 90deg;
    display: none;
}
#canvas-master-wrapper:has(.landscape) .dashicons-image-rotate-left {
    display: none;
}
#canvas-master-wrapper:has(.landscape) .dashicons-image-rotate-right {
    display: inline-block;
}
#vertical-bar:before, #vertical-bar:after {
    content: '';
    width: 1px;
    height: 100%;
    background: #6d6d6d;
}
#vertical-bar {
    border-top: solid;
    border-bottom: solid;
    display: flex;
    gap: 1em;
    flex-direction: column;
    align-items: center;
    width: 1em;
    position: absolute;
    right: -1em;
    padding-left: 1em;
    top: 50%;
    transform: translateY(-50%);
    height: 100%; /* Initial height, will be updated dynamically */
}
#vertical-bar span, #horizontal-bar span {
    aspect-ratio: 1;
    align-content: center;
    align-self: center;
    text-wrap: nowrap;
}
#vertical-bar span {
    rotate: 90deg;
}

.has-frame #vertical-bar {
    right: -5%;
}
.has-frame #horizontal-bar {
    bottom: -8%;
}
.has-frame .portrait #vertical-bar {
    right: -8%;
}
.has-frame .portrait #horizontal-bar {
    bottom: -5%;
}
.poster-size.portrait .horizontal-measure.landscape, .poster-size.portrait .vertical-measure.landscape {
    display: none;
}
.poster-size.landscape .horizontal-measure.portrait, .poster-size.landscape .vertical-measure.portrait {
    display: none;
}
.poster-size.portrait {
    max-height: 100%;
}
.poster-size.landscape {
    max-width: 100%;
}
#zoom-container {
    display: flex;
    flex-direction: column;
    position: absolute;
    top: 0;
    right: 0;
}
#toggle-frame {
    background: none;
    border: none;
    cursor: pointer;
    padding: 5px;
    margin: 5px;
    color: #333;
}

#toggle-frame:hover {
    color: #000;
}

#toggle-frame .dashicons {
    font-size: 20px;
}

#loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.9);
    z-index: 1000;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.loading-spinner {
    width: 50px;
    height: 50px;
    border: 5px solid #f3f3f3;
    border-top: 5px solid #000000;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 20px;
}

.loading-text {
    font-size: 18px;
    color: #333;
}

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

/* Preview label on cart/checkout thumbnails */
.woocommerce-checkout-review-order .product-thumbnail,
.cart_item .product-thumbnail {
    position: relative;
}

.woocommerce-checkout-review-order .product-thumbnail::after,
.cart_item .product-thumbnail::after {
    content: 'Preview';
    position: absolute;
    background: rgba(0, 0, 0, 0.3);
    color: white;
    padding: 2px 8px;
    font-size: 11px;
    border-radius: 3px;
    text-align: center;
    top: 20px;
    left: 50%;
    transform: translate(-50%);
    z-index: 1;
    -webkit-font-smoothing: antialiased;
    pointer-events: none;
}

/* Add these styles to fix product page layout */
.single-product .entry-summary {
    width: 100% !important;
    max-width: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
}

.single-product .content-area {
    width: 100% !important;
    max-width: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
}

.single-product #primary {
    width: 100% !important;
    max-width: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
}

.styles {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
}

.style-toggle {
    position: relative;
    padding: 0;
    border: 2px solid transparent;
    border-radius: 4px;
    overflow: hidden;
    cursor: pointer;
    background: none;
    transition: transform 0.2s ease;
    width: 150px;
    height: 150px;
}

.style-toggle img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.style-toggle .style-name {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: rgba(0, 0, 0, 0.7);
    color: white;
    padding: 5px;
    font-size: 12px;
    text-align: center;
}

.style-toggle:hover {
    transform: scale(1.05);
}

.style-toggle.selected {
    border-color: #000000;
}

.templates {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 20px;
}

.template-toggle {
    position: relative;
    padding: 0;
    border: 2px solid transparent;
    border-radius: 4px;
    overflow: hidden;
    cursor: pointer;
    background: none;
    transition: transform 0.2s ease;
    width: 150px;
}

.template-toggle .template-name {
    display: block;
    bottom: 0;
    left: 0;
    right: 0;
    background: rgba(0, 0, 0, 0.7);
    color: white;
    padding: 5px;
    font-size: 12px;
    text-align: center;
}

.template-toggle:hover {
    transform: scale(1.05);
}

.template-toggle.selected {
    border-color: hsl(0, 0%, 0%);
}

.frames {
    margin-top: 20px;
}

.frame-options {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 10px;
}

.frame-toggle {
    position: relative;
    padding: 5px;
    border: 2px solid transparent;
    border-radius: 4px;
    cursor: pointer;
    background: white;
    transition: transform 0.2s ease;
    min-width: 120px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.frame-toggle img {
    width: 100px;
    height: 100px;
    object-fit: cover;
    border-radius: 2px;
}

.frame-toggle .frame-name {
    font-size: 14px;
    text-align: center;
}

.frame-toggle:hover {
    transform: scale(1.05);
    border-color: #666;
}

.frame-toggle.selected {
    border-color: #000;
    background: #f0f0f0;
}

/* Style for the "No Frame" option */
.frame-toggle[data-frame-type="none"] {
    min-width: 100px;
    height: auto;
    padding: 10px;
}

.size-toggle {
    position: relative;
    padding: 10px 15px;
    border: 2px solid #e0e0e0;
    border-radius: 4px;
    cursor: pointer;
    background: white;
    transition: all 0.2s ease;
    width: 100%;
    text-align: left;
    margin-bottom: 5px;
    font-size: 14px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.size-toggle:hover {
    border-color: #666;
    background: #f9f9f9;
}

.size-toggle.selected {
    border-color: #000;
    background: #f0f0f0;
    font-weight: bold;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.size-toggle.selected:after {
    content: '✓';
    position: absolute;
    right: 10px;
    color: #000;
}

/* Price display within button */
.size-toggle .price {
    color: #666;
    font-weight: normal;
}

.size-toggle.selected .price {
    color: #000;
    font-weight: bold;
}

.frame-attributes {
    font-family: monospace;
    font-size: 12px;
    padding: 5px;
    border: 1px solid #ddd;
    border-radius: 4px;
    resize: vertical;
}

.frame-attributes:focus {
    border-color: #000;
    outline: none;
    box-shadow: 0 0 0 1px #000;
}
