:root {
    --primary: #FF6B6B;
    --secondary: #4ECDC4;
    --accent: #FFE66D;
    --dark: #2D3436;
    --light: #F7F9FC;
    --purple: #A29BFE;
    --pink: #FD79A8;
    --orange: #FDCB6E;
    --blue: #74B9FF;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Poppins', sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 50%, #f093fb 100%);
    min-height: 100vh;
    overflow-x: hidden;
}

body.modal-open {
    overflow: hidden;
}

/* ===================== ANIMATED BACKGROUND ===================== */
.bg-shapes {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 0;
    overflow: hidden;
}

.bg-shapes .shape {
    position: absolute;
    border-radius: 50%;
    opacity: 0.15;
    animation: float 20s infinite ease-in-out;
}

.shape:nth-child(1) {
    width: 300px;
    height: 300px;
    background: var(--accent);
    top: -100px;
    left: -100px;
    animation-delay: 0s;
}

.shape:nth-child(2) {
    width: 200px;
    height: 200px;
    background: var(--secondary);
    top: 50%;
    right: -50px;
    animation-delay: 5s;
}

.shape:nth-child(3) {
    width: 250px;
    height: 250px;
    background: var(--pink);
    bottom: -80px;
    left: 30%;
    animation-delay: 10s;
}

.shape:nth-child(4) {
    width: 150px;
    height: 150px;
    background: var(--orange);
    top: 20%;
    right: 20%;
    animation-delay: 15s;
}

@keyframes float {
    0%, 100% { transform: translateY(0) rotate(0deg); }
    25% { transform: translateY(-30px) rotate(90deg); }
    50% { transform: translateY(0) rotate(180deg); }
    75% { transform: translateY(30px) rotate(270deg); }
}

/* ===================== APP CONTAINER ===================== */
.app-container {
    position: relative;
    z-index: 1;
    max-width: 900px;
    margin: 0 auto;
    padding: 20px;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* ===================== HEADER ===================== */
.header {
    text-align: center;
    padding: 30px 0;
}

.logo {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    background: rgba(255,255,255,0.2);
    backdrop-filter: blur(20px);
    padding: 15px 30px;
    border-radius: 50px;
    border: 1px solid rgba(255,255,255,0.3);
    box-shadow: 0 8px 32px rgba(0,0,0,0.1);
}

.logo-icon {
    width: 50px;
    height: 50px;
    background: linear-gradient(135deg, var(--primary), var(--pink));
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    color: white;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); }
}

.logo-text {
    color: white;
    font-size: 28px;
    font-weight: 800;
    text-shadow: 0 2px 10px rgba(0,0,0,0.2);
}

.logo-text span {
    color: var(--accent);
}

.tagline {
    color: rgba(255,255,255,0.8);
    margin-top: 10px;
    font-size: 15px;
    font-weight: 400;
}

/* ===================== MAIN CARD ===================== */
.main-card {
    background: rgba(255,255,255,0.95);
    backdrop-filter: blur(20px);
    border-radius: 30px;
    padding: 40px;
    margin: 20px 0;
    box-shadow: 0 20px 60px rgba(0,0,0,0.15);
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 400px;
    position: relative;
    overflow: hidden;
}

.main-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 5px;
    background: linear-gradient(90deg, var(--primary), var(--secondary), var(--accent), var(--pink), var(--purple));
    background-size: 300% 100%;
    animation: gradientMove 3s ease infinite;
}

