/* ==========================================================================
   BLAZMA — Components
   أزرار، حقول، بطاقات، شارات، جداول، نوافذ، تنبيهات، رسوم بيانية
   ========================================================================== */

/* ==========================  BUTTONS  ========================== */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s-2);
  padding: 0 var(--s-5); height: 42px;
  border-radius: var(--r-sm);
  font-size: var(--fs-sm); font-weight: var(--fw-semibold);
  border: 1px solid transparent;
  white-space: nowrap; user-select: none;
  transition: background var(--t), border-color var(--t), color var(--t), transform var(--t-fast), box-shadow var(--t);
  position: relative;
}
.btn:active { transform: translateY(1px); }
.btn[disabled], .btn.is-disabled { opacity: .45; pointer-events: none; }
.btn svg { width: 17px; height: 17px; flex-shrink: 0; }

.btn-primary { background: var(--brand-grad); color: #14100c; box-shadow: var(--sh-glow); }
.btn-primary:hover { color: #14100c; filter: brightness(1.08); }

.btn-secondary { background: var(--card-3); color: var(--text); border-color: var(--border-strong); }
.btn-secondary:hover { background: var(--card-2); border-color: var(--brand-1); color: var(--text); }

.btn-ghost { background: transparent; color: var(--text-2); border-color: var(--border); }
.btn-ghost:hover { background: var(--neutral-bg); color: var(--text); }

.btn-danger { background: var(--danger-bg); color: var(--danger); border-color: rgba(255, 77, 77, .3); }
.btn-danger:hover { background: var(--danger); color: #fff; }

.btn-link {
  height: auto; padding: 0; background: none; color: var(--brand-2);
  display: inline-flex; align-items: center; gap: 6px; width: auto;
}
.btn-link:hover { text-decoration: underline; }
.btn-link svg { width: 15px; height: 15px; flex-shrink: 0; }

.btn-sm { height: 34px; padding: 0 var(--s-3); font-size: var(--fs-xs); border-radius: var(--r-xs); }
.btn-sm svg { width: 15px; height: 15px; }
.btn-lg { height: 52px; padding: 0 var(--s-8); font-size: var(--fs-body); border-radius: var(--r-md); }
.btn-block { width: 100%; }
.btn-icon { width: 42px; padding: 0; }
.btn-icon.btn-sm { width: 34px; }
.btn-icon.btn-lg { width: 52px; }

.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 40px; height: 40px; border-radius: var(--r-sm);
  color: var(--text-2); background: transparent; border: 1px solid transparent;
  transition: background var(--t), color var(--t), border-color var(--t);
  position: relative; flex-shrink: 0;
}
.icon-btn:hover { background: var(--neutral-bg); color: var(--text); }
.icon-btn svg { width: 19px; height: 19px; }
.icon-btn.is-active { color: var(--brand-2); background: rgba(255, 90, 31, .12); }

.btn-count {
  position: absolute; top: 2px; inset-inline-end: 2px;
  min-width: 17px; height: 17px; padding: 0 4px;
  background: var(--brand-1); color: #fff;
  border-radius: var(--r-pill); font-size: 10px; font-weight: var(--fw-bold);
  display: flex; align-items: center; justify-content: center; line-height: 1;
  border: 2px solid var(--bg);
}

/* ==========================  FORMS  ========================== */
.field { display: flex; flex-direction: column; gap: 6px; }
.field-label { font-size: var(--fs-xs); font-weight: var(--fw-semibold); color: var(--text-2); }
.field-label .req { color: var(--danger); }
.field-hint { font-size: var(--fs-caption); color: var(--text-3); }
.field-error { font-size: var(--fs-caption); color: var(--danger); display: flex; align-items: center; gap: 4px; }
.field-error svg { width: 13px; height: 13px; }

.input, .select, .textarea {
  width: 100%; height: 42px; padding: 0 var(--s-3);
  background: var(--card-2);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  color: var(--text); font-size: var(--fs-sm);
  transition: border-color var(--t), background var(--t), box-shadow var(--t);
}
.textarea { height: auto; min-height: 110px; padding: var(--s-3); line-height: 1.6; resize: vertical; }
.input::placeholder, .textarea::placeholder { color: var(--text-3); }
.input:hover, .select:hover, .textarea:hover { border-color: var(--border-strong); }
.input:focus, .select:focus, .textarea:focus {
  border-color: var(--brand-1); background: var(--card-3);
  box-shadow: 0 0 0 3px rgba(255, 90, 31, .14); outline: none;
}
.input.has-error, .select.has-error, .textarea.has-error { border-color: var(--danger); }
.input[disabled], .select[disabled], .textarea[disabled] { opacity: .5; cursor: not-allowed; }

.select {
  appearance: none; -webkit-appearance: none;
  padding-inline-end: 34px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23a5aab5' stroke-width='2.5' stroke-linecap='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-size: 15px;
  background-position: left var(--s-3) center;
  cursor: pointer;
}
html[dir="ltr"] .select { background-position: right var(--s-3) center; }
.select option { background: var(--card-2); color: var(--text); }

.input-group { position: relative; display: flex; align-items: center; }
.input-group .input { padding-inline-start: 40px; }
.input-group > svg {
  position: absolute; inset-inline-start: 13px; width: 17px; height: 17px;
  color: var(--text-3); pointer-events: none;
}

.checkbox, .radio {
  display: flex; align-items: center; gap: var(--s-2); cursor: pointer;
  font-size: var(--fs-sm); color: var(--text-2); user-select: none;
}
.checkbox input, .radio input {
  appearance: none; -webkit-appearance: none; margin: 0;
  width: 18px; height: 18px; flex-shrink: 0;
  border: 1.5px solid var(--border-strong); background: var(--card-2);
  border-radius: 5px; cursor: pointer; position: relative;
  transition: background var(--t), border-color var(--t);
}
.radio input { border-radius: 50%; }
.checkbox input:checked, .radio input:checked { background: var(--brand-1); border-color: var(--brand-1); }
.checkbox input:checked::after {
  content: ""; position: absolute; inset: 0;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23fff' stroke-width='3.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M20 6L9 17l-5-5'/%3E%3C/svg%3E") center / 12px no-repeat;
}
.radio input:checked::after {
  content: ""; position: absolute; inset: 4px; background: #fff; border-radius: 50%;
}
.checkbox:hover input, .radio:hover input { border-color: var(--brand-1); }
.checkbox input:focus-visible, .radio input:focus-visible { outline: 2px solid var(--brand-2); outline-offset: 2px; }

.switch { display: inline-flex; align-items: center; gap: var(--s-3); cursor: pointer; user-select: none; }
.switch input { appearance: none; -webkit-appearance: none; margin: 0; width: 40px; height: 22px; border-radius: 999px; background: var(--card-3); border: 1px solid var(--border-strong); position: relative; cursor: pointer; transition: background var(--t), border-color var(--t); flex-shrink: 0; }
.switch input::after { content: ""; position: absolute; top: 2px; inset-inline-start: 2px; width: 16px; height: 16px; border-radius: 50%; background: var(--text-3); transition: transform var(--t), background var(--t); }
.switch input:checked { background: var(--brand-1); border-color: var(--brand-1); }
.switch input:checked::after { background: #fff; transform: translateX(18px); }
html[dir="rtl"] .switch input:checked::after { transform: translateX(-18px); }
.switch input:focus-visible { outline: 2px solid var(--brand-2); outline-offset: 2px; }
.switch-label { font-size: var(--fs-sm); color: var(--text-2); }

.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: var(--s-4); }
.form-grid .full { grid-column: 1 / -1; }

/* ==========================  CARDS / PANELS  ========================== */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  box-shadow: var(--sh-inset);
}
.card-pad { padding: var(--s-5); }
.card-head {
  display: flex; align-items: center; justify-content: space-between; gap: var(--s-3);
  padding: var(--s-4) var(--s-5); border-bottom: 1px solid var(--border);
}
.card-head h3 { font-size: var(--fs-h4); }
.card-body { padding: var(--s-5); }
.card-foot { padding: var(--s-4) var(--s-5); border-top: 1px solid var(--border); }

.panel { background: var(--card-2); border: 1px solid var(--border); border-radius: var(--r-md); padding: var(--s-4); }

/* ==========================  BADGES  ========================== */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 9px; border-radius: var(--r-pill);
  font-size: var(--fs-caption); font-weight: var(--fw-semibold);
  background: var(--neutral-bg); color: var(--text-2);
  border: 1px solid var(--border); line-height: 1.6;
  white-space: nowrap;
}
.badge svg { width: 12px; height: 12px; }
.badge-brand { background: rgba(239, 103, 13, .14); color: var(--brand-2); border-color: rgba(255, 179, 111, .28); }
.badge-success { background: var(--success-bg); color: var(--success); border-color: rgba(46, 204, 130, .28); }
.badge-warning { background: var(--warning-bg); color: var(--warning); border-color: rgba(255, 176, 32, .28); }
.badge-danger { background: var(--danger-bg); color: var(--danger); border-color: rgba(255, 77, 77, .28); }
.badge-info { background: var(--info-bg); color: var(--info); border-color: rgba(255, 179, 111, .28); }
.badge-violet { background: var(--violet-soft); color: var(--brand-2); border-color: rgba(255, 179, 111, .3); }
.badge-lg { padding: 5px 12px; font-size: var(--fs-xs); }

