/* ─── واجهة التقديم - تصميم عصري ومميز (متناسق مع صفحة الوظائف) ─── */
:root {
  --primary: #0ea5e9;
  --primary-dark: #0284c7;
  --primary-darker: #0369a1;
  --primary-light: #e0f2fe;
  --primary-soft: rgba(14, 165, 233, 0.08);
  --border: #e2e8f0;
  --bg: #f8fafc;
  --white: #fff;
  --text: #0f172a;
  --text-muted: #64748b;
  --shadow: 0 4px 20px rgba(14, 165, 233, 0.08);
  --shadow-md: 0 10px 40px -10px rgba(14, 165, 233, 0.12);
  --radius: 16px;
  --radius-sm: 10px;
  --radius-xl: 24px;
  --error: #dc2626;
  --error-bg: #fef2f2;
}

* { box-sizing: border-box; }

.careers-form-page {
  font-family: 'Tajawal', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  margin: 0;
  padding: 0;
  min-height: 100vh;
  font-size: 15px;
  -webkit-text-size-adjust: 100%;
  overflow-x: hidden;
}

/* هيرو صفحة التقديم */
.form-page-hero {
  position: relative;
  background: linear-gradient(135deg, #0c4a6e 0%, #0369a1 40%, #0ea5e9 100%);
  color: var(--white);
  padding: 2.5rem 1.5rem 3rem;
  overflow: hidden;
}

.form-page-hero-bg {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: url("data:image/svg+xml,%3Csvg width='40' height='40' viewBox='0 0 40 40' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='%23ffffff' fill-opacity='0.04' fill-rule='evenodd'%3E%3Cpath d='M0 40L40 0H20L0 20M40 20V40H20'/%3E%3C/g%3E%3C/svg%3E");
  pointer-events: none;
}

.form-page-hero-content {
  position: relative;
  z-index: 1;
  max-width: 720px;
  margin: 0 auto;
}

.form-page-hero .back-to-jobs {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 1.25rem;
  padding: 0.5rem 0;
  color: rgba(255,255,255,0.9);
  text-decoration: none;
  font-weight: 600;
  font-size: 0.95rem;
  transition: color 0.2s, opacity 0.2s;
}

.form-page-hero .back-to-jobs:hover {
  color: var(--white);
  opacity: 1;
}

.form-page-hero-badge {
  display: inline-block;
  background: rgba(255,255,255,0.2);
  padding: 0.35rem 0.9rem;
  border-radius: 100px;
  font-size: 0.85rem;
  font-weight: 700;
  margin-bottom: 1rem;
  border: 1px solid rgba(255,255,255,0.25);
}

.form-page-hero-title {
  font-size: 1.75rem;
  font-weight: 800;
  margin: 0 0 0.5rem 0;
  line-height: 1.35;
  letter-spacing: -0.02em;
}

.form-page-hero-desc {
  margin: 0;
  font-size: 1rem;
  opacity: 0.95;
  line-height: 1.6;
}

/* منطقة النموذج */
.form-page-wrap {
  width: 100%;
  max-width: min(760px, 100vw);
  margin: -1.5rem auto 0;
  padding: 0 clamp(0.75rem, 4vw, 1.25rem) 3rem;
  position: relative;
  z-index: 2;
  box-sizing: border-box;
}

.form-page-container {
  position: relative;
}

.form-errors-box {
  display: flex;
  align-items: flex-start;
  gap: 1rem;
  background: var(--error-bg);
  border: 1px solid #fecaca;
  border-radius: var(--radius-sm);
  padding: 1.25rem 1.5rem;
  margin-bottom: 1.5rem;
  color: #b91c1c;
  font-weight: 500;
}

.form-errors-box i {
  font-size: 1.5rem;
  flex-shrink: 0;
  margin-top: 0.1rem;
}

.form-errors-box ul {
  margin: 0.5rem 0 0 0;
  padding-right: 1.25rem;
}

.form-errors-box li { margin: 0.35rem 0; }

/* بطاقة النموذج */
.form-container-wrapper {
  padding: 0;
  max-width: none;
}

.form-container-modern {
  background: var(--white);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-md);
  padding: 2rem 2rem 2.5rem;
  border: 1px solid rgba(14, 165, 233, 0.08);
  max-width: 100%;
  box-sizing: border-box;
}

.form-container-modern h1 {
  display: none; /* العنوان الآن في الهيرو */
}

/* شريط التقدم العصري */
.progress-modern {
  margin: 0 0 2rem 0;
  padding: 1.25rem 1.5rem;
  background: var(--primary-soft);
  border-radius: var(--radius);
  border: 1px solid rgba(14, 165, 233, 0.12);
}

.step-counter {
  font-weight: 700;
  color: var(--primary-darker);
  margin: 0 0 0.75rem 0;
  font-size: 1.05rem;
}

.progress-bar-wrap {
  height: 10px;
  background: rgba(14, 165, 233, 0.15);
  border-radius: 100px;
  overflow: hidden;
  margin-bottom: 1.25rem;
}

