/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Montserrat', sans-serif;
    background: linear-gradient(135deg, #8b5cf6 0%, #7c3aed 100%);
    color: #333;
    min-height: 100vh;
    overflow-x: hidden;
}

/* Gradient Background */
.gradient-bg {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #8b5cf6 0%, #7c3aed 100%);
    z-index: -1;
}

/* Header Styles */
.main-header {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
    padding: 8px 0; /* Reduced from 15px */
    position: sticky;
    top: 0;
    z-index: 1000;
}

.header-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 20px;
}

.logo {
    height: 30px;
    transition: transform 0.3s ease;
}

.logo:hover {
    transform: scale(1.05);
}

.title {
    font-size: 1.5rem;
    font-weight: 600;
    color: #4a5568;
    text-align: center;
    flex: 1;
}

.contact-us-btn {
    background: linear-gradient(135deg, #8b5cf6 0%, #7c3aed 100%);
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 25px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-weight: 500;
    font-size: 14px;
    box-shadow: 0 4px 15px rgba(139, 92, 246, 0.4);
}

.contact-us-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(139, 92, 246, 0.6);
}

/* Main Container */
.main-container {
    max-width: 1400px;
    margin: 20px auto;
    padding: 0 20px;
}

/* Mode Selector */
.mode-selector {
    display: flex;
    justify-content: center;
    gap: 20px;
    margin-bottom: 30px;
}

.mode-btn {
    background: transparent;
    border: 2px solid rgba(255, 255, 255, 0.3);
    padding: 15px 30px;
    border-radius: 25px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-weight: 500;
    font-size: 16px;
    color: white;
    backdrop-filter: blur(10px);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

.mode-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.15);
}

.mode-btn.active {
    background: white;
    color: #8b5cf6;
    border-color: #8b5cf6;
    box-shadow: 0 4px 15px rgba(139, 92, 246, 0.3);
}

/* Two Column Layout */
.content-wrapper {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px; /* Reduced from 30px */
    align-items: start;
    margin-top: 10px; /* Reduced top margin */
}

/* Left Column - Camera */
.camera-column {
    background: rgba(255, 255, 255, 0.95);
    border-radius: 20px;
    padding: 15px; /* Reduced from 25px */
    backdrop-filter: blur(10px);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.camera-container {
    position: relative;
    margin-bottom: 10px; /* Reduced from 20px */
}

.video-wrapper {
    position: relative;
    border-radius: 15px;
    overflow: hidden;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
    display: block; /* Ensure video is visible */
}

#video, .processed-video {
    width: 100%;
    height: 450px; /* Reduced from 500px */
    object-fit: cover;
    border-radius: 15px;
    display: block; /* Ensure video elements are visible */
}

/* Mirror effect for natural video experience */
.mirror-video {
    transform: scaleX(-1);
}

.camera-controls {
    position: absolute;
    bottom: 20px;
    right: 20px;
    display: flex;
    gap: 10px;
}

.control-btn {
    background: rgba(255, 255, 255, 0.9);
    border: none;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
}

.control-btn:hover {
    transform: scale(1.1);
    background: rgba(255, 255, 255, 1);
}

.camera-placeholder {
    height: 400px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #f7fafc 0%, #edf2f7 100%);
    border-radius: 15px;
    color: #a0aec0;
    border: 2px dashed #cbd5e0;
}

.camera-placeholder i {
    margin-bottom: 15px;
    color: #cbd5e0;
}

/* Multi Jewel Toggle */
.multi-jewel-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 15px;
    padding: 20px;
    background: rgba(247, 250, 252, 0.8);
    border-radius: 15px;
    border: 1px solid rgba(203, 213, 224, 0.3);
}

.switch {
    position: relative;
    display: inline-block;
    width: 60px;
    height: 34px;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #cbd5e0;
    transition: 0.4s;
    border-radius: 34px;
}

