/* Global Styles */
:root {
    --primary-color: #6c63ff;
    --primary-dark: #564fd8;
    --dark-color: #333;
    --light-color: #f8f9fa;
    --gray-color: #6c757d;
    --light-gray: #e9ecef;
    --box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
    --transition: all 0.3s ease;
}

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

body {
    font-family: 'Tajawal', sans-serif;
    line-height: 1.6;
    color: var(--dark-color);
    background-color: var(--light-color);
    direction: rtl;
}

.container {
    width: 90%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 15px;
}

h1, h2, h3, h4, h5, h6 {
    font-weight: 700;
    line-height: 1.2;
}

a {
    text-decoration: none;
    color: inherit;
}

ul {
    list-style: none;
}

img {
    max-width: 100%;
    height: auto;
}

.btn {
    display: inline-block;
    padding: 10px 20px;
    border-radius: 50px;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    border: none;
    outline: none;
    text-align: center;
}

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

.btn-primary:hover {
    background-color: var(--primary-dark);
    transform: translateY(-3px);
    box-shadow: var(--box-shadow);
}

/* Header Styles */
header {
    background-color: white;
    box-shadow: var(--box-shadow);
    position: fixed;
    width: 100%;
    top: 0;
    z-index: 1000;
    padding: 15px 0;
}

.logo h1 {
    font-size: 1.8rem;
    color: var(--primary-color);
}

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

/* Hero Section */
.hero {
    padding: 150px 0 100px;
    background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
    min-height: 100vh;
    display: flex;
    align-items: center;
}

.hero-content {
    text-align: center;
    max-width: 800px;
    margin: 0 auto;
}

.hero-content h2 {
    font-size: 2.5rem;
    margin-bottom: 20px;
    line-height: 1.3;
}

.hero-content h2 span {
    color: var(--primary-color);
}

.hero-content p {
    font-size: 1.2rem;
    color: var(--gray-color);
    margin-bottom: 30px;
}

.upload-area {
    background-color: white;
    border: 2px dashed var(--primary-color);
    border-radius: 10px;
    padding: 40px;
    text-align: center;
    cursor: pointer;
    transition: var(--transition);
    margin-bottom: 20px;
}

.upload-area:hover {
    transform: translateY(-5px);
    box-shadow: var(--box-shadow);
}

.upload-area i {
    font-size: 3rem;
    color: var(--primary-color);
    margin-bottom: 15px;
}

.upload-area p {
    font-size: 1.1rem;
    color: var(--gray-color);
}

.upload-area p span {
    color: var(--primary-color);
    font-weight: 500;
    text-decoration: underline;
}

.upload-area input {
    display: none;
}

.supported-formats p {
    font-size: 0.9rem;
    color: var(--gray-color);
    text-align: center;
}

/* Modal Styles */
.result-modal {
    display: none;
    position: fixed;
    top: 0;
    right: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.8);
    z-index: 2000;
    align-items: center;
    justify-content: center;
}

.modal-content {
    background-color: white;
    border-radius: 10px;
    width: 90%;
    max-width: 800px;
    padding: 30px;
    position: relative;
    animation: modalFadeIn 0.3s ease;
}

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

.close-modal {
    position: absolute;
    top: 15px;
    left: 15px;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--gray-color);
    transition: var(--transition);
}

.close-modal:hover {
    color: var(--dark-color);
}

.modal-content h3 {
    text-align: center;
    margin-bottom: 30px;
    font-size: 1.8rem;
    color: var(--primary-color);
}

.result-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 30px;
}

.original-image, .processed-image {
    text-align: center;
}

.original-image h4, .processed-image h4 {
    margin-bottom: 15px;
    font-size: 1.2rem;
}

.original-image img, .processed-image img {
    max-width: 100%;
    max-height: 300px;
    border-radius: 5px;
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.1);
}

.result-actions {
    display: flex;
    justify-content: center;
    gap: 1rem;
    margin-top: 1.5rem;
}

.download-btn {
    padding: 12px 25px;
    font-size: 1rem;
    background-color: var(--primary-color);
    color: white;
}

.download-btn {
    background: #2ecc71;
    color: white;
}

.download-btn:hover {
    background: #27ae60;
}

.share-btn {
    background: #3498db;
    color: white;
}

.share-btn:hover {
    background: #2980b9;
}

/* Loading Overlay */
.loading-overlay {
    display: none;
    position: fixed;
    top: 0;
    right: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    z-index: 2000;
    align-items: center;
    justify-content: center;
}

.loading-content {
    background-color: white;
    border-radius: 10px;
    padding: 40px;
    text-align: center;
    max-width: 500px;
    width: 90%;
}

.spinner {
    width: 50px;
    height: 50px;
    border: 5px solid var(--light-gray);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    margin: 0 auto 20px;
    animation: spin 1s linear infinite;
}

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

.loading-content p {
    font-size: 1.2rem;
    margin-bottom: 20px;
}

.progress-bar {
    width: 100%;
    height: 10px;
    background-color: var(--light-gray);
    border-radius: 5px;
    overflow: hidden;
}

.progress {
    height: 100%;
    background-color: var(--primary-color);
    width: 0;
    transition: width 0.3s ease;
}

/* Responsive Styles */
@media (max-width: 768px) {
    .hero-content h2 {
        font-size: 2rem;
    }
    
    .result-container {
        grid-template-columns: 1fr;
    }
}

.image-controls {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    margin: 1rem 0;
    padding: 1rem;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 10px;
}

