/* الإعدادات العامة */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

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

/* الخلفية المتحركة */
.animated-bg {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
    overflow: hidden;
}

.star {
    position: absolute;
    width: 3px;
    height: 3px;
    background: white;
    border-radius: 50%;
    animation: twinkle 3s infinite;
}

.star:nth-child(1) {
    top: 20%;
    left: 20%;
    animation-delay: 0s;
}

.star:nth-child(2) {
    top: 40%;
    left: 60%;
    animation-delay: 1s;
}

.star:nth-child(3) {
    top: 60%;
    left: 30%;
    animation-delay: 2s;
}

.star:nth-child(4) {
    top: 80%;
    left: 70%;
    animation-delay: 1.5s;
}

.star:nth-child(5) {
    top: 30%;
    left: 80%;
    animation-delay: 0.5s;
}

@keyframes twinkle {
    0%, 100% { opacity: 0.3; transform: scale(1); }
    50% { opacity: 1; transform: scale(1.5); }
}

/* الحاوية الرئيسية */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
    position: relative;
    z-index: 1;
}

/* الترويسة */
.header {
    text-align: center;
    margin-bottom: 40px;
    animation: slideDown 0.8s ease-out;
}

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

.logo-container {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 15px;
    margin-bottom: 10px;
}

.hero-icon {
    font-size: 3rem;
    color: #FFD700;
    animation: bounce 2s infinite;
}

@keyframes bounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-10px); }
}

.main-title {
    font-family: 'Fredoka', sans-serif;
    font-size: 2.5rem;
    font-weight: 900;
    color: white;
    text-shadow: 3px 3px 6px rgba(0, 0, 0, 0.3);
    margin: 0;
}

.subtitle {
    font-size: 1.3rem;
    color: #fff;
    opacity: 0.95;
    font-weight: 600;
}

/* الشاشات */
.screen {
    display: none;
    animation: fadeIn 0.5s ease-in;
}

.screen.active {
    display: block;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* قسم الرفع */
.upload-section {
    background: white;
    border-radius: 30px;
    padding: 40px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    margin-bottom: 30px;
}

.upload-box {
    text-align: center;
    padding: 40px;
    border: 3px dashed #667eea;
    border-radius: 20px;
    background: linear-gradient(135deg, #f5f7ff 0%, #e8eaff 100%);
    transition: all 0.3s ease;
}

.upload-box:hover {
    border-color: #764ba2;
    transform: scale(1.02);
}

.upload-icon {
    font-size: 4rem;
    color: #667eea;
    margin-bottom: 20px;
    animation: pulse 2s infinite;
}

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

.upload-box h2 {
    font-family: 'Fredoka', sans-serif;
    font-size: 1.8rem;
    color: #333;
    margin-bottom: 10px;
}

.upload-box p {
    font-size: 1.1rem;
    color: #666;
    margin-bottom: 30px;
}

.upload-buttons {
    display: flex;
    gap: 15px;
    justify-content: center;
    flex-wrap: wrap;
}

/* الأزرار */
.btn {
    padding: 15px 35px;
    font-size: 1.2rem;
    font-weight: 700;
    border: none;
    border-radius: 50px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    gap: 10px;
    font-family: 'Cairo', sans-serif;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
}

.btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.3);
}

.btn:active {
    transform: translateY(-1px);
}

.btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.btn-secondary {
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    color: white;
}

.btn-success {
    background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
    color: white;
}

.btn-transform {
    width: 100%;
    padding: 20px;
    font-size: 1.5rem;
    margin-top: 30px;
    background: linear-gradient(135deg, #ffd89b 0%, #19547b 100%);
    animation: glow 2s infinite;
}

.btn-transform:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    animation: none;
}

@keyframes glow {
    0%, 100% { box-shadow: 0 5px 15px rgba(255, 215, 0, 0.4); }
    50% { box-shadow: 0 5px 30px rgba(255, 215, 0, 0.8); }
}

/* معاينة الصورة */
.image-preview {
    text-align: center;
    position: relative;
}

.image-preview img {
    max-width: 100%;
    max-height: 400px;
    border-radius: 20px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    margin-bottom: 20px;
}

.btn-icon {
    background: #f5576c;
    color: white;
    border: none;
    padding: 12px 25px;
    border-radius: 30px;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    transition: all 0.3s ease;
    font-family: 'Cairo', sans-serif;
}

.btn-icon:hover {
    background: #e04458;
    transform: scale(1.05);
}

/* اختيار البطل */
.hero-selection {
    background: white;
    border-radius: 30px;
    padding: 40px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

.section-title {
    font-family: 'Fredoka', sans-serif;
    font-size: 2rem;
    text-align: center;
    color: #333;
    margin-bottom: 30px;
}

.heroes-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 20px;
    margin-bottom: 20px;
}

