/* ===============================
   تنسيق الأساسيات والخلفية
   =============================== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Noto Sans Arabic', 'Arial', sans-serif;
    background: linear-gradient(135deg, #1a1a1a 0%, #2d2d2d 100%);
    color: #fff;
    line-height: 1.6;
    direction: rtl;
}

.container {
    max-width: 900px;
    margin: 0 auto;
    padding: 20px;
}

/* ===============================
   تنسيق الرأس والشعار
   =============================== */
.header {
    text-align: center;
    margin-bottom: 30px;
    padding: 30px;
    background: linear-gradient(45deg, #e53e3e, #c53030);
    border-radius: 15px;
    box-shadow: 0 10px 30px rgba(229, 62, 62, 0.3);
}

.logo {
    width: 120px;
    height: 120px;
    margin: 0 auto 20px;
    background: #fff;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 48px;
    font-weight: bold;
    color: #e53e3e;
}

h1 {
    font-size: 2.5rem;
    margin-bottom: 10px;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.3);
}

.intro-text {
    background: rgba(255,255,255,0.1);
    padding: 20px;
    border-radius: 10px;
    margin-bottom: 20px;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255,255,255,0.2);
}

.show-full-text {
    background: #e53e3e;
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 25px;
    cursor: pointer;
    font-size: 14px;
    margin-top: 10px;
    transition: all 0.3s;
}

.show-full-text:hover {
    background: #c53030;
    transform: translateY(-2px);
}

/* ===============================
   تنسيق حاوي النموذج
   =============================== */
.form-container {
    background: rgba(255,255,255,0.05);
    border-radius: 20px;
    padding: 40px;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255,255,255,0.1);
    box-shadow: 0 20px 40px rgba(0,0,0,0.3);
}

/* ===============================
   تنسيق الخطوات والانتقالات
   =============================== */
.step {
    display: none;
    animation: fadeIn 0.5s ease-in;
}

.step.active {
    display: block;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

.step-header {
    text-align: center;
    margin-bottom: 30px;
    padding-bottom: 20px;
    border-bottom: 2px solid #e53e3e;
}

.step-title {
    font-size: 2rem;
    color: #e53e3e;
    margin-bottom: 10px;
}

/* ===============================
   شريط التقدم
   =============================== */
.progress-bar {
    width: 100%;
    height: 8px;
    background: rgba(255,255,255,0.1);
    border-radius: 4px;
    margin: 20px 0;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #e53e3e, #ff6b6b);
    transition: width 0.5s ease;
    border-radius: 4px;
}

/* ===============================
   تنسيق النموذج والحقول
   =============================== */
.form-group {
    margin-bottom: 25px;
}

.form-row {
    display: flex;
    gap: 20px;
    flex-wrap: wrap;
}

.form-row .form-group {
    flex: 1;
    min-width: 250px;
}

label {
    display: block;
    margin-bottom: 8px;
    font-weight: bold;
    color: #fff;
}

.required {
    color: #e53e3e;
}

input, select, textarea {
    width: 100%;
    padding: 12px 15px;
    border: 2px solid rgba(255,255,255,0.2);
    border-radius: 10px;
    background: rgba(255,255,255,0.1);
    color: #fff;
    font-size: 16px;
    font-family: 'Noto Sans Arabic', Arial, sans-serif;
    transition: all 0.3s;
}

/* ===============================
   تنسيق القوائم المنسدلة
   =============================== */
select {
    appearance: none;
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6,9 12,15 18,9'%3e%3c/polyline%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: left 12px center;
    background-size: 16px;
    padding-left: 40px;
}

select option {
    background: #2d2d2d;
    color: #fff;
    padding: 10px;
}

/* ===============================
   تأثيرات التركيز والحالات
   =============================== */
input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: #e53e3e;
    background: rgba(255,255,255,0.15);
    box-shadow: 0 0 20px rgba(229, 62, 62, 0.3);
}

input::placeholder, textarea::placeholder {
    color: rgba(255,255,255,0.6);
}

/* ===============================
   تنسيق رفع الملفات (مُصحح)
   =============================== */
.file-upload {
    position: relative;
    display: block;
    width: 100%;
    overflow: hidden;
}