.badge-region { background: rgba(255, 179, 111, .10); color: var(--cyan); border-color: rgba(255, 179, 111, .24); font-family: var(--font-mono); letter-spacing: .04em; }
.badge-platform { background: rgba(255,255,255,.07); color: var(--text); border-color: var(--border-strong); }
.badge-discount { background: var(--brand-grad); color: #14100c; border: 0; font-weight: var(--fw-black); }

.dot { width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0; display: inline-block; }
.dot-success { background: var(--success); box-shadow: 0 0 0 3px var(--success-bg); }
.dot-warning { background: var(--warning); box-shadow: 0 0 0 3px var(--warning-bg); }
.dot-danger { background: var(--danger); box-shadow: 0 0 0 3px var(--danger-bg); }
.dot-live { animation: pulseDot 1.6s ease-in-out infinite; }

/* ==========================  PRICE  ========================== */
.price { display: inline-flex; align-items: baseline; gap: var(--s-2); flex-wrap: nowrap; min-width: 0; }
.price-now { font-size: 1.06rem; font-weight: var(--fw-black); color: var(--text); letter-spacing: -0.02em; white-space: nowrap; }
.price-old { font-size: var(--fs-xs); color: var(--text-3); text-decoration: line-through; white-space: nowrap; }
.price-lg .price-now { font-size: 1.9rem; }
.price-lg .price-old { font-size: var(--fs-body); }
.price-sm .price-now { font-size: var(--fs-sm); }

/* ==========================  RATING  ========================== */
.rating { display: inline-flex; align-items: center; gap: 4px; font-size: var(--fs-xs); }
.stars { display: inline-flex; gap: 1px; color: var(--warning); }
.stars svg { width: 13px; height: 13px; }
.stars .empty { color: var(--text-3); opacity: .5; }
.rating-value { font-weight: var(--fw-bold); color: var(--text); }
.rating-count { color: var(--text-3); }
.stars-lg svg { width: 18px; height: 18px; }
.stars-input svg { width: 26px; height: 26px; cursor: pointer; transition: transform var(--t-fast); }
.stars-input svg:hover { transform: scale(1.15); }

/* ==========================  AVATAR  ========================== */
.avatar {
  width: 40px; height: 40px; border-radius: 50%; flex-shrink: 0;
  display: inline-flex; align-items: center; justify-content: center;
  font-weight: var(--fw-bold); font-size: var(--fs-sm); color: #14100c;
  background: var(--brand-grad); overflow: hidden; position: relative;
  border: 1px solid var(--border);
}
.avatar-sm { width: 30px; height: 30px; font-size: var(--fs-caption); }
.avatar-lg { width: 64px; height: 64px; font-size: 1.3rem; }
.avatar-xl { width: 92px; height: 92px; font-size: 2rem; border-radius: var(--r-lg); }
.avatar img { width: 100%; height: 100%; object-fit: cover; }

/* ==========================  PRODUCT CARD  ========================== */
.pcard {
  position: relative; display: flex; flex-direction: column;
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--r-md); overflow: hidden;
  transition: transform var(--t), border-color var(--t), box-shadow var(--t);
  height: 100%;
}
.pcard:hover { transform: translateY(-4px); border-color: var(--border-accent); box-shadow: var(--sh-lg); }
.pcard:hover .pcard-media img, .pcard:hover .pcard-media svg { transform: scale(1.07); }
.pcard:hover .pcard-quick { opacity: 1; transform: translateY(0); }