.hero-card {
    background: linear-gradient(135deg, #f5f7ff 0%, #ffffff 100%);
    border-radius: 20px;
    padding: 20px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    border: 3px solid transparent;
}

.hero-card:hover {
    transform: translateY(-10px);
    box-shadow: 0 15px 40px rgba(0, 0, 0, 0.2);
}

.hero-card.selected {
    border-color: #FFD700;
    background: linear-gradient(135deg, #fff9e6 0%, #ffffff 100%);
    transform: scale(1.05);
}

.hero-image {
    width: 100px;
    height: 100px;
    margin: 0 auto 15px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 3rem;
    color: white;
    position: relative;
    overflow: hidden;
}

.hero-initial {
    font-family: 'Fredoka', sans-serif;
    font-size: 4rem;
    font-weight: 900;
}

.superman-bg {
    background: linear-gradient(135deg, #0099ff 0%, #ff0000 100%);
}

.batman-bg {
    background: linear-gradient(135deg, #2c3e50 0%, #000000 100%);
}

.spiderman-bg {
    background: linear-gradient(135deg, #ff0000 0%, #000080 100%);
}

.wonderwoman-bg {
    background: linear-gradient(135deg, #ff0000 0%, #ffd700 100%);
}

.captainamerica-bg {
    background: linear-gradient(135deg, #003399 0%, #ff0000 100%);
}

.ironman-bg {
    background: linear-gradient(135deg, #ff0000 0%, #ffd700 100%);
}

.elsa-bg {
    background: linear-gradient(135deg, #4dd0e1 0%, #b39ddb 100%);
}

.moana-bg {
    background: linear-gradient(135deg, #ff6f00 0%, #00acc1 100%);
}

.hero-card h3 {
    font-family: 'Fredoka', sans-serif;
    font-size: 1.2rem;
    color: #333;
    margin-bottom: 5px;
}

.hero-card p {
    font-size: 0.9rem;
    color: #666;
}

/* شاشة التحميل */
.loading-animation {
    text-align: center;
    padding: 60px 40px;
    background: white;
    border-radius: 30px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

.spinner {
    width: 100px;
    height: 100px;
    margin: 0 auto 30px;
    border: 8px solid #f3f3f3;
    border-top: 8px solid #667eea;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

.loading-text {
    font-family: 'Fredoka', sans-serif;
    font-size: 2rem;
    color: #333;
    margin-bottom: 15px;
}

.loading-message {
    font-size: 1.3rem;
    color: #666;
    margin-bottom: 30px;
}

.progress-bar {
    width: 100%;
    height: 30px;
    background: #e0e0e0;
    border-radius: 15px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #667eea 0%, #764ba2 100%);
    border-radius: 15px;
    width: 0%;
    transition: width 0.3s ease;
    animation: progressAnimation 3s ease-in-out infinite;
}

@keyframes progressAnimation {
    0% { width: 0%; }
    50% { width: 70%; }
    100% { width: 100%; }
}

/* شاشة النتيجة */
.result-container {
    background: white;
    border-radius: 30px;
    padding: 40px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    text-align: center;
}

.result-title {
    font-family: 'Fredoka', sans-serif;
    font-size: 2.2rem;
    color: #333;
    margin-bottom: 30px;
    animation: celebrationBounce 0.6s ease-out;
}

@keyframes celebrationBounce {
    0%, 100% { transform: scale(1); }
    25% { transform: scale(1.1); }
    50% { transform: scale(0.95); }
    75% { transform: scale(1.05); }
}

.result-image-container {
    position: relative;
    margin-bottom: 30px;
}

.result-image-container img {
    max-width: 100%;
    max-height: 500px;
    border-radius: 20px;
    box-shadow: 0 15px 40px rgba(0, 0, 0, 0.3);
}

.result-actions {
    display: flex;
    gap: 15px;
    justify-content: center;
    flex-wrap: wrap;
}

/* نافذة الكاميرا */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    z-index: 1000;
    justify-content: center;
    align-items: center;
}

.modal.active {
    display: flex;
}

.modal-content {
    background: white;
    border-radius: 20px;
    padding: 30px;
    max-width: 600px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.modal-header h3 {
    font-family: 'Fredoka', sans-serif;
    font-size: 1.8rem;
    color: #333;
}

.close-btn {
    background: #f5576c;
    color: white;
    border: none;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 1.2rem;
    transition: all 0.3s ease;
}

.close-btn:hover {
    background: #e04458;
    transform: rotate(90deg);
}

.camera-container {
    margin-bottom: 20px;
}

.camera-container video {
    width: 100%;
    border-radius: 15px;
    background: #000;
}

.camera-actions {
    text-align: center;
}

/* التصميم المتجاوب */
@media (max-width: 768px) {
    .main-title {
        font-size: 1.8rem;
    }

    .subtitle {
        font-size: 1rem;
    }

    .upload-section,
    .hero-selection,
    .loading-animation,
    .result-container {
        padding: 25px;
    }

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

    .hero-image {
        width: 80px;
        height: 80px;
        font-size: 2rem;
    }

    .btn {
        padding: 12px 25px;
        font-size: 1rem;
    }

    .result-actions {
        flex-direction: column;
    }

    .result-actions .btn {
        width: 100%;
    }
}

@media (max-width: 480px) {
    .container {
        padding: 15px;
    }

    .main-title {
        font-size: 1.5rem;
    }

    .heroes-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}
