/* VERA Control — shared components built by VeraUI (field, tabs, pagination, drawer, upload…). */

/* ── field ────────────────────────────────────────────────────────── */
.field { display: grid; gap: 6px; min-width: 0; }
.field-label {
  display: flex; align-items: center; gap: 4px;
  font-size: var(--fs-xs); font-weight: 700; color: var(--text-2);
}
.field-label .req { color: var(--danger); }
.field-control { position: relative; display: flex; align-items: center; }
.field-control .input, .field-control textarea.input { width: 100%; min-width: 0; }
.field-affix {
  position: absolute; top: 50%; transform: translateY(-50%);
  color: var(--text-muted); font-size: var(--fs-sm); pointer-events: none; display: inline-flex;
}
.field-affix.prefix { inset-inline-start: 14px; }
.field-affix.suffix { inset-inline-end: 14px; }
.field-control.has-prefix .input { padding-inline-start: 40px; }
.field-control.has-suffix .input { padding-inline-end: 52px; }
.field-foot { display: flex; justify-content: space-between; gap: 8px; min-height: 0; }
.field-hint { font-size: var(--fs-xs); color: var(--text-muted); }
.field-error { font-size: var(--fs-xs); color: #fca5a5; display: none; }
.field-count { font-size: 11px; color: var(--text-muted); margin-inline-start: auto; direction: ltr; }
.field.invalid .input { border-color: var(--danger); box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.2); }
.field.invalid .field-error { display: block; }
.field.invalid .field-hint { display: none; }
.input[dir="ltr"] { text-align: left; }
.fields-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s4); }
.fields-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--s4); }
@media (max-width: 700px) { .fields-2, .fields-3 { grid-template-columns: 1fr; } }

/* ── switch ───────────────────────────────────────────────────────── */
.switch-row {
  display: flex; align-items: center; justify-content: space-between; gap: var(--s4);
  padding: 12px 14px; border: 1px solid var(--border); border-radius: var(--r-md);
  background: var(--field); cursor: pointer;
}
.switch-row .switch-text { display: grid; gap: 2px; }
.switch-row .switch-title { font-weight: 700; font-size: var(--fs-sm); }
.switch-row .switch-sub { font-size: var(--fs-xs); color: var(--text-muted); }
.switch { position: relative; width: 44px; height: 24px; flex: none; }
.switch input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; width: 100%; height: 100%; }
.switch .track {
  position: absolute; inset: 0; border-radius: var(--r-full); background: #24324f; transition: var(--ease);
}
.switch .track::after {
  content: ""; position: absolute; top: 3px; inset-inline-start: 3px; width: 18px; height: 18px;
  border-radius: 50%; background: #fff; transition: var(--ease); box-shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
}
.switch input:checked + .track { background: var(--primary); }
.switch input:checked + .track::after { inset-inline-start: 23px; }
.switch input:focus-visible + .track { box-shadow: var(--ring); }

/* ── radio cards ──────────────────────────────────────────────────── */
.choice-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: var(--s2); }
.choice {
  position: relative; display: flex; gap: 10px; align-items: flex-start;
  padding: 12px 14px; border: 1px solid var(--border-strong); border-radius: var(--r-md);
  background: var(--field); cursor: pointer; transition: var(--ease);
}
.choice input { position: absolute; opacity: 0; pointer-events: none; }
.choice .choice-title { font-weight: 700; font-size: var(--fs-sm); }
.choice .choice-sub { font-size: var(--fs-xs); color: var(--text-muted); }
.choice:has(input:checked) { border-color: var(--primary-light); background: var(--primary-soft); }
.choice:has(input:focus-visible) { box-shadow: var(--ring); }

