/**
 * Virtual Try-On CSS - Modern Redesign v2
 * Targeting fashion/apparel business expectations.
 */

/* Base variables (can be overridden by themes) */
:root {
    --aivrtltryon-font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol";
    --aivrtltryon-border-radius-medium: 8px;
    --aivrtltryon-border-radius-large: 12px;
    --aivrtltryon-transition-duration: 0.2s;
}

/* Reset / Base styles within modal */
.aivrtltryon-modal *,
.aivrtltryon-modal *::before,
.aivrtltryon-modal *::after {
    box-sizing: border-box;
    font-family: var(--aivrtltryon-font-family);
}

.aivrtltryon-modal h2 {
    margin: 0 0 15px 0;
    font-size: 1.4em;
    font-weight: 600;
    line-height: 1.3;
}

.aivrtltryon-modal p {
    margin: 0 0 1em 0;
    line-height: 1.6;
    font-size: 1em;
}

#aivrtltryon-tryon-button {
    margin-top: 6px;
}

/* Modal container */
.aivrtltryon-modal {
    display: none;
    position: fixed;
    z-index: 999999;
    inset: 0; /* replaces left, top, width, height */
    overflow: auto;
    background-color: rgba(0, 0, 0, 0.6); /* Slightly darker overlay */
    padding: 20px; /* Add padding for small screens */
    align-items: center;
    justify-content: center;
}

/* Modal content styling */
.aivrtltryon-modal-content {
    position: relative;
    margin: auto; /* Centered by flex container */
    padding: 30px; /* Increased padding */
    border-radius: var(--aivrtltryon-border-radius-large);
    width: 100%;
    max-width: 550px; /* Slightly adjusted max-width */
    animation: aivrtltryon-fade-in-scale 0.3s ease-out;
    transition: background-color var(--aivrtltryon-transition-duration) ease, color var(--aivrtltryon-transition-duration) ease;
}

@keyframes aivrtltryon-fade-in-scale {
    from { opacity: 0; transform: scale(0.95); }
    to { opacity: 1; transform: scale(1); }
}

/* Close button */
.aivrtltryon-close {
    position: absolute;
    top: 15px; /* Adjust position */
    right: 15px; /* Adjust position */
    font-size: 1.8em; /* Larger, clearer */
    font-weight: 300; /* Lighter weight */
    line-height: 1;
    cursor: pointer;
    padding: 5px;
    border: none;
    background: transparent;
    transition: color var(--aivrtltryon-transition-duration) ease, transform var(--aivrtltryon-transition-duration) ease;
}
.aivrtltryon-close:hover {
    transform: scale(1.1);
}

/* Header */
.aivrtltryon-modal-header {
    margin-bottom: 25px; /* Increased spacing */
    padding-bottom: 15px;
    border-bottom-style: solid;
    border-bottom-width: 1px;
}

/* Body / Views */
.aivrtltryon-modal-body {
    min-height: 150px; /* Adjusted min-height */
}

.aivrtltryon-view {
    text-align: center;
}

.aivrtltryon-restrictions {
    font-size: 0.9em; /* Slightly smaller */
    margin-bottom: 25px;
    opacity: 0.8;
}

/* File Input - Enhanced */
.aivrtltryon-file-input {
    display: flex;
    flex-direction: column; /* Stack elements */
    align-items: center;
    justify-content: center;
    border-width: 2px;
    border-style: dashed;
    border-radius: var(--aivrtltryon-border-radius-medium);
    padding: 30px 20px;
    margin-bottom: 25px;
    cursor: pointer;
    transition: border-color var(--aivrtltryon-transition-duration) ease, background-color var(--aivrtltryon-transition-duration) ease;
}


.aivrtltryon-file-input input[type="file"] {
    /* Visually hidden, accessible */
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border-width: 0;
}

/* Custom label acting as the button within the dashed area */
.aivrtltryon-file-input label.button {
    /* Button styles are applied below */
    margin-bottom: 10px; /* Space between button and text */
}

#aivrtltryon-file-name {
    font-size: 0.9em;
    margin-top: 5px;
    display: block; /* Ensure it takes full width */
    opacity: 0.8;
}

/* Image Preview Styling */
#aivrtltryon-image-preview-container {
    position: relative; /* For positioning the remove button */
    width: 100%;
    max-width: 200px; /* Or adjust as needed */
    margin: 15px auto 0; /* Spacing from the top, centered */
}

#aivrtltryon-image-preview {
    display: block;
    width: 100%;
    height: auto;
    max-height: 200px; /* Control max preview height */
    object-fit: cover; /* Or 'contain' based on preference */
    border-radius: var(--aivrtltryon-border-radius-medium);
    border-style: solid;
    border-width: 1px;
    /* Border color will be inherited or can be set in themes */
}

