/* ============================================
   INDEX PAGE STYLES
   Upload Screen, Photo Selection, Camera Scan
   ============================================ */

/* Z-Index Hierarchy */
:root {
    --z-background: 0;
    --z-content: 10;
    --z-ui-elements: 100;
    --z-controls: 200;
    --z-modals: 1000;
    --z-tooltips: 2000;
    --z-errors: 9999;
}

body { 
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; 
    margin: 0; 
    padding: 20px; 
    background: linear-gradient(135deg, #2d1b69 0%, #1a0e3d 50%, #0f0624 100%);
    min-height: 100vh;
    overflow-x: auto;
    overflow-y: auto;
}

.container { 
    max-width: 800px; 
    margin: auto; 
    padding: 40px; 
    background: rgba(45, 27, 105, 0.95);
    border-radius: 20px; 
    box-shadow: 0 20px 40px rgba(0,0,0,0.4);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(138, 43, 226, 0.2);
}

h1 { 
    text-align: center; 
    color: #e8eaed; 
    margin-bottom: 40px;
    font-size: 2.5em;
    font-weight: 300;
    text-shadow: 0 0 20px rgba(100, 200, 255, 0.3);
}

.upload-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 30px;
}

.upload-box {
    position: relative;
    height: 200px;
    border: 3px dashed rgba(100, 200, 255, 0.4);
    border-radius: 15px;
    background: linear-gradient(135deg, rgba(30, 30, 50, 0.8) 0%, rgba(40, 40, 70, 0.6) 100%);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
    overflow: hidden;
    backdrop-filter: blur(5px);
}

.upload-box:hover {
    border-color: rgba(100, 200, 255, 0.8);
    background: linear-gradient(135deg, rgba(40, 40, 70, 0.9) 0%, rgba(60, 60, 100, 0.7) 100%);
    transform: translateY(-2px);
    box-shadow: 0 10px 25px rgba(100, 200, 255, 0.2);
}

.upload-box.dragover {
    border-color: rgba(46, 204, 113, 0.8);
    background: linear-gradient(135deg, rgba(30, 60, 40, 0.8) 0%, rgba(40, 80, 50, 0.6) 100%);
    transform: scale(1.02);
}

.upload-box.has-file {
    border-color: rgba(46, 204, 113, 0.6);
    background: linear-gradient(135deg, rgba(30, 60, 40, 0.8) 0%, rgba(40, 80, 50, 0.6) 100%);
}

