/* ==========================================================================
   css/sandbox.css - النظام التدريبي (sandbox.html)
   طبقتين:
   1) إطار البورتال بالعربي (RTL) — بيستعمل توكنز css/styles.css
   2) منطقة `.sys` (LTR) اللي بتحاكي شكل سيستم العيادة الحقيقي (Bootstrap 4)
   مفيش أي مكتبات خارجية — كل الستايل مكتوب بالإيد.
   ========================================================================== */

/* ---------------------------------------------------------------- 1) الإطار */

body.sandbox-body { display: block; background: var(--sand-100); }

.portal-bar { position: sticky; top: 0; z-index: 40; background: var(--teal-900); color: #EFF5F3; }
.portal-bar-inner {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 9px 16px; max-width: 1600px; margin: 0 auto;
}
.portal-brand { font-family: 'Cairo', sans-serif; font-weight: 700; font-size: 14.5px; }
.portal-mode {
  font-size: 12px; font-weight: 700; padding: 3px 10px; border-radius: 999px;
  background: rgba(255, 255, 255, .14); white-space: nowrap;
}
.portal-mode.is-exam { background: var(--gold-500); color: #22180a; }
.portal-spacer { flex: 1 1 auto; }
.portal-bar .pbtn {
  font-family: 'Tajawal', sans-serif; font-size: 13px; font-weight: 700; cursor: pointer;
  background: rgba(255, 255, 255, .12); color: #EFF5F3; border: 1px solid rgba(255, 255, 255, .22);
  padding: 6px 12px; border-radius: 8px; text-decoration: none; display: inline-block;
}
.portal-bar .pbtn:hover { background: rgba(255, 255, 255, .22); }
.portal-bar .pbtn.on { background: var(--gold-100); color: #4a3410; border-color: var(--gold-100); }
.portal-bar .pbtn.submit { background: var(--danger); border-color: var(--danger); color: #fff; }
.portal-bar .pbtn.submit:hover { background: #8f3831; }
.portal-bar .pbtn[disabled] { opacity: .5; cursor: default; }
.portal-bar .exam-timer { font-size: 19px; padding: 3px 12px; }

.sb-main { padding: 0; }
.sb-center { max-width: 860px; margin: 0 auto; padding: 26px 18px 70px; }

.sb-work { display: flex; align-items: flex-start; gap: 14px; padding: 14px 14px 60px; }
.sb-work > .sys { flex: 1 1 auto; min-width: 0; }

.task-panel {
  flex: 0 0 320px; width: 320px; background: var(--paper); border: 1px solid var(--line);
  border-radius: 14px; padding: 14px 16px; position: sticky; top: 58px;
  max-height: calc(100vh - 74px); overflow: auto;
  font-family: 'Tajawal', sans-serif; font-size: 13.4px; line-height: 1.85; color: var(--ink-900);
}
.task-panel h2 { font-family: 'Cairo', sans-serif; font-size: 15.5px; color: var(--teal-900); margin: 0 0 8px; }
.task-panel .tp-intro {
  white-space: pre-line; background: var(--teal-100); border-radius: 10px;
  padding: 10px 12px; font-size: 12.8px; margin-bottom: 12px;
}
.task-panel .tp-task {
  border: 1px solid var(--line); border-radius: 10px; padding: 9px 11px; margin-bottom: 9px;
  background: #fff;
}
.task-panel .tp-task.done { background: #EFF6F1; border-color: #A9CDB8; }
.task-panel .tp-text { white-space: pre-line; font-size: 12.9px; }
.task-panel .tp-check { display: flex; align-items: center; gap: 7px; margin-top: 7px; font-weight: 700; font-size: 12.3px; color: var(--ink-500); cursor: pointer; }
.task-panel .tp-check input { width: 15px; height: 15px; }
.task-panel .tp-note { font-size: 11.8px; color: var(--ink-500); margin-top: 10px; }

.sb-banner {
  position: fixed; bottom: 14px; left: 14px; right: 14px; max-width: 720px; margin: 0 auto;
  background: #3b2f13; color: #fff; padding: 11px 15px; border-radius: 12px; z-index: 60;
  font-family: 'Tajawal', sans-serif; font-size: 13.3px; line-height: 1.7;
  box-shadow: 0 6px 18px rgba(0, 0, 0, .18);
}

/* لوج النشاط (وضع التدريب) */
.sb-log { margin: 0 14px 40px; font-family: 'Tajawal', sans-serif; }
.sb-log-head {
  background: var(--teal-700); color: #fff; border: none; border-radius: 10px;
  padding: 9px 14px; font-family: 'Tajawal', sans-serif; font-weight: 700; font-size: 13.2px; cursor: pointer;
}
.sb-log-body {
  background: var(--paper); border: 1px solid var(--line); border-top: none;
  border-radius: 0 0 10px 10px; padding: 10px 14px; max-height: 240px; overflow: auto;
}
.sb-log-row { font-size: 12.6px; padding: 5px 0; border-bottom: 1px dashed var(--line); direction: ltr; text-align: left; }
.sb-log-row:last-child { border-bottom: none; }
.sb-log-row .lg-type { font-weight: 700; color: var(--teal-700); }
.sb-log-row .lg-time { color: var(--ink-500); font-size: 11.5px; }
.sb-log-empty { font-size: 12.6px; color: var(--ink-500); }

@media (max-width: 1100px) {
  .sb-work { flex-direction: column; }
  .task-panel { width: 100%; flex: 0 0 auto; position: relative; top: 0; max-height: none; }
}

/* ---------------------------------------------------- 2) منطقة السيستم (LTR) */

.sys {
  direction: ltr; text-align: left;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 14px; line-height: 1.5; color: #212529;
}
.sys *, .sys *::before, .sys *::after { box-sizing: border-box; }

/* navbar */
.sys .navbar {
  background: #343a40; color: #fff; display: flex; align-items: center; flex-wrap: wrap;
  gap: 6px 16px; padding: 8px 16px; border-radius: 6px 6px 0 0;
}
.sys .navbar-brand { font-size: 16px; font-weight: 600; color: #fff; margin-right: 14px; white-space: nowrap; }
.sys .navbar-nav { display: flex; align-items: center; gap: 2px; flex-wrap: wrap; }
.sys .nav-link {
  color: rgba(255, 255, 255, .68); padding: 6px 11px; border-radius: 4px;
  font-size: 13.5px; cursor: pointer; text-decoration: none; display: inline-block; background: none; border: none;
  font-family: inherit;
}
.sys .nav-link:hover { color: #fff; background: rgba(255, 255, 255, .08); }
.sys .nav-link.active { color: #fff; background: rgba(255, 255, 255, .16); font-weight: 600; }
.sys .navbar-right { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.sys .navbar-user { font-size: 12.5px; color: rgba(255, 255, 255, .6); }

/* container / cards */
.sys .container { background: #f8f9fa; border: 1px solid #dee2e6; border-top: none; padding: 16px; border-radius: 0 0 6px 6px; min-height: 420px; }
.sys .card { background: #fff; border: 1px solid rgba(0, 0, 0, .125); border-radius: 4px; margin-bottom: 16px; box-shadow: none; padding: 0; }
.sys .card-header {
  background: #f7f7f9; border-bottom: 1px solid rgba(0, 0, 0, .125); padding: 10px 14px;
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap; font-weight: 600; font-size: 15px; color: #212529;
}
.sys .card-header .spacer { flex: 1 1 auto; }
.sys .card-body { padding: 14px; }
.sys .card-title { font-size: 15px; font-weight: 600; margin: 0 0 10px; color: #212529; }
.sys .muted { color: #6c757d; font-size: 12.5px; }
.sys .text-right { text-align: right; }
.sys .row-2 { display: flex; gap: 14px; flex-wrap: wrap; }
.sys .row-2 > * { flex: 1 1 220px; min-width: 0; }

/* tables */
.sys .table { width: 100%; border-collapse: collapse; background: #fff; font-size: 13.5px; }
.sys .table th, .sys .table td { padding: 8px 10px; border-top: 1px solid #dee2e6; vertical-align: middle; text-align: left; }
.sys .table thead th {
  border-top: none; border-bottom: 2px solid #dee2e6; background: #f1f3f5;
  font-weight: 600; font-size: 12.5px; text-transform: uppercase; letter-spacing: .02em; color: #495057; white-space: nowrap;
}
.sys .table tbody tr:nth-of-type(odd) { background: rgba(0, 0, 0, .025); }
.sys .table tbody tr:hover { background: rgba(0, 123, 255, .07); }
.sys .table.clickable tbody tr { cursor: pointer; }
.sys .table td.num, .sys .table th.num { text-align: right; white-space: nowrap; }
.sys .table .empty { text-align: center; color: #6c757d; padding: 22px 10px; font-style: italic; }
.sys .table-wrap { overflow-x: auto; }
.sys .table tfoot td { border-top: 2px solid #dee2e6; font-weight: 600; background: #f1f3f5; }

/* buttons */
.sys .btn {
  display: inline-block; font-family: inherit; font-weight: 400; font-size: 14px; line-height: 1.5;
  padding: 6px 12px; border-radius: 4px; border: 1px solid transparent; cursor: pointer;
  text-align: center; text-decoration: none; background: #6c757d; color: #fff; transition: none; gap: 0;
}
.sys .btn:hover { filter: brightness(.93); }
.sys .btn[disabled] { opacity: .65; cursor: default; filter: none; }
.sys .btn-primary { background: #007bff; border-color: #007bff; color: #fff; }
.sys .btn-success { background: #28a745; border-color: #28a745; color: #fff; }
.sys .btn-danger { background: #dc3545; border-color: #dc3545; color: #fff; }
.sys .btn-warning { background: #ffc107; border-color: #ffc107; color: #212529; }
.sys .btn-info { background: #17a2b8; border-color: #17a2b8; color: #fff; }
.sys .btn-light { background: #f8f9fa; border-color: #ced4da; color: #212529; }
.sys .btn-secondary { background: #6c757d; border-color: #6c757d; color: #fff; }
.sys .btn-xs { padding: 2px 7px; font-size: 12px; line-height: 1.5; }
.sys .btn-sm { padding: 4px 9px; font-size: 12.8px; }
.sys .btn-group-xs { display: inline-flex; gap: 4px; flex-wrap: wrap; }

/* badges */
.sys .badge {
  display: inline-block; padding: 4px 8px; font-size: 11.5px; font-weight: 700; line-height: 1;
  border-radius: 10rem; background: #6c757d; color: #fff; white-space: nowrap; letter-spacing: 0;
}
.sys .badge-success { background: #28a745; color: #fff; }
.sys .badge-warning { background: #ffc107; color: #212529; }
.sys .badge-danger { background: #dc3545; color: #fff; }
.sys .badge-primary { background: #007bff; color: #fff; }
.sys .badge-info { background: #17a2b8; color: #fff; }
.sys .badge-light { background: #e9ecef; color: #495057; }

/* chips (balance) */
.sys .chips { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 8px; }
.sys .chip { background: #e9ecef; border-radius: 4px; padding: 6px 12px; font-size: 13px; }
.sys .chip b { font-size: 15px; }
.sys .chip.paid { background: #d4edda; color: #155724; }
.sys .chip.remaining { background: #f8d7da; color: #721c24; }
.sys .chip.remaining.zero { background: #d4edda; color: #155724; }
.sys .chip.required { background: #e2e3e5; color: #383d41; }

/* forms */
.sys .form-group { margin-bottom: 12px; }
.sys .form-group > label { display: block; font-weight: 600; font-size: 13px; margin-bottom: 4px; color: #212529; }
.sys .form-control {
  display: block; width: 100%; padding: 6px 10px; font-family: inherit; font-size: 14px; line-height: 1.5;
  color: #495057; background: #fff; border: 1px solid #ced4da; border-radius: 4px;
}
.sys .form-control:focus { border-color: #80bdff; outline: 0; box-shadow: 0 0 0 3px rgba(0, 123, 255, .18); }
.sys .form-control[readonly], .sys .form-control:disabled { background: #e9ecef; }
.sys textarea.form-control { min-height: 62px; resize: vertical; }
.sys .form-control.is-invalid { border-color: #dc3545; }
.sys .invalid-feedback { display: block; width: 100%; margin-top: 3px; font-size: 12.2px; color: #dc3545; }
.sys .form-text { font-size: 12px; color: #6c757d; margin-top: 3px; }
.sys .sb-hint {
  display: block; direction: rtl; text-align: right; font-family: 'Tajawal', sans-serif;
  font-size: 12px; color: #8a6a2f; background: #fdf6e6; border-radius: 4px; padding: 3px 8px; margin-top: 4px;
}
.sys .form-check { display: flex; align-items: flex-start; gap: 7px; padding: 4px 0; font-size: 13.5px; }
.sys .form-check input { margin-top: 3px; width: 15px; height: 15px; flex: 0 0 auto; }
.sys .form-check label { cursor: pointer; margin: 0; font-weight: 400; }
.sys .check-list { border: 1px solid #ced4da; border-radius: 4px; padding: 6px 10px; max-height: 190px; overflow: auto; background: #fff; }
.sys .check-list.is-invalid { border-color: #dc3545; }

/* tabs */
.sys .nav-tabs { display: flex; gap: 2px; flex-wrap: wrap; border-bottom: 1px solid #dee2e6; margin-bottom: 0; padding: 0 6px; }
.sys .nav-tabs .tab {
  background: none; border: 1px solid transparent; border-bottom: none; font-family: inherit; font-size: 13.8px;
  padding: 8px 14px; cursor: pointer; color: #007bff; border-radius: 4px 4px 0 0; margin-bottom: -1px;
}
.sys .nav-tabs .tab:hover { background: #e9ecef; }
.sys .nav-tabs .tab.active { background: #fff; border-color: #dee2e6 #dee2e6 #fff; color: #495057; font-weight: 600; }

/* alerts */
.sys .alert { padding: 9px 13px; border: 1px solid transparent; border-radius: 4px; font-size: 13.4px; margin-bottom: 12px; }
.sys .alert-danger { background: #f8d7da; border-color: #f5c6cb; color: #721c24; }
.sys .alert-success { background: #d4edda; border-color: #c3e6cb; color: #155724; }
.sys .alert-info { background: #d1ecf1; border-color: #bee5eb; color: #0c5460; }
.sys .alert-warning { background: #fff3cd; border-color: #ffeeba; color: #856404; }

/* search */
.sys .search-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: flex-end; margin-bottom: 12px; }
.sys .search-row .form-group { margin-bottom: 0; }
.sys .search-row .grow { flex: 1 1 260px; }
.sys .radio-row { display: flex; gap: 14px; flex-wrap: wrap; align-items: center; font-size: 13.4px; }
.sys .radio-row label { display: inline-flex; align-items: center; gap: 5px; cursor: pointer; }

/* modal */
#modalRoot:empty { display: none; }
.modal-backdrop { position: fixed; inset: 0; background: rgba(0, 0, 0, .5); z-index: 100; }
.sys-modal-layer {
  position: fixed; inset: 0; z-index: 101; overflow-y: auto; padding: 28px 14px;
  display: flex; align-items: flex-start; justify-content: center;
}
.sys .modal {
  background: #fff; border-radius: 6px; width: 100%; max-width: 620px; margin: 0 auto;
  box-shadow: 0 8px 30px rgba(0, 0, 0, .3);
}
.sys .modal.modal-lg { max-width: 900px; }
.sys .modal-header {
  display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-bottom: 1px solid #dee2e6;
  background: #f7f7f9; border-radius: 6px 6px 0 0;
}
.sys .modal-title { font-size: 16px; font-weight: 600; margin: 0; flex: 1 1 auto; }
.sys .modal-close {
  background: none; border: none; font-size: 22px; line-height: 1; cursor: pointer; color: #6c757d; padding: 0 4px;
}
.sys .modal-body { padding: 14px 16px; }
.sys .modal-footer {
  display: flex; justify-content: flex-end; gap: 8px; padding: 11px 16px;
  border-top: 1px solid #dee2e6; background: #f7f7f9; border-radius: 0 0 6px 6px;
}
.sys .section-title {
  font-size: 13px; font-weight: 700; text-transform: uppercase; color: #495057;
  border-bottom: 1px solid #dee2e6; padding-bottom: 4px; margin: 16px 0 8px;
}
.sys .result-list { border: 1px solid #ced4da; border-radius: 4px; max-height: 180px; overflow: auto; background: #fff; }
.sys .result-list .ritem { padding: 6px 10px; cursor: pointer; border-bottom: 1px solid #f1f3f5; font-size: 13.4px; }
.sys .result-list .ritem:last-child { border-bottom: none; }
.sys .result-list .ritem:hover { background: rgba(0, 123, 255, .08); }
.sys .picked-patient { background: #d1ecf1; border: 1px solid #bee5eb; border-radius: 4px; padding: 7px 10px; font-size: 13.5px; }

/* عناصر صغيرة بتستعملها sandbox-ui.js / sandbox-modals.js */
.sys .navbar-brand small { color: rgba(255, 255, 255, .55); font-size: 12.5px; font-weight: 400; }
.sys .link { color: #007bff; cursor: pointer; text-decoration: underline; }
.sys .link:hover { color: #0056b3; }
.sys .def-table th { width: 240px; color: #495057; background: #f8f9fa; font-weight: 600; }
.sys .def-table tbody tr:nth-of-type(odd) { background: transparent; }
.sys .field-mark.is-invalid { box-shadow: 0 0 0 2px rgba(220, 53, 69, .3); border-radius: 4px; }
.sys .result-list .ritem.muted { cursor: default; color: #6c757d; }
.sys [data-search-row] > .result-list { margin-top: 5px; }

/* صفوف مودال الـ Finish */
.sys .finish-row {
  display: flex; gap: 12px; flex-wrap: wrap; align-items: center; justify-content: space-between;
  border: 1px solid #e9ecef; border-radius: 4px; padding: 7px 10px; margin-bottom: 6px; background: #fff;
}
.sys .finish-sessions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 12.5px; }
.sys .finish-sessions label { font-weight: 600; font-size: 12.5px; margin: 0; }
.sys .finish-sessions .form-control { width: 90px; }

/* حقول جوه الجداول (مودال الدفع) */
.sys .table td .form-control { width: 120px; display: inline-block; text-align: right; }
.sys .table td .form-check { justify-content: flex-end; font-size: 12px; margin-top: 3px; }

@media (max-width: 620px) {
  .sys .navbar { border-radius: 0; }
  .sb-work { padding: 8px 6px 50px; }
  .sys .card-body, .sys .container { padding: 10px; }
}
