/**
 * Artwork Visualizer Frontend Styles
 *
 * @package Artwork_Visualizer
 */

/* Button Styles - Updated for better UX and theme integration */
.av-visualizer-button {
    background-color: var(--button-primary-color, #548C2F);
    color: var(--button-text-color, #fff) !important;
    border-radius: var(--button-border-radius, 4px);
    padding: var(--button-padding, 0.85rem 1.75rem);
    text-transform: uppercase;
    font-weight: var(--button-font-weight, 600);
    font-size: var(--button-font-size, 1rem);
    transition: all var(--transition-speed, 0.3s ease);
    text-align: center;
    display: inline-block;
    text-decoration: none !important;
    border: 2px solid var(--button-primary-color, #4a7f29);
    cursor: pointer;
    box-shadow: var(--button-box-shadow, 0 4px 8px rgba(0,0,0,0.2));
    line-height: 1.5;
    min-width: 220px;
    position: relative;
    overflow: hidden;
    letter-spacing: 0.5px;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% {
        transform: scale(1);
        box-shadow: var(--button-box-shadow, 0 4px 8px rgba(0,0,0,0.2));
    }
    50% {
        transform: scale(1.03);
        box-shadow: 0 6px 12px rgba(0,0,0,0.25);
    }
    100% {
        transform: scale(1);
        box-shadow: var(--button-box-shadow, 0 4px 8px rgba(0,0,0,0.2));
    }
}

.av-visualizer-button:hover,
.av-visualizer-button:focus {
    background-color: var(--button-hover-color, #3e6822);
    color: var(--button-text-color, #fff) !important;
    text-decoration: none !important;
    box-shadow: 0 6px 12px rgba(0,0,0,0.3);
    transform: translateY(-2px);
    border-color: var(--button-hover-color, #335a1c);
}

/* Add glint animation effect */
.av-visualizer-button::after {
    content: "";
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.5), transparent);
    z-index: 2;
    animation: glint 2.5s ease-in-out infinite;
    pointer-events: none;
}

@keyframes glint {
    0% {
        left: -100%;
    }
    20% {
        left: 100%;
    }
    100% {
        left: 100%;
    }
}

/* Center the top wrapper div */
.see-in-room-top-wrapper {
    display: flex;
    justify-content: center;
    width: 100%;
    margin: 1.5rem auto;
}

/* Standard container for the button that works with any theme */
.av-visualizer-button-container {
    margin: var(--container-margin, 1rem auto);
    padding: var(--container-padding, 1.25rem);
    text-align: center;
    clear: both;
    width: 100%;
    box-sizing: border-box;
    background-color: var(--container-bg-color, #f0f5ec);
    box-shadow: var(--container-box-shadow, 0 3px 10px rgba(0,0,0,0.08));
    z-index: 10;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    border-left: 3px solid var(--button-primary-color, #548C2F);
    border-right: 3px solid var(--button-primary-color, #548C2F);
}

/* Style the visualization prompt text */
.visualize-prompt {
    margin-bottom: 0.75rem;
    font-weight: 600;
    color: #333;
    margin-top: 0;
    font-size: 1.05rem;
}

/* Mobile responsiveness for the button */
@media (max-width: 768px) {
    .av-visualizer-button-container {
        margin: 1rem 0;
        padding: 0.75rem;
    }

    .av-visualizer-button {
        width: 100%;
        max-width: 300px;
        padding: 0.75rem 1rem;
    }

    .visualize-prompt {
        font-size: 1rem;
        margin-bottom: 0.75rem;
    }

    .av-artwork-image {
        width: 100%;
        height: auto;
        display: block;
        box-shadow: none;
        border: 0.8vw solid white !important; /* Mat border - scales with viewport */
        border-style: solid !important;
        box-sizing: border-box;
        border-radius: 0 !important; /* Ensures square corners for mat */
    }
}

/* Small screens */
@media (max-width: 576px) {
    .av-visualizer-button-container {
        padding: 0.5rem;
    }
    
    .av-visualizer-button {
        font-size: 0.9rem;
        padding: 0.75rem 1rem;
    }
}

/* Modal Styles */
.av-visualizer-modal {
    display: none;
    position: fixed;
    z-index: 99999;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow-y: auto;
    background-color: rgba(0, 0, 0, 0.8);
    transition: opacity 0.3s ease;
    -webkit-overflow-scrolling: touch;
}

.av-visualizer-modal-content {
    position: relative;
    background-color: #fff;
    margin: 2vh auto;
    padding: 0;
    width: 95%;
    max-width: 1400px;
    height: auto;
    max-height: 96vh;
    border-radius: 8px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.15);
    animation: fadeIn 0.3s;
    display: flex;
    flex-direction: column;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.av-visualizer-modal-header {
    padding: 15px 20px;
    background-color: #f8f8f8;
    border-bottom: 1px solid #e5e5e5;
    border-top-left-radius: 8px;
    border-top-right-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.av-visualizer-modal-header h2 {
    margin: 0;
    font-size: 1.5rem;
    color: #333;
    flex-grow: 1;
    text-align: center;
    font-weight: 500;
}

.av-visualizer-close {
    color: #aaa;
    float: right;
    font-size: 28px;
    font-weight: bold;
    line-height: 1;
    cursor: pointer;
}

.av-visualizer-close:hover,
.av-visualizer-close:focus {
    color: #000;
    text-decoration: none;
}

.av-room-selector {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 15px;
    margin-bottom: 20px;
}

.av-room-selector label {
    font-weight: 500;
    margin-bottom: 0;
    color: #333;
}

.av-room-selector select {
    padding: 8px 12px;
    border-radius: 4px;
    border: 1px solid #ddd;
    background-color: #fff;
    min-width: 200px;
    font-size: 0.9rem;
}

/* Room tabs styling */
.av-room-tab-list {
    display: flex;
    flex-wrap: wrap;
    list-style: none;
    padding: 0;
    margin: 0 0 20px 0;
}

.av-room-tab {
    padding: 10px 20px;
    margin-right: 20px;
    cursor: pointer;
    background-color: #f0f0f0;
    border-radius: 4px;
    transition: all 0.3s ease;
}

.av-room-tab.active {
    color: #333;
    border-bottom: 3px solid #548C2F;
}

.av-room-tab:hover {
    color: #333;
}

.av-visualizer-room-container {
    position: relative;
    background-color: #f1f1f1;
    border-radius: 4px;
    overflow: hidden;
    min-height: 300px;
    flex: 1;
    display: flex;
    flex-direction: column;
}

.av-visualizer-loading {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(255, 255, 255, 0.8);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 10;
}

.av-visualizer-spinner {
    width: 50px;
    height: 50px;
    border: 5px solid #f3f3f3;
    border-top: 5px solid #3498db;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 15px;
}

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

.av-visualizer-error {
    padding: 20px;
    text-align: center;
    color: #721c24;
    background-color: #f8d7da;
    border: 1px solid #f5c6cb;
    border-radius: 4px;
}

.av-visualizer-room-preview {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Ensure proper aspect ratio maintained for room images */
.av-room-image-container {
    position: relative;
    width: 100%;
    max-height: calc(90vh - 180px); /* Account for header, tabs, and footer */
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
}

.av-room-image {
    width: 100%;
    height: auto;
    display: block;
    max-height: 100%;
    object-fit: contain;
}

.av-artwork-container {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    z-index: 5;
    text-align: center;
    box-shadow: 0 1px 4px rgba(0,0,0,0.3);
    border: none !important;
    background-color: #000 !important; /* Frame color */
    padding: 3px !important; /* Frame thickness */
    border-radius: 0 !important; /* Ensures square corners for frame */
    box-sizing: border-box !important;
}

.av-artwork-image {
    width: 100%;
    height: auto;
    display: block;
    box-shadow: none;
    border: 0.8vw solid white !important; /* Mat border - scales with viewport */
    border-style: solid !important;
    box-sizing: border-box;
    border-radius: 0 !important; /* Ensures square corners for mat */
}

/* Artwork sizes */
.av-artwork-size-small {
    width: 15%;
}

.av-artwork-size-medium {
    width: 25%;
}

.av-artwork-size-large {
    width: 35%;
}

/* Portrait mode artwork styling */
.av-portrait-artwork {
    max-height: 60%; /* Limit height for portrait images */
}

#av-artwork-container.av-portrait-artwork {
    padding: 3px !important; /* Frame thickness */
    box-sizing: border-box !important;
}

.av-portrait-artwork .av-artwork-image {
    width: 100%;
    height: auto;
    /* Adjust mat proportionally for portrait orientation */
    border-left-width: 15px !important;
    border-right-width: 15px !important;
    border-top-width: 15px !important;
    border-bottom-width: 15px !important;
}

.av-visualizer-modal-footer {
    padding: 15px 20px;
    background-color: #f8f8f8;
    border-top: 1px solid #e5e5e5;
    text-align: right;
    border-bottom-left-radius: 4px;
    border-bottom-right-radius: 4px;
}

/* Hide overflow when modal is open */
body.av-modal-open {
    overflow: hidden;
    position: fixed;
    width: 100%;
    height: 100%;
}

/* Room Tabs */
.av-room-tabs {
    width: 100%;
    margin-bottom: 10px;
}

/* Responsive Styles - moved to the end for better organization */
@media (max-width: 768px) {
    .av-visualizer-modal-content {
        width: 98%;
        margin: 1vh auto;
        max-height: 98vh;
    }
    
    .av-visualizer-modal-header {
        padding: 10px 15px;
    }
    
    .av-visualizer-modal-header h2 {
        font-size: 1.2rem;
    }
    
    .av-visualizer-modal-body {
        padding: 10px;
    }
    
    .av-visualizer-modal-footer {
        padding: 10px 15px;
    }
    
    .av-visualizer-controls {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .av-room-selector {
        width: 100%;
    }
    
    .av-room-selector select {
        width: 100%;
    }
    
    .av-room-image-container {
        max-height: calc(90vh - 150px);
    }
    
    /* Responsive Tabs */
    .av-room-tab-list {
        flex-direction: column;
        width: 100%;
    }
    
    .av-room-tab {
        padding-left: 10px !important;
        margin-right: 0;
        margin-bottom: 5px;
        border: 2px solid #ddd;
        border-radius: 4px;
        width: 100%;
        text-align: center;
    }
    
    .av-room-tab.active {
        border-bottom: 2px solid #ddd;
    }
    
    /* Add minimum size to artwork container */
    .av-artwork-container {
        min-width: 150px;
    }
    
    /* Ensure artwork image doesn't get too small */
    .av-artwork-image {
        min-width: 100px;
    }
}

/* Large Screens */
@media (min-width: 1600px) {
    .av-visualizer-modal-content {
        max-width: 1600px;
    }
    
    .av-room-image-container {
        max-height: calc(90vh - 200px);
    }
}

/* Single product page layout integration */
.woocommerce.single-product div.product {
    display: grid;
    grid-template-columns: 58% 38%;
    grid-gap: 4%;
}

/* Position button in left column of product grid */
.woocommerce.single-product .see-in-room-wrapper {
    grid-column: 1;
    margin-top: -0.5rem;
    margin-bottom: 2rem;
}

/* Modal Styles */
.av-visualizer-modal {
    display: none;
    position: fixed;
    z-index: 99999;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow-y: auto;
    background-color: rgba(0, 0, 0, 0.8);
    transition: opacity 0.3s ease;
    -webkit-overflow-scrolling: touch;
}

.av-visualizer-modal-content {
    position: relative;
    background-color: #fff;
    margin: 2vh auto;
    padding: 0;
    width: 95%;
    max-width: 1400px;
    height: auto;
    max-height: 96vh;
    border-radius: 8px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.15);
    animation: fadeIn 0.3s;
    display: flex;
    flex-direction: column;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.av-visualizer-modal-header {
    padding: 15px 20px;
    background-color: #f8f8f8;
    border-bottom: 1px solid #e5e5e5;
    border-top-left-radius: 8px;
    border-top-right-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.av-visualizer-modal-header h2 {
    margin: 0;
    font-size: 1.5rem;
    color: #333;
    flex-grow: 1;
    text-align: center;
    font-weight: 500;
}

.av-visualizer-close {
    color: #aaa;
    float: right;
    font-size: 28px;
    font-weight: bold;
    line-height: 1;
    cursor: pointer;
}

.av-visualizer-close:hover,
.av-visualizer-close:focus {
    color: #000;
    text-decoration: none;
}

.av-visualizer-modal-body {
    padding: 15px;
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

.av-visualizer-controls {
    margin-bottom: 10px;
}

.av-room-selector {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 15px;
    margin-bottom: 20px;
}

.av-room-selector label {
    font-weight: 500;
    margin-bottom: 0;
    color: #333;
}

.av-room-selector select {
    padding: 8px 12px;
    border-radius: 4px;
    border: 1px solid #ddd;
    background-color: #fff;
    min-width: 200px;
    font-size: 0.9rem;
}

/* Room tabs styling */
.av-room-tab-list {
    display: flex;
    flex-wrap: wrap;
    list-style: none;
    padding: 0;
    margin: 0 0 20px 0;
}

.av-room-tab {
    padding: 10px 20px;
    margin-right: 20px;
    cursor: pointer;
    background-color: #f0f0f0;
    border-radius: 4px;
    transition: all 0.3s ease;
}

.av-room-tab.active {
    color: #333;
    border-bottom: 3px solid #548C2F;
}

.av-room-tab:hover {
    color: #333;
}

.av-visualizer-room-container {
    position: relative;
    background-color: #f1f1f1;
    border-radius: 4px;
    overflow: hidden;
    min-height: 300px;
    flex: 1;
    display: flex;
    flex-direction: column;
}

.av-visualizer-loading {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(255, 255, 255, 0.8);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 10;
}

.av-visualizer-spinner {
    width: 50px;
    height: 50px;
    border: 5px solid #f3f3f3;
    border-top: 5px solid #3498db;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 15px;
}

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

.av-visualizer-error {
    padding: 20px;
    text-align: center;
    color: #721c24;
    background-color: #f8d7da;
    border: 1px solid #f5c6cb;
    border-radius: 4px;
}

.av-visualizer-room-preview {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Ensure proper aspect ratio maintained for room images */
.av-room-image-container {
    position: relative;
    width: 100%;
    max-height: calc(90vh - 180px); /* Account for header and footer */
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
}

.av-room-image {
    width: 100%;
    height: auto;
    display: block;
    max-height: 100%;
    object-fit: contain;
}

.av-artwork-container {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    z-index: 5;
    text-align: center;
    box-shadow: 0 1px 4px rgba(0,0,0,0.3);
    border: none !important;
    background-color: #000 !important; /* Frame color */
    padding: 3px !important; /* Frame thickness */
    border-radius: 0 !important; /* Ensures square corners for frame */
    box-sizing: border-box !important;
}

.av-visualizer-modal-footer {
    padding: 15px 20px;
    background-color: #f8f8f8;
    border-top: 1px solid #e5e5e5;
    display: flex;
    justify-content: center;
    border-bottom-left-radius: 8px;
    border-bottom-right-radius: 8px;
}

.av-visualizer-close-btn {
    background-color: #6c757d;
    color: #fff;
    border: none !important;
    padding: 8px 16px;
    border-radius: 4px;
    cursor: pointer;
    font-weight: 500;
    transition: all 0.3s ease;
}

.av-visualizer-close-btn:hover {
    background-color: #5a6268;
}

/* Mobile responsiveness */
@media (max-width: 768px) {
    .woocommerce.single-product div.product {
        display: block;
    }

    .see-in-room-wrapper {
        margin: 1rem 0;
    }
    
    .av-visualizer-button {
        width: 100%;
        padding: 0.75rem 1rem;
    }
    
    .av-room-tab-list {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 10px;
        padding-bottom: 5px;
        overflow-x: visible;
        white-space: normal;
    }

    .av-room-tab {
        display: block;
        float: none;
        margin-right: 0;
        text-align: center;
        font-size: 0.9rem;
    }
    
    .av-visualizer-modal-content {
        width: 95%;
        margin: 1vh auto;
        max-height: 98vh;
    }
    
    /* Add minimum size to artwork container */
    .av-artwork-container {
        min-width: 150px;
    }
    
    /* Ensure artwork image doesn't get too small */
    .av-artwork-image {
        min-width: 100px;
    }
}

/* Center price in product cards */
.related.products li.product .price,
.recently-viewed-products li.product .price {
    justify-content: center;
    text-align: center;
    display: flex;
    width: 100%;
    padding: 0 var(--card-padding, 1rem) var(--card-padding, 1rem);
    margin: 0;
}

/* Fix for variable products price with range */
.related.products li.product .price > span,
.recently-viewed-products li.product .price > span {
    display: inline-flex;
    justify-content: center;
}

/* Mobile adjustments for price centering */
@media (max-width: 576px) {
    .related.products li.product .price,
    .recently-viewed-products li.product .price,
    .woocommerce ul.products li.product .price {
        padding: 0 var(--spacing-sm, 0.5rem) var(--spacing-sm, 0.5rem);
        font-size: 0.875rem;
    }
    
    .av-room-tab-list {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 8px;
        padding-bottom: 5px;
        overflow-x: visible;
        white-space: normal;
    }

    .av-room-tab {
        display: block;
        float: none;
        margin-right: 0;
        text-align: center;
        padding: 8px 12px;
        font-size: 0.85rem;
    }

    .av-visualizer-modal-header {
        padding: 8px 12px;
    }

    .av-visualizer-modal-header h2 {
        font-size: 1rem;
        line-height: 1.2;
    }

    /* Balanced sizing for small screens */
    .av-artwork-container {
        min-width: 80px;
    }
    
    /* Ensure artwork doesn't get too small */
    .av-artwork-image {
        min-width: 40px;
        border-width: 0.6vw; /* Slightly thinner mat border on small screens */
    }
}

/* Very small screens */
@media (max-width: 375px) {
    .av-artwork-container {
        min-width: 60px;
        padding: 2%; /* Slightly thinner frame on small screens */
    }

    .av-artwork-image {
        min-width: 30px;
        border-width: 0.5vw; /* Thinner mat border for very small screens */
    }

    .av-visualizer-modal-header {
        padding: 6px 10px;
    }

    .av-visualizer-modal-header h2 {
        font-size: 0.9rem;
        line-height: 1.1;
    }
}

/* Extremely small screens */
@media (max-width: 320px) {
    .av-artwork-container {
        min-width: 50px;
        padding: 1.5%; /* Minimal frame on tiny screens */
    }

    .av-artwork-image {
        min-width: 30px; /* Keep artwork visible */
        border-width: 0.4vw; /* Minimal mat border for extremely small screens */
    }

    .av-visualizer-modal-header {
        padding: 5px 8px;
    }

    .av-visualizer-modal-header h2 {
        font-size: 0.8rem;
        line-height: 1.1;
    }
} 