/* BASE APP STYLES - Enhanced for Meta AI Multi-Screen Layout with PNG Assets */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    height: 100%;
    width: 100%;
    overflow: hidden;
    position: fixed;
    -webkit-text-size-adjust: 100%;
    -ms-text-size-adjust: 100%;
    text-size-adjust: 100%;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    color: white;
    height: 100%;
    width: 100%;
    overflow: hidden;
    position: fixed;
    margin: 0;
    padding: 0;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    -khtml-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
}

/* Rest of your CSS continues... */

/* SCREEN CONTAINER BASE */
.screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
    display: none;
    transition: opacity 0.5s ease-in-out, transform 0.5s ease-in-out;
    opacity: 0;
    transform: translateY(20px);
}

.screen.active {
    display: block;
    opacity: 1;
    transform: translateY(0);
}

.screen.exiting {
    opacity: 0;
    transform: translateY(-20px);
}

/* UI OVERLAY - Floats on top of effects */
.ui-overlay, .loading-overlay, .selection-overlay, .success-overlay, .error-overlay {
    position: relative;
    z-index: 10;
    width: 100vw;
    height: 100vh;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    padding: 20px;
    pointer-events: none;
}

.ui-overlay *, .loading-overlay *, .selection-overlay *, .success-overlay *, .error-overlay * {
    pointer-events: auto;
}

/* Logo container - positioned absolutely at top */
.logo-container {
    position: absolute;
    top: 40px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 15;
}

.meta-logo {
    height: 64px;
    width: auto;
    filter: drop-shadow(0 2px 8px rgba(255, 255, 255, 0.8));
    transition: all 0.3s ease;
}

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

/* ================================
   SCREEN 1: PROMPT INPUT STYLES
   ================================ */

.prompt-screen {
    z-index: 10;
}

/* Background layers for prompt screen */
.prompt-background {
    position: absolute;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
}

/* Main background (furthest back) */
.main-background {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: url('../assets/success-bg.png') center/cover no-repeat;
    z-index: 1;
}

/* Cloud layers (in front of lens lines, behind UI) */
.cloud-layers {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 3;
    overflow: visible;
}

.cloud-layer {
    position: absolute;
    flex-shrink: 0;
    overflow: visible;
}

/* Top left cloud - medium size, partially off-screen */
.cloud-1 {
    top: 30%;
    left: -15%;
    z-index: 3;
}

.cloud-1 .cloud-image {
    width: 480px;
    height: auto;
}

/* Top right cloud - smaller, partially off-screen */
.cloud-2 {
    top: 35%;
    right: -5%;
    z-index: 3;
}

.cloud-2 .cloud-image {
    width: 310px;
    height: auto;
}

/* Bottom cloud - smallest, on-screen */
.cloud-3 {
    bottom: 110px;
    right: 30%;
    z-index: 3;
}

.cloud-3 .cloud-image {
    width: 180px;
    height: auto;
}

.cloud-image {
    border-radius: 50%;
    object-fit: contain;
    object-position: center;
    opacity: 0.95;
    flex-shrink: 0;
    padding: 4px;
    background: transparent;
    box-shadow: 0 0 8px 2px rgba(255, 255, 255, 0.2);
}

/* UI overlay positioned above all backgrounds */
.ui-overlay {
    z-index: 10;
}

/* Title positioned independently near top */
.main-title {
    position: absolute;
    top: 100px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 2.2rem;
    font-weight: 500;
    color: #2C3E50;
    text-shadow: 0 1px 3px rgba(255, 255, 255, 0.8);
    letter-spacing: -0.01em;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    margin: 0;
    margin-top: 20px;
    z-index: 15;
}

/* Input section stays naturally centered */
.input-section {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(20px);
    border-radius: 50px;
    padding: 6px;
    width: 100%;
    max-width: 500px;
    box-shadow: 
        0 4px 20px rgba(0, 0, 0, 0.1),
        0 1px 3px rgba(0, 0, 0, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.7);
    position: relative;
    z-index: 15;
}

.input-row {
    display: flex;
    align-items: center;
    gap: 8px;
}

