/* الأساسيات */
:root {
    --primary-color: #4a6fa5;
    --secondary-color: #166088;
    --accent-color: #4fc3f7;
    --text-color: #333;
    --light-color: #f8f9fa;
    --dark-color: #343a40;
    --success-color: #28a745;
    --danger-color: #dc3545;
    --border-radius: 8px;
    --box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Droid Arabic Kufi', Arial, sans-serif;
    line-height: 1.6;
    color: var(--text-color);
    background-color: #f5f5f5;
    direction: rtl;
}

/* التنسيق العام */
header {
    background-color: var(--primary-color);
    color: white;
    padding: 1rem;
    text-align: center;
    box-shadow: var(--box-shadow);
}

header h1 {
    margin-bottom: 0.5rem;
}

.lang-switcher {
    display: flex;
    justify-content: center;
    gap: 10px;
}

.lang-btn {
    padding: 5px 10px;
    border: none;
    border-radius: 4px;
    background-color: rgba(255, 255, 255, 0.2);
    color: white;
    cursor: pointer;
}

.lang-btn.active {
    background-color: white;
    color: var(--primary-color);
}

main {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    padding: 2rem;
    gap: 2rem;
    max-width: 1200px;
    margin: 0 auto;
}

.controls-container, .preview-container {
    background-color: white;
    border-radius: var(--border-radius);
    padding: 1.5rem;
    box-shadow: var(--box-shadow);
    flex: 1;
    min-width: 300px;
}

.preview-container {
    max-width: 500px;
}

.control-group {
    margin-bottom: 1.5rem;
}

.control-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: bold;
}

.form-control {
    width: 100%;
    padding: 0.5rem;
    border: 1px solid #ddd;
    border-radius: var(--border-radius);
    font-family: inherit;
}

input[type="range"] {
    -webkit-appearance: none;
    height: 8px;
    background: #ddd;
    border-radius: 4px;
    margin-top: 0.5rem;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 20px;
    height: 20px;
    background: var(--primary-color);
    border-radius: 50%;
    cursor: pointer;
}

.effects-container {
    display: flex;
    gap: 1rem;
}

.effects-container label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: normal;
    cursor: pointer;
}

.text-align-group .align-options {
    display: flex;
    gap: 0.5rem;
}

.align-btn {
    padding: 0.5rem;
    border: 1px solid #ddd;
    background: white;
    border-radius: 4px;
    cursor: pointer;
    font-size: 1rem;
}

.align-btn:hover {
    background: #f0f0f0;
}

.btn-primary, .btn-secondary {
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: var(--border-radius);
    cursor: pointer;
    font-weight: bold;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.btn-primary {
    background-color: var(--primary-color);
    color: white;
}

.btn-primary:hover {
    background-color: var(--secondary-color);
}

.btn-secondary {
    background-color: white;
    color: var(--primary-color);
    border: 1px solid var(--primary-color);
}

.btn-secondary:hover {
    background-color: #f0f8ff;
}

.preview-area {
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
    margin: 1rem auto;
    overflow: hidden;
    background-color: #f8f8f8;
    
    /* الحدود المبدئية */
    border: 2px dashed #aaa;
    min-width: 200px;
    min-height: 150px;
    max-width: 100%;
}


#template-image {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    display: block;
}

.draggable {
    position: absolute;
    cursor: move;
    user-select: none;
    padding: 0.5rem;
    border-radius: 4px;
}

#name-overlay {
    font-size: 24px;
    color: white;
    text-shadow: 1px 1px 3px rgba(0, 0, 0, 0.8);
}

.download-options {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 1rem;
}

.emoji-picker {
    position: relative;
    margin-top: 0.5rem;
}

.emoji-btn {
    padding: 0.5rem;
    border: 1px solid #ddd;
    background: white;
    border-radius: 4px;
    cursor: pointer;
}