.progress-container .progress-bar {
  height: 100%;
  width: 0;
  min-width: 0;
  transition: width 0.4s cubic-bezier(0.23, 1, 0.32, 1);
  border-radius: 100px;
  direction: ltr;
  background: linear-gradient(90deg, var(--primary), var(--primary-dark));
}

.progress-steps {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.progress-steps .step {
  font-size: 0.8rem;
  padding: 0.45rem 0.85rem;
  border-radius: 100px;
  background: var(--white);
  color: var(--text-muted);
  border: 1px solid var(--border);
  transition: all 0.25s ease;
  font-weight: 500;
}

.progress-steps .step.active {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: var(--white);
  border-color: transparent;
  font-weight: 600;
}

/* على الجوال: تقليل مساحة الخطوات */
@media (max-width: 768px) {
  .progress-modern {
    padding: 0.85rem 1rem;
    margin-bottom: 1.25rem;
  }
  .step-counter {
    font-size: 0.95rem;
    margin-bottom: 0.5rem;
  }
  .progress-bar-wrap {
    height: 8px;
    margin-bottom: 0.6rem;
  }
  .progress-steps {
    display: flex;
    flex-wrap: nowrap;
    gap: 0.35rem;
    overflow-x: auto;
    padding-bottom: 0.25rem;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  .progress-steps::-webkit-scrollbar {
    display: none;
  }
  .progress-steps .step {
    flex: 0 0 auto;
    font-size: 0.7rem;
    padding: 0.35rem 0.55rem;
    white-space: nowrap;
    max-width: 6.5em;
    overflow: hidden;
    text-overflow: ellipsis;
  }
}

/* الحقول والأقسام */
.form-container .container { padding: 0; max-width: none; }

fieldset {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.75rem 2rem;
  margin-bottom: 1.5rem;
  background: #fafbfc;
  transition: border-color 0.2s, box-shadow 0.2s;
}

fieldset:focus-within {
  border-color: rgba(14, 165, 233, 0.3);
  box-shadow: 0 0 0 3px var(--primary-soft);
}

legend {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--primary-darker);
  padding: 0 0.75rem;
  margin-bottom: 0.5rem;
}

label {
  display: block;
  font-weight: 600;
  color: var(--text);
  margin-top: 1rem;
  margin-bottom: 0.4rem;
  font-size: 0.95rem;
}

label:first-of-type { margin-top: 0; }

input[type="tel"],
input[type="text"],
input[type="number"],
input[type="email"],
input[type="date"] {
  width: 100%;
  padding: 0.8rem 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 1rem;
  font-family: inherit;
  transition: border-color 0.2s, box-shadow 0.2s;
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft);
}

select {
  width: 100%;
  padding: 0.8rem 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 1rem;
  font-family: inherit;
  background: var(--white);
}

textarea {
  width: 100%;
  padding: 0.8rem 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 1rem;
  font-family: inherit;
  min-height: 110px;
  resize: vertical;
}

.error-field {
  border: 2px solid var(--error) !important;
  background-color: var(--error-bg) !important;
}

.error {
  color: var(--error);
  font-size: 0.85rem;
  margin-top: 0.35rem;
  display: none;
  font-weight: 500;
}

/* أزرار الخطوات */
.step-navigation {
  text-align: center;
  margin-top: 1.75rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 1rem;
  justify-content: center;
  flex-wrap: wrap;
}

button, .btn-next, .btn-prev {
  cursor: pointer;
  padding: 0.8rem 1.6rem;
  min-height: 48px;
  border-radius: var(--radius-sm);
  border: none;
  font-size: 1rem;
  font-weight: 600;
  font-family: inherit;
  transition: all 0.25s ease;
}

button, .btn-next {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: var(--white);
  box-shadow: 0 4px 14px rgba(14, 165, 233, 0.3);
}

button:hover, .btn-next:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(14, 165, 233, 0.35);
}

.btn-prev {
  background: #f1f5f9;
  color: var(--text);
}

.btn-prev:hover {
  background: #e2e8f0;
  transform: translateY(-1px);
}

