/**
 * Frontend CSS for AI Generator
 * Provides modern, clean, and responsive styling for the custom design page.
 */

 .vivigoods-ai-container {
    width: 90%;
    margin: 0 auto;
    padding: 0px 15px 20px 15px; /* 去掉顶部的 20px padding */
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    color: #333;
}

/* --- Notice Area --- */
.vivigoods-ai-notice {
    background: linear-gradient(135deg, #fdfbfb 0%, #ebedee 100%);
    border-left: 4px solid #f39c12;
    padding: 15px 20px;
    border-radius: 0 8px 8px 0;
    margin-bottom: 30px;
    display: flex;
    align-items: flex-start;
    gap: 12px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.03);
}

.notice-icon {
    font-size: 1.2em;
    line-height: 1.4;
}

.vivigoods-ai-notice p {
    margin: 0;
    font-size: 0.95em;
    line-height: 1.5;
}

.vivigoods-ai-notice a {
    color: #e67e22;
    text-decoration: underline;
    font-weight: 500;
}

/* --- Form Elements --- */
.vivigoods-ai-generator-box {
    background: #fff;
    padding: 30px;
    border-radius: 12px;
    box-shadow: 0 5px 20px rgba(0,0,0,0.05);
    margin-bottom: 40px;
    border: 1px solid #eaeaea;
}

/* Product Preview Card */
.vivi-product-preview-card {
    display: flex;
    align-items: center;
    background: #f8f9fa;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    padding: 12px;
    margin-bottom: 25px;
    gap: 15px;
}

.vivi-product-preview-card img {
    width: 60px;
    height: 60px;
    object-fit: cover;
    border-radius: 6px;
    border: 1px solid #ddd;
}

.vivi-preview-info h4 {
    margin: 0 0 5px 0;
    font-size: 1em;
    color: #2c3e50;
}

.vivi-preview-info a {
    font-size: 0.85em;
    color: #3498db;
    text-decoration: none;
    font-weight: 500;
}

.vivi-preview-info a:hover {
    text-decoration: underline;
}

.vivigoods-form-group {
    margin-bottom: 25px;
}

.vivigoods-form-group:last-child {
    margin-bottom: 0;
}

.vivigoods-form-group label {
    display: block;
    font-weight: 600;
    margin-bottom: 10px;
    font-size: 1.1em;
    color: #2c3e50;
}

.vivigoods-select,
.vivigoods-textarea {
    width: 100%;
    padding: 12px 15px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 1em;
    font-family: inherit;
    transition: all 0.3s ease;
    box-sizing: border-box;
    line-height: 1.5; /* Ensure text is not cut off */
    height: auto; /* Override theme fixed heights */
}

/* Specific fix for select to ensure dropdown arrow aligns and text is fully visible */
.vivigoods-ai-generator-box select.vivigoods-select {
    min-height: 50px !important;
    height: 50px !important;
    line-height: 50px !important;
    padding-top: 0 !important;
    padding-bottom: 0 !important;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23333' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 15px center;
    background-size: 16px;
    padding-right: 40px !important; /* Space for the arrow */
    background-color: #fff;
    margin-bottom: 0;
    vertical-align: middle !important;
    box-sizing: border-box !important;
}

.vivigoods-select:focus,
.vivigoods-textarea:focus {
    border-color: #3498db;
    outline: none;
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.1);
}

.vivigoods-textarea {
    resize: vertical;
    min-height: 100px;
}

.prompt-hint {
    font-size: 0.8em;
    color: #7f8c8d;
    margin-top: 6px;
    text-align: right;
}

/* --- Buttons --- */
.submit-group {
    text-align: center;
    margin-top: 30px;
}

.vivigoods-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 14px 30px;
    border-radius: 30px;
    font-size: 1.1em;
    font-weight: 600;
    cursor: pointer;
    border: none;
    transition: all 0.3s ease;
}

.vivigoods-btn-primary {
    background: #2c3e50;
    color: #fff;
    width: 100%;
    max-width: 400px;
}