#promptInput {
    flex: 1;
    padding: 16px 20px;
    border: none;
    background: transparent;
    font-size: 1rem;
    color: #2C3E50;
    outline: none;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

#promptInput::placeholder {
    color: #9CA3AF;
    font-weight: 400;
}

#generateBtn {
    position: relative;
    width: 44px;
    height: 44px;
    border: none;
    border-radius: 50%;
    background: transparent;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    flex-shrink: 0;
    overflow: hidden;
}

.button-bg, .button-fg {
    position: absolute;
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.button-bg {
    z-index: 1;
}

.button-fg {
    z-index: 2;
}

#generateBtn:hover {
    transform: scale(1.05);
}

#generateBtn:active {
    transform: scale(0.98);
}

/* ================================
   SCREEN 2: LOADING STYLES
   ================================ */

.loading-screen {
    z-index: 20;
}

.loading-background {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: url('../assets/success-bg.png') center/cover no-repeat;
}

/* Meta petals layer for loading screen */
.meta-petals-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 2;
}

.meta-petals {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 120vw;
    height: 120vh;
    object-fit: cover;
    opacity: 0.8;
}

.loading-content {
    margin-top: 2rem;
    z-index: 10;
}

.loading-spinner {
    width: 80px;
    height: 80px;
    margin: 0 auto 2rem;
    background: url('../assets/loading-spinner.gif') center/contain no-repeat;
}

.loading-text {
    font-size: 1.3rem;
    color: #2C3E50;
    font-weight: 500;
    text-shadow: 0 1px 3px rgba(255, 255, 255, 0.8);
}

/* ================================
   SCREEN 3: SELECTION STYLES - MOBILE FIRST
   ================================ */

.selection-screen {
    z-index: 30;
}

.selection-background {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: url('../assets/success-bg.png') center/cover no-repeat;
}

.selection-header {
    margin-bottom: 2rem;
    margin-top: 1.5rem;
}

.selection-header h2 {
    font-size: 2rem;
    margin-bottom: 8px;
    color: #2C3E50;
    font-weight: 600;
    letter-spacing: -0.02em;
}

.selection-header p {
    color: #4A5568;
    font-size: 1.1rem;
    font-weight: 400;
}

/* Mobile-first grid - fits everything on phone screen */
.circular-grid {
    position: relative;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
    max-width: 350px;
    margin: 0 auto 2rem;
}

.circular-image-panel {
    position: relative;
    width: 120px;
    height: 120px;
    border-radius: 50%;
    overflow: hidden;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 
        0 4px 20px rgba(255, 255, 255, 0.5),
        0 2px 8px rgba(0, 0, 0, 0.1);
    border: 3px solid rgba(255, 255, 255, 0.6);
    background: rgba(255, 255, 255, 0.4);
    backdrop-filter: blur(10px);
}

@media (hover: hover) and (pointer:fine)
{
    .circular-image-panel:hover {
        transform: scale(1.05);
        box-shadow: 
            0 8px 30px rgba(59, 130, 246, 0.3),
            0 4px 12px rgba(0, 0, 0, 0.15);
        border-color: rgba(59, 130, 246, 0.6);
    }

    .circular-image-panel:hover .select-btn {
        opacity: 1;
        transform: scale(1);
    }
}


.circular-image-panel img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.circular-loading {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: #6B7280;
    font-size: 0.8rem;
    font-weight: 500;
}

