/* Modern Reset */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

:root {
    /* Color palette based on logo */
    --primary: #8B0000;      /* Dark red */
    --primary-light: #A52A2A; /* Slightly lighter red */
    --secondary: #D4AF37;    /* Gold */
    --light: #F5F5DC;       /* Beige */
    --dark: #3E2723;        /* Dark brown */
    --white: #FFFFFF;
    --gray-100: #F3F4F6;
    --gray-200: #E5E7EB;
    --gray-300: #D1D5DB;
    --gray-400: #9CA3AF;
    --gray-500: #6B7280;
    --gray-600: #4B5563;
    --gray-700: #374151;
    --gray-800: #1F2937;
    --gray-900: #111827;
    --red-500: #EF4444;
    --green-500: #10B981;
    --shadow: 0 2px 4px rgba(0,0,0,0.1);
    --border-radius: 8px;
    --transition: all 0.2s ease;
    /* Futuristic medieval extensions */
    --futuristic-bg-start: #290606; /* deep dark red */
    --futuristic-bg-end: #e1e1dc;   /* black */
    --glass-bg: rgba(255, 255, 255, 0.08);
    --glass-border: rgba(255, 255, 255, 0.15);
    --primary-neon: #ff2838;
}

/* Base Styles */
html {
    font-size: 16px;
    -webkit-text-size-adjust: 100%;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', sans-serif;
    line-height: 1.6;
    color: var(--dark);
    /* Futuristic gradient background with medieval dark red tones */
    background-color: var(--light);
    
    padding: 0;
    margin: 0;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Container */
.container {
    width: 100%;
    max-width: 100%;
    margin: 0 auto;
    padding: 1rem;
    flex: 1;
    display: flex;
    flex-direction: column;
}

/* Header */
header {
    text-align: center;
    padding: 1rem 0 0;
    margin-bottom: 1rem;
}

.logo {
    max-width: 220px;
    height: auto;
    margin: 0 auto 1rem;
    display: block;
}

h1 {
    font-size: 1.75rem;
    color: var(--primary);
    margin-bottom: 0.5rem;
    line-height: 1.2;
    font-family: 'Cinzel Decorative', serif;
    font-weight: 700;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.1);
}

/* Form */
.simple-form {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    backdrop-filter: blur(14px);
    border-radius: var(--border-radius);
    padding: 1.5rem;
    box-shadow: var(--shadow);
    width: 100%;
    max-width: 500px;
    margin: 0 auto;
}

.form-group {
    margin-bottom: 1.5rem;
}

label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: var(--gray-800);
}

input[type="text"],
input[type="email"] {
    width: 100%;
    padding: 0.75rem 1rem;
    font-size: 1rem;
    border: 1px solid var(--gray-300);
    border-radius: var(--border-radius);
    transition: var(--transition);
}

input[type="text"]:focus,
input[type="email"]:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(139, 0, 0, 0.1);
}

/* Photo Upload */
.photo-upload {
    margin: 1.5rem 0;
}

.upload-options {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin: 1rem 0;
}

/* Loading Overlay */
#loadingOverlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 9999;
    flex-direction: column;
}

#loadingOverlay .loading-content {
    background-color: rgba(255, 255, 255, 0.9);
    padding: 2rem;
    border-radius: var(--border-radius);
    text-align: center;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

#loadingOverlay h3 {
    color: var(--primary);
    margin-bottom: 1rem;
    font-family: 'Cinzel Decorative', serif;
}

.file-name {
    font-size: 0.9rem;
    color: var(--primary);
    margin-top: 0.5rem;
    word-break: break-all;
}

.hint {
    font-size: 0.875rem;
    color: var(--gray-600);
    margin-top: 0.5rem;
}

.security-note {
    font-size: 0.75rem;
    color: var(--gray-500);
    margin-top: 0.25rem;
    font-style: italic;
}

/* Buttons */
.btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    font-size: 1rem;
    font-weight: 500;
    border: none;
    border-radius: var(--border-radius);
    cursor: pointer;
    transition: var(--transition);
    text-align: center;
    background-color: var(--gray-100);
    color: var(--gray-800);
    text-decoration: none;
}

.btn i {
    font-size: 1.25rem;
}

.btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.btn.primary {
    background-color: var(--primary);
    color: white;
}

.btn.primary:hover {
    background-color: var(--primary-light);
}

.btn.secondary {
    background-color: var(--gray-200);
    color: var(--gray-800);
}

.btn.secondary:hover {
    background-color: var(--gray-300);
}

/* Submit Button */
.submit-btn {
    width: 100%;
    padding: 1rem;
    background-color: var(--secondary);
    color: var(--dark);
    border: none;
    border-radius: var(--border-radius);
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    margin: 1.5rem 0;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    font-family: 'Cinzel Decorative', serif;
}

.submit-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    background-color: #c9a832;
}

.submit-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

/* Success Message */
.success-message {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: var(--white);
    z-index: 1000;
    overflow-y: auto;
    padding: 2rem;
}

.success-content {
    max-width: 600px;
    margin: 0 auto;
    text-align: center;
    padding: 2rem;
    background-color: var(--white);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
}