.pcard-media {
  position: relative; aspect-ratio: 4 / 3; overflow: hidden;
  background: var(--card-2); flex-shrink: 0;
}
.pcard-media > img, .pcard-media > svg { width: 100%; height: 100%; object-fit: cover; transition: transform var(--t-slow); }
.pcard-media::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(to top, rgba(8,9,13,.85) 0%, rgba(8,9,13,.1) 45%, transparent 70%);
  pointer-events: none;
}
.pcard-link { position: absolute; inset: 0; z-index: 2; }
.pcard-link:focus-visible { outline-offset: -3px; }

.pcard-tags {
  position: absolute; top: 10px; inset-inline-start: 10px; z-index: 3;
  display: flex; flex-wrap: wrap; gap: 4px; max-width: calc(100% - 56px);
}
.pcard-tags .badge {
  font-size: 10px; padding: 2px 7px; max-width: 100%;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  background: rgba(8, 9, 13, .62); backdrop-filter: blur(6px);
}
.pcard-tags .badge svg { width: 11px; height: 11px; }
.pcard-fav {
  position: absolute; top: var(--s-3); inset-inline-end: var(--s-3); z-index: 4;
  width: 32px; height: 32px; border-radius: 50%;
  background: rgba(8, 9, 13, .68); backdrop-filter: blur(8px);
  border: 1px solid var(--border); color: var(--text-2);
  display: flex; align-items: center; justify-content: center;
  transition: color var(--t), background var(--t), transform var(--t-fast);
}
.pcard-fav svg { width: 16px; height: 16px; }
.pcard-fav:hover { color: var(--brand-3); background: rgba(8,9,13,.9); transform: scale(1.1); }
.pcard-fav.is-active { color: var(--brand-3); }
.pcard-fav.is-active svg { fill: var(--brand-3); }

.pcard-discount {
  position: absolute; bottom: var(--s-3); inset-inline-start: var(--s-3); z-index: 3;
}
.pcard-quick {
  position: absolute; bottom: var(--s-3); inset-inline-end: var(--s-3); z-index: 4;
  opacity: 0; transform: translateY(8px);
  transition: opacity var(--t), transform var(--t);
}
@media (hover: none) { .pcard-quick { opacity: 1; transform: none; } }

.pcard-body {
  padding: var(--s-3) var(--s-4) var(--s-4);
  display: flex; flex-direction: column; gap: 9px; flex: 1; min-width: 0;
}
.pcard-title {
  font-size: var(--fs-sm); font-weight: var(--fw-bold); line-height: 1.45;
  color: var(--text); transition: color var(--t); min-height: 2.6em;
}
.pcard:hover .pcard-title { color: var(--brand-2); }

.pcard-seller {
  display: flex; align-items: center; gap: 5px; min-width: 0;
  font-size: var(--fs-caption); color: var(--text-3); white-space: nowrap;
}
.pcard-seller .sname { min-width: 0; flex: 0 1 auto; }
.pcard-seller .verified { color: var(--info); display: flex; flex-shrink: 0; }
.pcard-seller .verified svg { width: 12px; height: 12px; }
.pcard-rate { display: inline-flex; align-items: center; gap: 3px; margin-inline-start: auto; flex-shrink: 0; }
.pcard-rate .stars svg { width: 11px; height: 11px; }

.pcard-foot {
  margin-top: auto; padding-top: var(--s-3); border-top: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  gap: var(--s-2); flex-wrap: wrap; row-gap: 6px;
}
.pcard-foot .price { flex: 1 1 auto; }
.pcard-stock { font-size: var(--fs-caption); display: inline-flex; align-items: center; gap: 5px; white-space: nowrap; flex-shrink: 0; }
.pcard-instant { display: inline-flex; color: var(--brand-2); }
.pcard-instant svg { width: 11px; height: 11px; }
.pcard-cta { position: relative; z-index: 3; }

.pcard.is-out .pcard-media { filter: grayscale(.7) brightness(.6); }
.pcard-ribbon {
  position: absolute; inset: 0; z-index: 3; display: flex; align-items: center; justify-content: center;
  pointer-events: none;
}
.pcard-ribbon span {
  background: rgba(8,9,13,.85); border: 1px solid var(--border-strong);
  padding: 6px 16px; border-radius: var(--r-pill);
  font-size: var(--fs-xs); font-weight: var(--fw-bold); color: var(--text-2);
  backdrop-filter: blur(6px);
}