.select-btn {
    position: absolute;
    bottom: -8px;
    right: -8px;
    width: 32px;
    height: 32px;
    border: none;
    border-radius: 50%;
    background: linear-gradient(135deg, #3B82F6 0%, #1E40AF 100%);
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    box-shadow: 0 2px 8px rgba(59, 130, 246, 0.3);
    opacity: 0;
    transform: scale(0.8);
}

.regenerate-btn {
    background: linear-gradient(135deg, #3B82F6 0%, #1E40AF 100%);
    color: white;
    border: none;
    padding: 12px 32px;
    border-radius: 50px;
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(59, 130, 246, 0.3);
    margin-top: 1rem;
}

.regenerate-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(59, 130, 246, 0.4);
}

/* ================================
   SCREEN 4: SUCCESS STYLES
   ================================ */

.success-screen {
    z-index: 40;
}

.success-background {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: url('../assets/success-bg.png') center/cover no-repeat;
}

.success-content {
    margin-top: 2rem;
}

.success-content h2 {
    font-size: 2.2rem;
    margin-bottom: 1rem;
    color: #2C3E50;
    font-weight: 600;
    letter-spacing: -0.02em;
}

.success-content p {
    color: #4A5568;
    font-size: 1.1rem;
    font-weight: 400;
    margin-bottom: 3rem;
}

.success-image-container {
    position: relative;
    margin-bottom: 3rem;
}

.success-image {
    width: 200px;
    height: 200px;
    border-radius: 50%;
    overflow: hidden;
    margin: 0 auto;
    box-shadow: 
        0 8px 30px rgba(0, 0, 0, 0.2),
        0 4px 12px rgba(0, 0, 0, 0.1);
    border: 4px solid rgba(255, 255, 255, 0.8);
    transition: opacity 0.3s ease;
}

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

/* Fade effect for image during animation */
.success-image.faded {
    opacity: 0.5;
}

/* Animated checkmark overlay - larger and centered */
.success-checkmark {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 220px;  /* Larger size to cover most of the image */
    height: 220px;
    opacity: 0;
    z-index: 10;
    pointer-events: none;
}

.success-checkmark.animating {
    opacity: 1;
}

/* Responsive sizing for checkmark */
@media (min-width: 600px) {
    .success-image {
        width: 225px;
        height: 225px;
    }
    
    .success-checkmark {
        width: 250px;
        height: 250px;
    }
}

@media (min-width: 900px) {
    .success-image {
        width: 250px;
        height: 250px;
    }
    
    .success-checkmark {
        width: 280px;
        height: 280px;
    }
}

.success-actions {
    display: flex;
    flex-direction: column;
    gap: 1.2rem;
    align-items: center;
    margin-top: 0.5rem;
}

.download-btn, .home-btn {
    padding: 15px 40px;
    border: none;
    border-radius: 50px;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    min-width: 200px;
}

.download-btn {
    background: linear-gradient(135deg, #EC4899 0%, #BE185D 100%);
    color: white;
    box-shadow: 0 4px 15px rgba(236, 72, 153, 0.3);
}

.download-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(236, 72, 153, 0.4);
}

.home-btn {
    background: linear-gradient(135deg, #3B82F6 0%, #1E40AF 100%);
    color: white;
    box-shadow: 0 4px 15px rgba(59, 130, 246, 0.3);
}

.home-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(59, 130, 246, 0.4);
}

/* ================================
   SCREEN 5: ERROR STYLES
   ================================ */

.error-screen {
    z-index: 50;
}

.error-background {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: url('../assets/success-bg.png') center/cover no-repeat;
}

.error-content {
    margin-top: 2rem;
}

.error-content h2 {
    font-size: 2.2rem;
    margin-bottom: 1rem;
    color: #2C3E50;
    font-weight: 600;
    letter-spacing: -0.02em;
}

.error-content p {
    color: #2C3E50;
    font-size: 1.1rem;
    font-weight: 400;
    margin-bottom: 3rem;
    line-height: 1.5;
}

.retry-btn {
    background: linear-gradient(135deg, #3B82F6 0%, #1E40AF 100%);
    color: white;
    border: none;
    padding: 15px 40px;
    border-radius: 50px;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(59, 130, 246, 0.3);
    min-width: 160px;
}

.retry-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(59, 130, 246, 0.4);
}

/* ================================
   RESPONSIVE DESIGN - MOBILE FIRST
   ================================ */

/* Tablet size - scale up from mobile */
@media (min-width: 600px) {
    .circular-grid {
        gap: 25px;
        max-width: 450px;
        margin: 0 auto 2.5rem;
    }
    
    .circular-image-panel {
        width: 160px;
        height: 160px;
    }
    
    .select-btn {
        bottom: -10px;
        right: -10px;
        width: 36px;
        height: 36px;
    }
    
    .circular-loading {
        font-size: 0.9rem;
    }
    
    .success-image {
        width: 225px;
        height: 225px;
    }
    
    .selection-header {
        margin-bottom: 2.5rem;
    }
    
    .regenerate-btn {
        padding: 14px 36px;
        font-size: 1rem;
    }
}

/* Desktop size - scale up further */
@media (min-width: 900px) {
    .circular-grid {
        gap: 40px;
        max-width: 600px;
        margin: 0 auto 3rem;
    }
    
    .circular-image-panel {
        width: 200px;
        height: 200px;
    }
    
    .select-btn {
        bottom: -10px;
        right: -10px;
        width: 40px;
        height: 40px;
    }
    
    .circular-loading {
        font-size: 0.9rem;
    }
    
    .success-image {
        width: 250px;
        height: 250px;
    }
    
    .selection-header {
        margin-bottom: 3rem;
    }
    
    .regenerate-btn {
        padding: 15px 40px;
        font-size: 1rem;
    }
}

/* Small screen adjustments */
@media (max-width: 768px) {
    .main-title {
        font-size: 1.8rem;
        top: 90px;
    }
    
    .input-section {
        padding: 5px;
        margin: 0 10px;
        max-width: 400px;
    }
    
    #promptInput {
        padding: 14px 18px;
        font-size: 0.95rem;
    }
    
    #generateBtn {
        width: 40px;
        height: 40px;
    }
    
    .selection-header h2,
    .success-content h2,
    .error-content h2 {
        font-size: 1.8rem;
    }
    
    .loading-spinner {
        width: 60px;
        height: 60px;
    }
}