.slider:before {
    position: absolute;
    content: "";
    height: 26px;
    width: 26px;
    left: 4px;
    bottom: 4px;
    background-color: white;
    transition: 0.4s;
    border-radius: 50%;
}

input:checked + .slider {
    background: linear-gradient(135deg, #8b5cf6 0%, #7c3aed 100%);
}

input:checked + .slider:before {
    transform: translateX(26px);
}

#multiJewelLabel {
    font-weight: 500;
    color: #4a5568;
}

/* Upload Form */
.upload-form {
    background: rgba(247, 250, 252, 0.8);
    border-radius: 15px;
    padding: 20px;
    border: 1px solid rgba(203, 213, 224, 0.3);
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.file-input {
    padding: 12px;
    border: 2px dashed #cbd5e0;
    border-radius: 10px;
    background: white;
    cursor: pointer;
    transition: all 0.3s ease;
}

.file-input:hover {
    border-color: #8b5cf6;
    background: #f7fafc;
}

.upload-btn {
    background: linear-gradient(135deg, #8b5cf6 0%, #7c3aed 100%);
    color: white;
    border: none;
    padding: 15px 30px;
    border-radius: 25px;
    cursor: pointer;
    font-weight: 500;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(139, 92, 246, 0.4);
}

.upload-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(139, 92, 246, 0.6);
}

/* Right Column - Jewelry */
.jewelry-column {
    background: rgba(255, 255, 255, 0.95);
    border-radius: 20px;
    padding: 15px; /* Reduced from 25px */
    backdrop-filter: blur(10px);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

/* Jewelry Preview Section - Dynamic Layout */
.jewelry-preview-section {
    display: flex;
    gap: 15px; /* Reduced from 20px */
    height: 450px; /* Reduced from 500px */
}

/* Left Side - Selected Jewelry (Hidden Initially) */
.selected-jewelry-side {
    flex: 0 0 300px; /* Fixed width for selected jewelry */
    background: rgba(247, 250, 252, 0.8);
    border-radius: 15px;
    padding: 20px;
    border: 1px solid rgba(203, 213, 224, 0.3);
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: #7c3aed #e0e7ff;
}

.selected-jewelry-side::-webkit-scrollbar {
    width: 6px;
}

.selected-jewelry-side::-webkit-scrollbar-track {
    background: #e0e7ff;
    border-radius: 3px;
}

.selected-jewelry-side::-webkit-scrollbar-thumb {
    background: #7c3aed;
    border-radius: 3px;
}

.selected-jewelry-side::-webkit-scrollbar-thumb:hover {
    background: #5b21b6;
}

/* Right Side - Available Jewelry (Full Width Initially) */
.available-jewelry-side {
    flex: 1; /* Takes remaining space */
    overflow: hidden;
}

/* When no jewelry is selected, make available side take full width */
.jewelry-preview-section:not(.has-selection) .available-jewelry-side {
    flex: 1;
}

/* When jewelry is selected, show both sides */
.jewelry-preview-section.has-selection .available-jewelry-side {
    flex: 1;
}

/* Jewelry Tabs */
.jewelry-tabs {
    display: flex;
    gap: 10px;
    margin-bottom: 15px; /* Reduced from 25px */
    flex-wrap: nowrap; /* Prevent wrapping to second line */
    overflow-x: auto;
    scrollbar-width: thin;
    scrollbar-color: #7c3aed #e0e7ff;
    padding-bottom: 8px;
    white-space: nowrap; /* Keep tabs in single line */
}

.jewelry-tabs::-webkit-scrollbar {
    height: 8px;
}

.jewelry-tabs::-webkit-scrollbar-track {
    background: #e0e7ff;
    border-radius: 4px;
}

.jewelry-tabs::-webkit-scrollbar-thumb {
    background: #8b5cf6;
    border-radius: 4px;
}

.jewelry-tabs::-webkit-scrollbar-thumb:hover {
    background: #7c3aed;
}

.tab-btn {
    background: rgba(247, 250, 252, 0.8);
    border: 1px solid rgba(203, 213, 224, 0.3);
    padding: 12px 20px;
    border-radius: 20px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-weight: 500;
    font-size: 14px;
    color: #4a5568;
    flex: 0 0 auto; /* Don't grow or shrink, maintain size */
    min-width: 120px;
    white-space: nowrap; /* Prevent text wrapping */
}

.tab-btn:hover {
    background: rgba(247, 250, 252, 1);
    transform: translateY(-1px);
}

.tab-btn.active {
    background: linear-gradient(135deg, #8b5cf6 0%, #7c3aed 100%);
    color: white;
    border-color: transparent;
}

/* Selected Jewelry Container */
.selected-jewelry-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
    margin-bottom: 25px;
}

.selected-display {
    display: none;
    background: rgba(247, 250, 252, 0.8);
    border-radius: 15px;
    padding: 20px;
    border: 1px solid rgba(203, 213, 224, 0.3);
    text-align: center;
}

.selected-display.active {
    display: block;
}

.jewelry-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}

.jewelry-header h3 {
    font-size: 16px;
    color: #4a5568;
    margin: 0;
}

.unselect-btn {
    background: none;
    border: none;
    color: #e53e3e;
    font-size: 20px;
    cursor: pointer;
    padding: 5px;
    border-radius: 50%;
    transition: all 0.3s ease;
}

.unselect-btn:hover {
    background: rgba(229, 62, 62, 0.1);
    color: #c53030;
}

.selected-display img {
    width: 100%;
    height: 150px; /* Optimized height for left sidebar */
    object-fit: contain;
    border-radius: 10px;
    background: white;
    padding: 10px;
}

/* Jewelry Gallery */
.jewelry-gallery {
    background: rgba(247, 250, 252, 0.8);
    border-radius: 15px;
    padding: 20px;
    border: 1px solid rgba(203, 213, 224, 0.3);
    height: 100%; /* Take full height of available space */
    overflow-y: auto;
}

.gallery-section {
    display: none;
}

.gallery-section.active {
    display: block;
}

/* Mixed jewelry view styles - only when no jewelry is selected */
.jewelry-gallery.mixed-view {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 15px;
    max-height: 450px;
    overflow-y: auto;
}

.jewelry-gallery.mixed-view .gallery-section h2 {
    display: none;
}

.jewelry-gallery.mixed-view .gallery-section {
    display: contents;
}

.jewelry-gallery.mixed-view .gallery-grid {
    display: contents;
}

/* When not in mixed view, show only active sections */
.jewelry-gallery:not(.mixed-view) .gallery-section {
    display: none;
}

.jewelry-gallery:not(.mixed-view) .gallery-section.active {
    display: block;
}

.gallery-section h2 {
    color: #4a5568;
    margin-bottom: 20px;
    font-size: 1.5rem;
    font-weight: 600;
    text-align: center;
}

.gallery-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); /* Increased size for larger jewelry boxes */
    gap: 20px;
    max-height: 450px;
    overflow-y: auto;
    padding-right: 10px;
    scrollbar-width: thin;
    scrollbar-color: #8b5cf6 #e0e7ff;
}

