:root {
    --primary-color: #bce5d7;
    --secondary-color: #a8dcc9;
    --accent-color: #4a9e81;
    --dark-color: #2a5c4c;
    --light-color: #f8f9fa;
    --border-radius: 15px;
    --box-shadow: 0 8px 25px rgba(0, 0, 0, 0.1);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    line-height: 1.6;
    color: var(--dark-color);
    background-image: url("./images/background.png");
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    height: 100vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    padding: 20px;
}

.header {
    text-align: center;
    margin-bottom: 10px;
    flex-shrink: 0;
}

.header h1 {
    color: var(--dark-color);
    font-size: 3rem;
    margin-bottom: 10px;
    font-weight: 800;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.1);
}

.header p {
    color: var(--dark-color);
    font-size: 1.3rem;
    max-width: 600px;
    margin: 0 auto;
    font-weight: 500;
}

.main-container {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 25px;
    flex: 1;
    max-width: 1800px;
    margin: 0 auto;
    width: 100%;
    overflow: hidden;
}

/* SECTION 1: BRANDING */
.branding-section {
    background: linear-gradient(145deg, rgba(255,255,255,0.9), rgba(255,255,255,0.7));
    border-radius: var(--border-radius);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--box-shadow);
    backdrop-filter: blur(10px);
}

.branding-image {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    border-radius: var(--border-radius);
}

/* SECTION 2: CAMERA */
.camera-section {
    background: rgba(255,255,255,0.95);
    border-radius: var(--border-radius);
    padding: 30px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    box-shadow: var(--box-shadow);
    backdrop-filter: blur(10px);
    overflow: hidden;
}

.camera-title {
    font-size: 1.8rem;
    color: var(--dark-color);
    margin-bottom: 25px;
    text-align: center;
}

/* Camera container with fixed portrait aspect ratio */
.camera-container {
    width: 100%;
    max-width: 450px;
    margin: 0 auto 25px auto;
    position: relative;
    aspect-ratio: 9/16; /* Maintain portrait aspect ratio */
}

/* Ensure video and image elements maintain portrait aspect ratio */
#video, #capturedImage {
    width: 100%;
    border-radius: var(--border-radius);
    background-color: #f0f0f0;
    aspect-ratio: 9/16; /* Portrait aspect ratio */
    object-fit: cover;
    border: 3px solid var(--primary-color);
    box-shadow: 0 5px 20px rgba(0,0,0,0.1);
}

#capturedImage {
    display: none;
}

.camera-controls {
    display: flex;
    justify-content: center;
    gap: 15px;
    width: 100%;
    flex-wrap: wrap;
    flex-shrink: 0;
}

.btn {
    padding: 16px 30px;
    border: none;
    border-radius: 50px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.1);
}

.btn-primary {
    background: linear-gradient(145deg, var(--accent-color), var(--dark-color));
    color: white;
}

.btn-primary:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 20px rgba(0,0,0,0.2);
}

.btn-secondary {
    background: linear-gradient(145deg, #e0e0e0, #d0d0d0);
    color: var(--dark-color);
}

.btn-secondary:hover {
    transform: translateY(-2px);
}

/* SECTION 3: OPTIONS */
.options-section {
    background: rgba(255,255,255,0.95);
    border-radius: var(--border-radius);
    padding: 30px;
    display: flex;
    flex-direction: column;
    box-shadow: var(--box-shadow);
    backdrop-filter: blur(10px);
    overflow: hidden;
}

.options-title {
    text-align: center;
    margin-bottom: 50px;
    color: var(--dark-color);
    font-size: 1.8rem;
    font-weight: 700;
}

.option-group {
    margin-bottom: 50px;
}

.option-group h3 {
    margin-bottom: 25px;
    color: var(--dark-color);
    font-size: 1.5rem;
    text-align: center;
    font-weight: 600;
}

.wavy-description {
    text-align: center;
    background: linear-gradient(145deg, var(--primary-color), var(--secondary-color));
    padding: 25px;
    border-radius: var(--border-radius);
    margin-bottom: 15px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.1);
}

.wavy-description h4 {
    color: var(--dark-color);
    font-size: 1.1rem;
    margin-bottom: 8px;
    font-weight: 700;
}

.wavy-description p {
    color: var(--dark-color);
    font-size: 0.9rem;
    line-height: 1.5;
}

.option-selectors {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 15px;
    justify-items: center;
    margin-bottom: 20px;
}

