/**
 * WooCommerce Try On Frontend CSS.
 *
 * @package WooCommerce_Try_On
 */

/**
 * Scroll Lock Class
 * Used to prevent body scrolling when popup/lightbox is open.
 * Uses a class instead of inline styles to avoid conflicts with theme scripts.
 */
body.tryloom-scroll-lock {
    overflow: hidden !important;
    position: fixed;
    width: 100%;
    height: 100%;
}

:root {
    /* Colors - Light Theme (Default) */
    --tryloom-bg-primary: #ffffff;
    --tryloom-bg-secondary: #f8f9fa;
    --tryloom-bg-tertiary: #f7fafc;
    --tryloom-bg-gradient-start: #ffffff;
    --tryloom-bg-gradient-end: #f8f9fa;

    --tryloom-text-main: #2d3748;
    --tryloom-text-body: #718096;
    --tryloom-text-label: #4a5568;
    --tryloom-text-light: #ffffff;

    --tryloom-border-color: #cbd5e0;
    --tryloom-border-light: rgba(0, 0, 0, 0.05);

    /* Functional Colors */
    --tryloom-success: #48bb78;
    --tryloom-error: #e53e3e;
    --tryloom-warning: #ecc94b;

    /* Shadows */
    --tryloom-shadow-sm: 0 4px 15px rgba(0, 0, 0, 0.1);
    --tryloom-shadow-md: 0 10px 25px rgba(0, 0, 0, 0.1);

    /* Component Specific */
    --tryloom-header-bg: rgba(255, 255, 255, 0.5);
    --tryloom-input-bg: #fff;
    --tryloom-input-border: #e2e8f0;
    --tryloom-close-color: #555;
    --tryloom-close-hover: #e53e3e;

    --tryloom-text-gradient-start: #667eea;
    --tryloom-text-gradient-end: #764ba2;

    --tryloom-scrollbar-track: rgba(0, 0, 0, 0.05);
    --tryloom-scrollbar-thumb: rgba(0, 0, 0, 0.2);
    --tryloom-scrollbar-hover: rgba(0, 0, 0, 0.3);

    --tryloom-container-bg: rgba(255, 255, 255, 0.5);
    --tryloom-container-border: rgba(0, 0, 0, 0.05);

    --tryloom-variation-bg: #fff;
    --tryloom-variation-border: rgba(0, 0, 0, 0.05);
    --tryloom-variation-hover-bg: rgba(102, 126, 234, 0.03);
    --tryloom-variation-hover-border: rgba(102, 126, 234, 0.3);

    --tryloom-retry-bg: #f7fafc;
    --tryloom-retry-text: #4a5568;
    --tryloom-retry-hover: #edf2f7;

    --tryloom-result-bg: linear-gradient(135deg, #f7fafc 0%, #edf2f7 100%);
    --tryloom-loading-overlay-bg: rgba(255, 255, 255, 0.95);
    --tryloom-spinner-track: rgba(102, 126, 234, 0.1);
    --tryloom-spinner-fill: #667eea;
}

.tryloom-theme-dark {
    /* Colors - Dark Theme Overrides */
    --tryloom-bg-primary: #1a1a2e;
    --tryloom-bg-secondary: #16213e;
    --tryloom-bg-tertiary: #2d3748;
    --tryloom-bg-gradient-start: #1a1a2e;
    --tryloom-bg-gradient-end: #16213e;

    --tryloom-text-main: #f7fafc;
    --tryloom-text-body: #cbd5e0;
    --tryloom-text-label: #e2e8f0;

    --tryloom-border-color: #4a5568;
    --tryloom-border-light: rgba(255, 255, 255, 0.1);

    --tryloom-shadow-sm: 0 4px 15px rgba(0, 0, 0, 0.3);
    --tryloom-shadow-md: 0 15px 35px rgba(0, 0, 0, 0.3);

    --tryloom-header-bg: rgba(255, 255, 255, 0.03);
    --tryloom-input-bg: #222851;
    --tryloom-input-border: #444a6a;
    --tryloom-close-color: #ccc;
    --tryloom-close-hover: #ff6b6b;

    --tryloom-text-gradient-start: #a8c0ff;
    --tryloom-text-gradient-end: #c5a1ff;

    --tryloom-scrollbar-track: rgba(255, 255, 255, 0.05);
    --tryloom-scrollbar-thumb: rgba(255, 255, 255, 0.2);
    --tryloom-scrollbar-hover: rgba(255, 255, 255, 0.3);

    --tryloom-container-bg: rgba(255, 255, 255, 0.03);
    --tryloom-container-border: rgba(255, 255, 255, 0.1);

    --tryloom-variation-bg: rgba(255, 255, 255, 0.03);
    --tryloom-variation-border: rgba(255, 255, 255, 0.1);
    --tryloom-variation-hover-bg: rgba(168, 192, 255, 0.05);
    --tryloom-variation-hover-border: rgba(168, 192, 255, 0.3);

    --tryloom-retry-bg: #2d3748;
    --tryloom-retry-text: #cbd5e0;
    --tryloom-retry-hover: #4a5568;

    --tryloom-result-bg: linear-gradient(135deg, #2d3748 0%, #1a202c 100%);
    --tryloom-loading-overlay-bg: rgba(26, 32, 44, 0.95);
    --tryloom-spinner-track: rgba(168, 192, 255, 0.1);
    --tryloom-spinner-fill: #a8c0ff;
}

/* Try On Button */
.tryloom-button {
    margin-left: 10px;
    vertical-align: middle;
    padding: 12px 28px;
    border-radius: 8px;
    font-weight: 600;
    font-size: 15px;
    border: none;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(0, 115, 170, 0.2);
    position: relative;
    overflow: hidden;
}

.tryloom-button>* {
    position: relative;
}

.tryloom-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 115, 170, 0.3);
}

