/* CSS Custom Properties for Theming */
:root {
    --primary-gradient: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --secondary-gradient: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    --dark-bg: linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%);
    --glass-bg: rgba(255, 255, 255, 0.1);
    --glass-border: rgba(255, 255, 255, 0.2);
    --text-primary: #ffffff;
    --text-secondary: rgba(255, 255, 255, 0.7);
    --shadow-sm: 0 4px 6px rgba(0, 0, 0, 0.1);
    --shadow-md: 0 8px 16px rgba(0, 0, 0, 0.2);
    --shadow-lg: 0 16px 32px rgba(0, 0, 0, 0.3);
}

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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: var(--dark-bg);
    background-attachment: fixed;
    color: var(--text-primary);
    min-height: 100vh;
    padding: 20px;
    line-height: 1.6;
}

/* Glassmorphic Base Class */
.glass-card {
    background: var(--glass-bg);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid var(--glass-border);
    border-radius: 20px;
    padding: 30px;
    box-shadow: var(--shadow-md);
    transition: all 0.3s ease;
}

.glass-card:hover {
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
    box-shadow: var(--shadow-lg);
    transform: translateY(-2px);
}

/* Header Styles */
.glass-header {
    background: var(--glass-bg);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid var(--glass-border);
    border-radius: 20px;
    padding: 40px;
    text-align: center;
    margin-bottom: 40px;
    box-shadow: var(--shadow-md);
}