@keyframes gradientMove {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

/* ===================== UPLOAD AREA ===================== */
.upload-area {
    width: 100%;
    max-width: 500px;
    border: 3px dashed #ddd;
    border-radius: 24px;
    padding: 60px 40px;
    text-align: center;
    cursor: pointer;
    transition: all 0.4s ease;
    background: #fafafa;
    position: relative;
    overflow: hidden;
}

.upload-area:hover {
    border-color: var(--secondary);
    background: #f0fffe;
    transform: translateY(-5px);
    box-shadow: 0 15px 40px rgba(78, 205, 196, 0.2);
}

.upload-area.dragover {
    border-color: var(--primary);
    background: #fff0f0;
    transform: scale(1.02);
}

.upload-icon {
    width: 100px;
    height: 100px;
    background: linear-gradient(135deg, var(--secondary), var(--blue));
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 25px;
    font-size: 40px;
    color: white;
    box-shadow: 0 10px 30px rgba(78, 205, 196, 0.4);
    transition: transform 0.3s ease;
}

.upload-area:hover .upload-icon {
    transform: scale(1.1) rotate(-5deg);
}

.upload-title {
    font-size: 24px;
    font-weight: 700;
    color: var(--dark);
    margin-bottom: 10px;
}

.upload-subtitle {
    color: #888;
    font-size: 14px;
    margin-bottom: 20px;
}

.upload-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: linear-gradient(135deg, var(--primary), var(--pink));
    color: white;
    border: none;
    padding: 14px 35px;
    border-radius: 50px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 5px 20px rgba(255, 107, 107, 0.4);
}

.upload-btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 30px rgba(255, 107, 107, 0.5);
}

#fileInput {
    display: none;
}

/* ===================== IMAGE PREVIEW AREA ===================== */
.preview-area {
    width: 100%;
    display: none;
    flex-direction: column;
    align-items: center;
    gap: 25px;
}

.preview-area.active {
    display: flex;
}

.image-container {
    display: flex;
    gap: 20px;
    flex-wrap: wrap;
    justify-content: center;
    width: 100%;
}

.image-box {
    flex: 1;
    min-width: 280px;
    max-width: 400px;
    text-align: center;
}

.image-box-label {
    font-size: 14px;
    font-weight: 600;
    color: #666;
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.image-box-label .dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
}

.dot.original { background: #888; }
.dot.enhanced { background: linear-gradient(135deg, var(--primary), var(--secondary)); }

.image-wrapper {
    position: relative;
    border-radius: 20px;
    overflow: hidden;
    box-shadow: 0 10px 40px rgba(0,0,0,0.1);
    background: #f0f0f0;
    aspect-ratio: 4/3;
    display: flex;
    align-items: center;
    justify-content: center;
}

.image-wrapper img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

#enhancedImg.preview-ready {
    cursor: zoom-in;
}

#enhancedImg.preview-ready:hover {
    filter: brightness(0.95);
}

.image-wrapper .placeholder-text {
    color: #aaa;
    font-size: 14px;
}

/* ===================== ENHANCING OVERLAY ===================== */
.enhancing-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.7);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 15px;
    z-index: 10;
}

.enhancing-overlay.hidden {
    display: none;
}

.spinner {
    width: 60px;
    height: 60px;
    border: 4px solid rgba(255,255,255,0.2);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.enhancing-text {
    color: white;
    font-size: 16px;
    font-weight: 500;
}

.enhancing-subtext {
    color: rgba(255,255,255,0.6);
    font-size: 12px;
}

.progress-bar {
    width: 200px;
    height: 6px;
    background: rgba(255,255,255,0.2);
    border-radius: 10px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--accent), var(--secondary));
    border-radius: 10px;
    width: 0%;
    transition: width 0.3s ease;
}

/* ===================== ACTION BUTTONS ===================== */
.action-buttons {
    display: flex;
    gap: 15px;
    flex-wrap: wrap;
    justify-content: center;
    margin-top: 10px;
}

.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 14px 30px;
    border-radius: 50px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    border: none;
    transition: all 0.3s ease;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary), var(--pink));
    color: white;
    box-shadow: 0 5px 20px rgba(255, 107, 107, 0.4);
}

.btn-primary:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 30px rgba(255, 107, 107, 0.5);
}

.btn-secondary {
    background: white;
    color: var(--dark);
    border: 2px solid #eee;
    box-shadow: 0 2px 10px rgba(0,0,0,0.05);
}

.btn-secondary:hover {
    border-color: var(--secondary);
    color: var(--secondary);
    transform: translateY(-3px);
}

.btn-success {
    background: linear-gradient(135deg, #00b894, #00cec9);
    color: white;
    box-shadow: 0 5px 20px rgba(0, 184, 148, 0.4);
}

.btn-success:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 30px rgba(0, 184, 148, 0.5);
}