/* رفع الملفات */
.file-upload {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.file-input { display: none; }

.file-btn {
  background: var(--primary);
  color: var(--white);
  border: none;
  padding: 0.55rem 1.1rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 0.95rem;
  font-weight: 600;
  transition: background 0.2s, transform 0.2s;
}

.file-btn:hover {
  background: var(--primary-dark);
  transform: translateY(-1px);
}

.file-name {
  font-size: 0.9rem;
  color: var(--text-muted);
  max-width: min(180px, 100%);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.add-row-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  margin-top: 0.75rem;
  padding: 0.65rem 1rem;
  width: 100%;
  max-width: 100%;
  border: 2px dashed rgba(14, 165, 233, 0.45);
  border-radius: var(--radius-sm);
  background: var(--primary-soft);
  color: var(--primary-darker);
  font-weight: 700;
  font-family: inherit;
  font-size: 0.95rem;
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s;
}

.add-row-btn:hover {
  background: rgba(14, 165, 233, 0.15);
  border-color: var(--primary);
}

.form-container .form-group {
  margin-top: 1rem;
}

.form-container .form-group:first-child {
  margin-top: 0;
}

.remove-btn {
  background: #dc2626;
  color: var(--white);
  border: none;
  padding: 0.35rem 0.75rem;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.85rem;
}

.remove-btn:hover { background: #b91c1c; }

/* الجداول داخل النموذج */
.form-container table {
  width: 100%;
  max-width: 100%;
  border-collapse: collapse;
  margin: 0.5rem 0 1rem 0;
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.form-container th,
.form-container td {
  border: 1px solid var(--border);
  padding: 0.55rem 0.75rem;
  text-align: right;
}

.form-container th {
  background: #f8fafc;
  font-weight: 600;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.form-container .optional-note,
.form-container th .optional-note {
  color: var(--text-muted);
  font-size: 0.8rem;
  font-style: italic;
  margin-top: 0.2rem;
  font-weight: 400;
}

.careers-form-page .success {
  background: #ecfdf5;
  border: 1px solid #a7f3d0;
  color: #065f46;
  padding: 1rem 1.25rem;
  border-radius: var(--radius-sm);
  margin-bottom: 1.5rem;
  font-weight: 500;
}

/* نافذة منبثقة */
.popup {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
}

.popup-content {
  background: var(--white);
  padding: 1.5rem 2rem;
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  max-width: 90%;
}

@media (max-width: 768px) {
  .form-page-hero {
    padding: 1.75rem clamp(0.65rem, 3vw, 1rem) 2.25rem;
  }
  .form-page-hero-title {
    font-size: clamp(1.2rem, 5vw, 1.4rem);
    word-break: break-word;
  }
  .form-page-wrap {
    margin-top: -1rem;
    padding: 0 clamp(0.65rem, 3vw, 1rem) 2rem;
  }
  .form-container-modern {
    padding: 1.25rem clamp(0.65rem, 3vw, 1rem) 2rem;
    border-radius: var(--radius);
  }
  fieldset {
    padding: 1rem clamp(0.65rem, 3vw, 1rem);
    margin-bottom: 1.25rem;
  }
  legend {
    font-size: 1rem;
  }
  /* لا نستخدم عموداً للخطوات هنا — يبقى السلوك من القسم أعلاه (تمرير أفقي) */
  .step-navigation {
    flex-direction: column;
    gap: 0.75rem;
  }
  .step-navigation button,
  .btn-next,
  .btn-prev {
    width: 100%;
    max-width: 100%;
    touch-action: manipulation;
  }
  /* جداول متعددة الأعمدة → بطاقات عمودية (يستخدم data-label على الخلايا) */
  .form-container table thead {
    display: none;
  }
  .form-container table,
  .form-container tbody,
  .form-container table tbody tr {
    display: block;
    width: 100%;
  }
  .form-container table tbody tr {
    margin-bottom: 1rem;
    padding: 0;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--white);
    box-shadow: 0 1px 3px rgba(15, 23, 42, 0.06);
  }
  .form-container table tbody td {
    display: block;
    width: 100%;
    box-sizing: border-box;
    border: none;
    border-bottom: 1px solid var(--border);
    padding: 0.65rem 0.85rem;
    text-align: right;
  }
  .form-container table tbody td:last-child {
    border-bottom: none;
  }
  .form-container table tbody td[data-label]::before {
    content: attr(data-label);
    display: block;
    font-weight: 700;
    font-size: 0.82rem;
    color: var(--primary-darker);
    margin-bottom: 0.45rem;
    line-height: 1.3;
  }
  .form-container table tbody td input[type="text"],
  .form-container table tbody td input[type="number"],
  .form-container table tbody td input[type="tel"],
  .form-container table tbody td input[type="email"],
  .form-container table tbody td select,
  .form-container table tbody td textarea {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    box-sizing: border-box;
  }
  .form-container .file-upload {
    flex-direction: column;
    align-items: stretch;
    gap: 0.5rem;
  }
  .form-container .file-name {
    max-width: 100%;
    white-space: normal;
    word-break: break-word;
  }
  .form-container table tbody td .removeBtn {
    width: 100%;
    min-height: 44px;
    font-size: 1rem;
    border-radius: var(--radius-sm);
  }
  .add-row-btn {
    margin-top: 0.5rem;
    min-height: 48px;
    touch-action: manipulation;
  }
  /* يقلل تكبير Safari عند التركيز على الحقول */
  input[type="text"],
  input[type="tel"],
  input[type="email"],
  input[type="number"],
  input[type="date"],
  select,
  textarea {
    font-size: 16px;
  }
}

@media (max-width: 380px) {
  .progress-steps .step {
    max-width: none;
    font-size: 0.72rem;
  }
}