.app-title {
    font-size: 3rem;
    font-weight: 700;
    background: var(--primary-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 10px;
}

.app-tagline {
    font-size: 1.2rem;
    color: var(--text-secondary);
}

/* Container */
.container {
    max-width: 1200px;
    margin: 0 auto;
    display: grid;
    grid-template-columns: 1fr;
    gap: 30px;
}

/* Upload Section */
.upload-section h2 {
    margin-bottom: 20px;
    font-size: 1.5rem;
}

.upload-area {
    position: relative;
    min-height: 300px;
    border: 2px dashed var(--glass-border);
    border-radius: 15px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
}

.upload-area:hover {
    border-color: rgba(255, 255, 255, 0.4);
    background: rgba(255, 255, 255, 0.05);
}

.upload-placeholder {
    text-align: center;
    padding: 40px;
}

.upload-placeholder svg {
    margin-bottom: 20px;
    opacity: 0.7;
}

.upload-placeholder p {
    font-size: 1.2rem;
    margin-bottom: 10px;
}

.file-info {
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.preview-container {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.preview-container img {
    max-width: 100%;
    max-height: 400px;
    border-radius: 10px;
    box-shadow: var(--shadow-md);
}

.error-message {
    margin-top: 15px;
    padding: 15px;
    border-radius: 10px;
    background: rgba(245, 87, 108, 0.2);
    border: 1px solid rgba(245, 87, 108, 0.4);
    color: #ff6b6b;
    display: none;
}

.error-message.show {
    display: block;
}

/* Filter Section */
.filter-section h2 {
    margin-bottom: 20px;
    font-size: 1.5rem;
}

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

.filter-btn {
    background: var(--glass-bg);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid var(--glass-border);
    border-radius: 15px;
    padding: 25px 15px;
    cursor: pointer;
    transition: all 0.3s ease;
    color: var(--text-primary);
    font-size: 1rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
}

.filter-btn:hover {
    background: rgba(255, 255, 255, 0.15);
    transform: translateY(-3px);
    box-shadow: var(--shadow-md);
}

.filter-btn.active {
    background: var(--primary-gradient);
    border-color: transparent;
    box-shadow: var(--shadow-lg);
}

.filter-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.filter-icon {
    font-size: 2rem;
}

.filter-name {
    font-weight: 600;
}

/* Result Section */
.result-section h2 {
    margin-bottom: 20px;
    font-size: 1.5rem;
}

.result-container {
    position: relative;
    min-height: 400px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.loading-spinner {
    text-align: center;
}

.spinner {
    width: 60px;
    height: 60px;
    border: 4px solid rgba(255, 255, 255, 0.1);
    border-top-color: #667eea;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 20px;
}

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

.result-preview {
    width: 100%;
    text-align: center;
}

.result-preview img {
    max-width: 100%;
    max-height: 500px;
    border-radius: 10px;
    box-shadow: var(--shadow-lg);
}

.download-btn {
    width: 100%;
    margin-top: 20px;
    padding: 15px 30px;
    background: var(--primary-gradient);
    border: none;
    border-radius: 12px;
    color: white;
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    transition: all 0.3s ease;
    box-shadow: var(--shadow-md);
}

.download-btn:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

/* Responsive Design */
@media (max-width: 768px) {
    .app-title {
        font-size: 2rem;
    }
    
    .app-tagline {
        font-size: 1rem;
    }
    
    .glass-header {
        padding: 30px 20px;
    }
    
    .glass-card {
        padding: 20px;
    }
    
    .filter-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 480px) {
    body {
        padding: 10px;
    }
    
    .app-title {
        font-size: 1.5rem;
    }
    
    .filter-grid {
        grid-template-columns: 1fr;
    }
}

/* PWA Specific Styles */
.install-btn {
    position: absolute;
    top: 20px;
    right: 20px;
    background: var(--primary-gradient);
    border: none;
    border-radius: 25px;
    padding: 12px 20px;
    color: white;
    font-weight: 600;
    cursor: pointer;
    font-size: 0.9rem;
    box-shadow: var(--shadow-md);
    transition: all 0.3s ease;
    z-index: 1000;
}

.install-btn:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

/* PWA Display Mode Styles */
@media (display-mode: standalone) {
    body {
        padding-top: 40px; /* Account for status bar */
    }
    
    .glass-header {
        padding-top: 50px; /* Extra space for status bar */
    }
}

/* iOS Safari PWA Styles */
@media (display-mode: standalone) and (-webkit-touch-callout: none) {
    body {
        padding-top: env(safe-area-inset-top);
        padding-bottom: env(safe-area-inset-bottom);
    }
}

/* Offline Indicator */
.offline-indicator {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    background: rgba(255, 87, 108, 0.9);
    color: white;
    text-align: center;
    padding: 10px;
    font-weight: 600;
    z-index: 10000;
    transform: translateY(-100%);
    transition: transform 0.3s ease;
}

.offline-indicator.show {
    transform: translateY(0);
}

/* App-like Navigation */
.app-navigation {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--glass-bg);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-top: 1px solid var(--glass-border);
    padding: 10px;
    display: none; /* Show only in standalone mode */
}

@media (display-mode: standalone) {
    .app-navigation {
        display: flex;
        justify-content: space-around;
        align-items: center;
    }
    
    .container {
        padding-bottom: 80px; /* Space for navigation */
    }
}

.nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 8px 12px;
    border-radius: 12px;
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.8rem;
    transition: all 0.3s ease;
}

.nav-item:hover,
.nav-item.active {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
}

.nav-item svg {
    width: 24px;
    height: 24px;
    margin-bottom: 4px;
}

/* Splash Screen Styles */
.splash-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--dark-bg);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 10000;
    opacity: 1;
    transition: opacity 0.5s ease;
}

.splash-screen.hidden {
    opacity: 0;
    pointer-events: none;
}

.splash-logo {
    font-size: 3rem;
    font-weight: 700;
    background: var(--primary-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 20px;
}

.splash-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid rgba(255, 255, 255, 0.1);
    border-top-color: #667eea;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

/* Enhanced Mobile Styles for PWA */
@media (max-width: 768px) {
    .glass-header {
        position: relative;
    }
    
    .install-btn {
        position: static;
        margin-top: 15px;
        width: auto;
    }
    
    /* Touch-friendly buttons */
    .filter-btn {
        min-height: 60px;
        padding: 20px 15px;
    }
    
    .download-btn {
        min-height: 50px;
        font-size: 1.2rem;
    }
    
    /* Improved touch targets */
    .upload-area {
        min-height: 250px;
        padding: 20px;
    }
}

/* Dark mode support for PWA */
@media (prefers-color-scheme: dark) {
    :root {
        --glass-bg: rgba(255, 255, 255, 0.08);
        --glass-border: rgba(255, 255, 255, 0.15);
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
    
    .spinner {
        animation: none;
        border: 3px solid #667eea;
    }
}