.file-upload input[type=file] {
    position: absolute;
    left: -9999px;
    opacity: 0;
    pointer-events: none;
    width: 1px;
    height: 1px;
    visibility: hidden;
}

.file-upload-label {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
    border: 2px dashed rgba(255,255,255,0.3);
    border-radius: 10px;
    background: rgba(255,255,255,0.05);
    transition: all 0.3s;
    cursor: pointer;
    min-height: 200px;
    width: 100%;
    box-sizing: border-box;
    position: relative;
    overflow: hidden;
}

.file-upload-label:hover {
    border-color: #e53e3e;
    background: rgba(229, 62, 62, 0.1);
}

.upload-icon {
    font-size: 48px;
    margin-bottom: 15px;
    color: rgba(255,255,255,0.6);
}

.image-preview {
    width: 150px;
    height: 150px;
    border-radius: 50%;
    object-fit: cover;
    border: 3px solid #e53e3e;
    margin-bottom: 15px;
    flex-shrink: 0;
}

.upload-text {
    color: rgba(255,255,255,0.8);
    text-align: center;
    word-wrap: break-word;
    max-width: 100%;
}

.upload-text small {
    display: block;
    margin-top: 5px;
    font-size: 12px;
    opacity: 0.8;
}

/* ===============================
   تنسيق الأزرار الراديو
   =============================== */
.radio-group {
    display: flex;
    gap: 20px;
    flex-wrap: wrap;
}

.radio-item {
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    padding: 12px 20px;
    border-radius: 10px;
    background: rgba(255,255,255,0.05);
    border: 2px solid rgba(255,255,255,0.2);
    transition: all 0.3s;
    min-width: 120px;
    justify-content: center;
}

.radio-item:hover {
    background: rgba(255,255,255,0.1);
    border-color: rgba(255,255,255,0.4);
}

.radio-item.selected {
    background: rgba(229, 62, 62, 0.2);
    border-color: #e53e3e;
    color: #fff;
}

.radio-item input[type="radio"] {
    width: 20px;
    height: 20px;
    margin: 0;
    appearance: none;
    border: 2px solid rgba(255,255,255,0.5);
    border-radius: 50%;
    background: transparent;
    position: relative;
    cursor: pointer;
}

.radio-item input[type="radio"]:checked {
    border-color: #e53e3e;
    background: #e53e3e;
}

.radio-item input[type="radio"]:checked::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 8px;
    height: 8px;
    background: white;
    border-radius: 50%;
}

.radio-item label {
    margin: 0;
    cursor: pointer;
    font-weight: 500;
}

/* ===============================
   تنسيق الأزرار
   =============================== */
.btn-group {
    display: flex;
    justify-content: space-between;
    margin-top: 40px;
    gap: 20px;
}

.btn {
    padding: 15px 30px;
    border: none;
    border-radius: 25px;
    font-size: 16px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.btn-prev {
    background: rgba(255,255,255,0.2);
    color: #fff;
}

.btn-prev:hover {
    background: rgba(255,255,255,0.3);
    transform: translateY(-2px);
}

.btn-next, .btn-submit {
    background: linear-gradient(45deg, #e53e3e, #ff6b6b);
    color: white;
    box-shadow: 0 5px 15px rgba(229, 62, 62, 0.4);
}

.btn-next:hover, .btn-submit:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(229, 62, 62, 0.6);
}

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none !important;
}

/* ===============================
   تنسيق لوحة التوقيع (محسن)
   =============================== */
.signature-container {
    border: 2px solid rgba(255,255,255,0.2);
    border-radius: 10px;
    background: rgba(255,255,255,0.05);
    padding: 10px;
}

.signature-pad {
    width: 100%;
    border: 1px dashed rgba(255,255,255,0.3);
    border-radius: 8px;
    background: rgba(255,255,255,0.1);
    cursor: crosshair;
    display: block;
    touch-action: none;
}

.signature-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 10px;
    gap: 10px;
}

.btn-clear {
    background: #666;
    color: white;
    padding: 8px 16px;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    transition: all 0.3s;
}

.btn-clear:hover {
    background: #555;
}

.signature-hint {
    font-size: 14px;
    color: rgba(255,255,255,0.6);
    font-style: italic;
}

