/* ─── Makhzani — checkboxes, radios, chip toggles (system-wide) ─────────── */

:root {
  --mh-choice: #26b9cc;
  --mh-choice-dark: #00897b;
  --mh-choice-border: #cfd8dc;
  --mh-choice-bg: #fff;
  --mh-choice-muted: #546e7a;
  --mh-choice-chip-bg: #fafafa;
  --mh-choice-chip-border: #e0e0e0;
  --mh-tile-bg: #fafcfd;
  --mh-tile-border: #e8eef3;
  --mh-tile-hover-bg: #fff;
  --mh-tile-hover-border: #b0bec5;
  --mh-tile-checked-bg: #e0f7fa;
  --mh-tile-checked-border: #80cbc4;
  --mh-tile-checked-text: #00695c;
  --mh-check-icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 10'%3E%3Cpath fill='none' stroke='%23ffffff' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round' d='M1 5.5l3 3 7-7'/%3E%3C/svg%3E");
}

/* ── حقول الأرقام: بدون أسهم زيادة/نقصان (النظام بالكامل) ─────────────── */
input[type="number"] {
  -moz-appearance: textfield;
  appearance: textfield;
}

input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button {
  -webkit-appearance: none !important;
  appearance: none !important;
  display: none;
  margin: 0;
  opacity: 0;
  pointer-events: none;
  height: 0;
  width: 0;
}

/* ── Checkbox — النظام بالكامل ─────────────────────────────────────────── */

input[type="checkbox"]:not(.perm-bind):not([hidden]):not([style*="display: none"]):not([style*="display:none"]) {
  appearance: none;
  -webkit-appearance: none;
  width: 18px;
  height: 18px;
  min-width: 18px;
  margin: 0;
  border: 2px solid var(--mh-choice-border);
  border-radius: 4px;
  background-color: var(--mh-choice-bg);
  background-image: none;
  cursor: pointer;
  flex-shrink: 0;
  vertical-align: middle;
  transition: border-color .15s, background-color .15s, box-shadow .15s;
}

input[type="checkbox"]:not(.perm-bind):not([hidden]):not([style*="display: none"]):not([style*="display:none"]):checked {
  background-color: var(--mh-choice-dark);
  border-color: var(--mh-choice-dark);
  background-image: var(--mh-check-icon);
  background-repeat: no-repeat;
  background-position: center;
  background-size: 11px 9px;
}

input[type="checkbox"]:not(.perm-bind):not([hidden]):not([style*="display: none"]):not([style*="display:none"]):focus-visible {
  outline: 2px solid var(--mh-choice);
  outline-offset: 2px;
}

input[type="checkbox"]:not(.perm-bind):not([hidden]):not([style*="display: none"]):not([style*="display:none"]):disabled {
  opacity: .45;
  cursor: not-allowed;
}

/* بلاطة checkbox — كل النظام (مثل صلاحيات المستخدم) */
.check-group:not(:has(> input[type="radio"])):not(.mh-check-plain),
.user-perm-tile,
.user-status-tile,
.setup-option-tile,
label:has(> input[type="checkbox"]:not(.perm-bind):not([hidden])):not(.mh-check-plain):not(.auth-remember):not(.setup-inline-check) {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  flex: 1 1 auto;
  min-width: 0;
  padding: 10px 12px;
  margin: 0;
  border: 1px solid var(--mh-tile-border);
  border-radius: 8px;
  background: var(--mh-tile-bg);
  font-size: .86rem;
  font-weight: 600;
  color: #37474f;
  line-height: 1.4;
  cursor: pointer;
  user-select: none;
  transition: border-color .15s, background .15s, box-shadow .15s, color .15s;
}

.check-group:not(:has(> input[type="radio"])):not(.mh-check-plain):hover,
.user-perm-tile:hover,
.user-status-tile:hover,
.setup-option-tile:hover,
label:has(> input[type="checkbox"]:not(.perm-bind)):not(.mh-check-plain):not(.auth-remember):not(.setup-inline-check):hover {
  border-color: var(--mh-tile-hover-border);
  background: var(--mh-tile-hover-bg);
}