/* Upload Controls */
.remove-photo-btn {
    position: absolute;
    top: 8px;
    left: 8px;
    width: 24px;
    height: 24px;
    border: none;
    border-radius: 50%;
    background: rgba(40, 40, 60, 0.9);
    color: #e8eaed;
    font-size: 16px;
    cursor: pointer;
    z-index: var(--z-content);
    transition: background 0.2s;
    border: 1px solid rgba(255, 255, 255, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    padding-bottom: 7.5px;
}

.remove-photo-btn:hover {
    background: rgba(231,76,60,0.9);
    color: white;
    border-color: rgba(231,76,60,0.5);
}

.upload-options {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    display: none;
    flex-direction: column;
    gap: 10px;
    z-index: var(--z-content);
}

.upload-option-btn {
    padding: 10px 20px;
    border: none;
    border-radius: 8px;
    background: rgba(100, 200, 255, 0.9);
    color: #1a1a2e;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.2s;
    border: 1px solid rgba(100, 200, 255, 0.3);
}

.upload-option-btn:hover {
    background: rgba(100, 200, 255, 1);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(100, 200, 255, 0.3);
}

.upload-box:not(.has-file):hover .upload-options {
    display: flex;
}

.upload-box.has-file .upload-options {
    display: none;
}

.upload-icon {
    font-size: 3em;
    color: rgba(100, 200, 255, 0.8);
    margin-bottom: 10px;
    transition: all 0.3s ease;
}

.upload-box:hover .upload-icon {
    color: rgba(100, 200, 255, 1);
    transform: scale(1.1);
    text-shadow: 0 0 15px rgba(100, 200, 255, 0.5);
}

.upload-text {
    color: #e8eaed;
    font-size: 1.1em;
    font-weight: 600;
    text-align: center;
    margin: 0;
}

.upload-subtext {
    color: rgba(232, 234, 237, 0.7);
    font-size: 0.9em;
    margin-top: 5px;
}

.file-preview {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    border-radius: 12px;
}

input[type=file] { 
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: pointer;
}

/* Options Section */
.options-section {
    background: rgba(30, 30, 50, 0.6);
    padding: 20px;
    border-radius: 15px;
    margin-bottom: 30px;
    border: 1px solid rgba(100, 200, 255, 0.2);
    backdrop-filter: blur(5px);
}

/* Buttons */
.submit-btn {
    width: 100%;
    padding: 18px 32px;
    background: linear-gradient(135deg, rgba(0, 255, 127, 0.9), rgba(50, 205, 50, 0.9));
    color: #1a1a2e;
    border: none;
    border-radius: 50px;
    font-size: 18px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    text-transform: uppercase;
    letter-spacing: 1px;
    box-shadow: 0 8px 25px rgba(0, 255, 127, 0.3);
    border: 1px solid rgba(0, 255, 127, 0.4);
}

.submit-btn:hover {
    background: linear-gradient(135deg, rgba(0, 255, 127, 1), rgba(50, 205, 50, 1));
    transform: translateY(-2px);
    box-shadow: 0 12px 30px rgba(0, 255, 127, 0.4);
}

.submit-btn:disabled {
    background: rgba(60, 60, 80, 0.6);
    color: rgba(232, 234, 237, 0.5);
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
    border-color: rgba(60, 60, 80, 0.4);
}

/* Status Messages */
.status { 
    margin-top: 25px; 
    padding: 20px; 
    border-radius: 15px; 
    border: 1px solid rgba(100, 200, 255, 0.2); 
    background: rgba(30, 30, 50, 0.6); 
    line-height: 1.6; 
    backdrop-filter: blur(5px);
    color: #e8eaed;
}

.status p { margin: 0; }
.status p + p { margin-top: 10px; }
.status-message { font-weight: bold; }
.status-info { border-left: 5px solid rgba(100, 200, 255, 0.8); background: rgba(30, 50, 80, 0.6); padding-left: 15px; }
.status-success { border-left: 5px solid rgba(46, 204, 113, 0.8); background: rgba(30, 60, 40, 0.6); padding-left: 15px; color: rgba(46, 204, 113, 0.9); }
.status-warning { border-left: 5px solid rgba(243, 156, 18, 0.8); background: rgba(60, 50, 30, 0.6); padding-left: 15px; color: rgba(243, 156, 18, 0.9); }
.status-error { border-left: 5px solid rgba(231, 76, 60, 0.8); background: rgba(60, 30, 30, 0.6); padding-left: 15px; color: rgba(231, 76, 60, 0.9); }

.loader {
    border: 4px solid rgba(60, 60, 80, 0.3);
    border-radius: 50%;
    border-top: 4px solid rgba(100, 200, 255, 0.8);
    width: 20px;
    height: 20px;
    animation: spin 1s linear infinite;
    display: inline-block;
    margin-right: 10px;
    vertical-align: middle;
}

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

.fitmatch-logo {
    position: fixed;
    bottom: 20px;
    right: 20px;
    background: rgba(45, 27, 105, 0.9);
    padding: 10px 15px;
    border-radius: 10px;
    border: 1px solid rgba(138, 43, 226, 0.3);
    backdrop-filter: blur(10px);
    z-index: var(--z-ui-elements);
}

.fitmatch-logo-img {
    height: 20px;
    width: auto;
    transition: all 0.3s ease;
}

.fitmatch-logo:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(138, 43, 226, 0.3);
    transition: all 0.3s ease;
}

/* ============================================
   CAMERA SCAN MODAL
   ============================================ */

/* Camera Scan Modal - Desktop */
#camera-scan-modal .modal-content {
    max-width: 700px;
    width: 90%;
    max-height: 88vh;
    margin: 2% auto;
    padding: 20px;
    overflow-y: auto;
}

#camera-scan-modal .modal-header {
    border-bottom-color: #4da6ff;
}

#camera-scan-modal .modal-title {
    color: #ffffff;
    text-shadow: 0 2px 6px rgba(0,0,0,0.5);
    letter-spacing: 0.5px;
}

#camera-scan-close {
    color: #fff;
    opacity: 0.9;
}

#camera-scan-modal .form-single {
    margin-bottom: 20px;
}

#camera-instructions {
    background: rgba(77,166,255,0.12);
    color: #e8f4ff;
    border-left-color: #4da6ff;
}

#camera-instructions p {
    margin: 0;
    line-height: 1.5;
    font-size: 18px;
    font-weight: 500;
}

.camera-video-container {
    position: relative;
    background: #000;
    border-radius: 12px;
    overflow: hidden;
}

#camera-video {
    width: 100%;
    height: auto;
    max-height: 60vh;
    background: #000;
    object-fit: contain;
}

#camera-overlay {
    position: absolute;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

#pose-status {
    position: absolute;
    left: 16px;
    bottom: 16px;
    background: rgba(0,0,0,0.75);
    color: #fff;
    padding: 16px 20px;
    border-radius: 12px;
    font-size: 28px;
    font-weight: 600;
    letter-spacing: 0.3px;
    text-shadow: 0 1px 3px rgba(0,0,0,0.8);
}

.retry-scan-container {
    margin-top: 16px;
    text-align: center;
}