.emoji-container {
    position: absolute;
    bottom: 100%;
    right: 0;
    background: white;
    border: 1px solid #ddd;
    border-radius: 4px;
    padding: 0.5rem;
    width: 200px;
    height: 150px;
    overflow-y: auto;
    display: none;
    z-index: 10;
    box-shadow: var(--box-shadow);
}

.emoji-container.show {
    display: block;
}

.emoji-item {
    display: inline-block;
    padding: 0.25rem;
    cursor: pointer;
    font-size: 1.2rem;
}

.emoji-item:hover {
    transform: scale(1.2);
}

footer {
    text-align: center;
    padding: 1rem;
    background-color: var(--dark-color);
    color: white;
    margin-top: 2rem;
}

footer a {
    color: var(--accent-color);
    text-decoration: none;
}

footer a:hover {
    text-decoration: underline;
}

/* لوحة التحكم */
.admin-panel {
    max-width: 1000px;
    margin: 2rem auto;
    padding: 1rem;
}

.template-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 1rem;
    margin-top: 1rem;
}

.template-card {
    border: 1px solid #ddd;
    border-radius: var(--border-radius);
    overflow: hidden;
    box-shadow: var(--box-shadow);
}

.template-card img {
    width: 100%;
    height: 150px;
    object-fit: cover;
}

.template-card .card-body {
    padding: 0.5rem;
}

.template-card .card-actions {
    display: flex;
    justify-content: space-between;
    padding: 0.5rem;
    background-color: #f8f9fa;
}

.template-form {
    margin-top: 2rem;
}

/* صفحة تسجيل الدخول */
/* الصفحة بأكملها */
.login-wrapper {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
    padding: 20px;
    box-sizing: border-box;
    position: relative;
}

/* زر الرجوع */
.back-btn {
    position: absolute;
    top: 20px;
    right: 20px;
    color: #4a6fa5;
    text-decoration: none;
    font-size: 1.1rem;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.3s;
}

.back-btn:hover {
    color: #2c4a7a;
    transform: translateX(-5px);
}

/* بطاقة التسجيل */
.login-card {
    background: white;
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
    width: 100%;
    max-width: 400px;
    padding: 30px;
    text-align: center;
    animation: fadeIn 0.5s ease-out;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

.login-header {
    margin-bottom: 30px;
}

.login-header i {
    font-size: 2.5rem;
    color: #4a6fa5;
    margin-bottom: 15px;
}

.login-header h1 {
    color: #333;
    margin: 0;
    font-size: 1.5rem;
}

/* حقول الإدخال */
.input-group {
    margin-bottom: 20px;
    text-align: right;
}

.input-group label {
    display: block;
    margin-bottom: 8px;
    color: #555;
    font-weight: 600;
}

.input-group input {
    width: 100%;
    padding: 12px 15px;
    border: 2px solid #ddd;
    border-radius: 8px;
    font-size: 1rem;
    transition: border-color 0.3s;
    box-sizing: border-box;
}

.input-group input:focus {
    border-color: #4a6fa5;
    outline: none;
}

/* زر الدخول */
.login-btn {
    width: 100%;
    padding: 12px;
    background: #4a6fa5;
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    margin-top: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.login-btn:hover {
    background: #3a5a8a;
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(74, 111, 165, 0.3);
}

/* رسائل الخطأ */
.error-msg {
    color: #e74c3c;
    margin-top: 15px;
    font-size: 0.9rem;
    min-height: 20px;
    text-align: center;
}

/* للجوالات */
@media (max-width: 480px) {
    .login-card {
        padding: 20px;
    }
    
    .login-header i {
        font-size: 2rem;
    }
    
    .login-header h1 {
        font-size: 1.3rem;
    }
    
    .back-btn {
        top: 15px;
        right: 15px;
        font-size: 1rem;
    }
}

/* تأثير اهتزاز عند الخطأ */
.shake {
    animation: shake 0.5s;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    10%, 30%, 50%, 70%, 90% { transform: translateX(-5px); }
    20%, 40%, 60%, 80% { transform: translateX(5px); }
}
/* وسائط متجاوبة */
@media (max-width: 768px) {
    main {
        flex-direction: column;
        padding: 1rem;
    }
    
    .controls-container, .preview-container {
        width: 100%;
    }
    
    .download-options {
        flex-direction: column;
    }
    
    .download-options button {
        width: 100%;
    }
}


/* تحسينات لزر التحميل */
#generate-btn .fa-spinner {
    margin-left: 8px;
}

/* تحسينات لخيارات التحميل */
.download-options {
    display: none;
    flex-wrap: wrap;
    justify-content: center;
    gap: 1rem;
    margin-top: 1.5rem;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}



#generated-image {
    max-width: 100%;
    height: auto;
    display: block;
    margin: 0 auto;
}

