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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: linear-gradient(135deg, #fff 0%, #ddd 100%);
    min-height: 100vh;
    min-height: 100dvh;
    height: 100vh;
    height: 100dvh;
    color: #ddd;
    overflow-x: hidden;
    margin: 0;
    padding: 0;
}

#app {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    min-height: 100dvh;
    height: 100vh;
    height: 100dvh;
}

/* Header */
.header {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    padding: 1rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header h1 {
    font-size: 1.5rem;
    font-weight: 700;
    color: #4a5568;
}

.controls {
    display: flex;
    align-items: center;
    gap: 1rem;
}

/* Buttons */
.btn {
    padding: 0.5rem 1rem;
    border: none;
    border-radius: 8px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 0.9rem;
}

.btn-secondary {
    background: #e2e8f0;
    color: #4a5568;
}

.btn-secondary:hover {
    background: #cbd5e0;
    transform: translateY(-1px);
}

/* Checkbox */
.checkbox-container {
    display: flex;
    align-items: center;
    cursor: pointer;
    font-size: 0.9rem;
    color: #4a5568;
}

.checkbox-container input {
    margin-right: 0.5rem;
}

/* Main Content */
.main-content {
    flex: 1;
    display: flex;
    padding: 2rem;
    gap: 2rem;
    align-items: stretch;
}

/* Camera Section */
.camera-section {
    flex: 1;
    min-height: 400px;
}

.camera-container {
    position: relative;
    width: 100%;
    height: 100%;
    background: #000;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    cursor: pointer;
    min-height: 400px;
}

#cameraFeed {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

#cameraFeed::-webkit-media-controls {
    display: none !important;
}

#cameraFeed::-webkit-media-controls-panel {
    display: none !important;
}

#cameraFeed::-webkit-media-controls-play-button {
    display: none !important;
}

#cameraFeed::-webkit-media-controls-start-playback-button {
    display: none !important;
}

#cameraFeed::-webkit-media-controls-timeline {
    display: none !important;
}

#cameraFeed::-webkit-media-controls-current-time-display {
    display: none !important;
}

#cameraFeed::-webkit-media-controls-time-remaining-display {
    display: none !important;
}

#cameraFeed::-webkit-media-controls-mute-button {
    display: none !important;
}

#cameraFeed::-webkit-media-controls-volume-slider {
    display: none !important;
}

#cameraFeed::-webkit-media-controls-fullscreen-button {
    display: none !important;
}

/* Firefox */
#cameraFeed::-moz-media-controls {
    display: none !important;
}

/* General fallback */
#cameraFeed[controls] {
    visibility: hidden;
}

#cameraFeed:not([controls]) {
    visibility: visible;
}

.camera-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 1rem;
    background: linear-gradient(
        to bottom,
        rgba(0, 0, 0, 0.3) 0%,
        transparent 20%,
        transparent 80%,
        rgba(0, 0, 0, 0.3) 100%
    );
    pointer-events: none;
}

.capture-instructions {
    text-align: center;
    color: white;
    font-size: 1.1rem;
    font-weight: 500;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
}

.camera-status {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: white;
    font-size: 0.9rem;
}

.status-indicator {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #48bb78;
    box-shadow: 0 0 10px rgba(72, 187, 120, 0.5);
    animation: pulse 2s infinite;
}

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

/* Product Selection */
.product-selection {
    position: absolute;
    bottom: 1rem;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 1rem;
    z-index: 10;
}

.product-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    background: rgba(255, 255, 255, 0.95);
    border-radius: 12px;
    padding: 0.75rem;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    backdrop-filter: blur(10px);
    border: 2px solid rgba(255, 255, 255, 0.2);
}

.product-item:hover {
    transform: scale(1.05) translateY(-2px);
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.4);
    border-color: #667eea;
}

.product-item.selected {
    border-color: #667eea;
    background: rgba(255, 255, 255, 0.95);
    box-shadow: 0 8px 30px rgba(102, 126, 234, 0.4);
}

.product-item img {
    width: 60px;
    height: 60px;
    object-fit: cover;
    border-radius: 8px;
    margin-bottom: 0.5rem;
}

.product-item span {
    font-size: 0.8rem;
    font-weight: 500;
    color: #2d3748;
    text-align: center;
}

/* Countdown Overlay */
.countdown-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.3);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 100;
    backdrop-filter: blur(2px);
}

.countdown-number {
    font-size: 8rem;
    font-weight: 900;
    color: #fff;
    text-shadow: 0 0 30px rgba(102, 126, 234, 0.8);
    animation: countdownPulse 1s ease-in-out;
    line-height: 1;
}