/* ===============================
   تنسيق النافذة المنبثقة
   =============================== */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.8);
    backdrop-filter: blur(10px);
}

.modal-content {
    background: linear-gradient(135deg, #1a1a1a, #2d2d2d);
    margin: 5% auto;
    padding: 30px;
    border-radius: 20px;
    width: 90%;
    max-width: 800px;
    max-height: 80vh;
    overflow-y: auto;
    border: 1px solid rgba(255,255,255,0.2);
}

.close {
    color: #aaa;
    float: left;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    transition: color 0.3s;
}

.close:hover {
    color: #e53e3e;
}

/* ===============================
   رسالة النجاح
   =============================== */
.success-message {
    text-align: center;
    padding: 40px;
    background: linear-gradient(45deg, #28a745, #20c997);
    border-radius: 15px;
    margin: 20px 0;
    box-shadow: 0 10px 30px rgba(40, 167, 69, 0.3);
}

.success-message h2 {
    margin-bottom: 20px;
    font-size: 2rem;
}

.success-message p {
    margin-bottom: 15px;
    font-size: 1.1rem;
    line-height: 1.8;
}

/* ===============================
   تصميم متجاوب للشاشات الصغيرة
   =============================== */
@media (max-width: 768px) {
    .container {
        padding: 10px;
    }
    
    .form-container {
        padding: 20px;
    }
    
    .form-row {
        flex-direction: column;
    }
    
    .radio-group {
        flex-direction: column;
    }
    
    .btn-group {
        flex-direction: column;
    }
    
    h1 {
        font-size: 2rem;
    }
    
    .step-title {
        font-size: 1.5rem;
    }
    
    .logo {
        width: 100px;
        height: 100px;
        font-size: 36px;
    }
    
    .signature-pad {
        width: 100%;
        height: 150px;
    }
    
    .signature-controls {
        flex-direction: column;
        align-items: center;
        text-align: center;
    }
}

@media (max-width: 480px) {
    .header {
        padding: 20px;
    }
    
    .form-container {
        padding: 15px;
    }
    
    .btn {
        padding: 12px 20px;
        font-size: 14px;
    }
    
    .file-upload-label {
        padding: 20px;
        min-height: 150px;
    }
    
    .upload-icon {
        font-size: 36px;
    }
    
    .image-preview {
        width: 100px;
        height: 100px;
    }
}

/* ===============================
   تحسينات إضافية للتفاعل
   =============================== */
.form-group input:invalid {
    border-color: rgba(255, 82, 82, 0.5);
}

.form-group input:valid {
    border-color: rgba(76, 175, 80, 0.5);
}

.btn-submit.loading {
    position: relative;
    color: transparent;
}

.btn-submit.loading::after {
    content: '';
    position: absolute;
    width: 16px;
    height: 16px;
    top: 50%;
    left: 50%;
    margin-left: -8px;
    margin-top: -8px;
    border: 2px solid transparent;
    border-top-color: #ffffff;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* ===============================
   تحسينات للوحة التوقيع
   =============================== */
.signature-pad:focus {
    outline: 2px solid #e53e3e;
    outline-offset: 2px;
}

.signature-container.has-signature .signature-pad {
    border-color: rgba(76, 175, 80, 0.5);
    background: rgba(76, 175, 80, 0.05);
}

/* ===============================
   تأثيرات التحميل والانتظار
   =============================== */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9999;
}

.loading-spinner {
    width: 50px;
    height: 50px;
    border: 5px solid rgba(255, 255, 255, 0.3);
    border-top: 5px solid #e53e3e;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

/* ===============================
   تحسينات إمكانية الوصول
   =============================== */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* تحسين التباين للنصوص المهمة */
.required,
.error-message {
    color: #ff6b6b;
    font-weight: bold;
}

.success-indicator {
    color: #4CAF50;
    font-weight: bold;
}

/* تحسين تجربة لوحة المفاتيح */
.btn:focus,
input:focus,
select:focus,
textarea:focus {
    outline: 2px solid #e53e3e;
    outline-offset: 2px;
}

.radio-item:focus-within {
    outline: 2px solid #e53e3e;
    outline-offset: 2px;
}