/* لغة بصرية مأخوذة من الصفحة المرجعية: أبيض على #f0f4f8، حواف دائرية،
   أزرار على شكل حبّة، كحلي #1e3c5c أساسي، أزرق #3498db للتركيز. */

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

:root {
  --navy: #1e3c5c;
  --blue: #3498db;
  --bg: #f0f4f8;
  --line: #e2e8f0;
  --muted: #64748b;
  --faint: #94a3b8;
  --ok: #16a34a;
  --err: #dc2626;
  --warn: #d97706;
}

body {
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  background: var(--bg);
  color: #0f172a;
  padding: 10px;
  min-height: 100vh;
  line-height: 1.6;
}

.container {
  background: #fff;
  padding: 20px;
  border-radius: 24px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, .08);
  width: 100%;
  max-width: 1000px;
  margin: 10px auto;
}

h1 {
  color: var(--navy);
  text-align: center;
  font-size: 1.6em;
  margin-bottom: 18px;
  display: flex; align-items: center; justify-content: center; gap: 10px;
}

/* ── التنقل ── */

#nav {
  max-width: 1000px;
  margin: 0 auto 10px;
  background: #fff;
  border-radius: 50px;
  padding: 8px 14px;
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px; flex-wrap: wrap;
  box-shadow: 0 4px 16px rgba(0, 0, 0, .06);
}
.nav-links { display: flex; gap: 4px; flex-wrap: wrap; }
.nav-links a {
  padding: 8px 14px; border-radius: 40px; text-decoration: none;
  color: #475569; font-weight: 600; font-size: .9em; white-space: nowrap;
}
.nav-links a:hover { background: #f1f5f9; }
.nav-links a.active { background: var(--navy); color: #fff; }
.nav-user { display: flex; align-items: center; gap: 10px; font-size: .85em; color: var(--muted); }

/* ── تابات ── */

.tabs {
  display: flex; gap: 6px; background: #f1f5f9;
  padding: 6px; border-radius: 50px; margin-bottom: 16px; flex-wrap: wrap;
}
.tab-btn {
  flex: 1; min-width: 80px; padding: 10px 14px; border: none; border-radius: 40px;
  background: transparent; color: #475569; font-weight: 600; font-size: .95em;
  cursor: pointer; transition: all .25s; font-family: inherit;
}
.tab-btn:hover { background: #e2e8f0; }
.tab-btn.active { background: var(--navy); color: #fff; box-shadow: 0 4px 10px rgba(30, 60, 92, .3); }

/* ── البحث ── */

.search-box { position: relative; margin-bottom: 16px; }
.search-icon {
  position: absolute; right: 16px; top: 50%; transform: translateY(-50%);
  color: var(--faint); font-size: 1.1em; pointer-events: none;
}
.search-input {
  width: 100%; padding: 14px 46px; border: 2px solid var(--line);
  border-radius: 50px; font-size: 16px; background: #f8fafc;
  font-family: inherit; transition: all .25s;
}
.search-input:focus {
  border-color: var(--blue); outline: none; background: #fff;
  box-shadow: 0 0 0 3px rgba(52, 152, 219, .12);
}
.clear-btn {
  position: absolute; left: 14px; top: 50%; transform: translateY(-50%);
  background: none; border: none; font-size: 1.1em; color: var(--faint);
  cursor: pointer; display: none;
}
.clear-btn.show { display: block; }

/* ── شريط الإحصائيات ── */

.stats-bar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px; flex-wrap: wrap; padding: 12px 16px;
  background: #f8fafc; border-radius: 12px; margin-bottom: 16px;
  font-size: .9em; color: var(--muted);
}
.stats-bar strong { color: #0f172a; }
.total-badge {
  background: var(--navy); color: #fff; padding: 3px 12px;
  border-radius: 50px; font-weight: 600; font-size: .9em;
}

/* ── الأزرار ── */

.btn {
  padding: 9px 18px; border: none; border-radius: 50px; cursor: pointer;
  font-family: inherit; font-size: .9em; font-weight: 600;
  background: var(--navy); color: #fff; transition: all .2s;
}
.btn:hover { filter: brightness(1.15); }
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-plain { background: #e2e8f0; color: #334155; }
.btn-ok { background: var(--ok); }
.btn-danger { background: var(--err); }
.btn-sm { padding: 6px 13px; font-size: .82em; }
.btn-link {
  background: none; border: none; color: var(--blue);
  cursor: pointer; font-family: inherit; font-size: .85em; text-decoration: underline;
}

/* ── الجداول ── */

.table-container { border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.table-header, .table-row { display: grid; gap: 10px; padding: 12px 14px; align-items: center; }
.table-header {
  background: var(--navy); color: #fff; font-weight: 600; font-size: .88em;
}
.table-row { border-top: 1px solid var(--line); font-size: .92em; background: #fff; }
.table-row:nth-child(even) { background: #fafbfc; }
.table-row:hover { background: #f1f5f9; }
.table-row.dirty { background: #fef9e7; }
.table-row.empty-slot { background: #fef2f2; }

.area-badge {
  background: #e0f2fe; color: #075985; padding: 3px 10px;
  border-radius: 50px; font-size: .85em; white-space: nowrap;
}
.badge { padding: 3px 10px; border-radius: 50px; font-size: .8em; white-space: nowrap; }
.badge-primary { background: #dbeafe; color: #1e40af; }
.badge-volunteer { background: #dcfce7; color: #166534; }
.badge-off { background: #f1f5f9; color: #64748b; }
.badge-warn { background: #fef3c7; color: #92400e; }
.missing { color: var(--err); font-size: .85em; font-weight: 600; }
.muted { color: var(--faint); }
.mono { font-family: 'Consolas', 'Courier New', monospace; font-size: .9em; }

/* ── النماذج ── */

.form-grid { display: grid; gap: 14px; margin-bottom: 16px; }
.field label { display: block; font-size: .85em; color: var(--muted); margin-bottom: 5px; font-weight: 600; }
.field input, .field select, .field textarea {
  width: 100%; padding: 11px 14px; border: 2px solid var(--line);
  border-radius: 12px; font-size: 15px; font-family: inherit; background: #f8fafc;
}
.field input:focus, .field select:focus, .field textarea:focus {
  border-color: var(--blue); outline: none; background: #fff;
}
.field textarea { min-height: 70px; resize: vertical; }
.field .hint { font-size: .78em; color: var(--faint); margin-top: 4px; }
.field .error-text { font-size: .8em; color: var(--err); margin-top: 4px; }
.radio-row { display: flex; gap: 16px; align-items: center; }
.radio-row label { display: flex; align-items: center; gap: 6px; font-weight: normal; margin: 0; }
.radio-row input { width: auto; }

/* ── الحوار (Modal) ── */

.modal-backdrop, .custom-modal-backdrop {
  position: fixed !important; inset: 0 !important; background: rgba(15, 23, 42, 0.55) !important;
  display: none; align-items: flex-start; justify-content: center;
  padding: 20px; overflow-y: auto; z-index: 1055 !important;
  pointer-events: auto !important;
}
.modal-backdrop.show, .custom-modal-backdrop.show { display: flex !important; opacity: 1 !important; }
.modal, .custom-modal {
  background: #fff !important; border-radius: 20px !important; padding: 22px !important;
  width: 100% !important; max-width: 560px !important; margin: auto !important;
  display: block !important; position: relative !important; top: auto !important; left: auto !important;
  height: auto !important; opacity: 1 !important; z-index: 1060 !important;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.2) !important;
}
.modal h2, .custom-modal h2 { font-size: 1.2em; color: var(--navy); margin-bottom: 16px; }
.modal-actions, .custom-modal-actions { display: flex; gap: 10px; justify-content: flex-start; margin-top: 16px; }

/* ── الحالات ── */

.state { text-align: center; padding: 40px 20px; color: var(--muted); }
.state-icon { font-size: 2.5em; display: block; margin-bottom: 10px; }
.state.error { color: var(--err); }
.state .btn { margin-top: 14px; }
.spinner {
  width: 30px; height: 30px; margin: 0 auto 12px;
  border: 3px solid var(--line); border-top-color: var(--navy);
  border-radius: 50%; animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── التنبيهات ── */

.toast {
  position: fixed; bottom: -100px; right: 50%; transform: translateX(50%);
  padding: 13px 24px; border-radius: 50px; color: #fff; font-weight: 600;
  font-size: .9em; z-index: 1100; transition: bottom .3s; max-width: 90vw;
  box-shadow: 0 6px 20px rgba(0, 0, 0, .2);
}
.toast.show { bottom: 24px; }
.toast.ok { background: var(--ok); }
.toast.err { background: var(--err); }
.toast.warn { background: var(--warn); }

.notice {
  padding: 12px 16px; border-radius: 12px; margin-bottom: 14px; font-size: .9em;
}
.notice-info { background: #e0f2fe; color: #075985; }
.notice-warn { background: #fef3c7; color: #92400e; }
.notice-err { background: #fee2e2; color: #991b1b; }

/* ── الموبايل: الأعمدة تتحول لكروت ── */

@media (max-width: 700px) {
  body { padding: 6px; }
  .container { padding: 14px; border-radius: 18px; }
  h1 { font-size: 1.3em; }
  .table-header { display: none; }
  .table-row {
    grid-template-columns: 1fr !important;
    gap: 6px; padding: 14px;
    border-top: 8px solid var(--bg);
  }
  .table-row > * { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
  .table-row > *[data-label]::before {
    content: attr(data-label); color: var(--faint);
    font-size: .8em; font-weight: 600; flex-shrink: 0;
  }
  .nav-links a { font-size: .82em; padding: 7px 11px; }
}

@media print {
  body { background: #fff; padding: 0; }
  #nav, .tabs, .search-box, .btn, .stats-bar .btn { display: none !important; }
  .container { box-shadow: none; max-width: none; }
}

/* ── غطاء التحميل ── */

.app-loading {
  position: fixed; inset: 0; z-index: 2000;
  background: var(--bg);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 4px; color: var(--muted); font-size: .95em;
  transition: opacity .25s;
}
.app-loading .spinner { width: 38px; height: 38px; border-width: 4px; }
.app-loading.hide { opacity: 0; pointer-events: none; }

/* ── تخصيص Tom-Select والقوائم المنسدلة في بيئة RTL ── */

.ts-wrapper {
  width: 100%;
  direction: rtl !important;
  text-align: right !important;
}
.ts-control {
  border-radius: 10px !important;
  border: 1px solid var(--line) !important;
  padding: 7px 12px 7px 2.2rem !important;
  font-size: 0.9em !important;
  background-color: #fff !important;
  background-position: left 0.75rem center !important;
  box-shadow: none !important;
  min-height: 38px !important;
  direction: rtl !important;
  text-align: right !important;
  display: flex !important;
  align-items: center !important;
}
.ts-wrapper.single .ts-control::after {
  left: 12px !important;
  right: auto !important;
}
.ts-control > .item {
  direction: rtl !important;
  text-align: right !important;
  font-weight: 600;
  color: #0f172a;
  white-space: nowrap !important;
  overflow: hidden !important;
  text-overflow: ellipsis !important;
  max-width: 100% !important;
  padding-right: 0 !important;
}
.ts-control > input {
  direction: rtl !important;
  text-align: right !important;
  font-family: inherit !important;
}
.ts-dropdown {
  direction: rtl !important;
  text-align: right !important;
  border-radius: 12px !important;
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.25) !important;
  border: 1px solid var(--line) !important;
  z-index: 99999 !important;
  background: #fff !important;
}
.ts-dropdown .ts-dropdown-content {
  max-height: 280px !important;
  overflow-y: auto !important;
}
.ts-dropdown .dropdown-input-wrap {
  padding: 6px 8px !important;
  background: #f8fafc;
  border-bottom: 1px solid var(--line);
}
.ts-dropdown .dropdown-input {
  border-radius: 8px !important;
  border: 1px solid var(--line) !important;
  padding: 6px 10px !important;
  font-size: 0.88em !important;
  direction: rtl !important;
  text-align: right !important;
}
.ts-dropdown .option {
  padding: 9px 14px !important;
  font-size: 0.9em !important;
  direction: rtl !important;
  text-align: right !important;
}
.ts-dropdown .active {
  background-color: var(--navy) !important;
  color: #fff !important;
}
.ts-dropdown .active span {
  color: #fff !important;
}
.ts-dropdown .optgroup-header {
  font-weight: 700 !important;
  font-size: 0.82em !important;
  color: var(--navy) !important;
  background: #f1f5f9 !important;
  padding: 6px 14px !important;
  border-top: 1px solid var(--line) !important;
  border-bottom: 1px solid var(--line) !important;
  direction: rtl !important;
  text-align: right !important;
}