.option-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    cursor: pointer;
    transition: all 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    padding: 12px 12px;
    border-radius: var(--border-radius);
    min-width: 100px;
    max-width: 100px;
    border: 3px solid transparent;
    position: relative;
    overflow: hidden;
}

.option-item::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(45deg, 
        var(--primary-color), 
        var(--secondary-color), 
        var(--accent-color), 
        var(--primary-color));
    background-size: 300% 300%;
    opacity: 0;
    z-index: -1;
    border-radius: var(--border-radius);
    animation: gradientShift 3s ease-in-out infinite;
}

.option-item:hover {
    background-color: rgba(188, 229, 215, 0.3);
    transform: translateY(-3px) scale(1.05);
    box-shadow: 0 8px 25px rgba(0,0,0,0.2);
}

.option-item:hover::before {
    opacity: 0.3;
}

.option-item.selected {
    background-color: var(--primary-color);
    border-color: var(--accent-color);
    transform: translateY(-3px) scale(1.05);
    box-shadow: 0 8px 25px rgba(74, 158, 129, 0.4);
}

.option-item.selected::before {
    opacity: 0.5;
}

.option-image {
    width: 100px;
    height: 100px;
    border-radius: 50%;
    background-color: #f8f9fa;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 8px;
    font-size: 20px;
    color: var(--dark-color);
    border: 3px solid var(--primary-color);
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    transition: all 0.4s ease;
    animation: pulseGlow 2s ease-in-out infinite alternate;
}

/* Round image style */
.option-image img {
    width: 85px;
    height: 85px;
    object-fit: cover;
    border-radius: 50%;
    border: 4px solid transparent;
    transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
    display: block;
    margin: 0 auto;
}

/* Color borders */
.blonde-option .option-image img { border-color: gold; }
.pink-option .option-image img { border-color: hotpink; }
.green-option .option-image img { border-color: mediumseagreen; }
.blue-option .option-image img { border-color: dodgerblue; }
.burgundy-option .option-image img { border-color: firebrick; }
.brown-option .option-image img { border-color: saddlebrown; }
.red-option .option-image img { border-color: crimson; }
.purple-option .option-image img { border-color: purple; }

/* Hover effect */
.option-item:hover .option-image img {
    transform: scale(1.1);
    box-shadow: 0 0 12px rgba(0,0,0,0.2);
}

/* Selected effect */
.option-item.selected .option-image img {
    border-width: 5px;
    box-shadow: 0 0 15px rgba(0,0,0,0.3);
    transform: scale(1.1);
}

.option-item.selected .option-image {
    background-color: var(--accent-color);
    color: white;
    border-color: var(--dark-color);
    animation: selectedPulse 1.5s ease-in-out infinite;
}

.option-name {
    font-size: 0.8rem;
    text-align: center;
    font-weight: 600;
    color: var(--dark-color);
}

@keyframes gradientShift {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

@keyframes pulseGlow {
    0% { box-shadow: 0 4px 12px rgba(0,0,0,0.15); }
    100% { box-shadow: 0 6px 20px rgba(74, 158, 129, 0.3); }
}

@keyframes selectedPulse {
    0% { 
        box-shadow: 0 4px 15px rgba(74, 158, 129, 0.5);
        transform: scale(1);
    }
    50% { 
        box-shadow: 0 8px 25px rgba(74, 158, 129, 0.7);
        transform: scale(1.05);
    }
    100% { 
        box-shadow: 0 4px 15px rgba(74, 158, 129, 0.5);
        transform: scale(1);
    }
}

/* Color sub-options - Always visible */
.color-sub-options {
    margin-top: 15px;
    text-align: center;
}

.color-sub-options h4 {
    margin-bottom: 12px;
    color: var(--dark-color);
    font-size: 1.1rem;
}

.color-application-options {
    display: flex;
    justify-content: center;
    gap: 15px;
}

.color-app-item {
    padding: 10px 20px;
    border: 3px solid var(--primary-color);
    border-radius: 25px;
    cursor: pointer;
    transition: all 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    background: rgba(255, 255, 255, 0.8);
    font-weight: 600;
    font-size: 0.9rem;
    position: relative;
    overflow: hidden;
}

.color-app-item::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(45deg, var(--primary-color), var(--accent-color));
    opacity: 0;
    z-index: -1;
    transition: opacity 0.3s ease;
}

.color-app-item:hover {
    background: var(--primary-color);
    transform: translateY(-2px) scale(1.02);
    box-shadow: 0 6px 20px rgba(0,0,0,0.15);
}