/* ── upload ───────────────────────────────────────────────────────── */
.upload {
  position: relative; display: flex; align-items: center; gap: var(--s3);
  padding: 14px; border: 1.5px dashed var(--border-strong); border-radius: var(--r-md);
  background: var(--field); cursor: pointer; transition: var(--ease);
}
.upload:hover, .upload.drag { border-color: var(--primary-light); background: var(--primary-soft); }
.upload input[type="file"] { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.upload-preview {
  width: 64px; height: 64px; border-radius: var(--r-sm); flex: none; overflow: hidden;
  background: var(--surface-2); display: grid; place-items: center; color: var(--text-muted);
}
.upload-preview img { width: 100%; height: 100%; object-fit: contain; }
.upload-text { display: grid; gap: 2px; font-size: var(--fs-sm); }
.upload-text small { color: var(--text-muted); font-size: var(--fs-xs); }

/* ── tabs ─────────────────────────────────────────────────────────── */
.tabs {
  display: flex; gap: 4px; padding: 4px; margin-bottom: var(--s4);
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-md);
  overflow-x: auto; scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }
.tab {
  display: inline-flex; align-items: center; gap: 6px; flex: none;
  border: 0; background: transparent; color: var(--text-2); cursor: pointer;
  padding: 8px 14px; border-radius: var(--r-sm); font-size: var(--fs-sm); font-weight: 600;
  transition: var(--ease);
}
.tab:hover { color: var(--text); background: rgba(255, 255, 255, 0.04); }
.tab.on { background: var(--primary); color: #fff; font-weight: 700; box-shadow: 0 4px 12px rgba(30, 90, 255, 0.3); }
.tab-count {
  min-width: 18px; height: 18px; padding: 0 5px; border-radius: var(--r-full);
  background: var(--warning); color: #1a1000; font-size: 10px; font-weight: 800;
  display: inline-grid; place-items: center;
}

/* ── section card ─────────────────────────────────────────────────── */
.section { margin-bottom: var(--s4); }
.section-head {
  display: flex; align-items: center; justify-content: space-between; gap: var(--s3);
  padding: 14px var(--s4); border-bottom: 1px solid var(--border);
}
.section-title { margin: 0; font-size: var(--fs-md); font-weight: 800; display: flex; align-items: center; gap: 8px; }
.section-title .ico { color: var(--primary-light); }
.section-sub { margin: 2px 0 0; font-size: var(--fs-xs); color: var(--text-muted); }
.section-body { padding: var(--s4); }
.section.card { padding: 0; }
.section.attention { border-color: rgba(245, 158, 11, 0.4); }
.section.attention .section-title .ico { color: var(--warning); }

/* ── table extras ─────────────────────────────────────────────────── */
.table-bar { display: flex; align-items: center; justify-content: space-between; gap: var(--s3); flex-wrap: wrap; margin-bottom: var(--s3); }
.table-search { position: relative; flex: 1; max-width: 340px; }
.table-search .input { width: 100%; padding-inline-start: 38px; height: 40px; }
.table-search .ico { position: absolute; inset-inline-start: 12px; top: 50%; transform: translateY(-50%); color: var(--text-muted); }
.data-table th.sortable { cursor: pointer; user-select: none; }
.data-table th.sortable:hover { color: var(--text); }
.data-table th .sort-ico { opacity: 0.4; margin-inline-start: 4px; }
.data-table th.sorted .sort-ico { opacity: 1; color: var(--primary-light); }
.pager {
  display: flex; align-items: center; justify-content: space-between; gap: var(--s3);
  padding: 10px 14px; border-top: 1px solid var(--border); font-size: var(--fs-xs); color: var(--text-2);
}
.pager-btns { display: flex; gap: 4px; }
.pager .btn { height: 30px; min-width: 30px; padding: 0 8px; }
.pager .btn.on { background: var(--primary); color: #fff; border-color: transparent; }
@media (max-width: 700px) {
  .data-table.cards thead { display: none; }
  .data-table.cards, .data-table.cards tbody, .data-table.cards tr, .data-table.cards td { display: block; width: 100%; }
  .data-table.cards tr { padding: 10px 14px; border-bottom: 1px solid var(--border); }
  .data-table.cards td {
    border: 0; padding: 5px 0; display: grid; grid-template-columns: 96px minmax(0, 1fr);
    column-gap: 12px; align-items: center; justify-items: start;
  }
  .data-table.cards td > * { grid-column: 2; }
  .data-table.cards td::before {
    content: attr(data-label); grid-column: 1; grid-row: 1 / span 9; align-self: start; padding-top: 2px;
    color: var(--text-muted); font-size: 11px; font-weight: 700;
  }
  .data-table.cards td[data-label=""] { grid-template-columns: minmax(0, 1fr); }
  .data-table.cards td[data-label=""] > * { grid-column: 1; }
  .data-table.cards td[data-label=""]::before { display: none; }
}

/* ── drawer ───────────────────────────────────────────────────────── */
.drawer-root { position: fixed; inset: 0; z-index: 110; }
.drawer-root .modal-backdrop { position: absolute; inset: 0; }
.drawer {
  position: absolute; top: 0; bottom: 0; inset-inline-end: 0; width: min(560px, 100vw);
  display: flex; flex-direction: column; background: var(--surface);
  border-inline-start: 1px solid var(--border-strong); box-shadow: var(--shadow-2);
  animation: drawer-in 0.2s ease;
}
.drawer.wide { width: min(820px, 100vw); }
.drawer-head {
  display: flex; align-items: center; justify-content: space-between; gap: var(--s3);
  padding: var(--s4) var(--s5); border-bottom: 1px solid var(--border);
}
.drawer-head h3 { margin: 0; font-size: var(--fs-lg); font-weight: 800; }
.drawer-head p { margin: 2px 0 0; font-size: var(--fs-xs); color: var(--text-muted); }
.drawer-body { flex: 1; overflow: auto; padding: var(--s5); }
.drawer-foot {
  display: flex; gap: var(--s2); padding: var(--s4) var(--s5); border-top: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.15);
}
@keyframes drawer-in { from { transform: translateX(-24px); opacity: 0; } }

/* ── skeleton ─────────────────────────────────────────────────────── */
.skeleton { display: grid; gap: 10px; padding: var(--s4); }
.skeleton i {
  display: block; height: 14px; border-radius: 6px;
  background: linear-gradient(90deg, var(--surface-2) 0%, var(--surface-3) 50%, var(--surface-2) 100%);
  background-size: 200% 100%; animation: shimmer 1.2s linear infinite;
}
.skeleton i:nth-child(3n) { width: 70%; }
.skeleton i:nth-child(3n + 1) { width: 90%; }
@keyframes shimmer { to { background-position: -200% 0; } }

/* ── helpers ──────────────────────────────────────────────────────── */
.row { display: flex; align-items: center; gap: var(--s2); flex-wrap: wrap; }
.stack { display: grid; gap: var(--s3); }
.muted { color: var(--text-muted); }
.ltr { direction: ltr; unicode-bidi: isolate; }
.divider { height: 1px; background: var(--border); margin: var(--s4) 0; border: 0; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 8px 16px; font-size: var(--fs-sm); }
.kv dt { color: var(--text-muted); }
.kv dd { margin: 0; font-weight: 600; }
.flip { transform: scaleX(-1); }
.data-table tr[hidden], .pager[hidden] { display: none !important; }

/* ── dashboard ────────────────────────────────────────────────────── */
.dash-h { margin: var(--s5) 0 var(--s3); font-size: var(--fs-md); font-weight: 800; color: var(--text-2); }
.todo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: var(--s2); }
.todo {
  display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-radius: var(--r-md);
  background: var(--field); border: 1px solid var(--border); color: var(--text-2); transition: var(--ease);
}
.todo:hover { border-color: var(--border-strong); color: var(--text); }
.todo-ico { width: 34px; height: 34px; border-radius: var(--r-sm); display: grid; place-items: center; background: var(--surface-2); flex: none; }
.todo-label { flex: 1; font-size: var(--fs-sm); font-weight: 600; }
.todo-n { font-weight: 800; color: var(--success); display: inline-flex; }
.todo.has { border-color: rgba(245, 158, 11, 0.4); color: var(--text); }
.todo.has .todo-ico { background: var(--warning-soft); color: var(--warning); }
.todo.has .todo-n { color: var(--warning); font-size: var(--fs-lg); }
.chart-box { position: relative; height: 260px; }
.charts-grid .section { margin-bottom: 0; }
.feed { display: grid; }
.feed-row { display: flex; justify-content: space-between; align-items: center; gap: var(--s3); padding: 10px 0; border-bottom: 1px solid var(--border); font-size: var(--fs-sm); }
.feed-row:last-child { border-bottom: 0; }
.feed-side { display: flex; align-items: center; gap: var(--s3); flex-wrap: wrap; justify-content: flex-end; font-size: var(--fs-xs); }