/* بطاقة أفقية (السلة / قوائم) */
.pcard-h { display: flex; gap: var(--s-4); align-items: center; }
.pcard-h .thumb { width: 92px; aspect-ratio: 4/3; border-radius: var(--r-sm); overflow: hidden; flex-shrink: 0; background: var(--card-2); }
.pcard-h .thumb > img, .pcard-h .thumb > svg { width: 100%; height: 100%; object-fit: cover; }

/* ==========================  CATEGORY CARD  ========================== */
.ccard {
  position: relative; overflow: hidden;
  border-radius: var(--r-md); border: 1px solid var(--border);
  background: var(--card); padding: var(--s-5);
  display: flex; flex-direction: column; gap: var(--s-2);
  min-height: 156px; isolation: isolate;
  transition: transform var(--t), border-color var(--t), box-shadow var(--t);
}
.ccard::before {
  content: ""; position: absolute; inset: 0; z-index: -1; opacity: .55;
  background: radial-gradient(120% 90% at 100% 0%, var(--cc, rgba(255,90,31,.4)) 0%, transparent 62%);
  transition: opacity var(--t);
}
html[dir="rtl"] .ccard::before { background: radial-gradient(120% 90% at 0% 0%, var(--cc, rgba(255,90,31,.4)) 0%, transparent 62%); }
.ccard:hover { transform: translateY(-4px); border-color: var(--border-strong); box-shadow: var(--sh-lg); }
.ccard:hover::before { opacity: .9; }
.ccard:hover .ccard-icon { transform: scale(1.08) rotate(-4deg); }
.ccard-icon {
  width: 46px; height: 46px; border-radius: var(--r-sm);
  background: rgba(255,255,255,.08); border: 1px solid var(--border-strong);
  display: flex; align-items: center; justify-content: center; color: var(--text);
  transition: transform var(--t-slow); backdrop-filter: blur(6px);
}
.ccard-icon svg { width: 23px; height: 23px; }
.ccard h3 { font-size: var(--fs-h4); margin-top: var(--s-2); }
.ccard p { font-size: var(--fs-caption); color: var(--text-2); margin: 0; }
.ccard-count { margin-top: auto; font-size: var(--fs-caption); color: var(--text-3); display: flex; align-items: center; gap: 5px; }
.ccard-count svg { width: 13px; height: 13px; transition: transform var(--t); }
.ccard:hover .ccard-count { color: var(--brand-2); }
html[dir="rtl"] .ccard:hover .ccard-count svg { transform: translateX(-4px); }
html[dir="ltr"] .ccard:hover .ccard-count svg { transform: translateX(4px); }

/* ==========================  SELLER CARD  ========================== */
.scard {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--r-md);
  padding: var(--s-5); display: flex; flex-direction: column; gap: var(--s-3);
  transition: transform var(--t), border-color var(--t), box-shadow var(--t); position: relative;
}
.scard:hover { transform: translateY(-3px); border-color: var(--border-accent); box-shadow: var(--sh-md); }
.scard-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--s-2); margin-top: auto; padding-top: var(--s-3); border-top: 1px solid var(--border); }
.scard-stat { text-align: center; }
.scard-stat b { display: block; font-size: var(--fs-sm); color: var(--text); }
.scard-stat span { font-size: 10px; color: var(--text-3); }

/* ==========================  TABS  ========================== */
.tabs {
  display: flex; gap: var(--s-1); border-bottom: 1px solid var(--border);
  overflow-x: auto; scrollbar-width: none; -ms-overflow-style: none;
}
.tabs::-webkit-scrollbar { display: none; }
.tab {
  padding: var(--s-3) var(--s-4); font-size: var(--fs-sm); font-weight: var(--fw-semibold);
  color: var(--text-3); border-bottom: 2px solid transparent; margin-bottom: -1px;
  white-space: nowrap; transition: color var(--t), border-color var(--t);
}
.tab:hover { color: var(--text); }
.tab.is-active { color: var(--brand-2); border-bottom-color: var(--brand-1); }
.tab .count { font-size: var(--fs-caption); color: var(--text-3); margin-inline-start: 4px; }

.chips { display: flex; gap: var(--s-2); flex-wrap: wrap; }
.chip {
  padding: 7px 14px; border-radius: var(--r-pill);
  background: var(--card-2); border: 1px solid var(--border);
  font-size: var(--fs-xs); font-weight: var(--fw-medium); color: var(--text-2);
  transition: all var(--t); display: inline-flex; align-items: center; gap: 6px;
}
.chip:hover { border-color: var(--border-strong); color: var(--text); }
.chip.is-active { background: rgba(255,90,31,.14); border-color: var(--border-accent); color: var(--brand-2); }
.chip svg { width: 13px; height: 13px; }

/* ==========================  DROPDOWN  ========================== */
.dd { position: relative; }
.dd-menu {
  position: absolute; top: calc(100% + 8px); inset-inline-end: 0; z-index: 60;
  min-width: 210px; padding: var(--s-2);
  background: var(--card-2); border: 1px solid var(--border-strong);
  border-radius: var(--r-md); box-shadow: var(--sh-lg);
  animation: scaleIn var(--t) both; transform-origin: top var(--dd-origin, left);
  max-height: 70vh; overflow-y: auto;
}
.dd-item {
  display: flex; align-items: center; gap: var(--s-3); width: 100%;
  padding: 9px var(--s-3); border-radius: var(--r-xs);
  font-size: var(--fs-sm); color: var(--text-2); text-align: start;
  transition: background var(--t), color var(--t);
}
.dd-item:hover { background: var(--neutral-bg); color: var(--text); }
.dd-item.is-active { color: var(--brand-2); background: rgba(255,90,31,.1); }
.dd-item svg { width: 16px; height: 16px; flex-shrink: 0; }
.dd-item.danger { color: var(--danger); }
.dd-item.danger:hover { background: var(--danger-bg); }
.dd-sep { height: 1px; background: var(--border); margin: var(--s-2) 0; }
.dd-label { padding: var(--s-2) var(--s-3) 4px; font-size: 10px; letter-spacing: .1em; text-transform: uppercase; color: var(--text-3); font-weight: var(--fw-bold); }