.color-app-item:hover::before {
    opacity: 0.3;
}

.color-app-item.selected {
    background: var(--accent-color);
    color: white;
    border-color: var(--dark-color);
    transform: translateY(-2px) scale(1.02);
    box-shadow: 0 6px 20px rgba(74, 158, 129, 0.4);
}

.color-app-item.selected::before {
    opacity: 0.5;
}

.submit-container {
    text-align: center;
    margin-top: auto;
    padding-top: 15px;
    flex-shrink: 0;
}

.btn-submit {
    background: linear-gradient(145deg, var(--dark-color), #1a4d3d);
    color: white;
    padding: 16px 40px;
    font-size: 1.1rem;
    font-weight: 700;
    border-radius: 50px;
    box-shadow: 0 6px 20px rgba(0,0,0,0.2);
}

.btn-submit:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 25px rgba(0,0,0,0.3);
}

.btn-submit:disabled {
    background: #ccc;
    cursor: not-allowed;
    transform: none;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}

/* Custom Alert Box */
.custom-alert {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: linear-gradient(145deg, rgba(255,255,255,0.95), rgba(255,255,255,0.9));
    border: 3px solid var(--accent-color);
    border-radius: var(--border-radius);
    padding: 30px 40px;
    box-shadow: 0 15px 40px rgba(0,0,0,0.3);
    backdrop-filter: blur(15px);
    z-index: 2000;
    max-width: 450px;
    width: 90%;
    text-align: center;
    display: none;
}

.custom-alert.show {
    display: block;
}

.alert-icon {
    font-size: 3rem;
    color: var(--accent-color);
    margin-bottom: 20px;
    animation: bounce 1s infinite;
}

.alert-title {
    font-size: 1.5rem;
    color: var(--dark-color);
    margin-bottom: 15px;
    font-weight: 700;
}

.alert-message {
    font-size: 1.1rem;
    color: var(--dark-color);
    margin-bottom: 25px;
    line-height: 1.5;
}

.alert-button {
    background: linear-gradient(145deg, var(--accent-color), var(--dark-color));
    color: white;
    border: none;
    padding: 12px 30px;
    border-radius: 25px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.alert-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(0,0,0,0.2);
}

.alert-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(3px);
    z-index: 1999;
    display: none;
}

.alert-overlay.show {
    display: block;
}

/* Popup Modal */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.8);
    z-index: 1000;
    justify-content: center;
    align-items: center;
    backdrop-filter: blur(5px);
}

.modal-content {
    background: linear-gradient(145deg, rgba(255,255,255,0.98), rgba(255,255,255,0.95));
    border-radius: 25px;
    padding: 30px;
    max-width: 90vw;
    max-height: 90vh;
    overflow: hidden;
    text-align: center;
    position: relative;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
    backdrop-filter: blur(20px);
    border: 2px solid rgba(255,255,255,0.3);
    width: 900px;
}

.close-modal {
    position: absolute;
    top: 20px;
    right: 25px;
    font-size: 28px;
    cursor: pointer;
    color: var(--dark-color);
    transition: all 0.3s ease;
    z-index: 10;
}

.close-modal:hover {
    color: var(--accent-color);
    transform: rotate(90deg) scale(1.1);
}

/* Result Modal Layout - Side by side boxes */
.result-container {
    display: flex;
    gap: 30px;
    align-items: stretch;
    justify-content: center;
    max-width: 100%;
    margin: 20px 0;
    min-height: 400px;
}

.result-image-section, .result-qr-section {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: rgba(248, 249, 250, 0.9);
    border-radius: 20px;
    padding: 25px;
    border: 2px solid var(--primary-color);
    box-shadow: 0 8px 25px rgba(0,0,0,0.1);
    min-height: 400px;
    justify-content: center;
    align-items: center;
}

.result-image-section {
    background: linear-gradient(145deg, rgba(255,255,255,0.95), rgba(255,255,255,0.85));
}

.modal-image {
    max-width: 100%;
    max-height: auto;
    border-radius: 15px;
    
    box-shadow: 0 8px 25px rgba(0,0,0,0.15);
    border: 3px solid var(--primary-color);
    object-fit: contain;
}