.success-icon {
    font-size: 4rem;
    color: var(--green-500);
    margin-bottom: 1rem;
}

.success-actions {
    margin-top: 2rem;
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 1rem;
}

#downloadBtn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background-color: var(--secondary);
    color: var(--dark);
    font-weight: bold;
    text-decoration: none;
}

.donation-prompt {
    margin-bottom: 1rem;
    font-size: 1.1rem;
}

.success-content p {
    color: var(--gray-700);
    margin-bottom: 1.5rem;
    line-height: 1.6;
}

/* Processing Message */
#processingMessage {
    background-color: rgba(0, 0, 0, 0.9);
    color: var(--white);
}

#processingMessage .success-content {
    background-color: transparent;
    box-shadow: none;
    color: var(--white);
}

#processingMessage p {
    color: var(--gray-200);
}

.processing-spinner {
    width: 80px;
    height: 80px;
    border: 8px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: var(--secondary);
    animation: spin 1s ease-in-out infinite;
    margin: 0 auto 2rem;
}

.countdown {
    font-size: 1.2rem;
    margin: 1.5rem 0;
    color: var(--secondary);
}

.processing-progress {
    height: 10px;
    background-color: rgba(255, 255, 255, 0.2);
    border-radius: 5px;
    margin: 1rem 0;
    overflow: hidden;
}

.progress-bar {
    height: 100%;
    background-color: var(--secondary);
    width: 0%;
    transition: width 1s linear;
}

/* Generated Portrait */
.portrait-container {
    margin: 1.5rem 0;
    max-width: 100%;
    text-align: center;
    display: flex;
    justify-content: center;
    align-items: center;
}

.generated-portrait {
    max-width: 100%;
    max-height: 60vh;
    height: auto;
    border-radius: 8px;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
    display: block;
}

.success-actions {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.donation-prompt {
    font-size: 0.9rem;
    color: var(--gray-600);
    margin-bottom: 0.5rem;
}

/* Error states */
.error input {
    border-color: var(--red-500);
}

.error-message {
    color: var(--red-500);
    font-size: 0.875rem;
    margin-top: 0.5rem;
    display: none;
}

/* Terms */
.terms input[type="checkbox"] {
    transform: scale(2);
    margin-right: 0.5rem;
    cursor: pointer;
}

.terms {
    font-size: 0.875rem;
    color: var(--gray-600);
    text-align: center;
    margin-top: 1rem;
}

.terms a {
    color: var(--primary);
    text-decoration: none;
}

.terms a:hover {
    text-decoration: underline;
}

/* Donation Page */
.donation-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 1rem;
    max-width: 600px;
    margin: 0 auto;
}

.donation-box {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    backdrop-filter: blur(12px);
    padding: 1.25rem;
    text-align: center;
    border-radius: var(--border-radius);
    color: var(--primary);
    text-decoration: none;
    box-shadow: var(--shadow);
    transition: var(--transition);
}

.donation-box:hover {
    transform: translateY(-3px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.2);
}

.donation-box h3 {
    margin-bottom: 0.5rem;
    font-size: 1.25rem;
    font-family: 'Cinzel Decorative', serif;
}

.donation-box p {
    font-size: 0.9rem;
    color: var(--gray-700);
}

/* Footer */
.app-footer {
    background-color: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(5px);
    color: white;
    text-align: center;
    padding: 1rem;
    margin-top: auto;
}

.footer-content p {
    margin-bottom: 0.5rem;
    font-size: 0.875rem;
}

.footer-links {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.footer-links a {
    color: white;
    text-decoration: none;
    font-size: 0.875rem;
}

.footer-links a:hover {
    text-decoration: underline;
}

.divider {
    color: var(--gray-400);
}

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

.loading-spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: white;
    animation: spin 1s ease-in-out infinite;
    margin-right: 8px;
}

/* Animations */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.success-message.show {
    display: flex;
    animation: fadeIn 0.3s ease-out;
}

/* Responsive Design */
@media (min-width: 480px) {
    .upload-options {
        flex-direction: row;
    }
    
    .btn {
        width: auto;
        padding: 0.75rem 1.5rem;
    }
    
    .container {
        max-width: 480px;
        margin: 20px auto;
        border-radius: var(--border-radius);
        box-shadow: var(--shadow);
    }
    
    .success-actions {
        flex-direction: row;
        justify-content: center;
    }
}

@media (min-width: 768px) {
    .container {
        max-width: 600px;
        padding: 2rem;
        margin: 40px auto;
    }
    
    h1 {
        font-size: 2rem;
    }
    
    .simple-form {
        padding: 2rem;
    }
    
    .preview-container img {
        max-height: 300px;
    }
}

@media (max-width: 480px) {
    .container {
        padding: 1rem;
    }
    
    .simple-form {
        padding: 1rem;
    }
    
    h1 {
        font-size: 1.5rem;
    }
    
    .success-content {
        padding: 1.5rem;
        margin: 1rem;
    }
    
    .success-actions {
        gap: 0.75rem;
    }
}

/* Accessibility */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* Focus styles for keyboard navigation */
.btn:focus,
input:focus {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

/* Screen reader only content */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border-width: 0;
}