/* ==========================  MODAL  ========================== */
.modal-backdrop {
  position: fixed; inset: 0; z-index: var(--z-modal);
  background: var(--overlay); backdrop-filter: blur(6px);
  display: flex; align-items: center; justify-content: center; padding: var(--s-4);
  animation: fadeIn var(--t) both; overflow-y: auto;
}
.modal {
  width: 100%; max-width: 520px; margin: auto;
  background: var(--card); border: 1px solid var(--border-strong);
  border-radius: var(--r-lg); box-shadow: var(--sh-lg);
  animation: scaleIn var(--t-slow) both; overflow: hidden;
}
.modal-lg { max-width: 780px; }
.modal-xl { max-width: 1040px; }
.modal-head {
  display: flex; align-items: flex-start; justify-content: space-between; gap: var(--s-3);
  padding: var(--s-5); border-bottom: 1px solid var(--border);
}
.modal-head h3 { font-size: var(--fs-h3); }
.modal-head .sub { font-size: var(--fs-xs); color: var(--text-3); margin-top: 3px; }
.modal-body { padding: var(--s-5); max-height: min(70vh, 700px); overflow-y: auto; }
.modal-foot { padding: var(--s-4) var(--s-5); border-top: 1px solid var(--border); display: flex; gap: var(--s-3); justify-content: flex-end; flex-wrap: wrap; }

/* ==========================  DRAWER  ========================== */
.drawer-backdrop {
  position: fixed; inset: 0; z-index: var(--z-drawer);
  background: var(--overlay); backdrop-filter: blur(4px); animation: fadeIn var(--t) both;
}
.drawer {
  position: fixed; top: 0; bottom: 0; inset-inline-end: 0; z-index: calc(var(--z-drawer) + 1);
  width: min(420px, 100%); background: var(--card);
  border-inline-start: 1px solid var(--border-strong);
  display: flex; flex-direction: column;
  animation: drawerIn var(--t-slow) both; box-shadow: var(--sh-lg);
}
.drawer.from-start { inset-inline-end: auto; inset-inline-start: 0; border-inline-start: 0; border-inline-end: 1px solid var(--border-strong); animation-name: drawerInStart; }
@keyframes drawerIn { from { transform: translateX(var(--drawer-x, 100%)); } to { transform: none; } }
@keyframes drawerInStart { from { transform: translateX(var(--drawer-x-start, -100%)); } to { transform: none; } }
html[dir="rtl"] { --drawer-x: -100%; --drawer-x-start: 100%; }
html[dir="ltr"] { --drawer-x: 100%; --drawer-x-start: -100%; }
.drawer-head { padding: var(--s-4) var(--s-5); border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; gap: var(--s-3); flex-shrink: 0; }
.drawer-body { flex: 1; overflow-y: auto; padding: var(--s-5); }
.drawer-foot { padding: var(--s-5); border-top: 1px solid var(--border); background: var(--card-2); flex-shrink: 0; }

/* شيت سفلي للجوال */
@media (max-width: 767px) {
  .drawer.as-sheet {
    inset: auto 0 0 0; width: 100%; height: min(88vh, 720px);
    border-radius: var(--r-lg) var(--r-lg) 0 0; border: 1px solid var(--border-strong);
    animation: sheetIn var(--t-slow) both;
  }
  @keyframes sheetIn { from { transform: translateY(100%); } to { transform: none; } }
}

/* ==========================  TOAST  ========================== */
.toast-wrap {
  position: fixed; bottom: var(--s-5); inset-inline-end: var(--s-5); z-index: var(--z-toast);
  display: flex; flex-direction: column; gap: var(--s-2); pointer-events: none; max-width: 380px;
}
@media (max-width: 640px) { .toast-wrap { inset-inline: var(--s-3); bottom: calc(var(--s-3) + 64px); max-width: none; } }
.toast {
  display: flex; align-items: flex-start; gap: var(--s-3);
  padding: var(--s-3) var(--s-4);
  background: var(--card-2); border: 1px solid var(--border-strong);
  border-radius: var(--r-sm); box-shadow: var(--sh-lg);
  animation: toastIn var(--t-slow) both; pointer-events: all;
  font-size: var(--fs-sm); position: relative; overflow: hidden;
}
@keyframes toastIn { from { opacity: 0; transform: translateY(12px) scale(.97); } to { opacity: 1; transform: none; } }
.toast.is-out { animation: fadeIn var(--t) reverse both; }
.toast::before { content: ""; position: absolute; inset-block: 0; inset-inline-start: 0; width: 3px; background: var(--brand-1); }
.toast.success::before { background: var(--success); }
.toast.error::before { background: var(--danger); }
.toast.warning::before { background: var(--warning); }
.toast.info::before { background: var(--info); }
.toast-icon { flex-shrink: 0; margin-top: 2px; }
.toast-icon svg { width: 17px; height: 17px; }
.toast.success .toast-icon { color: var(--success); }
.toast.error .toast-icon { color: var(--danger); }
.toast.warning .toast-icon { color: var(--warning); }
.toast.info .toast-icon { color: var(--info); }
.toast-title { font-weight: var(--fw-semibold); color: var(--text); }
.toast-msg { font-size: var(--fs-xs); color: var(--text-2); }
.toast-close { color: var(--text-3); margin-inline-start: auto; }
.toast-close:hover { color: var(--text); }
.toast-close svg { width: 15px; height: 15px; }

