/* Scope to avoid conflicts but use Theme Variables */
.crm-public.crm-inbox .crm-form {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 20px; /* زيادة المسافة لتناسب الثيم */
}

/* في الشاشات الصغيرة، اجعل الحقول فوق بعضها */
@media (max-width: 600px) {
    .crm-public.crm-inbox .crm-form {
        grid-template-columns: 1fr;
    }
}

.crm-public.crm-inbox .crm-field {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* جعل بعض الحقول تأخذ العرض الكامل */
.crm-public.crm-inbox .crm-field--full {
  grid-column: 1 / -1;
}

/* تنسيق التسميات (Labels) */
.crm-public.crm-inbox label {
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--text); /* استخدام متغير النص من الثيم */
  margin: 0;
}

/* تنسيق الحقول (Inputs & Textarea) */
.crm-public.crm-inbox .crm-input,
.crm-public.crm-inbox textarea {
  width: 100%;
  padding: 12px 15px;
  border-radius: 12px; /* نفس انحناء الثيم */
  font-size: 1rem;
  
  /* الألوان من متغيرات الثيم */
  background: var(--surface); 
  color: var(--text);
  border: 1px solid color-mix(in oklab, var(--text), transparent 90%);
  
  transition: all 0.2s ease;
  outline: none;
}

/* تأثير التركيز (Focus) */
.crm-public.crm-inbox .crm-input:focus,
.crm-public.crm-inbox textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--ring); /* حلقة التوهج من الثيم */
}

.crm-public.crm-inbox textarea { 
    resize: vertical; 
    min-height: 120px;
}

/* تنسيق زر الإرسال */
.crm-public.crm-inbox .crm-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.8rem 1.5rem;
  border-radius: 14px;
  font-weight: 700;
  cursor: pointer;
  border: none;
  transition: 0.2s ease;
  
  /* ألوان الثيم */
  background: var(--primary);
  color: #fff; /* النص أبيض دائماً على اللون الأساسي */
  box-shadow: 0 4px 15px color-mix(in oklab, var(--primary), transparent 70%);
}

.crm-public.crm-inbox .crm-button:hover {
  background: var(--primary-600);
  transform: translateY(-2px);
}

.crm-public.crm-inbox .crm-button:disabled {
  opacity: 0.7;
  cursor: not-allowed;
  transform: none;
}

/* منطقة الإجراءات والحالة */
.crm-public.crm-inbox .crm-actions {
  display: flex;
  align-items: center;
  gap: 15px;
  margin-top: 10px;
}

.crm-public.crm-inbox .crm-form-status {
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--muted);
}

/* شريط التقدم (Progress Bar) */
.crm-public.crm-inbox .crm-form-progress {
  margin-top: 15px;
  max-width: 100%;
}

.crm-public.crm-inbox .crm-form-progress-bar {
  position: relative;
  width: 100%;
  height: 6px;
  border-radius: 999px;
  background: var(--surface); /* خلفية الشريط */
  overflow: hidden;
  margin-bottom: 5px;
}

.crm-public.crm-inbox .crm-form-progress-fill {
  position: absolute;
  top: 0;
  left: 0;
  height: 100%;
  width: 0;
  background: var(--accent); /* اللون المميز للتقدم */
  transition: width 0.16s linear;
}

.crm-public.crm-inbox .crm-form-progress-text {
  font-size: 0.85rem;
  color: var(--muted);
  text-align: right;
}

/* رسالة النجاح */
.crm-public.crm-inbox .crm-inbox-success {
  margin-top: 30px;
  animation: fadeIn 0.5s ease;
}

.crm-public.crm-inbox .crm-inbox-success-card {
  padding: 40px;
  border-radius: var(--radius);
  background: var(--card); /* لون الكارت من الثيم */
  border: 1px solid color-mix(in oklab, var(--text), transparent 90%);
  box-shadow: var(--shadow);
  text-align: center;
}

.crm-public.crm-inbox .crm-inbox-success-card h3 {
  margin: 0 0 10px;
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--primary);
}

.crm-public.crm-inbox .crm-inbox-success-card p {
  margin: 0;
  font-size: 1.1rem;
  color: var(--muted);
}

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

/* =========================================
   تنسيق حقل رفع الملفات (File Upload)
   ========================================= */

/* 1. الحاوية الخارجية للحقل */
.crm-public.crm-inbox input[type="file"] {
    background: var(--surface); /* لون خلفية السطح */
    padding: 10px; /* مسافة داخلية مريحة */
    border: 1px dashed color-mix(in oklab, var(--text), transparent 85%); /* حدود متقطعة توحي بمنطقة الرفع */
    border-radius: 12px; /* نفس انحناء باقي الحقول */
    width: 100%;
    color: var(--muted); /* لون نص اسم الملف المختار */
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 0.9rem;
}

/* عند مرور الماوس على المنطقة */
.crm-public.crm-inbox input[type="file"]:hover {
    border-color: var(--primary); /* تلوين الحدود بالأزرق */
    background: color-mix(in oklab, var(--primary), transparent 97%); /* خلفية زرقاء خفيفة جداً */
}

/* 2. تنسيق زر "اختيار ملف" الداخلي */
.crm-public.crm-inbox input[type="file"]::file-selector-button {
    background: var(--card); /* لون زر متباين قليلاً */
    color: var(--text);
    border: 1px solid color-mix(in oklab, var(--text), transparent 90%);
    padding: 6px 14px;
    margin-inline-end: 12px; /* مسافة بين الزر واسم الملف (تدعم العربية تلقائياً) */
    border-radius: 8px;
    font-weight: 600;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: inherit; /* لضمان وراثة خط الموقع */
}

/* عند مرور الماوس على الزر الداخلي */
.crm-public.crm-inbox input[type="file"]:hover::file-selector-button {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
    box-shadow: 0 2px 8px color-mix(in oklab, var(--primary), transparent 70%);
}