.vivigoods-btn-primary:hover:not(:disabled) {
    background: #1a252f;
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(44, 62, 80, 0.2);
}

.vivigoods-btn-secondary {
    background: #f1f2f6;
    color: #2c3e50;
    border: 1px solid #dfe4ea;
}

.vivigoods-btn-secondary:hover:not(:disabled) {
    background: #dfe4ea;
}

.btn-full-width {
    width: 100%;
}

.btn-cost {
    background: rgba(255,255,255,0.2);
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 0.85em;
    font-weight: 500;
}

/* Small Cost Notice Under Button */
.vivi-cost-notice {
    margin-top: 15px;
    font-size: 0.85em;
    color: #7f8c8d;
    text-align: center;
    line-height: 1.6;
    padding: 0 10px;
}

.vivi-cost-notice p {
    margin: 0;
    display: inline-block;
}

.vivi-cost-notice a {
    color: #e67e22;
    text-decoration: underline;
    white-space: nowrap; /* Prevent "Learn more" from breaking */
    margin-left: 4px;
}

/* Disabled / Loading State */
.vivigoods-btn:disabled,
.vivigoods-btn.loading {
    opacity: 0.7;
    cursor: not-allowed;
    transform: none;
}

/* --- Result Area --- */
.vivigoods-result-area {
    margin-top: 40px;
}

/* Loading Spinner */
.vivi-loading-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 50px 0;
    color: #7f8c8d;
}

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

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

/* Image Grid */
.vivi-image-grid {
    display: grid;
    grid-template-columns: 1fr; /* Currently single image */
    gap: 30px;
    margin-bottom: 20px;
}

.vivi-grid-item {
    background: #fff;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 4px 15px rgba(0,0,0,0.08);
    transition: transform 0.3s ease;
    padding: 0; /* Remove padding to allow image to touch edges */
    position: relative; /* For absolute positioning of the button */
}

.vivi-grid-item:hover {
    transform: translateY(-5px);
}

.vivi-grid-item::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.15); /* Much lighter overall overlay just to indicate hover */
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none; /* MUST BE NONE so clicks pass through to the wrapper */
}

.vivi-grid-item:hover::after {
    opacity: 1;
}

/* Hover "Click to Enlarge" Hint */
.vivi-enlarge-hint {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.9);
    color: #fff;
    opacity: 0;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    z-index: 5;
    pointer-events: none;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.5); /* Darker background for the circle to make it pop */
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    border-radius: 50%;
    width: 60px; /* Smaller since it only has the icon */
    height: 60px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.4);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.vivi-enlarge-hint i {
    font-size: 28px;
    font-style: normal;
    line-height: 1;
}

.vivi-grid-item:hover .vivi-enlarge-hint {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
}

.vivi-generated-img {
    width: 100%;
    height: 100%; /* Fill container */
    display: block;
    object-fit: cover;
    aspect-ratio: 3/2; /* Default for rug */
    background: #f8f9fa; /* Placeholder color while loading */
    margin-bottom: 0; /* Remove margin */
}

/* Hover Button Styling */
.vivi-order-btn {
    position: absolute;
    bottom: 15px; /* Move to bottom */
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    opacity: 0;
    transition: all 0.3s ease;
    z-index: 10; /* Ensure button is above the overlay if we want to click it */
    width: auto !important; /* Let it shrink to fit text */
    min-width: 140px; /* But give it a minimum width */
    height: 40px !important;
    line-height: 40px !important;
    padding: 0 20px !important;
    margin: 0 !important;
    box-shadow: 0 4px 15px rgba(0,0,0,0.3) !important;
    background-color: #fff !important; /* Clean white background */
    color: #2c3e50 !important; /* Dark text */
    border: none !important;
    border-radius: 20px !important; /* Pill shape */
    font-size: 14px !important;
    font-weight: 600 !important;
    white-space: nowrap !important; /* Prevent text wrapping */
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 8px !important;
}