.gallery-grid::-webkit-scrollbar {
    width: 8px;
}

.gallery-grid::-webkit-scrollbar-track {
    background: #e0e7ff;
    border-radius: 4px;
}

.gallery-grid::-webkit-scrollbar-thumb {
    background: #8b5cf6;
    border-radius: 4px;
}

.gallery-grid::-webkit-scrollbar-thumb:hover {
    background: #7c3aed;
}

.image-container {
    background: white;
    border-radius: 15px;
    padding: 20px; /* Increased padding */
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    transition: all 0.3s ease;
    cursor: pointer;
    border: 1px solid rgba(203, 213, 224, 0.2);
}

.image-container:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
    border-color: #8b5cf6;
}

.image-container img {
    width: 100%;
    height: 200px; /* Increased height for larger jewelry boxes */
    object-fit: cover;
    border-radius: 10px;
    margin-bottom: 15px; /* Increased margin */
}

.image-container p {
    font-size: 14px;
    color: #4a5568;
    text-align: center;
    font-weight: 500;
    margin: 0;
}

/* Loading and Processed Image */
.loading-container {
    text-align: center;
    padding: 30px;
}

.loader {
    width: 50px;
    height: 50px;
    border: 3px solid #f3f3f3;
    border-top: 3px solid #8b5cf6;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 15px;
}

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