/* تحسينات للعرض على الأجهزة المحمولة */
@media (max-width: 768px) {
    .preview-area {
        min-height: 200px;
        max-height: 400px;
    }
}

/* تنسيقات لوحة التحكم */
.template-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 20px;
    margin-top: 20px;
}

.template-card {
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    overflow: hidden;
    transition: transform 0.3s, box-shadow 0.3s;
}

.template-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
}

.template-card img {
    width: 100%;
    height: 180px;
    object-fit: cover;
}

.card-body {
    padding: 15px;
}

.card-body h4 {
    margin: 0;
    color: #333;
}

.card-actions {
    display: flex;
    justify-content: space-between;
    padding: 10px 15px;
    border-top: 1px solid #f0f0f0;
}

/* نموذج الرفع */
.upload-form {
    background: #f9f9f9;
    padding: 20px;
    border-radius: 8px;
    margin-bottom: 30px;
}

.form-group {
    margin-bottom: 15px;
}

/* تنسيقات الخطوط والإيموجي الجديدة */
.font-properties {
    margin-top: 15px;
}

.font-options {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
    margin-top: 8px;
}

.font-options label {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 0.9rem;
}

.emoji-categories {
    display: flex;
    gap: 5px;
    margin-bottom: 10px;
    flex-wrap: wrap;
}

.emoji-category-btn {
    padding: 5px 10px;
    border: 1px solid #ddd;
    background: white;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.8rem;
}

.emoji-category-btn.active {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

.emoji-grid {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 5px;
    max-height: 200px;
    overflow-y: auto;
    padding: 5px;
}

.emoji-item {
    font-size: 1.5rem;
    cursor: pointer;
    text-align: center;
    transition: transform 0.2s;
}

.emoji-item:hover {
    transform: scale(1.2);
}

/* تنسيقات إدارة الخطوط في لوحة التحكم */
.font-management {
    margin-top: 30px;
    padding: 20px;
    background: #f9f9f9;
    border-radius: var(--border-radius);
}



.emoji-container {
    position: absolute;
    bottom: 100%;
    right: 0;
    background: white;
    border: 1px solid #ddd;
    border-radius: 8px;
    padding: 0.5rem;
    width: 250px;
    height: 200px;
    overflow-y: auto;
    display: none;
    z-index: 1000;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
}

.emoji-container.show {
    display: block;
    animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.emoji-categories {
    display: flex;
    gap: 5px;
    margin-bottom: 10px;
    padding-bottom: 5px;
    border-bottom: 1px solid #eee;
}

.emoji-category-btn {
    padding: 5px 10px;
    border: none;
    background: #f0f0f0;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.8rem;
    transition: all 0.2s;
}

.emoji-category-btn.active {
    background: var(--primary-color);
    color: white;
}

.emoji-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(30px, 1fr));
    gap: 5px;
    max-height: 150px;
    overflow-y: auto;
    padding: 5px;
}

.emoji-item {
    font-size: 1.5rem;
    cursor: pointer;
    text-align: center;
    transition: transform 0.2s;
    padding: 5px;
    border-radius: 4px;
}

.emoji-item:hover {
    transform: scale(1.3);
    background: #f0f0f0;
}