.aivrtltryon-remove-image-button {
    position: absolute;
    top: 5px; /* Inset slightly from the top */
    right: 5px; /* Inset slightly from the right */
    background-color: rgba(255, 255, 255, 0.8); /* Semi-transparent white */
    color: #000; /* Black X for better contrast on image */
    border: none; /* No border */
    border-radius: 50%; /* Keep it circular for a modern look */
    width: 24px; /* Smaller, more standard size */
    height: 24px;
    font-size: 14px; /* Adjusted for new size */
    font-weight: bold;
    line-height: 1; /* Reset line-height */
    display: flex; /* For centering */
    align-items: center; /* Center X vertically */
    justify-content: center; /* Center X horizontally */
    cursor: pointer;
    box-shadow: 0 1px 2px rgba(0,0,0,0.15);
    transition: all var(--aivrtltryon-transition-duration) ease;
    padding: 0; /* Remove padding if using fixed width/height and flex for centering */
}

.aivrtltryon-remove-image-button:hover {
    background-color: rgba(240, 240, 240, 0.9);
    transform: scale(1.1);
}

/* Adjustments for light/dark themes for preview border and remove button */
.aivrtltryon-modal--light #aivrtltryon-image-preview {
    border-color: var(--aivrtltryon-light-border-color, #e0e0e0); /* From existing theme */
}

.aivrtltryon-modal--dark #aivrtltryon-image-preview {
    border-color: var(--aivrtltryon-dark-border-color, #555); /* From existing theme */
}

.aivrtltryon-modal--dark .aivrtltryon-remove-image-button {
    background-color: rgba(40, 40, 40, 0.8); /* Semi-transparent dark */
    color: #fff; /* White X */
    box-shadow: 0 1px 2px rgba(0,0,0,0.3);
}

.aivrtltryon-modal--dark .aivrtltryon-remove-image-button:hover {
    background-color: rgba(60, 60, 60, 0.9);
}

/* Form Actions (Generate button container) */
.aivrtltryon-form-actions {
    margin-top: 25px;
}

/* Button General Styles */
.aivrtltryon-modal .button,
.aivrtltryon-modal .button.alt,
.aivrtltryon-tryon-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 20px;
    border: 1px solid transparent;
    border-radius: var(--aivrtltryon-border-radius-medium);
    font-size: 0.95em;
    font-weight: 500;
    text-align: center;
    cursor: pointer;
    transition: background-color var(--aivrtltryon-transition-duration) ease, color var(--aivrtltryon-transition-duration) ease, border-color var(--aivrtltryon-transition-duration) ease, transform var(--aivrtltryon-transition-duration) ease, box-shadow var(--aivrtltryon-transition-duration) ease;
    box-shadow: 0 2px 4px rgba(0,0,0,0.07);
}
.aivrtltryon-modal .button:hover,
.aivrtltryon-modal .button.alt:hover,
.aivrtltryon-tryon-button:hover {
    transform: translateY(-1px);
    box-shadow: 0 3px 6px rgba(0,0,0,0.1);
}
.aivrtltryon-modal .button:active,
.aivrtltryon-modal .button.alt:active,
.aivrtltryon-tryon-button:active {
    transform: translateY(0px);
    box-shadow: 0 1px 2px rgba(0,0,0,0.08);
}



/* Style for the main Virtual Try-On button on the product page (non-modal) */
.aivrtltryon-tryon-button.button.alt {
    background-color: #007bff;
    color: #ffffff;
    border-color: #007bff;
}

.aivrtltryon-tryon-button.button.alt:hover {
    background-color: #0056b3;
    border-color: #0056b3;
}

/* Loading View */
.aivrtltryon-loading-spinner {
    width: 40px; /* Slightly smaller */
    height: 40px;
    border-width: 4px; /* Thinner border */
    border-style: solid;
    border-radius: 50%;
    margin: 30px auto 20px auto; /* Adjusted margin */
    animation: aivrtltryon-spin 1s linear infinite;
    /* Colors set in themes */
}

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

/* Styling for loading text elements */
.aivrtltryon-loading-text {
    margin-top: 10px;
    font-size: 1.1em;
}

#aivrtltryon-loading-percentage {
    font-weight: 600;
    font-size: 1.5em;
    margin-bottom: 5px; /* Space between percentage and text */
}

/* Result View */
.aivrtltryon-result-image-container {
    margin: 20px auto;
    max-width: 100%;
    text-align: center;
}

#aivrtltryon-result-image {
    max-width: 100%;
    max-height: 40vh; /* Limit image height */
    height: auto;
    display: block; /* Prevent extra space below */
    margin: 0 auto; /* Center image */
    border-radius: var(--aivrtltryon-border-radius-medium);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.15);
}

.aivrtltryon-watermark-note {
    font-size: 0.8em;
    margin-top: 15px;
    opacity: 0.7;
}

.aivrtltryon-result-actions {
    margin-top: 25px;
}