/* second-level tabs (e.g. inside «قسم البطولات») */
.subtabs .tabs { background: transparent; border: 0; padding: 0; gap: 6px; margin-top: -6px; }
.subtabs .tab { border: 1px solid var(--border); background: var(--surface); padding: 6px 14px; border-radius: var(--r-full); font-size: var(--fs-xs); }
.subtabs .tab.on { background: var(--primary-soft); color: #fff; border-color: rgba(75, 139, 255, 0.5); box-shadow: none; }

.page-note {
  margin: 0 0 var(--s4); padding: 10px 14px; border-radius: var(--r-md);
  background: var(--primary-soft); border: 1px solid rgba(75, 139, 255, 0.22);
  color: #c5d6f5; font-size: var(--fs-sm); line-height: 1.7;
}
.hint { color: var(--text-muted); font-size: var(--fs-xs); }
.row.tight { gap: 4px; }

/* checkbox labels inside forms → selectable chips (no markup change needed) */
.modal-body label:has(> input[type="checkbox"]:not(.toggle)),
.panel label:has(> input[type="checkbox"]:not(.toggle)):not(.switch-row):not(.perm-item) {
  display: inline-flex; align-items: center; gap: 6px; margin: 0 0 6px 6px;
  padding: 6px 12px; border: 1px solid var(--border-strong); border-radius: var(--r-full);
  background: var(--field); font-size: var(--fs-xs); font-weight: 600; color: var(--text-2);
  cursor: pointer; transition: var(--ease); user-select: none;
}
.modal-body label:has(> input[type="checkbox"]:not(.toggle):checked),
.panel label:has(> input[type="checkbox"]:not(.toggle):checked):not(.switch-row):not(.perm-item) {
  border-color: rgba(75, 139, 255, 0.55); background: var(--primary-soft); color: #fff;
}

input[type="file"].input { padding: 6px; height: auto; color: var(--text-2); font-size: var(--fs-xs); }
input[type="file"]::file-selector-button {
  margin-inline-end: 10px; padding: 7px 14px; border-radius: var(--r-sm); cursor: pointer;
  border: 1px solid var(--border-strong); background: var(--surface-2); color: var(--text); font: inherit; font-weight: 700;
}
input[type="file"]::file-selector-button:hover { background: var(--surface-3); }
.toolbar .tabs { margin: 0; }

/* checkbox → on/off switch (add class="toggle"; value/checked unchanged) */
input[type="checkbox"].toggle {
  appearance: none; -webkit-appearance: none; position: relative; flex: none; margin: 0;
  width: 44px; height: 24px; border-radius: var(--r-full); background: #24324f; cursor: pointer;
  transition: background var(--ease);
}
input[type="checkbox"].toggle::after {
  content: ""; position: absolute; top: 3px; inset-inline-start: 3px; width: 18px; height: 18px;
  border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.4); transition: inset-inline-start var(--ease);
}
input[type="checkbox"].toggle:checked { background: var(--primary); }
input[type="checkbox"].toggle:checked::after { inset-inline-start: 23px; }
input[type="checkbox"].toggle:focus-visible { outline: none; box-shadow: var(--ring); }
input[type="checkbox"].toggle:disabled { opacity: 0.5; cursor: not-allowed; }
.switch-line {
  display: flex; align-items: center; justify-content: space-between; gap: var(--s4);
  padding: 12px 14px; border: 1px solid var(--border); border-radius: var(--r-md); background: var(--field);
  cursor: pointer; font-size: var(--fs-sm);
}
.perm-item.switch-line:has(input:checked) { background: var(--field); border-color: var(--border); }

.stat-value { overflow-wrap: anywhere; }
.drawer .stat-value, .modal-panel .stat-value { font-size: 20px; }
.drawer .stats-grid { grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); }