.control-group {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.tool-btn {
    padding: 0.5rem 1rem;
    background: #6c63ff;
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.tool-btn:hover {
    background: #5449ff;
    transform: translateY(-2px);
}

.tool-btn.active {
    background: #4CAF50;
}

.crop-overlay {
    position: absolute;
    border: 2px dashed #fff;
    background: rgba(0, 0, 0, 0.3);
    pointer-events: none;
    display: none;
}

.processed-image {
    position: relative;
    overflow: hidden;
}

#processedImage {
    max-width: 100%;
    transition: transform 0.3s ease;
}

/* تنسيق منتقي الألوان */
input[type="color"] {
    width: 50px;
    height: 30px;
    padding: 0;
    border: none;
    border-radius: 5px;
    cursor: pointer;
}

/* تأثيرات التحويل */
.flip-horizontal {
    transform: scaleX(-1);
}

.flip-vertical {
    transform: scaleY(-1);
}

/* تحسينات للموبايل */
@media (max-width: 768px) {
    .control-group {
        flex-basis: 100%;
        justify-content: center;
    }
    
    .tool-btn {
        padding: 0.8rem;
        font-size: 1.1rem;
    }
}

/* حقوق الطبع والنشر */
.copyright {
    text-align: center;
    padding: 2rem 0;
    margin-top: 3rem;
    background-color: #f8f9fa;
    border-top: 1px solid #e9ecef;
}

.copyright p {
    color: #6c757d;
    font-size: 0.9rem;
    margin-bottom: 0.5rem;
}

copyright p:last-child {
    margin-bottom: 0;
}

/* تأثيرات الحركة عند التمرير */
.animate-on-scroll {
    opacity: 0;
    transition: opacity 0.6s ease, transform 0.6s ease;
}

.animate-on-scroll[data-aos="fade-up"] {
    transform: translateY(20px);
}

.animate-on-scroll.animated {
    opacity: 1;
    transform: translateY(0);
}

/* Result Modal Styles */
.result-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    z-index: 1000;
    overflow-y: auto;
}

.modal-content {
    background: #fff;
    border-radius: 15px;
    width: 90%;
    max-width: 1200px;
    margin: 20px auto;
    position: relative;
    animation: modalSlideIn 0.3s ease-out;
}

.modal-header {
    padding: 20px;
    border-bottom: 1px solid #eee;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h3 {
    margin: 0;
    color: #333;
    font-size: 1.5rem;
}

.close-modal {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: #666;
    transition: color 0.3s;
}

.close-modal:hover {
    color: #ff4444;
}

.modal-body {
    padding: 20px;
    max-height: 70vh;
    overflow-y: auto;
}

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

.comparison-item {
    background: #f8f9fa;
    border-radius: 10px;
    padding: 15px;
    text-align: center;
}

.comparison-item h4 {
    margin: 0 0 15px 0;
    color: #333;
}

.image-wrapper {
    position: relative;
    width: 100%;
    min-height: 200px;
    background: #fff;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.image-wrapper img {
    max-width: 100%;
    height: auto;
    display: block;
    margin: 0 auto;
}

.editing-tools {
    background: #f8f9fa;
    border-radius: 10px;
    padding: 20px;
    margin-top: 20px;
}

.editing-tools h4 {
    margin: 0 0 15px 0;
    color: #333;
}

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

.control-group {
    background: #fff;
    padding: 10px;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

.control-group label {
    display: block;
    margin-bottom: 8px;
    color: #555;
}

.quality-control {
    display: flex;
    align-items: center;
    gap: 10px;
}

.tool-btn {
    padding: 10px;
    border: none;
    border-radius: 8px;
    background: #fff;
    color: #333;
    cursor: pointer;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

.tool-btn:hover {
    background: #6c63ff;
    color: #fff;
}

.modal-footer {
    padding: 20px;
    border-top: 1px solid #eee;
    display: flex;
    justify-content: flex-end;
    gap: 15px;
}

.download-btn, .share-btn {
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-weight: bold;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.3s;
}

.download-btn {
    background: #6c63ff;
    color: #fff;
}

.share-btn {
    background: #f8f9fa;
    color: #333;
}

.download-btn:hover {
    background: #5a52d5;
}

.share-btn:hover {
    background: #e9ecef;
}

/* Responsive Design */
@media (max-width: 768px) {
    .modal-content {
        width: 95%;
        margin: 10px auto;
    }

    .modal-body {
        padding: 15px;
    }

    .image-comparison {
        grid-template-columns: 1fr;
    }

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

    .tool-btn {
        padding: 8px;
        font-size: 0.9rem;
    }

    .modal-footer {
        flex-direction: column;
    }

    .download-btn, .share-btn {
        width: 100%;
        justify-content: center;
    }
}

/* Animation */
@keyframes modalSlideIn {
    from {
        transform: translateY(-20px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

/* RTL Support */
[dir="rtl"] .modal-content {
    text-align: right;
}

[dir="rtl"] .close-modal {
    margin-right: auto;
    margin-left: 0;
}

/* Smooth Scrolling for Modal Body */
.modal-body {
    scrollbar-width: thin;
    scrollbar-color: #6c63ff #f0f0f0;
}

.modal-body::-webkit-scrollbar {
    width: 8px;
}

.modal-body::-webkit-scrollbar-track {
    background: #f0f0f0;
    border-radius: 4px;
}

.modal-body::-webkit-scrollbar-thumb {
    background: #6c63ff;
    border-radius: 4px;
}

/* Image Transitions */
.image-wrapper img {
    transition: transform 0.3s ease;
}

.image-wrapper:hover img {
    transform: scale(1.02);
}