.btn-compare {
    background: linear-gradient(135deg, var(--purple), var(--blue));
    color: white;
    box-shadow: 0 5px 20px rgba(162, 155, 254, 0.4);
}

.btn-compare:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 30px rgba(162, 155, 254, 0.5);
}

/* ===================== ENHANCEMENT OPTIONS ===================== */
.enhance-options {
    display: none;
    width: 100%;
    max-width: 700px;
    margin-bottom: 20px;
}

.enhance-options.active {
    display: block;
}

.options-title {
    font-size: 18px;
    font-weight: 700;
    color: var(--dark);
    margin-bottom: 20px;
    text-align: center;
}

.options-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
    gap: 15px;
}

.option-card {
    background: white;
    border: 2px solid #eee;
    border-radius: 16px;
    padding: 20px 15px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.option-card:hover {
    border-color: var(--secondary);
    transform: translateY(-5px);
    box-shadow: 0 10px 30px rgba(0,0,0,0.08);
}

.option-card.selected {
    border-color: var(--primary);
    background: linear-gradient(135deg, rgba(255,107,107,0.05), rgba(253,121,168,0.05));
    box-shadow: 0 5px 20px rgba(255,107,107,0.15);
}

.option-icon {
    width: 45px;
    height: 45px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 10px;
    font-size: 20px;
}

.option-card:nth-child(1) .option-icon { background: linear-gradient(135deg, #ffecd2, #fcb69f); }
.option-card:nth-child(2) .option-icon { background: linear-gradient(135deg, #a8edea, #fed6e3); }
.option-card:nth-child(3) .option-icon { background: linear-gradient(135deg, #d299c2, #fef9d7); }
.option-card:nth-child(4) .option-icon { background: linear-gradient(135deg, #89f7fe, #66a6ff); }
.option-card:nth-child(5) .option-icon { background: linear-gradient(135deg, #ffecd2, #fcb69f); }
.option-card:nth-child(6) .option-icon { background: linear-gradient(135deg, #a18cd1, #fbc2eb); }
.option-card:nth-child(7) .option-icon { background: linear-gradient(135deg, #667eea, #764ba2); }
.option-card:nth-child(8) .option-icon { background: linear-gradient(135deg, #f093fb, #f5576c); }
.option-card:nth-child(9) .option-icon { background: linear-gradient(135deg, #2c3e50, #4ca1af); }

.option-name {
    font-size: 13px;
    font-weight: 600;
    color: var(--dark);
}

/* Preset Tag */
.preset-tag {
    position: absolute;
    top: 6px;
    right: 6px;
    background: linear-gradient(135deg, var(--primary), var(--pink));
    color: white;
    font-size: 9px;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 10px;
    letter-spacing: 0.5px;
}

/* ===================== TOAST NOTIFICATION ===================== */
.toast {
    position: fixed;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: var(--dark);
    color: white;
    padding: 15px 30px;
    border-radius: 50px;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 10px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.3);
    z-index: 1000;
    opacity: 0;
    transition: all 0.4s ease;
}

.toast.show {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
}

.toast i {
    color: var(--secondary);
}

/* ===================== IMAGE PREVIEW MODAL ===================== */
.preview-modal {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.82);
    display: none;
    align-items: center;
    justify-content: center;
    padding: 24px;
    z-index: 2000;
}

.preview-modal.show {
    display: flex;
}

.preview-modal img {
    max-width: min(100%, 1100px);
    max-height: 88vh;
    object-fit: contain;
    border-radius: 16px;
    box-shadow: 0 20px 70px rgba(0,0,0,0.45);
}

.preview-close {
    position: absolute;
    top: 20px;
    right: 20px;
    width: 44px;
    height: 44px;
    border: none;
    border-radius: 50%;
    background: white;
    color: var(--dark);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.25);
    transition: transform 0.2s ease;
}

.preview-close:hover {
    transform: scale(1.06);
}

/* ===================== LOADING OVERLAY ===================== */
.loading-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.75);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 3000;
    backdrop-filter: blur(8px);
}

.loading-overlay.show {
    display: flex;
}

.loading-box {
    background: white;
    border-radius: 24px;
    padding: 50px 60px;
    text-align: center;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
    animation: popIn 0.4s ease;
}

@keyframes popIn {
    0% { transform: scale(0.8); opacity: 0; }
    100% { transform: scale(1); opacity: 1; }
}

.loading-ring {
    display: inline-block;
    position: relative;
    width: 64px;
    height: 64px;
    margin-bottom: 20px;
}

.loading-ring div {
    box-sizing: border-box;
    display: block;
    position: absolute;
    width: 51px;
    height: 51px;
    margin: 6px;
    border: 4px solid var(--primary);
    border-radius: 50%;
    animation: loadingRing 1.2s cubic-bezier(0.5, 0, 0.5, 1) infinite;
    border-color: var(--primary) transparent transparent transparent;
}

.loading-ring div:nth-child(1) { animation-delay: -0.45s; }
.loading-ring div:nth-child(2) { animation-delay: -0.3s; }
.loading-ring div:nth-child(3) { animation-delay: -0.15s; }

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

.loading-text {
    font-size: 18px;
    font-weight: 700;
    color: var(--dark);
    margin-bottom: 6px;
}

.loading-subtext {
    font-size: 13px;
    color: #888;
    margin-bottom: 20px;
}

.loading-progress {
    width: 200px;
    height: 6px;
    background: #eee;
    border-radius: 10px;
    overflow: hidden;
    margin: 0 auto;
}

.loading-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary), var(--secondary));
    border-radius: 10px;
    width: 0%;
    transition: width 0.3s ease;
}

/* ===================== BEFORE/AFTER COMPARE SLIDER ===================== */
.compare-slider {
    position: relative;
    width: 100%;
    max-width: 600px;
    aspect-ratio: 4/3;
    border-radius: 20px;
    overflow: hidden;
    box-shadow: 0 10px 40px rgba(0,0,0,0.15);
    display: none;
    user-select: none;
    -webkit-user-select: none;
}

.compare-slider.active {
    display: block;
}

.compare-img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    pointer-events: none;
}

.compare-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 50%;
    height: 100%;
    overflow: hidden;
    border-right: 3px solid white;
}

.compare-handle {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 50px;
    height: 50px;
    background: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 5px 20px rgba(0,0,0,0.3);
    cursor: ew-resize;
    z-index: 10;
    transition: transform 0.2s ease;
}

.compare-handle:hover {
    transform: translate(-50%, -50%) scale(1.1);
}

.compare-handle i {
    color: var(--dark);
    font-size: 18px;
}

.compare-labels {
    position: absolute;
    top: 15px;
    left: 0;
    right: 0;
    display: flex;
    justify-content: space-between;
    padding: 0 20px;
    pointer-events: none;
    z-index: 5;
}

.compare-label {
    background: rgba(0,0,0,0.6);
    color: white;
    padding: 5px 15px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
}

/* ===================== FOOTER ===================== */
.footer {
    text-align: center;
    padding: 20px;
    color: rgba(255,255,255,0.6);
    font-size: 13px;
}

.footer a {
    color: var(--accent);
    text-decoration: none;
    font-weight: 600;
}

/* ===================== RESPONSIVE ===================== */
@media (max-width: 600px) {
    .main-card {
        padding: 25px 20px;
        border-radius: 20px;
    }
    .upload-area {
        padding: 40px 20px;
    }
    .logo-text {
        font-size: 22px;
    }
    .image-container {
        flex-direction: column;
        align-items: center;
    }
    .image-box {
        max-width: 100%;
        width: 100%;
    }
    .options-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    .action-buttons {
        flex-direction: column;
        width: 100%;
    }
    .btn {
        width: 100%;
        justify-content: center;
    }
    .loading-box {
        padding: 35px 30px;
        margin: 0 20px;
    }
    .compare-slider {
        max-width: 100%;
    }
}

@media (max-width: 400px) {
    .options-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
    }
    .option-card {
        padding: 15px 10px;
    }
    .option-icon {
        width: 38px;
        height: 38px;
        font-size: 16px;
    }
    .option-name {
        font-size: 11px;
    }
}