.result-title {
    color: var(--dark-color);
    font-size: 2.2rem;
    margin-bottom: 20px;
    font-weight: 700;
    text-align: center;
    background: linear-gradient(145deg, var(--dark-color), var(--accent-color));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.style-info {
    font-size: 1.1rem;
    color: var(--accent-color);
    margin-bottom: 15px;
    font-weight: 600;
    text-align: center;
    background: rgba(188, 229, 215, 0.3);
    padding: 12px 20px;
    border-radius: 12px;
    border: 2px solid var(--primary-color);
    width: 100%;
}

.qr-section-title {
    font-size: 1.5rem;
    color: var(--dark-color);
    margin-bottom: 20px;
    font-weight: 700;
}

.qr-code-display {
    display: flex;
    justify-content: center;
    margin: 20px 0;
    min-height: 200px;
    align-items: center;
}

.qr-code-display canvas {
    border-radius: 10px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.1);
    border: 2px solid var(--primary-color);
}

.qr-instructions {
    font-size: 0.9rem;
    color: var(--dark-color);
    margin-top: 15px;
    line-height: 1.4;
    background: rgba(255,255,255,0.7);
    padding: 12px;
    border-radius: 10px;
    width: 100%;
}

.modal-buttons {
    display: flex;
    justify-content: center;
    gap: 15px;
    margin-top: 25px;
    flex-wrap: wrap;
}

.btn-regenerate {
    background: linear-gradient(145deg, var(--secondary-color), var(--primary-color));
    color: var(--dark-color);
    border: 2px solid var(--accent-color);
    padding: 12px 25px;
}

.btn-regenerate:hover {
    background: linear-gradient(145deg, var(--accent-color), var(--dark-color));
    color: white;
    transform: translateY(-2px);
}

/* Upload Button */
#fileInput {
    display: none;
}

/* Loading with GIF */
.loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px 0;
}

.loading-gif {
    width: 100px;
    height: 100px;
    margin-bottom: 25px;
    border-radius: 10px;
}

.loading h3 {
    color: var(--dark-color);
    margin-bottom: 15px;
    font-size: 1.8rem;
    font-weight: 700;
}

.loading p {
    color: var(--dark-color);
    font-size: 1.1rem;
    line-height: 1.5;
    text-align: center;
    margin-bottom: 10px;
}

.loading-style-info {
    font-size: 1rem;
    color: var(--accent-color);
    margin-top: 20px;
    font-weight: 600;
    background: rgba(188, 229, 215, 0.3);
    padding: 15px;
    border-radius: 15px;
    border: 2px solid var(--primary-color);
}

.error-message {
    background: linear-gradient(145deg, #ffe6e6, #ffd6d6);
    border: 3px solid #ff9999;
    color: #cc0000;
    padding: 25px;
    border-radius: 20px;
    margin-top: 25px;
    box-shadow: 0 8px 25px rgba(0,0,0,0.1);
}

.error-message h3 {
    font-size: 1.5rem;
    margin-bottom: 15px;
}

.error-message p {
    font-size: 1.1rem;
    line-height: 1.5;
}

@media (max-width: 1200px) {
    .main-container {
        grid-template-columns: 1fr;
        grid-template-rows: auto auto auto;
        gap: 20px;
        overflow-y: auto;
    }
    
    body {
        overflow: auto;
    }
    
    .header h1 {
        font-size: 2.5rem;
    }
    
    .result-container {
        flex-direction: column;
        gap: 20px;
        min-height: auto;
    }
}

@media (max-width: 1000px) {
    .modal-content {
        width: 95%;
        padding: 20px;
    }
    
    .result-container {
        flex-direction: column;
        gap: 20px;
        min-height: auto;
    }
    
    .result-image-section, .result-qr-section {
        min-height: auto;
        padding: 20px;
    }
    
    .modal-image {
        max-height: 280px;
    }
}

@media (max-width: 768px) {
    body {
        padding: 15px;
    }
    
    .option-selectors {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
    }
    
    .option-item {
        min-width: 70px;
        max-width: 90px;
    }
    
    .option-image img {
        width: 60px;
        height: 60px;
    }
    
    .camera-controls {
        flex-direction: column;
        align-items: center;
    }
    
    .modal-content {
        padding: 15px;
        border-radius: 20px;
    }
    
    .result-container {
        gap: 15px;
    }
    
    .result-image-section, .result-qr-section {
        padding: 15px;
    }
    
    .modal-buttons {
        flex-direction: column;
    }
    
    .modal-image {
        max-height: 250px;
    }
    
    .result-title {
        font-size: 1.8rem;
    }
}

.mirror-image {
    transform: rotateY(180deg);
}