.check-group:not(:has(> input[type="radio"])):not(.mh-check-plain):has(input[type="checkbox"]:checked),
.user-perm-tile:has(input:checked),
.user-status-tile:has(input:checked),
.setup-option-tile:has(input:checked),
label:has(> input[type="checkbox"]:checked):not(.mh-check-plain):not(.auth-remember):not(.setup-inline-check) {
  border-color: var(--mh-tile-checked-border);
  background: var(--mh-tile-checked-bg);
  color: var(--mh-tile-checked-text);
  box-shadow: 0 1px 4px rgba(38, 185, 204, .12);
}

.check-group:not(:has(> input[type="radio"])) input[type="checkbox"],
.user-perm-tile input[type="checkbox"],
.user-status-tile input[type="checkbox"],
.setup-option-tile input[type="checkbox"],
label:has(> input[type="checkbox"]) input[type="checkbox"] {
  margin-top: 2px;
}

.check-group:not(:has(> input[type="radio"])) > span,
.user-perm-tile > span,
.setup-option-tile > span,
label:has(> input[type="checkbox"]) > span:not(.user-perm-tile__hint) {
  flex: 1;
}

.check-group:has(input:disabled),
label:has(> input[type="checkbox"]:disabled):not(.mh-check-plain) {
  opacity: .5;
  cursor: not-allowed;
}

/* شبكة بلاطات checkbox */
.mh-check-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 8px;
}
.mh-check-grid > .check-group,
.mh-check-grid > label:has(> input[type="checkbox"]) {
  width: 100%;
}

/* بلاطة بعرض كامل */
.mh-check-wide { width: 100%; grid-column: 1 / -1; }

/* بدون بلاطة — للجداول والحالات المدمجة */
.mh-check-plain,
.auth-remember {
  display: inline-flex !important;
  align-items: center !important;
  gap: 8px !important;
  padding: 0 !important;
  border: none !important;
  border-radius: 0 !important;
  background: transparent !important;
  box-shadow: none !important;
  font-weight: 400 !important;
  color: inherit !important;
}

/* ── Inline radio (radio-group, check-group) ───────────────────────────── */

.radio-group {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
}

.radio-group label,
.check-group:has(> input[type="radio"]) {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: .88rem;
  cursor: pointer;
  font-weight: 400;
  user-select: none;
}

.radio-group input[type="radio"],
.check-group input[type="radio"] {
  appearance: none;
  -webkit-appearance: none;
  width: 18px;
  height: 18px;
  min-width: 18px;
  margin: 0;
  border: 2px solid var(--mh-choice-border);
  border-radius: 50%;
  background: var(--mh-choice-bg);
  cursor: pointer;
  flex-shrink: 0;
  transition: border-color .15s, box-shadow .15s;
}

.radio-group input[type="radio"]:checked,
.check-group input[type="radio"]:checked {
  border-color: var(--mh-choice);
  box-shadow: inset 0 0 0 4px var(--mh-choice);
}

.radio-group input[type="radio"]:focus-visible,
.check-group input[type="radio"]:focus-visible {
  outline: 2px solid var(--mh-choice);
  outline-offset: 2px;
}

/* ── Chip / pill radio groups (reports, filters) ─────────────────────────── */

.mh-chip-group,
.reports-group-radios {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.mh-chip-group label,
.reports-group-radios label {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0;
  cursor: pointer;
  font-size: .82rem;
  font-weight: 600;
  padding: 7px 14px;
  border-radius: 20px;
  border: 1px solid var(--mh-choice-chip-border);
  background: var(--mh-choice-chip-bg);
  color: var(--mh-choice-muted);
  transition: background .15s, color .15s, border-color .15s, box-shadow .15s;
  user-select: none;
  line-height: 1.2;
}

.mh-chip-group label:hover,
.reports-group-radios label:hover {
  border-color: #c5c5c5;
  background: #f5f5f5;
}

.mh-chip-group input[type="radio"],
.reports-group-radios input[type="radio"] {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
  margin: 0;
  pointer-events: none;
}

.mh-chip-group label:has(input:checked),
.reports-group-radios label:has(input:checked) {
  background: var(--mh-choice);
  border-color: var(--mh-choice);
  color: #fff;
  box-shadow: 0 2px 8px rgba(45, 106, 79, .25);
}

.mh-chip-group label:has(input:focus-visible),
.reports-group-radios label:has(input:focus-visible) {
  outline: 2px solid var(--mh-choice);
  outline-offset: 2px;
}

.mh-chip-group label:has(input:disabled),
.reports-group-radios label:has(input:disabled) {
  opacity: .5;
  cursor: not-allowed;
}