/* Popup */
.tryloom-popup {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(8px);
    z-index: 999999;
    justify-content: center;
    align-items: center;
    opacity: 0;
    visibility: hidden;
    display: none;
}

.tryloom-popup.open {
    display: flex !important;
    opacity: 1;
    visibility: visible;
    animation: tryloom-popup-fadein 0.3s ease forwards;
}

@keyframes tryloom-popup-fadein {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

.tryloom-popup-content {
    width: 90%;
    max-width: 900px;
    max-height: 90vh;
    background: linear-gradient(135deg, var(--tryloom-bg-gradient-start) 0%, var(--tryloom-bg-gradient-end) 100%);
    border-radius: 20px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    box-shadow: var(--tryloom-shadow-md);
    transform: scale(0.95);
    transition: transform 0.3s ease;
    position: relative;
    color: var(--tryloom-text-main);
}

.tryloom-popup.open .tryloom-popup-content {
    transform: scale(1);
}

/* Dark mode overrides handled by variables */

/* Component Styling using Variables */
.tryloom-popup-content input,
.tryloom-popup-content select {
    background: var(--tryloom-input-bg) !important;
    color: var(--tryloom-text-main) !important;
    border-color: var(--tryloom-input-border);
}

.tryloom-popup-header,
.tryloom-popup-body,
.tryloom-result,
.tryloom-account,
.tryloom-upload-preview,
.tryloom-popup-footer,
.tryloom-history-table th,
.tryloom-history-table td {
    color: var(--tryloom-text-main);
}



/* Keep button text white but allow inline background-color to work */
.tryloom-theme-dark .tryloom-generate,
.tryloom-theme-dark .tryloom-add-to-cart {
    color: #fff !important;
    border-color: transparent;
}

.tryloom-theme-dark .tryloom-variation.selected {
    background: rgba(255, 255, 255, 0.08) !important;
}

.tryloom-popup-header {
    padding: 25px 30px;
    background: var(--tryloom-header-bg);
    border-bottom: 1px solid var(--tryloom-border-light);
    display: flex;
    justify-content: space-between;
    align-items: center;
    backdrop-filter: blur(10px);
}

.tryloom-popup-header h3 {
    margin: 0;
    font-size: 24px;
    font-weight: 700;
    background: linear-gradient(135deg, var(--tryloom-text-gradient-start) 0%, var(--tryloom-text-gradient-end) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.tryloom-popup-close {
    background: transparent;
    border: none;
    width: 40px;
    height: 40px;
    font-size: 24px;
    cursor: pointer;
    color: var(--tryloom-close-color);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}

.tryloom-popup-close:hover {
    transform: rotate(90deg) scale(1);
    color: var(--tryloom-close-hover);
    background: transparent
}

.tryloom-popup-body {
    padding: 30px;
    overflow-y: auto;
    flex: 1;
    position: relative;
}

/* Custom Scrollbar */
.tryloom-popup-body::-webkit-scrollbar {
    width: 8px;
}

.tryloom-popup-body::-webkit-scrollbar-track {
    background: var(--tryloom-scrollbar-track);
    border-radius: 10px;
}

.tryloom-popup-body::-webkit-scrollbar-thumb {
    background: var(--tryloom-scrollbar-thumb);
    border-radius: 10px;
}

.tryloom-popup-body::-webkit-scrollbar-thumb:hover {
    background: var(--tryloom-scrollbar-hover);
}

/* Step 1 */
.tryloom-step {
    display: flex;
    flex-wrap: wrap;
    /* Force 2 columns on desktop, wrap actions to bottom */
    gap: 30px;
}

.tryloom-upload {
    flex: 1 1 calc(50% - 15px);
    min-width: 280px;
}

.tryloom-variations {
    flex: 1 1 calc(50% - 15px);
    min-width: 280px;
}

/* Single Column Layout with Fixed Buttons */
@media (max-width: 768px) {
    .tryloom-popup-content {
        width: 95%;
        max-height: 90vh;
        display: flex;
        flex-direction: column;
    }

    .tryloom-popup-header {
        padding: 15px 20px;
        flex-shrink: 0;
    }

    .tryloom-popup-body {
        padding: 20px;
        padding-bottom: 90px;
        /* Space for fixed button */
        flex: 1;
        overflow-y: auto;
    }

    .tryloom-step {
        flex-direction: column;
        gap: 20px;
    }

    .tryloom-upload,
    .tryloom-variations {
        display: flex;
        flex-direction: column;
    }

    .tryloom-upload h4,
    .tryloom-variations h4 {
        font-size: 16px;
    }

    /* Fixed Generate Button at Bottom */
    .tryloom-step-1 .tryloom-actions {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        z-index: 100;
        background: rgba(255, 255, 255, 0.98);
        backdrop-filter: blur(10px);
        padding: 15px 20px;
        margin: 0;
        box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.1);
        border-top: 1px solid rgba(0, 0, 0, 0.05);
        width: AUTO;
    }

    .tryloom-theme-dark .tryloom-step-1 .tryloom-actions {
        background: rgba(26, 32, 44, 0.98);
        border-top-color: rgba(255, 255, 255, 0.1);
    }

    .tryloom-step-1 .tryloom-actions .tryloom-generate {
        width: 100%;
        margin: 0;
        padding: 14px 20px;
        font-size: 16px;
    }

    /* Fixed Looks Good Button at Bottom for Step 2 */
    .tryloom-step-2 .tryloom-result-actions {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        z-index: 999;
        background: rgba(255, 255, 255, 0.98);
        backdrop-filter: blur(10px);
        padding: 15px 20px;
        margin: 0;
        box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.1);
        border-top: 1px solid rgba(0, 0, 0, 0.05);
    }

    .tryloom-theme-dark .tryloom-step-2 .tryloom-result-actions {
        background: rgba(26, 32, 44, 0.98);
        border-top-color: rgba(255, 255, 255, 0.1);
    }

    .tryloom-step-2 .tryloom-result-actions .button,
    .tryloom-step-2 .tryloom-result-actions .tryloom-add-to-cart {
        width: 100%;
        max-width: none;
        margin: 0;
        padding: 14px 20px;
        font-size: 16px;
    }

    .tryloom-result-image {
        padding: 15px;
    }

    .tryloom-image-actions {
        bottom: 15px;
        right: 15px;
    }

    /* Scroll lock during generation */
    .tryloom-popup-body.is-generating {
        overflow: hidden !important;
        touch-action: none;
        -webkit-overflow-scrolling: none;
    }
}

.tryloom-upload h4,
.tryloom-variations h4 {
    margin-top: 0;
    margin-bottom: 20px;
    font-size: 18px;
    font-weight: 700;
    color: var(--tryloom-text-main);
}

.tryloom-upload-area,
.tryloom-variations-container {
    flex: 1;
    /* Grow to fill space if needed */
    height: 320px;
    /* Fixed height for consistency */
    min-height: 320px;
    /* Prevent shrinking */
    max-height: 320px;
    /* Prevent growing (enables scrolling for variations) */
    box-sizing: border-box;

}

.tryloom-upload-area {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    margin-bottom: 0;
    border: 3px dashed #cbd5e0;
    border-radius: 16px;
    padding: 30px;
    text-align: center;
    cursor: pointer;
    min-height: 250px;
    background: linear-gradient(135deg, #f7fafc 0%, #edf2f7 100%);
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}


.tryloom-upload-area:before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: color-mix(in srgb, var(--tryloom-primary-color, #667eea) 10%, transparent);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.tryloom-upload-area:hover:before {
    opacity: 1;
}

.tryloom-upload-area:hover {
    border-color: var(--tryloom-primary-color, #667eea);
    transform: translateY(-2px);
    box-shadow: 0 10px 30px rgba(102, 126, 234, 0.1);
}

.tryloom-theme-dark .tryloom-upload-area {
    border-color: #4a5568;
    background: linear-gradient(135deg, #2d3748 0%, #1a202c 100%);
}

.tryloom-theme-dark .tryloom-upload-area:hover {
    border-color: var(--tryloom-primary-color, #a8c0ff);
}

.tryloom-upload-placeholder p {
    margin: 0;
    color: #718096;
}

.tryloom-upload-title {
    font-size: 20px;
    font-weight: 500;
    color: #5a5a5a;
}

.tryloom-upload-subtitle {
    font-size: 14px;
    font-weight: 400;
    color: #888;
}

.tryloom-theme-dark .tryloom-upload-title {
    color: #e0e0e0;
}

.tryloom-theme-dark .tryloom-upload-subtitle {
    color: #a0a0a0;
}

.tryloom-file {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    border: 0;
}

.tryloom-preview {
    max-width: 100%;
    max-height: 250px;
    margin: 0 auto;
    position: relative;
    z-index: 1;
}

.tryloom-preview img {
    max-width: 100%;
    max-height: 250px;
    object-fit: contain;
    border-radius: 12px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
}

.tryloom-remove-image {
    position: absolute;
    top: 10px;
    right: 10px;
    background: transparent;
    border: none;
    padding: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
    z-index: 10;
    color: #e53e3e;
    font-size: 20px;
    background-color: transparent !important;
}

.tryloom-remove-image:hover {
    transform: scale(1.2);
    color: #c53030;
    background-color: transparent !important;
}

.tryloom-remove-image svg,
.tryloom-remove-image i {
    width: 20px;
    height: 20px;
    fill: none;
    stroke: currentColor;
    font-size: 20px;
}



.tryloom-variations-container {
    max-height: 350px;
    overflow-y: auto;
    border: 1px solid var(--tryloom-container-border);
    border-radius: 12px;
    padding: 15px;
    background: var(--tryloom-container-bg);
}

.tryloom-variations-container::-webkit-scrollbar {
    width: 6px;
}

.tryloom-variations-container::-webkit-scrollbar-track {
    background: var(--tryloom-scrollbar-track);
    border-radius: 10px;
}

.tryloom-variations-container::-webkit-scrollbar-thumb {
    background: var(--tryloom-scrollbar-thumb);
    border-radius: 10px;
}

.tryloom-variation {
    display: flex;
    align-items: center;
    margin-bottom: 12px;
    padding: 15px;
    border: 2px solid var(--tryloom-variation-border);
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.3s ease;
    background: var(--tryloom-variation-bg);
}

.tryloom-variation:hover {
    border-color: var(--tryloom-variation-hover-border);
    background: var(--tryloom-variation-hover-bg);
    transform: translateX(5px);
}

.tryloom-variation.selected {
    border-color: var(--tryloom-primary-color, #667eea);
    background: color-mix(in srgb, var(--tryloom-primary-color, #667eea) 5%, transparent);
    box-shadow: 0 4px 15px color-mix(in srgb, var(--tryloom-primary-color, #667eea) 20%, transparent);
}

.tryloom-theme-dark .tryloom-variation.selected {
    border-color: var(--tryloom-primary-color, #a8c0ff);
    background: color-mix(in srgb, var(--tryloom-primary-color, #a8c0ff) 15%, transparent);
}

.tryloom-variation-image {
    width: 60px;
    height: 60px;
    margin-right: 15px;
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
}

.tryloom-variation-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.tryloom-variation-details {
    flex: 1;
}

.tryloom-variation-name {
    font-weight: 600;
    margin-bottom: 6px;
    color: var(--tryloom-text-main);
    font-size: 15px;
}

.tryloom-variation-price {
    font-size: 14px;
    color: var(--tryloom-text-body);
    font-weight: 500;
}

.tryloom-actions {
    flex-basis: 100%;
    margin-top: 10px;
    text-align: center;
    width: 100%;
}

.tryloom-generate,
.tryloom-retry,
.tryloom-add-to-cart,
.tryloom-download {
    padding: 14px 32px;
    border-radius: 10px;
    font-weight: 600;
    font-size: 15px;
    border: none;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    position: relative;
    overflow: hidden;
}

/* Disabled button styles - only change color, don't make smaller */
.tryloom-generate:disabled,
.tryloom-retry:disabled,
.tryloom-add-to-cart:disabled,
.tryloom-download:disabled {
    background-color: #cccccc !important;
    color: #666666 !important;
    cursor: not-allowed;
    transform: none !important;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1) !important;
}

.tryloom-generate:before,
.tryloom-add-to-cart:before,
.tryloom-download:before {
    content: none;
}

.tryloom-generate>*,
.tryloom-add-to-cart>*,
.tryloom-download>* {
    position: relative;
    z-index: 1;
}

.tryloom-generate:hover,
.tryloom-add-to-cart:hover,
.tryloom-download:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.15);
}

/* Disabled buttons should not have hover effects */
.tryloom-generate:disabled:hover,
.tryloom-add-to-cart:disabled:hover,
.tryloom-download:disabled:hover {
    transform: none !important;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1) !important;
}

.tryloom-retry {
    background: var(--tryloom-retry-bg);
    color: var(--tryloom-retry-text);
    position: relative;
    overflow: hidden;
}

.tryloom-retry:before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.3), transparent);
    transition: left 0.5s;
    z-index: 0;
    pointer-events: none;
}

.tryloom-retry:hover:before {
    left: 100%;
}

.tryloom-retry>* {
    position: relative;
    z-index: 1;
}

.tryloom-retry:hover {
    background: var(--tryloom-retry-hover);
    transform: translateY(-2px);
}

/* Step 2 */
.tryloom-result {
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 100%;
}

.tryloom-result-image {
    margin-bottom: 30px;
    width: 100%;
    max-width: 500px;
    padding: 15px;
    background: var(--tryloom-result-bg);
    border-radius: 16px;
    box-shadow: inset 0 2px 10px rgba(0, 0, 0, 0.05);
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
    min-height: 300px;
    margin-left: auto;
    margin-right: auto;
}

.tryloom-result-image img {
    max-width: 100%;
    max-height: 450px;
    object-fit: contain;
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
    transition: opacity 0.3s ease;
}

.tryloom-result-image.is-loading img {
    opacity: 0;
}

.tryloom-result-loading {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(247, 250, 252, 0.85);
    border-radius: inherit;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s ease;
    pointer-events: none;
    z-index: 6;
}

.tryloom-theme-dark .tryloom-result-loading {
    background: rgba(26, 32, 44, 0.85);
}

.tryloom-result-loading.is-active {
    opacity: 1;
    visibility: visible;
}

.tryloom-image-actions {
    display: flex;
    gap: 10px;
    position: absolute;
    bottom: 30px;
    right: 30px;
    z-index: 5;
}

.tryloom-icon-button {
    width: auto;
    height: auto;
    border-radius: 0;
    background: transparent;
    border: none;
    padding: 8px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
    color: #667eea;
    background-color: transparent !important;
}

.tryloom-icon-button:hover {
    transform: scale(1.1);
    color: #764ba2;
    background-color: white !important;
}

.tryloom-icon-button svg,
.tryloom-icon-button i {
    width: 20px;
    height: 20px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
    font-size: 18px;
}

.tryloom-download-icon {
    color: #667eea;
}

.tryloom-download-icon:hover {
    color: #764ba2;
}

.tryloom-download-icon:hover svg,
.tryloom-download-icon:hover i {
    color: #764ba2;
}

.tryloom-retry-icon {
    color: #718096;
}

.tryloom-retry-icon:hover {
    color: #4a5568;
}

.tryloom-theme-dark .tryloom-icon-button {
    color: #a8c0ff;
}

.tryloom-theme-dark .tryloom-retry-icon:hover {
    color: #cbd5e0;
}

.tryloom-result-actions {
    display: flex;
    justify-content: center;
    gap: 15px;
    flex-wrap: wrap;
    width: 100%;
    padding: 0 20px;
    box-sizing: border-box;
}

.tryloom-result-actions .button,
.tryloom-result-actions .tryloom-add-to-cart {
    width: 100%;
    max-width: 400px;
    text-align: center;
}

/* Loading Overlay */
.tryloom-loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    height: 100%;
    background: var(--tryloom-loading-overlay-bg);
    z-index: 1000;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    pointer-events: all;
}

.tryloom-spinner {
    border: 4px solid var(--tryloom-spinner-track);
    border-radius: 50%;
    border-top: 4px solid var(--tryloom-spinner-fill);
    width: 50px;
    height: 50px;
    animation: tryloom-spin 1s linear infinite;
    margin-bottom: 20px;
}

.tryloom-loading-overlay p {
    font-size: 16px;
    font-weight: 600;
    color: var(--tryloom-text-main);
    margin-top: 20px;
    letter-spacing: 0.5px;
}

@keyframes tryloom-spin {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

/* Upload Progress */
.tryloom-upload-progress-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--tryloom-loading-overlay-bg);
    backdrop-filter: blur(10px);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    border-radius: 16px;
    z-index: 5;
}

.tryloom-upload-progress-overlay .tryloom-progress-circle {
    order: 1;
}

.tryloom-upload-progress-overlay .tryloom-progress-text {
    order: 2;
    margin-top: 25px;
    margin-bottom: 0;
    font-size: 13px;
    font-weight: 500;
    color: var(--tryloom-text-label);
    text-align: center;
    display: block;
}

.tryloom-progress-circle {
    width: 80px;
    height: 80px;
    position: relative;
}

.tryloom-progress-circle svg {
    transform: rotate(-90deg);
}

.tryloom-progress-circle-bg {
    fill: none;
    stroke: rgba(102, 126, 234, 0.1);
    stroke-width: 8;
}

.tryloom-progress-circle-fill {
    fill: none;
    stroke: #667eea;
    stroke-width: 8;
    stroke-linecap: round;
    transition: stroke-dashoffset 0.3s ease;
}

.tryloom-theme-dark .tryloom-progress-circle-fill {
    stroke: #a8c0ff;
}

.tryloom-progress-text {
    margin-top: 15px;
    margin-bottom: 0;
    font-size: 13px;
    font-weight: 500;
    color: #4a5568;
    text-align: center;
}

.tryloom-theme-dark .tryloom-progress-text {
    color: #cbd5e0;
}

/* Upload overlay specific styling */
.tryloom-upload-progress-overlay .tryloom-spinner {
    display: block !important;
    margin: 0 auto;
    width: 50px;
    height: 50px;
}

.tryloom-upload-progress-overlay .tryloom-progress-text {
    margin-top: 20px;
    font-size: 13px;
    text-align: center;
}

.tryloom-progress-percent {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 18px;
    font-weight: 700;
    color: #667eea;
}

.tryloom-theme-dark .tryloom-progress-percent {
    color: #a8c0ff;
}

/* Account Page */
.tryloom-upload-new-photo-section {
    margin: 20px 0 30px;
    padding: 20px;
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.05) 0%, rgba(118, 75, 162, 0.05) 100%);
    border-radius: 12px;
    border: 2px dashed rgba(102, 126, 234, 0.3);
}

.tryloom-upload-photo-btn {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white !important;
    border: none !important;
    padding: 12px 24px;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.tryloom-upload-photo-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.4);
}

.tryloom-history-actions {
    margin: 20px 0;
    text-align: right;
}

.tryloom-delete-all-history {
    background: rgba(229, 62, 62, 0.1);
    color: #e53e3e;
    border: 2px solid rgba(229, 62, 62, 0.3);
    padding: 10px 20px;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.tryloom-delete-all-history:hover {
    background: rgba(229, 62, 62, 0.2);
    transform: translateY(-2px);
}

.tryloom-delete-history {
    background: rgba(229, 62, 62, 0.1);
    color: #e53e3e !important;
    border: 1px solid rgba(229, 62, 62, 0.3);
    padding: 8px 16px;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.tryloom-delete-history:hover {
    background: rgba(229, 62, 62, 0.2);
    transform: translateY(-2px);
}

.tryloom-account-photos {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 25px;
    margin-bottom: 40px;
}

.tryloom-account-photo {
    border: 2px solid rgba(0, 0, 0, 0.05);
    border-radius: 16px;
    overflow: hidden;
    position: relative;
    transition: all 0.3s ease;
    background: white;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.05);
}

.tryloom-account-photo:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
}

.tryloom-account-photo.is-default {
    border-color: #667eea;
    box-shadow: 0 4px 20px rgba(102, 126, 234, 0.2);
}

.tryloom-account-photo.is-default:before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.1) 0%, rgba(118, 75, 162, 0.1) 100%);
    pointer-events: none;
    z-index: 1;
}