.countdown-text {
    font-size: 1.5rem;
    color: #fff;
    margin-top: 1rem;
    text-shadow: 0 2px 10px rgba(0, 0, 0, 0.5);
}

.cancel-btn {
    background: rgba(255, 255, 255, 0.9);
    border: 2px solid rgba(255, 255, 255, 1);
    color: #333;
    padding: 0.5rem 1rem;
    border-radius: 8px;
    font-size: 0.9rem;
    cursor: pointer;
    margin-top: 1.5rem;
    transition: all 0.2s ease;
    backdrop-filter: blur(10px);
    font-weight: 500;
    pointer-events: auto;
    z-index: 1000;
    position: relative;
}

.cancel-btn:hover {
    background: rgba(255, 255, 255, 1);
    border-color: rgba(255, 255, 255, 1);
    transform: scale(1.05);
}

@keyframes countdownPulse {
    0% {
        transform: scale(0.5);
        opacity: 0;
    }
    50% {
        transform: scale(1.2);
        opacity: 1;
    }
    100% {
        transform: scale(1);
        opacity: 1;
    }
}

/* Result Section */
.result-section {
    flex: 1;
    min-height: 400px;
}

.result-container {
    position: relative;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.95);
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
    min-height: 400px;
}

.result-area {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

.result-placeholder {
    text-align: center;
    color: #a0aec0;
}

.result-icon {
    font-size: 4rem;
    margin-bottom: 1rem;
}

.result-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Loading Spinner */
.loading-spinner {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(5px);
    z-index: 1000;
}

.spinner {
    width: 60px;
    height: 60px;
    border: 4px solid #e2e8f0;
    border-top: 4px solid #667eea;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 1rem;
}

.loading-spinner p {
    color: white;
    font-size: 1.1rem;
    font-weight: 500;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
    margin-bottom: 1rem;
}

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

.progress-bar {
    width: 200px;
    height: 6px;
    background: #e2e8f0;
    border-radius: 3px;
    overflow: hidden;
    margin-top: 1rem;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #667eea, #764ba2);
    width: 0%;
    transition: width 0.3s ease;
}

@keyframes progressPulse {
    0%, 100% { width: 10%; }
    50% { width: 90%; }
}

/* Specific styling for cancel button in loading spinner */
.loading-spinner .cancel-btn {
    background: rgba(255, 255, 255, 0.9) !important;
    border: 2px solid rgba(255, 255, 255, 1) !important;
    color: #333 !important;
    cursor: pointer !important;
    pointer-events: auto !important;
    z-index: 2001 !important;
    position: relative !important;
    touch-action: manipulation !important;
    user-select: none !important;
}

/* Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    backdrop-filter: blur(5px);
}

.modal-content {
    background: white;
    border-radius: 12px;
    max-width: 500px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem 2rem;
    border-bottom: 1px solid #e2e8f0;
}

.modal-header h2 {
    margin: 0;
    color: #2d3748;
}

.close-btn {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: #a0aec0;
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.close-btn:hover {
    color: #4a5568;
}

.modal-body {
    padding: 2rem;
}

.garment-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 1rem;
    margin: 1rem 0;
}

.garment-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 1rem;
    border: 2px solid #e2e8f0;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.garment-item:hover {
    border-color: #667eea;
    transform: translateY(-2px);
}

.garment-item img {
    width: 80px;
    height: 80px;
    object-fit: cover;
    border-radius: 6px;
    margin-bottom: 0.5rem;
}

.upload-section {
    margin-top: 2rem;
    text-align: center;
}

.upload-btn {
    display: inline-block;
    padding: 0.75rem 1.5rem;
    background: #667eea;
    color: white;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.2s ease;
}

.upload-btn:hover {
    background: #5a67d8;
}

/* Messages */
.error-message, .success-message {
    position: fixed;
    top: 100px;
    right: 2rem;
    z-index: 1001;
    border-radius: 8px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
    animation: slideIn 0.3s ease;
}

.error-message {
    background: #fed7d7;
    border: 1px solid #feb2b2;
    color: #c53030;
}

.success-message {
    background: #c6f6d5;
    border: 1px solid #9ae6b4;
    color: #2f855a;
}

.error-content, .success-content {
    display: flex;
    align-items: center;
    padding: 1rem 1.5rem;
    gap: 0.5rem;
}

.error-close, .success-close {
    background: none;
    border: none;
    font-size: 1.2rem;
    cursor: pointer;
    margin-left: auto;
    opacity: 0.7;
}

.error-close:hover, .success-close:hover {
    opacity: 1;
}

@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* Responsive Design */
@media (max-width: 768px) {
    .header {
        padding: 0.5rem;
        flex-direction: row;
        justify-content: center;
        min-height: auto;
    }

    .header h1 {
        display: none;
    }

    .controls {
        flex-direction: row;
        gap: 1rem;
        width: 100%;
        justify-content: center;
    }

    .main-content {
        flex-direction: column;
        padding: 0.5rem;
        padding-bottom: 4px;
        gap: 0.5rem;
        height: calc(100vh - 60px);
        height: calc(100dvh - 60px);
    }

    .camera-section, .result-section {
        min-height: calc(50vh - 30px);
        min-height: calc(50dvh - 30px);
        height: calc(50vh - 30px);
        height: calc(50dvh - 30px);
        flex: none;
    }

    .camera-container, .result-container {
        min-height: calc(50vh - 30px);
        min-height: calc(50dvh - 30px);
        height: calc(50vh - 30px);
        height: calc(50dvh - 30px);
    }

    .capture-instructions {
        font-size: 0.9rem;
    }

    .modal-content {
        margin: 1rem;
        width: calc(100% - 2rem);
    }

    .garment-grid {
        grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
    }

    .error-message, .success-message {
        right: 1rem;
        left: 1rem;
        top: 70px;
    }
    
    .product-selection {
        bottom: 0.5rem;
        gap: 0.5rem;
    }
    
    .product-item {
        padding: 0.4rem;
    }
    
    .product-item img {
        width: 45px;
        height: 45px;
    }
    
    .product-item span {
        font-size: 0.7rem;
    }
    
    .countdown-number {
        font-size: 5rem;
    }
}

@media (max-width: 480px) {
    .controls {
        flex-direction: row;
        gap: 0.8rem;
        flex-wrap: wrap;
    }

    .btn {
        padding: 0.4rem 0.8rem;
        font-size: 0.8rem;
    }

    .checkbox-container {
        font-size: 0.8rem;
    }

    .camera-section, .result-section {
        min-height: calc(50vh - 30px);
        min-height: calc(50dvh - 30px);
        height: calc(50vh - 30px);
        height: calc(50dvh - 30px);
    }

    .camera-container, .result-container {
        min-height: calc(50vh - 30px);
        min-height: calc(50dvh - 30px);
        height: calc(50vh - 30px);
        height: calc(50dvh - 30px);
    }

    .product-item {
        padding: 0.3rem;
    }
    
    .product-item img {
        width: 40px;
        height: 40px;
    }
    
    .countdown-number {
        font-size: 4rem;
    }
}

/* Portrait mode adjustments */
@media (orientation: portrait) and (max-width: 768px) {
    .main-content {
        flex-direction: column;
        height: calc(100vh - 60px);
        height: calc(100dvh - 60px);
    }
    
    .camera-section {
        order: 1;
        height: calc(50vh - 30px);
        height: calc(50dvh - 30px);
    }
    
    .result-section {
        order: 2;
        height: calc(50vh - 30px);
        height: calc(50dvh - 30px);
    }
    
    .camera-container, .result-container {
        height: calc(50vh - 30px);
        height: calc(50dvh - 30px);
    }
}

/* Landscape mode adjustments */
@media (orientation: landscape) and (max-width: 768px) {
    .header {
        padding: 0.3rem 0.5rem;
        min-height: 50px;
    }
    
    .header h1 {
        display: none;
    }
    
    .main-content {
        flex-direction: row;
        padding: 0.5rem;
        height: calc(100vh - 50px);
    }
    
    .camera-section, .result-section {
        height: calc(100vh - 50px);
        flex: 1;
    }
    
    .camera-container, .result-container {
        height: calc(100vh - 50px);
    }
}

/* Footer Styles */
.footer {
    background-color: #2d3748;
    color: #e2e8f0;
    padding: 3rem 0;
    margin-top: 4rem;
}

.footer-content {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 2rem;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 2rem;
}

.footer-section h3 {
    color: #a0aec0;
    font-size: 0.875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 1rem;
}

.footer-section a {
    display: block;
    color: #cbd5e0;
    text-decoration: none;
    padding: 0.25rem 0;
    transition: color 0.2s ease;
}

.footer-section a:hover {
    color: #ffffff;
}

.footer-bottom {
    max-width: 1200px;
    margin: 2rem auto 0;
    padding: 2rem 2rem 0;
    border-top: 1px solid #4a5568;
    text-align: center;
}

.footer-bottom p {
    color: #a0aec0;
    margin: 0;
}