/* Error View */
.aivrtltryon-error-icon {
    font-size: 3em; /* Adjusted size */
    margin: 20px 0 10px 0;
    opacity: 0.8;
}

#aivrtltryon-error-message {
    margin-bottom: 25px;
    font-weight: 500;
}

/* --- Theme Variants --- */

/* Light Theme */
.aivrtltryon-modal--light .aivrtltryon-modal-content {
    background-color: #f8f9fa; /* Off-white */
    color: #343a40; /* Dark gray text */
}
.aivrtltryon-modal--light .aivrtltryon-modal-header {
    border-bottom-color: #e9ecef; /* Light border */
}
.aivrtltryon-modal--light .aivrtltryon-close {
    color: #6c757d; /* Gray */
}
.aivrtltryon-modal--light .aivrtltryon-close:hover {
    color: #343a40; /* Darker gray on hover */
}
.aivrtltryon-modal--light .aivrtltryon-file-input {
    border-color: #ced4da; /* Light gray dashed border */
    background-color: #ffffff;
}
.aivrtltryon-modal--light .aivrtltryon-file-input:hover {
    border-color: #adb5bd;
    background-color: #fdfdfd;
}
.aivrtltryon-modal--light .button { /* Secondary button - e.g., Select Image, Try Again */
    background-color: #ffffff;
    color: #495057;
    border-color: #ced4da;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}
.aivrtltryon-modal--light .button:hover {
    background-color: #f8f9fa;
    border-color: #adb5bd;
}
.aivrtltryon-modal--light .button.alt { /* Primary button - e.g., Generate Try-On */
    background-color: #007bff; /* Primary blue */
    color: #ffffff;
    border-color: #007bff;
}
.aivrtltryon-modal--light .button.alt:hover {
    background-color: #0056b3;
    border-color: #0056b3;
}
.aivrtltryon-modal--light .aivrtltryon-loading-spinner {
    border-color: #e9ecef; /* Light track */
    border-top-color: #007bff; /* Blue spinner */
}
.aivrtltryon-modal--light #aivrtltryon-error-message {
    color: #dc3545; /* Standard red for errors */
}
.aivrtltryon-modal--light .aivrtltryon-error-icon {
    color: #dc3545;
}

/* Dark Theme */
.aivrtltryon-modal--dark .aivrtltryon-modal-content {
    background-color: #212529; /* Dark charcoal */
    color: #e9ecef; /* Light gray text */
}
.aivrtltryon-modal--dark .aivrtltryon-modal-header {
    border-bottom-color: #495057; /* Darker border */
}
.aivrtltryon-modal--dark .aivrtltryon-close {
    color: #adb5bd; /* Lighter gray */
}
.aivrtltryon-modal--dark .aivrtltryon-close:hover {
    color: #f8f9fa; /* Off-white on hover */
}
.aivrtltryon-modal--dark .aivrtltryon-file-input {
    border-color: #495057; /* Dark gray dashed border */
    background-color: #343a40; /* Slightly lighter dark shade */
}
.aivrtltryon-modal--dark .aivrtltryon-file-input:hover {
    border-color: #6c757d;
    background-color: #3e444a;
}
.aivrtltryon-modal--dark .button { /* Secondary button */
    background-color: #495057;
    color: #f8f9fa;
    border-color: #6c757d;
    box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}
.aivrtltryon-modal--dark .button:hover {
    background-color: #5a6268;
    border-color: #adb5bd;
}
.aivrtltryon-modal--dark .button.alt { /* Primary button */
    background-color: #0d6efd; /* Vibrant blue for dark mode */
    color: #ffffff;
    border-color: #0d6efd;
}
.aivrtltryon-modal--dark .button.alt:hover {
    background-color: #0b5ed7;
    border-color: #0a58ca;
}
.aivrtltryon-modal--dark .aivrtltryon-loading-spinner {
    border-color: #495057; /* Dark track */
    border-top-color: #0d6efd; /* Blue spinner */
}
.aivrtltryon-modal--dark #aivrtltryon-error-message {
    color: #ff8fa3; /* Lighter red for errors */
}
.aivrtltryon-modal--dark .aivrtltryon-error-icon {
    color: #ff8fa3;
}


/* Responsive Adjustments - Simplified */
@media (max-width: 600px) {
    .aivrtltryon-modal-content {
        padding: 20px; /* Slightly less padding on small screens */
        max-width: calc(100% - 20px); /* Ensure padding is respected */
        margin: 10px;
    }
    .aivrtltryon-modal h2 {
        font-size: 1.2em;
    }
    .aivrtltryon-modal-body {
        min-height: 100px;
    }
     .aivrtltryon-file-input {
        padding: 20px;
    }
}

/* Ensure specific theme overrides basic styles if needed */
/* Example: you might need !important occasionally but avoid if possible */ 