.tryloom-account-photo-image {
    height: 220px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #f7fafc 0%, #edf2f7 100%);
    position: relative;
    overflow: hidden;
}

.tryloom-account-photo-image img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    position: relative;
    z-index: 2;
}

.tryloom-account-photo-actions {
    padding: 15px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(247, 250, 252, 0.8);
    backdrop-filter: blur(10px);
    gap: 10px;
}

.tryloom-account-photo-actions button {
    padding: 8px 16px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    border: none;
    cursor: pointer;
    transition: all 0.3s ease;
}

.tryloom-set-default {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.tryloom-set-default:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

.tryloom-delete {
    background: rgba(0, 0, 0, 0.05);
    color: #e53e3e;
}

.tryloom-delete:hover {
    background: rgba(229, 62, 62, 0.1);
    transform: translateY(-2px);
}

.tryloom-default-label {
    font-size: 12px;
    font-weight: 700;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #fff;
    padding: 6px 12px;
    border-radius: 6px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.tryloom-history-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0 12px;
}

.tryloom-history-table th,
.tryloom-history-table td {
    padding: 16px;
    text-align: left;
}

.tryloom-history-table thead tr {
    background: transparent;
    color: inherit;
}

.tryloom-history-table th {
    font-weight: 600;
    text-transform: none;
    font-size: 14px;
    letter-spacing: normal;
}

.tryloom-history-table th:first-child {
    border-radius: 10px 0 0 10px;
}

.tryloom-history-table th:last-child {
    border-radius: 0 10px 10px 0;
}

.tryloom-history-table tbody tr {
    background: white;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
    transition: all 0.3s ease;
}

.tryloom-history-table tbody tr:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
}