/* ==========================  TABLE  ========================== */
.table-wrap { overflow-x: auto; border-radius: var(--r-md); border: 1px solid var(--border); background: var(--card); }
.table { width: 100%; min-width: 640px; font-size: var(--fs-sm); }
.table thead th {
  text-align: start; padding: var(--s-3) var(--s-4);
  font-size: var(--fs-caption); font-weight: var(--fw-bold); color: var(--text-3);
  text-transform: uppercase; letter-spacing: .06em;
  background: var(--card-2); border-bottom: 1px solid var(--border); white-space: nowrap;
  position: sticky; top: 0; z-index: 2;
}
.table tbody td { padding: var(--s-3) var(--s-4); border-bottom: 1px solid var(--border); color: var(--text-2); vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr { transition: background var(--t); }
.table tbody tr:hover { background: rgba(255,255,255,.025); }
.table tbody tr.is-selected { background: rgba(255,90,31,.07); }
.table .cell-strong { color: var(--text); font-weight: var(--fw-semibold); }
.table .cell-actions { display: flex; gap: 4px; justify-content: flex-end; }

/* ==========================  PAGINATION  ========================== */
.pagination { display: flex; align-items: center; justify-content: center; gap: var(--s-2); flex-wrap: wrap; }
.page-btn {
  min-width: 38px; height: 38px; padding: 0 var(--s-2);
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: var(--r-xs); border: 1px solid var(--border);
  background: var(--card); color: var(--text-2); font-size: var(--fs-sm);
  transition: all var(--t);
}
.page-btn:hover:not([disabled]) { border-color: var(--border-accent); color: var(--text); }
.page-btn.is-active { background: var(--brand-grad); color: #14100c; border-color: transparent; font-weight: var(--fw-bold); }
.page-btn[disabled] { opacity: .35; pointer-events: none; }
.page-btn svg { width: 15px; height: 15px; }
html[dir="rtl"] .page-btn svg.flip { transform: scaleX(-1); }

/* ==========================  SKELETON  ========================== */
.sk { position: relative; overflow: hidden; background: var(--card-2); border-radius: var(--r-xs); }
.sk::after {
  content: ""; position: absolute; inset: 0; transform: translateX(-100%);
  background: linear-gradient(90deg, transparent, rgba(255,255,255,.055), transparent);
  animation: shimmer 1.4s infinite;
}
.sk-text { height: 11px; margin-bottom: 8px; }
.sk-title { height: 15px; width: 70%; margin-bottom: 10px; }
.sk-card { border-radius: var(--r-md); border: 1px solid var(--border); background: var(--card); overflow: hidden; }
.sk-media { aspect-ratio: 4/3; background: var(--card-2); }

.spinner {
  width: 18px; height: 18px; border-radius: 50%;
  border: 2px solid rgba(255,255,255,.2); border-top-color: var(--brand-2);
  animation: spin .7s linear infinite; display: inline-block;
}
.spinner-lg { width: 34px; height: 34px; border-width: 3px; }
.loading-center { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: var(--s-3); padding: var(--s-16) 0; color: var(--text-3); }

/* ==========================  EMPTY / ERROR STATES  ========================== */
.empty {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center; padding: var(--s-12) var(--s-5); gap: var(--s-3);
}
.empty-icon {
  width: 74px; height: 74px; border-radius: var(--r-lg);
  background: var(--card-2); border: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center; color: var(--text-3);
  margin-bottom: var(--s-2);
}
.empty-icon svg { width: 32px; height: 32px; }
.empty h3 { font-size: var(--fs-h3); }
.empty p { color: var(--text-3); font-size: var(--fs-sm); max-width: 46ch; }

/* ==========================  ALERT  ========================== */
.alert {
  display: flex; gap: var(--s-3); padding: var(--s-3) var(--s-4);
  border-radius: var(--r-sm); border: 1px solid var(--border);
  background: var(--card-2); font-size: var(--fs-sm); align-items: flex-start;
}
.alert svg { width: 18px; height: 18px; flex-shrink: 0; margin-top: 2px; }
.alert-title { font-weight: var(--fw-semibold); color: var(--text); display: block; margin-bottom: 2px; }
.alert-info { background: var(--info-bg); border-color: rgba(255,179,111,.25); color: var(--info); }
.alert-success { background: var(--success-bg); border-color: rgba(46,204,130,.25); color: var(--success); }
.alert-warning { background: var(--warning-bg); border-color: rgba(255,176,32,.25); color: var(--warning); }
.alert-danger { background: var(--danger-bg); border-color: rgba(255,77,77,.25); color: var(--danger); }
.alert p, .alert .alert-text { color: inherit; opacity: .92; margin: 0; }

/* ==========================  TOOLTIP  ========================== */
[data-tip] { position: relative; }
[data-tip]::after {
  content: attr(data-tip); position: absolute; bottom: calc(100% + 8px); left: 50%;
  transform: translateX(-50%) translateY(4px);
  background: var(--card-3); color: var(--text); border: 1px solid var(--border-strong);
  padding: 5px 10px; border-radius: var(--r-xs); font-size: var(--fs-caption);
  white-space: nowrap; opacity: 0; pointer-events: none; z-index: 90;
  transition: opacity var(--t), transform var(--t); box-shadow: var(--sh-md);
}
[data-tip]:hover::after { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ==========================  BREADCRUMBS  ========================== */
.crumbs { display: flex; align-items: center; gap: var(--s-2); font-size: var(--fs-xs); color: var(--text-3); flex-wrap: wrap; }
.crumbs a:hover { color: var(--brand-2); }
.crumbs .sep { opacity: .5; }
.crumbs .sep svg { width: 13px; height: 13px; }
html[dir="rtl"] .crumbs .sep svg { transform: scaleX(-1); }
.crumbs .current { color: var(--text-2); }

/* ==========================  PROGRESS  ========================== */
.progress { height: 6px; border-radius: 999px; background: var(--card-3); overflow: hidden; }
.progress-bar { height: 100%; border-radius: 999px; background: var(--brand-grad); transition: width var(--t-slow); }
.progress.thin { height: 4px; }

/* ==========================  STAT TILE  ========================== */
.stat {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--r-md);
  padding: var(--s-4); display: flex; flex-direction: column; gap: var(--s-2);
  position: relative; overflow: hidden; transition: border-color var(--t);
}
.stat:hover { border-color: var(--border-strong); }
.stat-head { display: flex; align-items: center; justify-content: space-between; gap: var(--s-2); }
.stat-label { font-size: var(--fs-caption); color: var(--text-3); font-weight: var(--fw-medium); }
.stat-icon {
  width: 34px; height: 34px; border-radius: var(--r-xs);
  display: flex; align-items: center; justify-content: center;
  background: var(--neutral-bg); color: var(--text-2); flex-shrink: 0;
}
.stat-icon svg { width: 17px; height: 17px; }
.stat-value { font-size: 1.5rem; font-weight: var(--fw-black); letter-spacing: -.02em; line-height: 1.1; }
.stat-delta { display: inline-flex; align-items: center; gap: 3px; font-size: var(--fs-caption); font-weight: var(--fw-semibold); }
.stat-delta svg { width: 13px; height: 13px; }
.stat-delta.up { color: var(--success); }
.stat-delta.down { color: var(--danger); }
.stat-foot { font-size: var(--fs-caption); color: var(--text-3); display: flex; align-items: center; gap: var(--s-2); }

/* ==========================  CHARTS  ========================== */
.chart { width: 100%; overflow: hidden; }
.chart svg { width: 100%; height: auto; display: block; overflow: visible; }
.chart-legend { display: flex; flex-wrap: wrap; gap: var(--s-3); margin-top: var(--s-3); font-size: var(--fs-caption); color: var(--text-2); }
.chart-legend .li { display: inline-flex; align-items: center; gap: 6px; }
.chart-legend .sw { width: 9px; height: 9px; border-radius: 3px; }
.chart-bar-track { flex: 1; height: 7px; border-radius: 999px; background: var(--card-3); overflow: hidden; }
.chart-bar-fill { height: 100%; border-radius: 999px; }

/* ==========================  KEY REVEAL  ========================== */
.keybox {
  display: flex; align-items: center; gap: var(--s-3); flex-wrap: wrap;
  padding: var(--s-3) var(--s-4); border-radius: var(--r-sm);
  background: var(--bg-2); border: 1px dashed var(--border-strong);
  font-family: var(--font-mono); font-size: var(--fs-sm); letter-spacing: .12em;
  direction: ltr; text-align: left;
}
.keybox.is-hidden { color: var(--text-3); }
.keybox.is-revealed { border-style: solid; border-color: var(--border-accent); background: rgba(255,90,31,.06); color: var(--text); }
.keybox .key-value { flex: 1; min-width: 180px; user-select: all; word-break: break-all; }

/* ==========================  MISC  ========================== */
.divider-text { display: flex; align-items: center; gap: var(--s-3); color: var(--text-3); font-size: var(--fs-xs); }
.divider-text::before, .divider-text::after { content: ""; flex: 1; height: 1px; background: var(--border); }

.timeline { position: relative; padding-inline-start: var(--s-6); }
.timeline::before { content: ""; position: absolute; inset-block: 6px; inset-inline-start: 7px; width: 2px; background: var(--border); }
.tl-item { position: relative; padding-bottom: var(--s-5); }
.tl-item:last-child { padding-bottom: 0; }
.tl-dot {
  position: absolute; inset-inline-start: calc(var(--s-6) * -1 + 1px); top: 3px;
  width: 14px; height: 14px; border-radius: 50%;
  background: var(--card-3); border: 2px solid var(--bg); box-shadow: 0 0 0 2px var(--border);
}
.tl-item.done .tl-dot { background: var(--success); box-shadow: 0 0 0 2px var(--success-bg); }
.tl-item.active .tl-dot { background: var(--brand-1); box-shadow: 0 0 0 2px rgba(255,90,31,.25); }
.tl-item.failed .tl-dot { background: var(--danger); box-shadow: 0 0 0 2px var(--danger-bg); }
.tl-title { font-size: var(--fs-sm); font-weight: var(--fw-semibold); color: var(--text); }
.tl-time { font-size: var(--fs-caption); color: var(--text-3); }

.kbd {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 20px; height: 20px; padding: 0 5px;
  background: var(--card-3); border: 1px solid var(--border-strong);
  border-radius: 5px; font-size: 11px; color: var(--text-3); font-family: var(--font-mono);
}

/* أي حاوية مصغّرة تعرض غلافاً مولّداً */
.thumb { overflow: hidden; }
.thumb > svg, .thumb > img { width: 100%; height: 100%; object-fit: cover; display: block; }
.sp-thumb > svg, .avatar > svg { width: 100%; height: 100%; display: block; }

/* بطاقات ضيقة (جوال / شبكة كثيفة) — تصغير متناسق يمنع الازدحام */
@media (max-width: 480px) {
  .pcard-body { padding: 10px 12px 12px; gap: 7px; }
  .pcard-title { font-size: var(--fs-xs); min-height: 2.5em; }
  .price-now { font-size: .95rem; }
  .price-old { display: none; }
  .pcard-rate { display: none; }
  .pcard-foot { padding-top: 10px; }
}

/* على الأجهزة اللمسية: زر الإضافة السريعة أيقونة فقط حتى لا يغطّي شارة الخصم */
@media (hover: none), (max-width: 640px) {
  .pcard-quick .qa-label { display: none; }
  .pcard-quick .btn { width: 34px; padding: 0; border-radius: 50%; }
}

/* زر داخل الحقل (إظهار كلمة المرور) — لا يتداخل مع رسالة الخطأ */
.input-group { position: relative; display: flex; align-items: center; width: 100%; }
.input-group > .input { width: 100%; }
.input.has-affix { padding-inline-end: 42px; }
.input-affix {
  position: absolute; inset-inline-end: 4px; top: 50%; transform: translateY(-50%);
  width: 34px; height: 34px; border-radius: var(--r-xs);
  display: flex; align-items: center; justify-content: center;
  color: var(--text-3); background: transparent; border: 0;
  transition: color var(--t), background var(--t);
}
.input-affix:hover { color: var(--text); background: var(--neutral-bg); }
.input-affix svg { width: 17px; height: 17px; }
/* رسالة الخطأ تأخذ سطراً كاملاً دائماً */
.field-error { width: 100%; flex-basis: 100%; }

/* ==========================  COLOR PICKER  ========================== */
.color-field { display: flex; align-items: center; gap: var(--s-2); }
.color-swatch {
  appearance: none; -webkit-appearance: none;
  width: 46px; height: 42px; flex-shrink: 0; padding: 3px;
  background: var(--card-2); border: 1px solid var(--border);
  border-radius: var(--r-sm); cursor: pointer;
  transition: border-color var(--t);
}
.color-swatch:hover { border-color: var(--border-strong); }
.color-swatch::-webkit-color-swatch-wrapper { padding: 0; }
.color-swatch::-webkit-color-swatch { border: 0; border-radius: 7px; }
.color-swatch::-moz-color-swatch { border: 0; border-radius: 7px; }
.color-field [data-color-name] { font-size: var(--fs-sm); font-weight: 600; color: var(--text); }
.color-field .color-hex {
  flex: 0 0 92px; width: 92px; min-width: 0; text-align: center;
  text-transform: lowercase; font-size: var(--fs-xs); color: var(--text-3);
  padding-inline: var(--s-2);
}

.swatch-row {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(28px, 1fr));
  gap: 6px; margin-top: 8px;
}
.swatch {
  width: 26px; height: 26px; border-radius: 8px; flex-shrink: 0;
  border: 2px solid transparent; box-shadow: inset 0 0 0 1px rgba(255,255,255,.12);
  transition: transform var(--t-fast), border-color var(--t);
}
.swatch:hover { transform: scale(1.12); }
.swatch.is-active { border-color: var(--text); transform: scale(1.12); }

/* ==========================  ICON PICKER  ========================== */
.icon-trigger {
  display: flex; align-items: center; gap: var(--s-3); width: 100%;
  height: 42px; padding: 0 var(--s-3);
  background: var(--card-2); border: 1px solid var(--border);
  border-radius: var(--r-sm); color: var(--text);
  transition: border-color var(--t), background var(--t);
}
.icon-trigger:hover { border-color: var(--border-strong); }
.icon-trigger.is-open { border-color: var(--brand-1); background: var(--card-3); }
.icon-trigger > svg:last-child { width: 15px; height: 15px; color: var(--text-3); transition: transform var(--t); }
.icon-trigger.is-open > svg:last-child { transform: rotate(180deg); }
.icon-trigger-preview {
  display: flex; align-items: center; justify-content: center;
  width: 30px; height: 30px; flex-shrink: 0; border-radius: 8px;
  background: var(--brand-grad-soft); border: 1px solid var(--border-accent); color: var(--brand-2);
}
.icon-trigger-preview svg { width: 17px; height: 17px; }

.icon-picker {
  margin-top: var(--s-2); padding: var(--s-3);
  background: var(--card-2); border: 1px solid var(--border-strong);
  border-radius: var(--r-sm); animation: fadeIn var(--t) both;
}
.icon-search { height: 38px; margin-bottom: 10px; }
.icon-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(84px, 1fr));
  gap: 6px; max-height: 236px; overflow-y: auto; padding-inline-end: 4px;
}
.icon-cell {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 5px; min-height: 62px; padding: 6px 4px; border-radius: 8px;
  background: var(--card-3); border: 1px solid transparent; color: var(--text-2);
  transition: all var(--t-fast);
}
.icon-cell svg { width: 18px; height: 18px; flex-shrink: 0; }
.icon-cell-name {
  font-size: 10px; line-height: 1.25; text-align: center; color: var(--text-3);
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden; word-break: break-word;
}
.icon-cell.is-active .icon-cell-name,
.icon-cell:hover .icon-cell-name { color: inherit; }
.icon-cell:hover { color: var(--text); border-color: var(--border-strong); transform: translateY(-2px); }
.icon-cell.is-active { background: rgba(255,90,31,.16); border-color: var(--brand-1); color: var(--brand-2); }

/* قائمة نصية بنقاط — لصناديق الإرشاد داخل اللوحة */
.list-plain li { position: relative; padding-inline-start: 16px; line-height: 1.7; }
.list-plain li::before {
  content: ''; position: absolute; inset-inline-start: 0; top: 10px;
  width: 5px; height: 5px; border-radius: 50%; background: var(--brand-1);
}