.loading-emoji {
    text-align: center;
    padding: 10px;
    color: #666;
}

/* أنماط إدارة الخطوط */
.font-management {
    margin-top: 2rem;
    padding: 1.5rem;
    background: #f9f9f9;
    border-radius: var(--border-radius);
    border: 1px solid #eee;
}

.font-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 1rem;
    margin-top: 1rem;
}

.font-card {
    border: 1px solid #ddd;
    border-radius: var(--border-radius);
    padding: 1rem;
    display: flex;
    flex-direction: column;
    background: white;
}

.font-preview {
    font-size: 1.2rem;
    margin-bottom: 0.5rem;
    padding: 0.5rem;
    border-bottom: 1px solid #eee;
    text-align: center;
}

.font-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
}

.font-type {
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-size: 0.8rem;
}

.font-type.arabic {
    background: #e3f2fd;
    color: #0d47a1;
}

.font-type.english {
    background: #e8f5e9;
    color: #2e7d32;
}

.font-download {
    color: var(--primary-color);
    text-decoration: none;
}

.font-actions {
    display: flex;
    justify-content: flex-end;
}

.delete-font-btn {
    padding: 0.25rem 0.5rem;
    font-size: 0.8rem;
}

.text-muted {
    color: #666;
    font-size: 0.8rem;
    display: block;
    margin-top: 0.25rem;
}

/* أنماط الخطوط */
.font-management {
    margin-top: 2rem;
    padding: 1.5rem;
    background: #f9f9f9;
    border-radius: 8px;
    border: 1px solid #eee;
}

.font-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 1rem;
    margin-top: 1rem;
}

.font-card {
    border: 1px solid #ddd;
    border-radius: 8px;
    padding: 1rem;
    background: white;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.font-preview {
    font-size: 1.2rem;
    padding: 0.5rem;
    margin-bottom: 0.5rem;
    border-bottom: 1px solid #eee;
    text-align: center;
    min-height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.font-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
}

.font-type {
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-size: 0.8rem;
}

.font-type.arabic {
    background: #e3f2fd;
    color: #0d47a1;
}

.font-type.english {
    background: #e8f5e9;
    color: #2e7d32;
}

.font-download {
    color: #4a6fa5;
    font-size: 0.9rem;
}

.font-actions {
    display: flex;
    justify-content: flex-end;
}

.delete-font-btn {
    padding: 0.25rem 0.5rem;
    font-size: 0.8rem;
}

.text-muted {
    color: #666;
    font-size: 0.8rem;
    margin-top: 0.25rem;
}

/* تحسينات جدول الإيموجي */
.emoji-container {
    position: absolute;
    bottom: 100%;
    right: 0;
    background: white;
    border: 1px solid #ddd;
    border-radius: 8px;
    width: 250px;
    height: 200px;
    display: none;
    z-index: 1000;
    box-shadow: 0 5px 15px rgba(0,0,0,0.1);
}

.emoji-container.show {
    display: flex;
    flex-direction: column;
}

.emoji-categories {
    display: flex;
    gap: 5px;
    padding: 10px;
    border-bottom: 1px solid #eee;
    background: #f5f5f5;
    border-radius: 8px 8px 0 0;
}

.emoji-category-btn {
    padding: 5px 10px;
    border: none;
    background: none;
    cursor: pointer;
    font-size: 0.8rem;
    border-radius: 4px;
}

.emoji-category-btn.active {
    background: #4a6fa5;
    color: white;
}

.emoji-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(30px, 1fr));
    gap: 5px;
    padding: 10px;
    overflow-y: auto;
    flex-grow: 1;
}

.emoji-item {
    font-size: 1.5rem;
    cursor: pointer;
    text-align: center;
    padding: 5px;
    border-radius: 4px;
    transition: all 0.2s;
}

.emoji-item:hover {
    background: #f0f0f0;
    transform: scale(1.2);
}
#color-picker{
    height: 40px;
    width: 15%;
}
/* باقي الأنماط تبقى كما هي */