.tryloom-history-table td:first-child {
    border-radius: 10px 0 0 10px;
}

.tryloom-history-table td:last-child {
    border-radius: 0 10px 10px 0;
}

.tryloom-history-image img {
    width: 60px;
    height: 60px;
    object-fit: cover;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    transition: transform 0.3s ease;
}

.tryloom-history-image img:hover {
    transform: scale(1.1);
}

.tryloom-upload-area.dragover {
    border-color: var(--tryloom-primary-color, #667eea);
    background: color-mix(in srgb, var(--tryloom-primary-color, #667eea) 10%, transparent);
    transform: scale(1.02);
}

.tryloom-theme-dark .tryloom-upload-area.dragover {
    border-color: var(--tryloom-primary-color, #a8c0ff);
    background: color-mix(in srgb, var(--tryloom-primary-color, #a8c0ff) 15%, transparent);
}

.tryloom-upload-placeholder svg {
    opacity: 0.5;
    transition: all 0.3s ease;
}

.tryloom-upload-area:hover .tryloom-upload-placeholder svg {
    opacity: 0.8;
    transform: scale(1.1);
}

/* Pagination Styles */
.tryloom-pagination {
    margin: 20px 0;
    text-align: center;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.tryloom-page-link,
.tryloom-current-page {
    display: inline-block;
    padding: 8px 12px;
    border-radius: 6px;
    text-decoration: none;
    font-weight: 600;
    transition: all 0.3s ease;
    min-width: 40px;
    text-align: center;
}

.tryloom-page-link {
    background: #f7fafc;
    color: #4a5568;
    border: 1px solid #e2e8f0;
}

.tryloom-page-link:hover {
    background: #e2e8f0;
    color: #2d3748;
    border-color: #cbd5e0;
}

.tryloom-current-page {
    background: #667eea;
    color: white;
    border: 1px solid #667eea;
}

.tryloom-theme-dark .tryloom-page-link {
    background: #2d3748;
    color: #cbd5e0;
    border: 1px solid #4a5568;
}

.tryloom-theme-dark .tryloom-page-link:hover {
    background: #4a5568;
    color: #f7fafc;
    border-color: #718096;
}

.tryloom-theme-dark .tryloom-current-page {
    background: #667eea;
    color: white;
    border: 1px solid #667eea;
}

/* Font Awesome icon styling */
.tryloom-history-actions .button i,
.tryloom-delete-history i,
.tryloom-generate i,
.tryloom-download i,
.tryloom-retry i,
.tryloom-add-to-cart i {
    margin-right: 6px;
    font-size: 14px;
}

/* Lightbox Styles */
.tryloom-lightbox {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.9);
    z-index: 9999999;
    justify-content: center;
    align-items: center;
    cursor: pointer;
}

.tryloom-lightbox.open {
    display: flex;
}

.tryloom-lightbox-content {
    max-width: 90%;
    max-height: 90%;
    cursor: default;
}

.tryloom-lightbox-content img {
    max-width: 100%;
    max-height: 90vh;
    object-fit: contain;
    border-radius: 8px;
    box-shadow: 0 0 30px rgba(255, 255, 255, 0.1);
}

.tryloom-lightbox-close {
    position: absolute;
    top: 20px;
    right: 20px;
    color: white;
    font-size: 30px;
    cursor: pointer;
    background: transparent;
    border: none;
    width: 50px;
    height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background 0.3s ease;
}

.tryloom-lightbox-close:hover {
    background: rgba(255, 255, 255, 0.1);
}

/* Make history images clickable for lightbox */
.tryloom-history-image {
    display: inline-block;
    cursor: pointer;
}

.tryloom-history-image img {
    transition: transform 0.3s ease;
}

.tryloom-history-image:hover img {
    transform: scale(1.05);
}

/* Result image in popup also clickable for lightbox */
.tryloom-result-image {
    cursor: pointer;
}

/* Removed redundant 'Undo' button styles and Dead Code */

/* Mobile Responsive Fixes - Consolidated */
/* Bug R2-8: Icon buttons standard size */
.tryloom-icon-button {
    width: 44px !important;
    height: 44px !important;
    padding: 0 !important;
    border-radius: 50% !important;
    background: rgba(255, 255, 255, 0.95) !important;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.15) !important;
}

.tryloom-theme-dark .tryloom-icon-button {
    background: rgba(45, 55, 72, 0.95) !important;
}

/* Bug R2-7: Prevent scroll during generation overlay */
.tryloom-popup-body.is-generating {
    overflow: hidden !important;
    max-height: 100% !important;
    pointer-events: none;
}

.tryloom-popup-body.is-generating .tryloom-loading-overlay {
    pointer-events: all;
}

/* Circular Progress Ring (Filling Animation) */
.tryloom-progress-ring-container {
    position: relative;
    width: 80px;
    height: 80px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto;
}

.tryloom-progress-ring {
    transform: rotate(-90deg);
}

.tryloom-progress-ring-bg {
    stroke: var(--tryloom-spinner-track);
}

.tryloom-progress-ring-fill {
    stroke: var(--tryloom-primary-color, #667eea);
    transition: stroke-dashoffset 0.3s ease-out;
}

.tryloom-progress-percent {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 20px;
    font-weight: 700;
    color: var(--tryloom-spinner-fill);
}