.vivi-order-btn:hover {
    background-color: #f8f9fa !important;
    transform: translateX(-50%) scale(1.05) !important;
}

.vivi-grid-item:hover .vivi-order-btn {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* Global Notice */
.vivi-global-notice {
    background: #e8f8f5;
    border-left: 4px solid #27ae60;
    color: #27ae60;
    padding: 12px 20px;
    border-radius: 4px;
    margin-bottom: 25px;
    font-size: 0.95em;
    text-align: center;
    animation: fadeIn 0.5s ease;
}

/* Footnote */
.vivi-retention-note {
    text-align: center;
    color: #95a5a6;
    font-size: 0.85em;
    margin-top: 20px;
    padding: 10px;
    border-top: 1px dashed #ecf0f1;
}

/* --- Modals --- */
.vivi-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    backdrop-filter: blur(4px);
    opacity: 1;
    animation: fadeIn 0.3s ease;
}

.vivi-modal-content {
    background: #fff;
    padding: 40px 30px;
    border-radius: 16px;
    width: 90%;
    max-width: 400px;
    text-align: center;
    position: relative;
    box-shadow: 0 10px 30px rgba(0,0,0,0.2);
    transform: translateY(0);
    animation: slideUp 0.3s ease;
}

.vivi-modal-close {
    position: absolute;
    top: 15px;
    right: 20px;
    font-size: 24px;
    color: #95a5a6;
    cursor: pointer;
    transition: color 0.2s;
}

.vivi-modal-close:hover {
    color: #333;
}

.vivi-modal-icon {
    font-size: 48px;
    margin-bottom: 15px;
    line-height: 1;
}

.vivi-modal-content h3 {
    margin: 0 0 15px 0;
    color: #2c3e50;
    font-size: 1.5em;
}

.vivi-modal-content p {
    color: #7f8c8d;
    margin-bottom: 25px;
    line-height: 1.5;
}

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