.processed-image-container {
    text-align: center;
    margin-top: 20px;
}

.processed-image-container h3 {
    color: #4a5568;
    margin-bottom: 15px;
}

#processedImage {
    max-width: 100%;
    border-radius: 15px;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
    margin-bottom: 15px;
}

.download-btn {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 25px;
    cursor: pointer;
    font-weight: 500;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(16, 185, 129, 0.4);
}

.download-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(16, 185, 129, 0.6);
}

/* Back to Top Button */
#backToTopBtn {
    position: fixed;
    bottom: 30px;
    right: 30px;
    width: 60px;
    height: 60px;
    background: linear-gradient(135deg, #8b5cf6 0%, #7c3aed 100%);
    color: white;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.3s ease;
    opacity: 0;
    visibility: hidden;
    box-shadow: 0 4px 15px rgba(139, 92, 246, 0.4);
    z-index: 1000;
}

#backToTopBtn.show {
    opacity: 1;
    visibility: visible;
}

#backToTopBtn:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 20px rgba(139, 92, 246, 0.6);
}

/* Utility Classes */
.hidden {
    display: none !important;
}

/* Responsive Design */
@media (max-width: 1200px) {
    .content-wrapper {
        grid-template-columns: 1fr;
        gap: 20px;
    }
    
    .camera-column, .jewelry-column {
        padding: 20px;
    }
    
    .jewelry-preview-section {
        flex-direction: column;
        height: auto;
    }
    
    .selected-jewelry-side {
        flex: none;
        height: 200px;
    }
    
    .available-jewelry-side {
        flex: 1;
        height: 400px;
    }
}

@media (max-width: 768px) {
    .header-content {
        flex-direction: column;
        gap: 15px;
        text-align: center;
    }
    
    .title {
        font-size: 1.2rem;
    }
    
    .mode-selector {
        flex-direction: column;
        align-items: center;
    }
    
    .mode-btn {
        width: 100%;
        max-width: 300px;
    }
    
    .jewelry-tabs {
        flex-direction: column;
    }
    
    .tab-btn {
        min-width: auto;
    }
    
    .selected-jewelry-container {
        grid-template-columns: 1fr;
    }
    
    .gallery-grid {
        grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
        gap: 15px;
    }
    
    .camera-controls {
        bottom: 15px;
        right: 15px;
    }
    
    .control-btn {
        width: 45px;
        height: 45px;
    }
}

@media (max-width: 480px) {
    .main-container {
        padding: 0 15px;
        margin: 15px auto;
    }
    
    .camera-column, .jewelry-column {
        padding: 15px;
    }
    
    .gallery-grid {
        grid-template-columns: 1fr;
    }
    
    #video, .processed-video, .camera-placeholder {
        height: 300px;
    }
}

/* Smooth Transitions */
.gallery-section {
    transition: opacity 0.3s ease, transform 0.3s ease;
}

.image-container {
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Custom Scrollbar */
.jewelry-gallery::-webkit-scrollbar {
    width: 6px;
}

.jewelry-gallery::-webkit-scrollbar-track {
    background: rgba(203, 213, 224, 0.3);
    border-radius: 3px;
}

.jewelry-gallery::-webkit-scrollbar-thumb {
    background: linear-gradient(135deg, #7c3aed 0%, #5b21b6 100%);
    border-radius: 3px;
}

.jewelry-gallery::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(135deg, #5b21b6 0%, #4c1d95 100%);
}