@media (max-width: 480px) {
    .logo-container {
        top: 20px;
    }
    
    .meta-logo {
        height: 48px;
    }
    
    .main-title {
        font-size: 1.6rem;
        top: 80px;
    }
    
    .cloud-1 .cloud-image {
        width: 280px;
        left: -35%;
    }
    .cloud-2 .cloud-image {
        width: 200px; 
        right: -25%;
    }
    .cloud-3 .cloud-image {
        width: 120px; 
        right: 10%;
    }
    
    .success-actions {
        gap: 0.8rem;
    }
    
    .download-btn, .home-btn, .retry-btn {
        min-width: 180px;
        padding: 12px 30px;
    }
    
    .selection-header {
        margin-bottom: 1.5rem;
        margin-top: 1rem;
    }
    
    .selection-header h2 {
        font-size: 1.6rem;
        margin-bottom: 6px;
    }
    
    .selection-header p {
        font-size: 1rem;
    }
}

/* ================================
   UTILITY CLASSES
   ================================ */

.fade-in {
    animation: fadeIn 0.5s ease-in-out;
}

.fade-out {
    animation: fadeOut 0.5s ease-in-out;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeOut {
    from {
        opacity: 1;
        transform: translateY(0);
    }
    to {
        opacity: 0;
        transform: translateY(-20px);
    }
}

/* Hidden class for managing screen visibility */
.hidden {
    display: none !important;
}

/* Loading shimmer effect for placeholders */
.shimmer {
    background: linear-gradient(45deg, 
        rgba(255, 255, 255, 0.3), 
        rgba(255, 255, 255, 0.6), 
        rgba(255, 255, 255, 0.3)
    );
    background-size: 200% 200%;
    animation: shimmer 2s ease-in-out infinite;
}

@keyframes shimmer {
    0% { background-position: -200% 0; }
    100% { background-position: 200% 0; }
}

/* Legal footer for prompt screen */
.legal-footer {
    position: absolute;
    bottom: 110px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 50;
    display: flex;
    gap: 20px;
    align-items: center;
}

.legal-footer a {
    color: #6B7280;
    font-size: 0.5rem;
    text-decoration: none;
    opacity: 0.8;
    transition: opacity 0.2s ease;
}

.legal-footer a:hover {
    opacity: 1;
    text-decoration: underline;
}

.legal-footer .separator {
    color: #9CA3AF;
    font-size: 0.75rem;
    opacity: 0.6;
}