@keyframes slideUp {
    from { transform: translateY(20px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

/* Modal Specific Button Styling */
.vivi-modal-btn {
    padding: 0 !important;
    height: 44px !important;
    line-height: 44px !important;
    font-size: 0.9em !important;
    width: 200px !important;
    max-width: 100% !important;
    display: inline-flex !important;
    justify-content: center;
    align-items: center;
    margin: 10px auto 0 auto;
    box-shadow: 0 4px 12px rgba(44, 62, 80, 0.15) !important;
    text-decoration: none !important;
    box-sizing: border-box !important;
    color: #ffffff !important; /* Force initial text color */
}

.vivi-modal-btn:hover,
.vivi-modal-btn:focus,
.vivi-modal-btn:active {
    transform: translateY(-1px) !important;
    box-shadow: 0 6px 15px rgba(44, 62, 80, 0.2) !important;
    color: #ffffff !important; /* Force hover text color */
    text-decoration: none !important;
}

/* Lightbox Modal Specific Styles */
.vivi-lightbox-content {
    background: #fff;
    width: 95%;
    max-width: 1200px; /* Increased from 1000px to make popup larger */
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    animation: zoomIn 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    padding: 30px;
    border-radius: 16px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
}

.vivi-lightbox-content .vivi-modal-close {
    position: absolute;
    top: -45px;
    right: -40px;
    color: #fff;
    font-size: 40px;
    font-weight: 300;
    transition: transform 0.3s ease;
}

.vivi-lightbox-content .vivi-modal-close:hover {
    color: #fff;
    transform: rotate(90deg);
}

.vivi-lightbox-layout {
    display: flex;
    width: 100%;
    gap: 30px;
    align-items: center;
}

.vivi-lightbox-img-wrapper {
    flex: 2; /* Increased flex to give more space to image */
    display: flex;
    justify-content: center;
    align-items: center;
    background: #f8f9fa;
    border-radius: 8px;
    overflow: hidden;
    position: relative;
    min-height: 400px; /* Ensure loading overlay has enough space even if image is empty */
}

#vivi-lightbox-img {
    width: 100%;
    max-height: 80vh; /* Increased from 75vh */
    object-fit: contain;
    display: block;
    transition: opacity 0.3s ease;
}

/* Loading Overlay */
.vivi-lightbox-loading {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(248, 249, 250, 0.95); /* Increased opacity to hide the image underneath better */
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 20;
    backdrop-filter: blur(5px); /* Increased blur */
    color: #2c3e50;
    font-weight: 600;
    border-radius: 8px; /* Match the wrapper radius */
}

.vivi-lightbox-loading .vivi-spinner {
    width: 50px;
    height: 50px;
    border: 4px solid #e0e0e0;
    border-top: 4px solid #3498db;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 20px;
}

.vivi-lightbox-loading p {
    font-size: 1.1em;
    margin: 0;
    animation: pulse 1.5s infinite;
}

@keyframes pulse {
    0% { opacity: 0.6; }
    50% { opacity: 1; }
    100% { opacity: 0.6; }
}

/* Carousel Nav */
.vivi-lightbox-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    font-size: 30px;
    color: rgba(255, 255, 255, 0.8);
    background: rgba(0, 0, 0, 0.3);
    width: 50px;
    height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    cursor: pointer;
    user-select: none;
    transition: all 0.3s ease;
    z-index: 10;
}

.vivi-lightbox-nav:hover {
    background: rgba(0, 0, 0, 0.7);
    color: #fff;
}

.vivi-lightbox-prev {
    left: 15px;
}

.vivi-lightbox-next {
    right: 15px;
}

.vivi-lightbox-dots {
    position: absolute;
    bottom: 15px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 8px;
    z-index: 10;
}

.vivi-lightbox-dot {
    width: 10px;
    height: 10px;
    background: rgba(255, 255, 255, 0.5);
    border-radius: 50%;
    cursor: pointer;
    transition: background 0.3s ease;
    box-shadow: 0 1px 3px rgba(0,0,0,0.3);
}

.vivi-lightbox-dot.active, .vivi-lightbox-dot:hover {
    background: #fff;
}

.vivi-lightbox-sidebar {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.vivi-lightbox-title {
    font-size: 1.8em;
    color: #2c3e50;
    margin-bottom: 15px;
    font-weight: 600;
}

.vivi-lightbox-caption {
    color: #555;
    margin-bottom: 30px;
    line-height: 1.6;
    font-size: 1.05em;
    background: #f8f9fa;
    padding: 15px;
    border-radius: 8px;
    border-left: 4px solid #3498db;
}

.vivi-lightbox-btn {
    width: auto !important; /* Don't force full width */
    min-width: 250px !important;
    padding: 12px 30px !important; /* Less padding to reduce bulk */
    font-size: 1.1em !important; /* Slightly smaller font */
    border-radius: 25px !important; /* Pill shape */
    box-shadow: 0 8px 15px rgba(44, 62, 80, 0.2) !important; /* Softer shadow */
    transition: all 0.3s ease !important;
    margin: 0 auto !important; /* Center the button */
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 10px !important;
}

.vivi-lightbox-btn:hover {
    transform: translateY(-2px) !important;
    box-shadow: 0 12px 20px rgba(44, 62, 80, 0.3) !important;
}

/* Responsive Lightbox */
@media (max-width: 900px) {
    .vivi-lightbox-layout {
        flex-direction: column;
        gap: 20px;
    }
    
    .vivi-lightbox-content .vivi-modal-close {
        top: -40px;
        right: 0;
    }
    
    #vivi-lightbox-img {
        max-height: 50vh;
    }
}

/* --- Responsive --- */
@media (max-width: 600px) {
    .vivigoods-ai-generator-box {
        padding: 20px 15px;
    }
    
    .vivigoods-btn {
        width: 100%;
        max-width: none;
    }
    
    .vivigoods-ai-notice {
        flex-direction: column;
        gap: 8px;
    }
}