#retry-scan {
    background: linear-gradient(135deg, #f39c12, #e67e22);
}

/* ============================================
   RESPONSIVE STYLES
   ============================================ */

/* Tablets and Mobile (768px and below) */
@media (max-width: 768px) {
    .upload-grid {
        grid-template-columns: 1fr 1fr;
        gap: 10px;
    }
    
    .upload-box {
        height: 120px;
    }
    
    .upload-text {
        font-size: 0.9em;
    }
    
    .upload-subtext {
        font-size: 0.75em;
        margin-top: 3px;
    }
    
    .upload-option-btn {
        padding: 3px 6px;
        font-size: 0.65em;
        margin: 1px;
        border-radius: 4px;
        white-space: nowrap;
        min-width: 0;
    }
    
    .upload-options {
        gap: 4px;
    }
    
    .upload-icon {
        font-size: 1.5em;
        margin-bottom: 5px;
    }
    
    .container {
        padding: 20px;
        margin: 10px;
    }
    
    h1 {
        font-size: 2em;
    }
    
    /* Camera scan modal specific */
    #camera-scan-modal .modal-content {
        padding: 15px;
        width: auto;
        max-width: none;
    }
    
    #camera-instructions {
        margin-bottom: 15px;
        padding: 12px;
    }
    
    #camera-instructions p {
        font-size: 14px;
        line-height: 1.4;
    }
    
    #pose-status {
        left: 10px;
        bottom: 10px;
        right: 10px;
        padding: 8px 10px;
        font-size: 13px;
        border-radius: 6px;
        max-width: none;
        width: auto;
        word-wrap: break-word;
        line-height: 1.2;
        background: rgba(0, 0, 0, 0.85);
        text-align: center;
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
    }
    
    #retry-scan {
        padding: 12px 20px;
        font-size: 14px;
        width: 100%;
        max-width: 100%;
    }
}

/* iPhone SE and very small screens (375px and below) */
@media (max-width: 375px) {
    body {
        padding: 10px;
        overflow-x: auto;
        overflow-y: scroll;
        -webkit-overflow-scrolling: touch; /* Smooth scrolling on iOS */
    }
    
    .container {
        padding: 15px;
        margin: 5px;
        border-radius: 15px;
        max-width: 100%;
        box-sizing: border-box;
        overflow: visible;
    }
    
    h1 {
        font-size: 1.8em;
        margin-bottom: 20px;
    }
    
    .submit-btn {
        font-size: 16px;
        padding: 15px 24px;
        margin-bottom: 15px;
    }
    
    .upload-grid {
        gap: 8px;
    }
    
    .upload-box {
        height: 100px;
        border-radius: 12px;
    }
    
    .upload-text {
        font-size: 0.8em;
        font-weight: 500;
    }
    
    .upload-subtext {
        font-size: 0.7em;
        margin-top: 2px;
    }
    
    .upload-icon {
        font-size: 1.3em;
        margin-bottom: 3px;
    }
    
    .upload-option-btn {
        padding: 2px 4px;
        font-size: 0.6em;
        border-radius: 3px;
    }
    
    .upload-options {
        gap: 3px;
    }
    
    .remove-photo-btn {
        width: 20px;
        height: 20px;
        font-size: 14px;
        top: 6px;
        right: 6px;
    }
    
    .fitmatch-logo {
        bottom: 15px;
        right: 15px;
        padding: 8px 12px;
        border-radius: 8px;
    }
    
    .fitmatch-logo-img {
        height: 16px;
    }
    
    .status {
        padding: 15px;
        font-size: 0.9em;
    }
    
    #camera-scan-modal .modal-content {
        padding: 12px;
    }
    
    #camera-instructions {
        padding: 10px;
        margin-bottom: 12px;
    }
    
    #camera-instructions p {
        font-size: 12px;
        line-height: 1.3;
    }
    
    #pose-status {
        left: 8px;
        bottom: 8px;
        right: 8px;
        padding: 6px 8px;
        font-size: 12px;
        line-height: 1.1;
    }
    
    #retry-scan {
        padding: 10px 16px;
        font-size: 13px;
    }
}

/* Extra small screens (320px and below) - older phones */
@media (max-width: 320px) {
    body {
        padding: 5px;
    }
    
    .container {
        padding: 10px;
        margin: 2px;
        min-width: 300px; /* Ensure minimum usable width */
    }
    
    h1 {
        font-size: 1.6em;
        margin-bottom: 15px;
    }
    
    .upload-grid {
        gap: 6px;
        min-width: 280px; /* Ensure grid doesn't get too cramped */
    }
    
    .upload-box {
        height: 90px;
        min-width: 130px; /* Minimum box width */
    }
    
    .submit-btn {
        font-size: 14px;
        padding: 12px 20px;
    }
}

