/* ============================================
   TROF System v2.0 — Components (Part 1/3)
   ============================================
   Buttons, Inputs, Cards, Badges, Avatars
   يعتمد على tokens.css و base.css و layout.css
   ============================================ */

/* ==========================================
   🔘 BUTTONS — الأزرار
   ========================================== */

.btn {
  /* Layout */
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--s-2);

  /* Size */
  min-height: var(--btn-h-md);
  padding: 10px var(--btn-px-md);

  /* Typography */
  font-family: inherit;
  font-size: var(--fs-sm);
  font-weight: var(--fw-bold);
  line-height: 1;
  text-decoration: none;
  white-space: nowrap;

  /* Appearance */
  border: 1px solid transparent;
  border-radius: var(--r-md);
  background: transparent;
  color: inherit;
  cursor: pointer;
  user-select: none;
  position: relative;
  overflow: hidden;

  /* Transitions */
  transition: var(--tr-base);

  /* Reset */
  -webkit-appearance: none;
  appearance: none;
}

.btn svg,
.btn .icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

.btn:disabled,
.btn.disabled {
  opacity: 0.5;
  cursor: not-allowed;
  pointer-events: none;
}

.btn:focus-visible {
  outline: var(--focus-ring-width) solid var(--focus-ring-color);
  outline-offset: var(--focus-ring-offset);
}

/* ========== Button Sizes ========== */

.btn-xs {
  min-height: 28px;
  padding: 4px 10px;
  font-size: var(--fs-2xs);
  border-radius: var(--r-sm);
}
.btn-xs svg { width: 14px; height: 14px; }

.btn-sm {
  min-height: var(--btn-h-sm);
  padding: 6px 12px;
  font-size: var(--fs-xs);
  border-radius: var(--r-sm);
}
.btn-sm svg { width: 16px; height: 16px; }

.btn-md {
  /* default */
}

.btn-lg {
  min-height: var(--btn-h-lg);
  padding: 12px var(--btn-px-lg);
  font-size: var(--fs-base);
  border-radius: var(--r-lg);
}
.btn-lg svg { width: 20px; height: 20px; }

.btn-xl {
  min-height: var(--btn-h-xl);
  padding: 16px 36px;
  font-size: var(--fs-lg);
  border-radius: var(--r-lg);
}
.btn-xl svg { width: 22px; height: 22px; }

/* Full width */
.btn-block,
.btn-full {
  width: 100%;
}

/* Pill */
.btn-pill {
  border-radius: var(--r-full);
}

/* ========== Button Variants ========== */

/* Primary — Gold */
.btn-primary {
  background: var(--g-gold);
  color: var(--c-text-inv);
  box-shadow: 0 4px 16px -4px rgba(242, 194, 60, 0.4);
}

.btn-primary:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px -4px rgba(242, 194, 60, 0.5);
}

.btn-primary:active:not(:disabled) {
  transform: translateY(0);
  box-shadow: 0 2px 8px -2px rgba(242, 194, 60, 0.4);
}

/* Secondary — Surface */
.btn-secondary {
  background: var(--c-surface-2);
  color: var(--c-text);
  border-color: var(--c-border);
}

.btn-secondary:hover:not(:disabled) {
  background: var(--c-surface-3);
  border-color: var(--c-border-hi);
}

/* Ghost — transparent */
.btn-ghost {
  background: transparent;
  color: var(--c-text-mut);
}

.btn-ghost:hover:not(:disabled) {
  background: var(--c-surface-2);
  color: var(--c-text);
}

/* Outline */
.btn-outline {
  background: transparent;
  color: var(--c-primary-400);
  border-color: var(--c-primary-500);
}

.btn-outline:hover:not(:disabled) {
  background: var(--c-primary-500);
  color: var(--c-text-inv);
}

/* Danger */
.btn-danger {
  background: var(--c-danger);
  color: #ffffff;
}

.btn-danger:hover:not(:disabled) {
  background: var(--c-danger-lo);
  transform: translateY(-2px);
  box-shadow: var(--sh-danger);
}

/* Success */
.btn-success {
  background: var(--c-success);
  color: #ffffff;
}

.btn-success:hover:not(:disabled) {
  background: var(--c-success-lo);
  transform: translateY(-2px);
  box-shadow: var(--sh-success);
}

/* Warning */
.btn-warning {
  background: var(--c-warning);
  color: var(--c-text-inv);
}

/* Info */
.btn-info {
  background: var(--c-info);
  color: #ffffff;
}

/* Premium */
.btn-premium {
  background: var(--g-premium-btn);
  color: #1a0a28;
  box-shadow: var(--sh-premium);
}

.btn-premium:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px -4px rgba(168, 85, 247, 0.6);
}



/* Discord */
.btn-discord {
  background: var(--c-discord);
  color: #ffffff;
}

.btn-discord:hover:not(:disabled) {
  background: var(--c-discord-lo);
  transform: translateY(-2px);
}

/* Link */
.btn-link {
  background: transparent;
  color: var(--c-primary-400);
  padding-inline: var(--s-2);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.btn-link:hover:not(:disabled) {
  color: var(--c-primary-200);
}

/* ========== Icon Button ========== */

.btn-icon {
  width: var(--btn-h-md);
  height: var(--btn-h-md);
  padding: 0;
  border-radius: var(--r-md);
}

.btn-icon.btn-xs {
  width: 28px;
  height: 28px;
  border-radius: var(--r-sm);
}

.btn-icon.btn-sm {
  width: var(--btn-h-sm);
  height: var(--btn-h-sm);
  border-radius: var(--r-sm);
}

.btn-icon.btn-lg {
  width: var(--btn-h-lg);
  height: var(--btn-h-lg);
}

.btn-icon.btn-circle {
  border-radius: var(--r-circle);
}

/* Icon only with rounded */
.btn-icon-rounded {
  border-radius: var(--r-circle);
  width: var(--btn-h-md);
  height: var(--btn-h-md);
  padding: 0;
}

/* ========== Loading State ========== */

.btn.loading {
  color: transparent !important;
  pointer-events: none;
  position: relative;
}

.btn.loading::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 18px;
  height: 18px;
  margin: -9px 0 0 -9px;
  border: 2px solid currentColor;
  border-top-color: transparent;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  color: var(--c-text-inv);
}

.btn.loading.btn-ghost::after,
.btn.loading.btn-secondary::after,
.btn.loading.btn-outline::after {
  color: var(--c-primary-500);
}

/* ========== Button Group ========== */

.btn-group {
  display: inline-flex;
  align-items: center;
  border-radius: var(--r-md);
  overflow: hidden;
  border: 1px solid var(--c-border);
  background: var(--c-surface);
}

.btn-group .btn {
  border-radius: 0;
  border: none;
  border-inline-end: 1px solid var(--c-border);
  background: transparent;
  color: var(--c-text-mut);
}

.btn-group .btn:last-child {
  border-inline-end: none;
}

.btn-group .btn.active {
  background: var(--c-primary-500);
  color: var(--c-text-inv);
}

.btn-group .btn:hover:not(.active):not(:disabled) {
  background: var(--c-surface-2);
  color: var(--c-text);
}

/* ==========================================
   📝 INPUTS — الحقول
   ========================================== */

.input,
.select,
.textarea {
  /* Layout */
  display: block;
  width: 100%;
  min-height: var(--input-h-md);
  padding: 10px var(--input-px);

  /* Typography */
  font-family: inherit;
  font-size: var(--fs-sm);
  font-weight: var(--fw-normal);
  line-height: var(--lh-normal);
  color: var(--c-text);

  /* Appearance */
  background: var(--c-bg-alt);
  border: 1px solid var(--c-border);
  border-radius: var(--r-md);

  /* Transitions */
  transition: var(--tr-base);

  /* Reset */
  -webkit-appearance: none;
  appearance: none;
  outline: none;
}

.input:hover,
.select:hover,
.textarea:hover {
  border-color: var(--c-border-hi);
}

.input:focus,
.select:focus,
.textarea:focus {
  border-color: var(--c-primary-500);
  box-shadow: 0 0 0 3px rgba(242, 194, 60, 0.15);
  background: var(--c-surface);
}

.input:disabled,
.select:disabled,
.textarea:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.input::placeholder,
.textarea::placeholder {
  color: var(--c-text-dim);
}

/* Sizes */
.input-sm,
.select-sm {
  min-height: var(--input-h-sm);
  padding: 6px 10px;
  font-size: var(--fs-xs);
}

.input-lg,
.select-lg {
  min-height: var(--input-h-lg);
  padding: 14px var(--s-5);
  font-size: var(--fs-base);
}

/* Textarea */
.textarea {
  min-height: 100px;
  resize: vertical;
  line-height: var(--lh-relaxed);
  padding: 12px var(--input-px);
}

/* Select */
.select {
  cursor: pointer;
  padding-inline-end: 40px;
  background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23a89f88' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 16px;
  padding-right: 40px;
}

html[dir="rtl"] .select {
  background-position: left 12px center;
  padding-right: var(--input-px);
  padding-left: 40px;
}

/* ========== Input States ========== */

.input.error,
.select.error,
.textarea.error {
  border-color: var(--c-danger);
  box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.15);
}

.input.success,
.select.success,
.textarea.success {
  border-color: var(--c-success);
  box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.15);
}

/* ========== Input Group ========== */

.input-group {
  display: flex;
  align-items: stretch;
  border-radius: var(--r-md);
  overflow: hidden;
  border: 1px solid var(--c-border);
  background: var(--c-bg-alt);
  transition: var(--tr-base);
}

.input-group:focus-within {
  border-color: var(--c-primary-500);
  box-shadow: 0 0 0 3px rgba(242, 194, 60, 0.15);
}

.input-group .input,
.input-group .select {
  border: none;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}

.input-group .input:focus,
.input-group .select:focus {
  box-shadow: none;
}

.input-group-addon {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 var(--s-4);
  background: var(--c-surface-2);
  color: var(--c-text-mut);
  font-size: var(--fs-sm);
  font-weight: var(--fw-bold);
  border-inline-end: 1px solid var(--c-border);
  flex-shrink: 0;
}

.input-group-addon:last-child {
  border-inline-end: none;
  border-inline-start: 1px solid var(--c-border);
}

.input-group .btn {
  border-radius: 0;
  border: none;
  background: var(--c-surface-2);
  color: var(--c-text);
  min-height: 100%;
}

.input-group .btn:hover {
  background: var(--c-surface-3);
}

/* ========== Input with Icon ========== */

.input-wrapper {
  position: relative;
  width: 100%;
}

.input-wrapper .input {
  padding-inline-start: 40px;
}

.input-icon {
  position: absolute;
  top: 50%;
  inset-inline-start: 12px;
  transform: translateY(-50%);
  color: var(--c-text-mut);
  pointer-events: none;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--fs-base);
}

.input-icon-end {
  inset-inline-start: auto;
  inset-inline-end: 12px;
}

.input-wrapper .input-icon-end ~ .input,
.input-wrapper .input.has-icon-end {
  padding-inline-end: 40px;
}

/* ========== Form Field ========== */

.field {
  display: flex;
  flex-direction: column;
  gap: var(--s-2);
  width: 100%;
}

.field-label {
  font-size: var(--fs-sm);
  font-weight: var(--fw-bold);
  color: var(--c-text);
  display: flex;
  align-items: center;
  gap: var(--s-2);
}

.field-label .required {
  color: var(--c-danger);
  font-weight: var(--fw-black);
}

.field-label .optional {
  font-size: var(--fs-xs);
  color: var(--c-text-dim);
  font-weight: var(--fw-normal);
}

.field-hint {
  font-size: var(--fs-xs);
  color: var(--c-text-mut);
  line-height: var(--lh-relaxed);
}

.field-error {
  font-size: var(--fs-xs);
  color: var(--c-danger);
  font-weight: var(--fw-medium);
  display: flex;
  align-items: center;
  gap: var(--s-1);
}

.field-success {
  font-size: var(--fs-xs);
  color: var(--c-success);
  font-weight: var(--fw-medium);
}

/* ========== Switch ========== */

.switch {
  position: relative;
  display: inline-block;
  width: 46px;
  height: 26px;
  flex-shrink: 0;
  cursor: pointer;
}

.switch input {
  position: absolute;
  opacity: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  cursor: pointer;
  z-index: 2;
}

.switch-track {
  position: absolute;
  inset: 0;
  background: var(--c-surface-3);
  border: 1px solid var(--c-border);
  border-radius: var(--r-full);
  transition: all var(--t-base) var(--ease);
}

.switch-track::before {
  content: '';
  position: absolute;
  top: 2px;
  inset-inline-start: 2px;
  width: 20px;
  height: 20px;
  background: var(--c-text-mut);
  border-radius: var(--r-circle);
  transition: all var(--t-base) var(--ease);
  box-shadow: var(--sh-sm);
}

.switch input:checked + .switch-track {
  background: var(--c-primary-500);
  border-color: var(--c-primary-500);
}

.switch input:checked + .switch-track::before {
  background: var(--c-text-inv);
  transform: translateX(20px);
}

html[dir="rtl"] .switch input:checked + .switch-track::before {
  transform: translateX(-20px);
}

.switch input:focus-visible + .switch-track {
  box-shadow: 0 0 0 3px rgba(242, 194, 60, 0.3);
}

.switch input:disabled + .switch-track {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Switch sizes */
.switch-sm {
  width: 36px;
  height: 20px;
}

.switch-sm .switch-track::before {
  width: 14px;
  height: 14px;
}

.switch-sm input:checked + .switch-track::before {
  transform: translateX(16px);
}

html[dir="rtl"] .switch-sm input:checked + .switch-track::before {
  transform: translateX(-16px);
}

.switch-lg {
  width: 56px;
  height: 32px;
}

.switch-lg .switch-track::before {
  width: 26px;
  height: 26px;
}

.switch-lg input:checked + .switch-track::before {
  transform: translateX(24px);
}

html[dir="rtl"] .switch-lg input:checked + .switch-track::before {
  transform: translateX(-24px);
}

/* ========== Checkbox ========== */

.checkbox {
  display: inline-flex;
  align-items: center;
  gap: var(--s-2);
  cursor: pointer;
  user-select: none;
  font-size: var(--fs-sm);
}

.checkbox input[type="checkbox"] {
  position: relative;
  width: 18px;
  height: 18px;
  appearance: none;
  -webkit-appearance: none;
  background: var(--c-bg-alt);
  border: 2px solid var(--c-border);
  border-radius: var(--r-xs);
  cursor: pointer;
  transition: var(--tr-fast);
  flex-shrink: 0;
  margin: 0;
}

.checkbox input[type="checkbox"]:hover {
  border-color: var(--c-border-hi);
}

.checkbox input[type="checkbox"]:checked {
  background: var(--c-primary-500);
  border-color: var(--c-primary-500);
}

.checkbox input[type="checkbox"]:checked::after {
  content: '';
  position: absolute;
  top: 1px;
  left: 4px;
  width: 5px;
  height: 9px;
  border: solid var(--c-text-inv);
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}

.checkbox input[type="checkbox"]:focus-visible {
  box-shadow: 0 0 0 3px rgba(242, 194, 60, 0.3);
}

.checkbox input[type="checkbox"]:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* ========== Radio ========== */

.radio {
  display: inline-flex;
  align-items: center;
  gap: var(--s-2);
  cursor: pointer;
  user-select: none;
  font-size: var(--fs-sm);
}

.radio input[type="radio"] {
  position: relative;
  width: 18px;
  height: 18px;
  appearance: none;
  -webkit-appearance: none;
  background: var(--c-bg-alt);
  border: 2px solid var(--c-border);
  border-radius: var(--r-circle);
  cursor: pointer;
  transition: var(--tr-fast);
  flex-shrink: 0;
  margin: 0;
}

.radio input[type="radio"]:checked {
  border-color: var(--c-primary-500);
  background: var(--c-primary-500);
}

.radio input[type="radio"]:checked::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 6px;
  height: 6px;
  background: var(--c-text-inv);
  border-radius: var(--r-circle);
  transform: translate(-50%, -50%);
}

.radio input[type="radio"]:focus-visible {
  box-shadow: 0 0 0 3px rgba(242, 194, 60, 0.3);
}

/* ========== Range Slider ========== */

.range {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 6px;
  background: var(--c-surface-3);
  border-radius: var(--r-full);
  outline: none;
  cursor: pointer;
}

.range::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 20px;
  height: 20px;
  background: var(--g-gold);
  border-radius: var(--r-circle);
  cursor: pointer;
  border: 2px solid var(--c-bg);
  box-shadow: var(--sh-md);
  transition: var(--tr-fast);
}

.range::-webkit-slider-thumb:hover {
  transform: scale(1.15);
}

.range::-moz-range-thumb {
  width: 20px;
  height: 20px;
  background: var(--c-primary-500);
  border-radius: var(--r-circle);
  cursor: pointer;
  border: 2px solid var(--c-bg);
  box-shadow: var(--sh-md);
}

.range::-moz-range-track {
  background: var(--c-surface-3);
  height: 6px;
  border-radius: var(--r-full);
}

.range::-moz-range-progress {
  background: var(--c-primary-500);
  height: 6px;
  border-radius: var(--r-full);
}

.range:focus {
  box-shadow: 0 0 0 3px rgba(242, 194, 60, 0.2);
  border-radius: var(--r-full);
}

/* ==========================================
   📇 CARDS — البطاقات
   ========================================== */

.card {
  display: flex;
  flex-direction: column;
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--r-lg);
  overflow: hidden;
  transition: var(--tr-base);
  position: relative;
}

.card:hover {
  border-color: var(--c-border-hi);
}

/* Card variants */
.card-hover:hover {
  transform: translateY(-4px);
  box-shadow: var(--sh-lg);
  border-color: var(--c-primary-500);
}

.card-flat {
  box-shadow: none;
  background: var(--c-bg-alt);
}

.card-elevated {
  box-shadow: var(--sh-md);
}

.card-interactive {
  cursor: pointer;
  user-select: none;
}

.card-interactive:hover {
  border-color: var(--c-primary-500);
  transform: translateY(-2px);
  box-shadow: var(--sh-md);
}

.card-interactive:active {
  transform: translateY(0);
}

/* Card sections */
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-4);
  padding: var(--s-5) var(--s-6);
  border-bottom: 1px solid var(--c-border);
  flex-wrap: wrap;
}

.card-title {
  font-size: var(--fs-lg);
  font-weight: var(--fw-bold);
  color: var(--c-text);
  margin: 0;
  display: flex;
  align-items: center;
  gap: var(--s-2);
}

.card-subtitle {
  font-size: var(--fs-sm);
  color: var(--c-text-mut);
  margin-top: 2px;
  font-weight: var(--fw-normal);
}

.card-body {
  padding: var(--s-6);
  flex: 1;
  min-width: 0;
}

.card-footer {
  padding: var(--s-4) var(--s-6);
  border-top: 1px solid var(--c-border);
  background: var(--c-bg-alt);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: var(--s-2);
  flex-wrap: wrap;
}

.card-media {
  width: 100%;
  aspect-ratio: 16 / 9;
  background: var(--c-surface-2);
  overflow: hidden;
}

.card-media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* Card with padding variants */
.card-p-sm .card-body { padding: var(--s-4); }
.card-p-lg .card-body { padding: var(--s-8); }

/* Card no-padding */
.card-flush .card-body { padding: 0; }
.card-flush .card-header { padding-inline: 0; }

/* Card variant colors */
.card-primary { border-color: var(--c-primary-500); }
.card-primary::before {
  content: '';
  position: absolute;
  inset: 0 0 auto 0;
  height: 3px;
  background: var(--g-gold);
}

.card-premium { border-color: var(--c-premium); }
.card-premium::before {
  content: '';
  position: absolute;
  inset: 0 0 auto 0;
  height: 3px;
  background: var(--g-premium-h);
}


.card-danger { border-color: var(--c-danger); }

/* Glass card */
.card-glass {
  background: var(--g-glass);
  backdrop-filter: var(--blur-md);
  -webkit-backdrop-filter: var(--blur-md);
}

/* ==========================================
   🏷️ BADGES — الشارات
   ========================================== */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  font-size: var(--fs-2xs);
  font-weight: var(--fw-bold);
  line-height: 1;
  border-radius: var(--r-full);
  white-space: nowrap;
  letter-spacing: var(--ls-wide);
  text-transform: uppercase;
}

.badge svg {
  width: 12px;
  height: 12px;
}

/* Variants */
.badge-primary {
  background: rgba(242, 194, 60, 0.15);
  color: var(--c-primary-300);
  border: 1px solid rgba(242, 194, 60, 0.3);
}

.badge-secondary {
  background: var(--c-surface-2);
  color: var(--c-text-mut);
  border: 1px solid var(--c-border);
}

.badge-success {
  background: var(--c-success-bg);
  color: var(--c-success-hi);
  border: 1px solid var(--c-success-border);
}

.badge-danger {
  background: var(--c-danger-bg);
  color: var(--c-danger-hi);
  border: 1px solid var(--c-danger-border);
}

.badge-warning {
  background: var(--c-warning-bg);
  color: var(--c-warning-hi);
  border: 1px solid var(--c-warning-border);
}

.badge-info {
  background: var(--c-info-bg);
  color: var(--c-info-hi);
  border: 1px solid var(--c-info-border);
}

/* Special badges */
.badge-premium {
  background: var(--g-premium-btn);
  color: #1a0a28;
  border: none;
}


.badge-owner {
  background: linear-gradient(180deg, #ffe9a3, #f2c23c);
  color: #1a1305;
}

/* Badge sizes */
.badge-sm {
  padding: 2px 8px;
  font-size: 0.625rem;
}

.badge-lg {
  padding: 5px 14px;
  font-size: var(--fs-xs);
}

/* Badge dot */
.badge-dot {
  width: 6px;
  height: 6px;
  padding: 0;
  border-radius: var(--r-circle);
  min-width: 6px;
}

.badge-dot.badge-success { background: var(--c-success); border: none; }
.badge-dot.badge-danger { background: var(--c-danger); border: none; }
.badge-dot.badge-warning { background: var(--c-warning); border: none; }
.badge-dot.badge-primary { background: var(--c-primary-500); border: none; }

/* Pulse dot */
.badge-dot.pulse {
  position: relative;
}

.badge-dot.pulse::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: var(--r-circle);
  background: currentColor;
  animation: ping 1.5s cubic-bezier(0, 0, 0.2, 1) infinite;
  opacity: 0.75;
}

/* ==========================================
   👤 AVATARS — الصور الرمزية
   ========================================== */

.avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: var(--img-avatar-md);
  height: var(--img-avatar-md);
  border-radius: var(--r-circle);
  overflow: hidden;
  background: var(--c-surface-3);
  color: var(--c-primary-400);
  font-weight: var(--fw-bold);
  font-size: var(--fs-sm);
  flex-shrink: 0;
  user-select: none;
  position: relative;
}

.avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* Sizes */
.avatar-xs {
  width: 24px;
  height: 24px;
  font-size: var(--fs-2xs);
}

.avatar-sm {
  width: var(--img-avatar-sm);
  height: var(--img-avatar-sm);
  font-size: var(--fs-xs);
}

.avatar-md {
  /* default */
}

.avatar-lg {
  width: var(--img-avatar-lg);
  height: var(--img-avatar-lg);
  font-size: var(--fs-lg);
}

.avatar-xl {
  width: var(--img-avatar-xl);
  height: var(--img-avatar-xl);
  font-size: var(--fs-2xl);
}

.avatar-2xl {
  width: var(--img-avatar-2xl);
  height: var(--img-avatar-2xl);
  font-size: var(--fs-4xl);
}

/* Avatar shapes */
.avatar-square {
  border-radius: var(--r-md);
}

.avatar-rounded {
  border-radius: 30%;
}

/* Avatar ring */
.avatar-ring {
  padding: 2px;
  background: conic-gradient(from 0deg, var(--c-primary-800), var(--c-primary-200), var(--c-primary-800));
}

.avatar-ring img,
.avatar-ring::before {
  border-radius: inherit;
}

.avatar-ring-premium {
  background: var(--g-premium-h);
}


/* Avatar group */
.avatar-group {
  display: flex;
  align-items: center;
}

.avatar-group .avatar {
  border: 2px solid var(--c-bg);
  margin-inline-start: -10px;
  transition: transform var(--t-fast) var(--ease);
}

.avatar-group .avatar:first-child {
  margin-inline-start: 0;
}

.avatar-group .avatar:hover {
  transform: scale(1.1);
  z-index: 2;
  position: relative;
}

/* Avatar with status */
.avatar-status {
  position: relative;
}

.avatar-status::after {
  content: '';
  position: absolute;
  bottom: 0;
  inset-inline-end: 0;
  width: 25%;
  height: 25%;
  min-width: 8px;
  min-height: 8px;
  border-radius: var(--r-circle);
  border: 2px solid var(--c-bg);
}

.avatar-status.online::after { background: var(--c-success); }
.avatar-status.idle::after { background: var(--c-warning); }
.avatar-status.dnd::after { background: var(--c-danger); }
.avatar-status.offline::after { background: var(--c-text-dim); }

/* ==========================================
   📊 PROGRESS — شريط التقدم
   ========================================== */

.progress {
  width: 100%;
  height: 8px;
  background: var(--c-surface-3);
  border-radius: var(--r-full);
  overflow: hidden;
  position: relative;
}

.progress-bar {
  height: 100%;
  background: var(--g-gold);
  border-radius: var(--r-full);
  transition: width var(--t-slow) var(--ease);
  position: relative;
}

.progress-bar::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.3), transparent);
  animation: shimmer 2s infinite;
}

@keyframes shimmer {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(100%); }
}

/* Progress sizes */
.progress-sm { height: 4px; }
.progress-lg { height: 12px; }
.progress-xl { height: 16px; }

/* Progress variants */
.progress-success .progress-bar { background: var(--c-success); }
.progress-danger .progress-bar { background: var(--c-danger); }
.progress-warning .progress-bar { background: var(--c-warning); }
.progress-info .progress-bar { background: var(--c-info); }
.progress-premium .progress-bar { background: var(--g-premium-btn); }

/* Progress with label */
.progress-labeled {
  position: relative;
}

.progress-label {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: var(--fs-2xs);
  font-weight: var(--fw-bold);
  color: var(--c-text);
  text-shadow: 0 0 4px rgba(0, 0, 0, 0.8);
  z-index: 2;
}

/* Circular progress */
.progress-circle {
  position: relative;
  width: 80px;
  height: 80px;
}

.progress-circle svg {
  transform: rotate(-90deg);
  width: 100%;
  height: 100%;
}

.progress-circle-track {
  fill: none;
  stroke: var(--c-surface-3);
  stroke-width: 6;
}

.progress-circle-bar {
  fill: none;
  stroke: var(--c-primary-500);
  stroke-width: 6;
  stroke-linecap: round;
  transition: stroke-dashoffset var(--t-slow) var(--ease);
}

.progress-circle-label {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: var(--fs-lg);
  font-weight: var(--fw-black);
  color: var(--c-primary-400);
}

/* ==========================================
   🎯 DIVIDER — الفواصل
   ========================================== */

.divider {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  color: var(--c-text-dim);
  font-size: var(--fs-xs);
  font-weight: var(--fw-medium);
  text-transform: uppercase;
  letter-spacing: var(--ls-wider);
  margin-block: var(--s-4);
}

.divider::before,
.divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--c-border);
}

.divider-no-text::before,
.divider-no-text::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--c-border);
}

/* Vertical divider */
.divider-vertical {
  width: 1px;
  height: 100%;
  min-height: 20px;
  background: var(--c-border);
  margin-inline: var(--s-3);
  display: inline-block;
}
/* ============================================
   TROF System v2.0 — Components (Part 2/3)
   ============================================
   Tables, Tabs, Dropdowns, Toast, Modal, Skeleton
   ============================================ */

/* ==========================================
   📊 TABLES — الجداول
   ========================================== */

.table-wrapper {
  width: 100%;
  overflow-x: auto;
  border: 1px solid var(--c-border);
  border-radius: var(--r-lg);
  background: var(--c-surface);
}

.table {
  width: 100%;
  border-collapse: collapse;
  border-spacing: 0;
  font-size: var(--fs-sm);
}

.table thead {
  background: var(--c-surface-2);
  border-bottom: 1px solid var(--c-border);
}

.table th {
  padding: var(--s-4) var(--s-5);
  text-align: start;
  font-size: var(--fs-xs);
  font-weight: var(--fw-bold);
  color: var(--c-text-mut);
  text-transform: uppercase;
  letter-spacing: var(--ls-wider);
  white-space: nowrap;
}

.table td {
  padding: var(--s-4) var(--s-5);
  border-top: 1px solid var(--c-border);
  color: var(--c-text);
  vertical-align: middle;
}

.table tbody tr {
  transition: background var(--t-fast) var(--ease);
}

.table tbody tr:hover {
  background: var(--c-surface-2);
}

.table tbody tr:first-child td {
  border-top: 1px solid var(--c-border);
}

/* Table variants */
.table-striped tbody tr:nth-child(even) {
  background: var(--c-surface-2);
}

.table-striped tbody tr:nth-child(even):hover {
  background: var(--c-surface-3);
}

.table-compact th,
.table-compact td {
  padding: var(--s-2) var(--s-4);
}

.table-bordered {
  border: 1px solid var(--c-border);
}

.table-bordered th,
.table-bordered td {
  border: 1px solid var(--c-border);
}

/* Table cell helpers */
.table th.td-actions,
.table td.td-actions {
  width: 1%;
  white-space: nowrap;
  text-align: end;
}

.table .td-check {
  width: 1%;
  padding-inline-end: 0;
}

.table .td-avatar {
  width: 1%;
}

/* Table with avatar cell */
.table-user {
  display: flex;
  align-items: center;
  gap: var(--s-3);
}

.table-user-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.table-user-name {
  font-weight: var(--fw-medium);
  color: var(--c-text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.table-user-sub {
  font-size: var(--fs-xs);
  color: var(--c-text-mut);
}

/* Empty table state */
.table-empty {
  padding: var(--s-16) var(--s-6);
  text-align: center;
  color: var(--c-text-mut);
}

/* Responsive table (cards on mobile) */
@media (max-width: 640px) {
  .table-responsive thead {
    display: none;
  }

  .table-responsive tbody,
  .table-responsive tr,
  .table-responsive td {
    display: block;
    width: 100%;
  }

  .table-responsive tr {
    border-bottom: 1px solid var(--c-border);
    padding: var(--s-3) 0;
  }

  .table-responsive td {
    border: none;
    padding: var(--s-2) var(--s-5);
    text-align: start;
  }

  .table-responsive td::before {
    content: attr(data-label);
    display: block;
    font-size: var(--fs-xs);
    font-weight: var(--fw-bold);
    color: var(--c-text-mut);
    text-transform: uppercase;
    letter-spacing: var(--ls-wider);
    margin-bottom: 4px;
  }
}

/* ==========================================
   📑 TABS — التبويبات
   ========================================== */

.tabs {
  display: flex;
  align-items: center;
  gap: var(--s-1);
  padding: var(--s-1);
  background: var(--c-surface-2);
  border: 1px solid var(--c-border);
  border-radius: var(--r-md);
  overflow-x: auto;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
  width: fit-content;
  max-width: 100%;
}

.tabs::-webkit-scrollbar {
  display: none;
}

.tab {
  display: inline-flex;
  align-items: center;
  gap: var(--s-2);
  padding: var(--s-2) var(--s-4);
  font-family: inherit;
  font-size: var(--fs-sm);
  font-weight: var(--fw-medium);
  color: var(--c-text-mut);
  background: transparent;
  border: none;
  border-radius: var(--r-sm);
  cursor: pointer;
  transition: var(--tr-fast);
  white-space: nowrap;
  user-select: none;
  flex-shrink: 0;
}

.tab:hover {
  color: var(--c-text);
  background: var(--c-surface-3);
}

.tab.active {
  color: var(--c-text-inv);
  background: var(--c-primary-500);
  font-weight: var(--fw-bold);
  box-shadow: 0 2px 8px -2px rgba(242, 194, 60, 0.4);
}

.tab svg {
  width: 16px;
  height: 16px;
}

/* Tabs full width */
.tabs-full {
  width: 100%;
}

.tabs-full .tab {
  flex: 1;
  justify-content: center;
}

/* Underline tabs */
.tabs-underline {
  padding: 0;
  background: transparent;
  border: none;
  border-bottom: 1px solid var(--c-border);
  border-radius: 0;
  gap: var(--s-6);
}

.tabs-underline .tab {
  padding: var(--s-3) 0;
  border-radius: 0;
  background: transparent;
  border-bottom: 2px solid transparent;
  position: relative;
  color: var(--c-text-mut);
}

.tabs-underline .tab:hover {
  background: transparent;
  color: var(--c-text);
}

.tabs-underline .tab.active {
  background: transparent;
  color: var(--c-primary-400);
  border-bottom-color: var(--c-primary-500);
  box-shadow: none;
}

/* Pills tabs */
.tabs-pills {
  background: transparent;
  border: none;
  padding: 0;
  gap: var(--s-2);
}

.tabs-pills .tab {
  border-radius: var(--r-full);
  background: var(--c-surface-2);
  border: 1px solid var(--c-border);
}

.tabs-pills .tab.active {
  background: var(--c-primary-500);
  border-color: var(--c-primary-500);
  color: var(--c-text-inv);
}

/* ==========================================
   📋 DROPDOWN — القوائم المنسدلة
   ========================================== */

.dropdown {
  position: absolute;
  top: calc(100% + 8px);
  inset-inline-end: 0;
  min-width: 220px;
  max-width: 320px;
  background: var(--c-surface-2);
  border: 1px solid var(--c-border);
  border-radius: var(--r-md);
  box-shadow: var(--sh-lg);
  padding: var(--s-2);
  z-index: var(--z-dropdown);
  opacity: 0;
  transform: translateY(-8px);
  pointer-events: none;
  transition: opacity var(--t-fast) var(--ease), transform var(--t-fast) var(--ease);
  backdrop-filter: var(--blur-md);
  -webkit-backdrop-filter: var(--blur-md);
}

.dropdown.show,
.dropdown:not([hidden]) {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

/* Dropdown items */
.dropdown-item {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  width: 100%;
  padding: var(--s-3) var(--s-3);
  font-family: inherit;
  font-size: var(--fs-sm);
  font-weight: var(--fw-medium);
  color: var(--c-text);
  background: transparent;
  border: none;
  border-radius: var(--r-sm);
  cursor: pointer;
  transition: var(--tr-fast);
  text-align: start;
  text-decoration: none;
}

.dropdown-item:hover {
  background: var(--c-surface-3);
  color: var(--c-text);
}

.dropdown-item:focus-visible {
  outline: var(--focus-ring-width) solid var(--focus-ring-color);
  outline-offset: 2px;
}

.dropdown-item:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.dropdown-item svg,
.dropdown-item .icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  color: var(--c-text-mut);
}

.dropdown-item.danger {
  color: var(--c-danger);
}

.dropdown-item.danger:hover {
  background: var(--c-danger-bg);
}

.dropdown-item.danger svg {
  color: var(--c-danger);
}

.dropdown-item.active {
  background: var(--c-surface-3);
  color: var(--c-primary-400);
}

.dropdown-item.active::after {
  content: '✓';
  margin-inline-start: auto;
  color: var(--c-primary-500);
  font-weight: var(--fw-black);
}

/* Dropdown divider */
.dropdown-divider {
  height: 1px;
  background: var(--c-border);
  margin: var(--s-2) 0;
}

/* Dropdown header */
.dropdown-header {
  padding: var(--s-2) var(--s-3);
  font-size: var(--fs-2xs);
  font-weight: var(--fw-bold);
  color: var(--c-text-dim);
  text-transform: uppercase;
  letter-spacing: var(--ls-wider);
}

/* Dropdown positions */
.dropdown-start {
  inset-inline-start: 0;
  inset-inline-end: auto;
}

.dropdown-center {
  inset-inline-start: 50%;
  inset-inline-end: auto;
  transform: translateX(-50%) translateY(-8px);
}

.dropdown-center.show {
  transform: translateX(-50%) translateY(0);
}

/* Dropdown menu (للقوائم الكبيرة) */
.dropdown-lg {
  min-width: 320px;
  max-width: 480px;
}

.dropdown-sm {
  min-width: 160px;
}

/* ==========================================
   📢 TOAST — الإشعارات المنبثقة
   ========================================== */

.toast-container {
  position: fixed;
  top: var(--s-5);
  inset-inline-end: var(--s-5);
  z-index: var(--z-toast);
  display: flex;
  flex-direction: column;
  gap: var(--s-3);
  pointer-events: none;
  max-width: 400px;
  width: calc(100% - var(--s-10));
}

.toast {
  display: flex;
  align-items: flex-start;
  gap: var(--s-3);
  padding: var(--s-4);
  background: var(--c-surface-2);
  border: 1px solid var(--c-border);
  border-inline-start: 4px solid var(--c-primary-500);
  border-radius: var(--r-md);
  box-shadow: var(--sh-lg);
  pointer-events: auto;
  backdrop-filter: var(--blur-md);
  -webkit-backdrop-filter: var(--blur-md);
  animation: toast-in var(--t-base) var(--ease-bounce);
  position: relative;
  overflow: hidden;
  min-width: 300px;
}

.toast.removing {
  animation: toast-out var(--t-base) var(--ease) forwards;
}

/* Toast variants */
.toast-success { border-inline-start-color: var(--c-success); }
.toast-error { border-inline-start-color: var(--c-danger); }
.toast-warning { border-inline-start-color: var(--c-warning); }
.toast-info { border-inline-start-color: var(--c-info); }
.toast-loading { border-inline-start-color: var(--c-primary-500); }

/* Toast icon */
.toast-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  flex-shrink: 0;
  width: 24px;
  height: 24px;
  line-height: 1;
}

.toast-loading .toast-icon {
  animation: spin 1s linear infinite;
}

/* Toast content */
.toast-content {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.toast-title {
  font-size: var(--fs-sm);
  font-weight: var(--fw-bold);
  color: var(--c-text);
  line-height: var(--lh-tight);
}

.toast-msg {
  font-size: var(--fs-sm);
  color: var(--c-text-mut);
  line-height: var(--lh-normal);
  word-wrap: break-word;
}

.toast-action {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  font-size: var(--fs-xs);
  font-weight: var(--fw-bold);
  color: var(--c-primary-400);
  background: transparent;
  border: 1px solid var(--c-primary-500);
  border-radius: var(--r-sm);
  cursor: pointer;
  transition: var(--tr-fast);
  margin-top: var(--s-2);
  width: fit-content;
}

.toast-action:hover {
  background: var(--c-primary-500);
  color: var(--c-text-inv);
}

/* Toast close */
.toast-close {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  padding: 0;
  background: transparent;
  border: none;
  color: var(--c-text-dim);
  cursor: pointer;
  border-radius: var(--r-xs);
  transition: var(--tr-fast);
  flex-shrink: 0;
  font-size: var(--fs-base);
}

.toast-close:hover {
  color: var(--c-text);
  background: var(--c-surface-3);
}

/* Progress bar for auto-dismiss */
.toast-progress {
  position: absolute;
  bottom: 0;
  inset-inline-start: 0;
  height: 2px;
  background: var(--c-primary-500);
  animation: toast-progress linear forwards;
}

/* Animations */
@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateX(100%) scale(0.9);
  }
  to {
    opacity: 1;
    transform: translateX(0) scale(1);
  }
}

@keyframes toast-out {
  from {
    opacity: 1;
    transform: translateX(0) scale(1);
    max-height: 500px;
    margin-bottom: 0;
  }
  to {
    opacity: 0;
    transform: translateX(100%) scale(0.9);
    max-height: 0;
    margin-bottom: -12px;
  }
}

@keyframes toast-progress {
  from { width: 100%; }
  to { width: 0%; }
}

/* Mobile toasts */
@media (max-width: 640px) {
  .toast-container {
    inset-inline: var(--s-3);
    top: var(--s-3);
    max-width: none;
    width: auto;
  }

  .toast {
    min-width: 0;
  }
}

/* ==========================================
   🪟 MODAL — النوافذ المنبثقة
   ========================================== */

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: var(--z-modal-backdrop);
  background: var(--backdrop);
  backdrop-filter: var(--blur-sm);
  -webkit-backdrop-filter: var(--blur-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--s-5);
  animation: fade-in var(--t-base) var(--ease);
  overflow-y: auto;
}

.modal-backdrop.closing {
  animation: fade-out var(--t-base) var(--ease) forwards;
}

.modal {
  position: relative;
  z-index: var(--z-modal);
  width: 100%;
  max-width: 520px;
  max-height: calc(100vh - var(--s-10));
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--r-xl);
  box-shadow: var(--sh-xl);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: modal-in var(--t-slow) var(--ease-bounce);
}

.modal.closing {
  animation: modal-out var(--t-base) var(--ease) forwards;
}

/* Modal sizes */
.modal-sm { max-width: 400px; }
.modal-md { max-width: 520px; }
.modal-lg { max-width: 720px; }
.modal-xl { max-width: 960px; }
.modal-2xl { max-width: 1200px; }
.modal-full {
  max-width: none;
  width: 100%;
  height: 100%;
  max-height: none;
  border-radius: 0;
}

/* Modal header */
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-4);
  padding: var(--s-5) var(--s-6);
  border-bottom: 1px solid var(--c-border);
  flex-shrink: 0;
}

.modal-title {
  font-size: var(--fs-xl);
  font-weight: var(--fw-bold);
  color: var(--c-text);
  margin: 0;
  display: flex;
  align-items: center;
  gap: var(--s-2);
}

.modal-close {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  padding: 0;
  background: transparent;
  border: none;
  color: var(--c-text-mut);
  border-radius: var(--r-sm);
  cursor: pointer;
  transition: var(--tr-fast);
  font-size: var(--fs-lg);
  flex-shrink: 0;
}

.modal-close:hover {
  background: var(--c-surface-3);
  color: var(--c-text);
}

/* Modal body */
.modal-body {
  padding: var(--s-6);
  overflow-y: auto;
  flex: 1;
  min-height: 0;
}

.modal-body::-webkit-scrollbar {
  width: 6px;
}

/* Modal footer */
.modal-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: var(--s-3);
  padding: var(--s-4) var(--s-6);
  border-top: 1px solid var(--c-border);
  background: var(--c-bg-alt);
  flex-shrink: 0;
  flex-wrap: wrap;
}

.modal-footer.space-between {
  justify-content: space-between;
}

/* Animations */
@keyframes modal-in {
  from {
    opacity: 0;
    transform: scale(0.95) translateY(-10px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

@keyframes modal-out {
  from {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
  to {
    opacity: 0;
    transform: scale(0.95) translateY(-10px);
  }
}

/* Mobile modal */
@media (max-width: 640px) {
  .modal-backdrop {
    padding: 0;
    align-items: flex-end;
  }

  .modal {
    max-height: 90vh;
    border-radius: var(--r-xl) var(--r-xl) 0 0;
    animation: modal-slide-up var(--t-slow) var(--ease);
  }

  .modal-header {
    padding: var(--s-4);
  }

  .modal-body {
    padding: var(--s-4);
  }

  .modal-footer {
    padding: var(--s-4);
    padding-bottom: calc(var(--s-4) + env(safe-area-inset-bottom));
  }

  .modal-footer .btn {
    flex: 1;
  }
}

@keyframes modal-slide-up {
  from {
    transform: translateY(100%);
  }
  to {
    transform: translateY(0);
  }
}

/* ==========================================
   💀 SKELETON — هياكل التحميل
   ========================================== */

.skeleton {
  display: block;
  background: var(--g-skeleton);
  background-size: 200% 100%;
  border-radius: var(--r-md);
  animation: skeleton-loading 1.5s ease-in-out infinite;
  pointer-events: none;
  user-select: none;
}

@keyframes skeleton-loading {
  0% {
    background-position: 200% 0;
  }
  100% {
    background-position: -200% 0;
  }
}

/* Skeleton variants */
.skeleton-text {
  height: 14px;
  width: 100%;
  border-radius: var(--r-sm);
  margin-bottom: var(--s-2);
}

.skeleton-text:last-child {
  margin-bottom: 0;
}

.skeleton-title {
  height: 24px;
  width: 60%;
  border-radius: var(--r-sm);
  margin-bottom: var(--s-3);
}

.skeleton-heading {
  height: 32px;
  width: 40%;
  border-radius: var(--r-sm);
  margin-bottom: var(--s-4);
}

.skeleton-avatar {
  width: 48px;
  height: 48px;
  border-radius: var(--r-circle);
  flex-shrink: 0;
}

.skeleton-button {
  height: var(--btn-h-md);
  width: 120px;
  border-radius: var(--r-md);
}

.skeleton-image {
  width: 100%;
  aspect-ratio: 16 / 9;
  border-radius: var(--r-md);
}

.skeleton-card {
  height: 180px;
  width: 100%;
  border-radius: var(--r-lg);
}

.skeleton-input {
  height: var(--input-h-md);
  width: 100%;
  border-radius: var(--r-md);
}

/* Skeleton group */
.skeleton-group {
  display: flex;
  flex-direction: column;
  gap: var(--s-3);
}

.skeleton-group .skeleton-text:last-child {
  width: 60%;
}

/* Skeleton row */
.skeleton-row {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  padding: var(--s-3) 0;
  border-bottom: 1px solid var(--c-border);
}

.skeleton-row:last-child {
  border-bottom: none;
}

.skeleton-row .skeleton-text {
  flex: 1;
  margin-bottom: 0;
}

/* Skeleton list */
.skeleton-list {
  display: flex;
  flex-direction: column;
  gap: var(--s-1);
}

/* Skeleton with circle + lines */
.skeleton-profile {
  display: flex;
  align-items: center;
  gap: var(--s-3);
}

.skeleton-profile-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: var(--s-2);
}

/* Shimmer variant (لون واحد) */
.skeleton-shimmer {
  position: relative;
  overflow: hidden;
  background: var(--c-surface-2);
}

.skeleton-shimmer::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(
    90deg,
    transparent,
    rgba(255, 255, 255, 0.05),
    transparent
  );
  animation: shimmer-slide 1.8s infinite;
}

@keyframes shimmer-slide {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(100%); }
}

/* ==========================================
   🎯 EMPTY STATE — حالة الفراغ
   ========================================== */

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--s-4);
  padding: var(--s-16) var(--s-6);
  text-align: center;
  color: var(--c-text-mut);
}

.empty-state-icon {
  font-size: 3.5rem;
  line-height: 1;
  opacity: 0.5;
  margin-bottom: var(--s-2);
}

.empty-state-title {
  font-size: var(--fs-xl);
  font-weight: var(--fw-bold);
  color: var(--c-text);
  margin: 0;
}

.empty-state-message {
  font-size: var(--fs-sm);
  color: var(--c-text-mut);
  max-width: 400px;
  line-height: var(--lh-relaxed);
}

.empty-state-actions {
  display: flex;
  gap: var(--s-2);
  flex-wrap: wrap;
  justify-content: center;
  margin-top: var(--s-2);
}

/* Compact empty state */
.empty-state-sm {
  padding: var(--s-8) var(--s-4);
}

.empty-state-sm .empty-state-icon {
  font-size: 2.5rem;
}

.empty-state-sm .empty-state-title {
  font-size: var(--fs-lg);
}

/* ==========================================
   📊 STAT CARD — بطاقة إحصائية
   ========================================== */

.stat {
  display: flex;
  flex-direction: column;
  gap: var(--s-2);
  padding: var(--s-5);
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--r-lg);
  transition: var(--tr-base);
  position: relative;
  overflow: hidden;
}

.stat:hover {
  border-color: var(--c-border-hi);
  transform: translateY(-2px);
  box-shadow: var(--sh-md);
}

.stat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-2);
}

.stat-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  background: var(--c-surface-3);
  border-radius: var(--r-md);
  font-size: var(--fs-xl);
  flex-shrink: 0;
}

.stat-icon-primary {
  background: rgba(242, 194, 60, 0.15);
  color: var(--c-primary-400);
}

.stat-icon-success {
  background: var(--c-success-bg);
  color: var(--c-success);
}

.stat-icon-danger {
  background: var(--c-danger-bg);
  color: var(--c-danger);
}

.stat-icon-info {
  background: var(--c-info-bg);
  color: var(--c-info);
}

.stat-label {
  font-size: var(--fs-xs);
  font-weight: var(--fw-medium);
  color: var(--c-text-mut);
  text-transform: uppercase;
  letter-spacing: var(--ls-wider);
}

.stat-value {
  font-size: clamp(var(--fs-2xl), 3vw, var(--fs-3xl));
  font-weight: var(--fw-black);
  color: var(--c-text);
  line-height: 1;
  letter-spacing: var(--ls-tight);
}

.stat-value-primary { color: var(--c-primary-400); }
.stat-value-success { color: var(--c-success); }
.stat-value-danger { color: var(--c-danger); }

.stat-change {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: var(--fs-xs);
  font-weight: var(--fw-bold);
  padding: 2px 8px;
  border-radius: var(--r-full);
}

.stat-change.up {
  background: var(--c-success-bg);
  color: var(--c-success);
}

.stat-change.down {
  background: var(--c-danger-bg);
  color: var(--c-danger);
}

/* Stat compact */
.stat-compact {
  padding: var(--s-4);
  gap: var(--s-1);
}

.stat-compact .stat-value {
  font-size: var(--fs-2xl);
}

/* ==========================================
   🎯 ALERT — التنبيهات المدمجة
   ========================================== */

.alert {
  display: flex;
  align-items: flex-start;
  gap: var(--s-3);
  padding: var(--s-4) var(--s-5);
  border-radius: var(--r-md);
  border: 1px solid;
  font-size: var(--fs-sm);
  line-height: var(--lh-relaxed);
}

.alert-icon {
  flex-shrink: 0;
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--fs-lg);
  line-height: 1;
  margin-top: 1px;
}

.alert-content {
  flex: 1;
  min-width: 0;
}

.alert-title {
  font-weight: var(--fw-bold);
  margin-bottom: 4px;
  color: inherit;
}

.alert-message {
  color: inherit;
  opacity: 0.9;
}

.alert-close {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  background: transparent;
  border: none;
  color: inherit;
  opacity: 0.6;
  cursor: pointer;
  border-radius: var(--r-sm);
  transition: var(--tr-fast);
  flex-shrink: 0;
  margin: -4px -4px -4px 0;
}

.alert-close:hover {
  opacity: 1;
  background: rgba(255, 255, 255, 0.1);
}

/* Alert variants */
.alert-info {
  background: var(--c-info-bg);
  border-color: var(--c-info-border);
  color: var(--c-info-hi);
}

.alert-success {
  background: var(--c-success-bg);
  border-color: var(--c-success-border);
  color: var(--c-success-hi);
}

.alert-warning {
  background: var(--c-warning-bg);
  border-color: var(--c-warning-border);
  color: var(--c-warning-hi);
}

.alert-danger,
.alert-error {
  background: var(--c-danger-bg);
  border-color: var(--c-danger-border);
  color: var(--c-danger-hi);
}

.alert-neutral {
  background: var(--c-surface-2);
  border-color: var(--c-border);
  color: var(--c-text);
}

/* ==========================================
   🎯 LOADER — مؤشرات التحميل
   ========================================== */

.spinner {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 2px solid var(--c-surface-3);
  border-top-color: var(--c-primary-500);
  border-radius: var(--r-circle);
  animation: spin 0.8s linear infinite;
  flex-shrink: 0;
}

.spinner-sm { width: 14px; height: 14px; border-width: 2px; }
.spinner-md { width: 20px; height: 20px; border-width: 2px; }
.spinner-lg { width: 32px; height: 32px; border-width: 3px; }
.spinner-xl { width: 48px; height: 48px; border-width: 4px; }

.spinner-primary { border-top-color: var(--c-primary-500); }
.spinner-premium { border-top-color: var(--c-premium); }

/* Dots loader */
.dots {
  display: inline-flex;
  gap: 4px;
  align-items: center;
}

.dots > span {
  width: 8px;
  height: 8px;
  background: var(--c-primary-500);
  border-radius: var(--r-circle);
  animation: dot-pulse 1.4s ease-in-out infinite;
}

.dots > span:nth-child(2) { animation-delay: 0.2s; }
.dots > span:nth-child(3) { animation-delay: 0.4s; }

@keyframes dot-pulse {
  0%, 80%, 100% {
    transform: scale(0.6);
    opacity: 0.5;
  }
  40% {
    transform: scale(1);
    opacity: 1;
  }
}

/* Pulse loader */
.pulse-loader {
  width: 40px;
  height: 40px;
  border-radius: var(--r-circle);
  background: var(--c-primary-500);
  animation: pulse-scale 1.2s ease-in-out infinite;
}

@keyframes pulse-scale {
  0% { transform: scale(0); opacity: 1; }
  100% { transform: scale(1); opacity: 0; }
}

/* Global Loader */
.global-loader {
  position: fixed;
  inset: 0;
  z-index: var(--z-max);
  background: var(--backdrop);
  backdrop-filter: var(--blur-md);
  -webkit-backdrop-filter: var(--blur-md);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity var(--t-base) var(--ease);
  pointer-events: none;
}

.global-loader.show {
  opacity: 1;
  pointer-events: auto;
}

.global-loader-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--s-4);
  text-align: center;
  padding: var(--s-6);
}

.global-loader-content .spinner {
  width: 48px;
  height: 48px;
  border-width: 4px;
}

.global-loader-text {
  font-size: var(--fs-base);
  font-weight: var(--fw-medium);
  color: var(--c-text);
}

/* Linear progress (top of page) */
.progress-linear {
  position: fixed;
  top: 0;
  inset-inline: 0;
  height: 3px;
  background: transparent;
  z-index: var(--z-max);
  pointer-events: none;
}

.progress-linear-bar {
  height: 100%;
  background: var(--g-gold);
  width: 0%;
  transition: width var(--t-base) var(--ease);
  box-shadow: 0 0 8px var(--c-primary-500);
}
/* ============================================
   TROF System v2.0 — Components (Part 3/3)
   ============================================
   Profile, Upload, Tags, Tooltip, Popover, Accordion, Misc
   ============================================ */

/* ==========================================
   👤 USER MENU — قائمة المستخدم
   ========================================== */

.user-menu {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  padding: var(--s-2);
  background: var(--c-surface-2);
  border: 1px solid var(--c-border);
  border-radius: var(--r-full);
  cursor: pointer;
  transition: var(--tr-base);
  user-select: none;
}

.user-menu:hover {
  border-color: var(--c-border-hi);
  background: var(--c-surface-3);
}

.user-menu-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  padding-inline-end: var(--s-2);
}

.user-menu-name {
  font-size: var(--fs-sm);
  font-weight: var(--fw-bold);
  color: var(--c-text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 140px;
}

.user-menu-role {
  font-size: var(--fs-2xs);
  color: var(--c-text-mut);
  text-transform: uppercase;
  letter-spacing: var(--ls-wide);
}

/* Compact user chip */
.user-chip {
  display: inline-flex;
  align-items: center;
  gap: var(--s-2);
  padding: 4px 12px 4px 4px;
  background: var(--c-surface-2);
  border: 1px solid var(--c-border);
  border-radius: var(--r-full);
  font-size: var(--fs-xs);
  font-weight: var(--fw-medium);
  transition: var(--tr-fast);
}

.user-chip .avatar {
  width: 24px;
  height: 24px;
  font-size: var(--fs-2xs);
}

/* ==========================================
   📁 FILE UPLOAD — رفع الملفات
   ========================================== */

.upload-zone {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--s-3);
  padding: var(--s-10) var(--s-6);
  background: var(--c-bg-alt);
  border: 2px dashed var(--c-border);
  border-radius: var(--r-lg);
  cursor: pointer;
  transition: var(--tr-base);
  text-align: center;
  min-height: 200px;
  position: relative;
  overflow: hidden;
}

.upload-zone:hover {
  border-color: var(--c-primary-500);
  background: rgba(242, 194, 60, 0.03);
}

.upload-zone.dragging {
  border-color: var(--c-primary-500);
  background: rgba(242, 194, 60, 0.08);
  transform: scale(1.01);
}

.upload-zone.dragging .upload-zone-icon {
  transform: scale(1.15);
  color: var(--c-primary-500);
}

.upload-zone.has-file {
  padding: 0;
  border-style: solid;
  border-color: var(--c-primary-500);
  min-height: auto;
}

.upload-zone.has-error {
  border-color: var(--c-danger);
}

.upload-zone-icon {
  font-size: 3rem;
  color: var(--c-text-dim);
  transition: var(--tr-base);
  line-height: 1;
}

.upload-zone-title {
  font-size: var(--fs-base);
  font-weight: var(--fw-bold);
  color: var(--c-text);
}

.upload-zone-hint {
  font-size: var(--fs-sm);
  color: var(--c-text-mut);
  max-width: 320px;
  line-height: var(--lh-relaxed);
}

.upload-zone-limit {
  font-size: var(--fs-xs);
  color: var(--c-text-dim);
  margin-top: var(--s-1);
}

.upload-zone input[type="file"] {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
}

/* Upload preview */
.upload-preview {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  background: var(--c-surface-2);
  border-radius: var(--r-md);
  overflow: hidden;
}

.upload-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.upload-preview-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(to top, rgba(0, 0, 0, 0.8), transparent 60%);
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  padding: var(--s-3);
  opacity: 0;
  transition: opacity var(--t-base);
}

.upload-preview:hover .upload-preview-overlay {
  opacity: 1;
}

.upload-preview-actions {
  display: flex;
  gap: var(--s-2);
}

.upload-preview-file {
  font-size: var(--fs-xs);
  color: #ffffff;
  font-weight: var(--fw-medium);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
  min-width: 0;
}

/* Upload progress */
.upload-progress {
  width: 100%;
  height: 4px;
  background: var(--c-surface-3);
  border-radius: var(--r-full);
  overflow: hidden;
  margin-top: var(--s-3);
}

.upload-progress-bar {
  height: 100%;
  background: var(--g-gold);
  border-radius: var(--r-full);
  transition: width var(--t-base) var(--ease);
}

/* ==========================================
   🏷️ TAGS / CHIPS — الوسوم
   ========================================== */

.tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  background: var(--c-surface-2);
  border: 1px solid var(--c-border);
  border-radius: var(--r-full);
  font-size: var(--fs-xs);
  font-weight: var(--fw-medium);
  color: var(--c-text);
  transition: var(--tr-fast);
  white-space: nowrap;
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tag-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--fs-sm);
  line-height: 1;
  flex-shrink: 0;
}

.tag-close {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  padding: 0;
  background: transparent;
  border: none;
  color: var(--c-text-dim);
  cursor: pointer;
  border-radius: var(--r-circle);
  transition: var(--tr-fast);
  font-size: var(--fs-xs);
  line-height: 1;
  flex-shrink: 0;
}

.tag-close:hover {
  background: var(--c-danger);
  color: #ffffff;
}

/* Tag variants */
.tag-primary {
  background: rgba(242, 194, 60, 0.15);
  border-color: rgba(242, 194, 60, 0.3);
  color: var(--c-primary-300);
}

.tag-success {
  background: var(--c-success-bg);
  border-color: var(--c-success-border);
  color: var(--c-success-hi);
}

.tag-danger {
  background: var(--c-danger-bg);
  border-color: var(--c-danger-border);
  color: var(--c-danger-hi);
}

.tag-premium {
  background: rgba(168, 85, 247, 0.15);
  border-color: rgba(168, 85, 247, 0.3);
  color: var(--c-premium-hi);
}


/* Clickable tag */
.tag-clickable {
  cursor: pointer;
}

.tag-clickable:hover {
  background: var(--c-surface-3);
  border-color: var(--c-border-hi);
}

.tag-clickable.active {
  background: var(--c-primary-500);
  border-color: var(--c-primary-500);
  color: var(--c-text-inv);
}

/* Tag sizes */
.tag-sm {
  padding: 2px 8px;
  font-size: var(--fs-2xs);
}

.tag-lg {
  padding: 6px 14px;
  font-size: var(--fs-sm);
}

/* Tag group */
.tag-group {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s-2);
}

/* ==========================================
   🔍 SEARCH BAR — شريط البحث
   ========================================== */

.search {
  position: relative;
  width: 100%;
  max-width: 400px;
}

.search-input {
  width: 100%;
  padding: 10px 40px 10px 40px;
  background: var(--c-bg-alt);
  border: 1px solid var(--c-border);
  border-radius: var(--r-full);
  font-family: inherit;
  font-size: var(--fs-sm);
  color: var(--c-text);
  transition: var(--tr-base);
  outline: none;
}

.search-input:hover {
  border-color: var(--c-border-hi);
}

.search-input:focus {
  border-color: var(--c-primary-500);
  box-shadow: 0 0 0 3px rgba(242, 194, 60, 0.15);
  background: var(--c-surface);
}

.search-icon {
  position: absolute;
  top: 50%;
  inset-inline-start: 14px;
  transform: translateY(-50%);
  color: var(--c-text-mut);
  pointer-events: none;
  font-size: var(--fs-base);
  display: flex;
  align-items: center;
  justify-content: center;
}

.search-clear {
  position: absolute;
  top: 50%;
  inset-inline-end: 12px;
  transform: translateY(-50%);
  width: 24px;
  height: 24px;
  padding: 0;
  background: transparent;
  border: none;
  color: var(--c-text-dim);
  cursor: pointer;
  border-radius: var(--r-circle);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--tr-fast);
  font-size: var(--fs-base);
}

.search-clear:hover {
  background: var(--c-surface-3);
  color: var(--c-text);
}

/* Search keyboard hint */
.search-kbd {
  position: absolute;
  top: 50%;
  inset-inline-end: 12px;
  transform: translateY(-50%);
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 2px 6px;
  background: var(--c-surface-3);
  border: 1px solid var(--c-border);
  border-radius: var(--r-xs);
  font-family: var(--f-mono);
  font-size: var(--fs-2xs);
  color: var(--c-text-mut);
  pointer-events: none;
}

/* ==========================================
   🎯 TOOLTIP — التلميحات
   ========================================== */

.tooltip {
  position: fixed;
  z-index: var(--z-tooltip);
  padding: 6px 10px;
  background: var(--c-surface-3);
  color: var(--c-text);
  border: 1px solid var(--c-border);
  border-radius: var(--r-sm);
  font-size: var(--fs-xs);
  font-weight: var(--fw-medium);
  line-height: 1.4;
  max-width: 280px;
  box-shadow: var(--sh-md);
  pointer-events: none;
  opacity: 0;
  animation: tooltip-in var(--t-fast) var(--ease) forwards;
  white-space: normal;
  text-align: center;
}

@keyframes tooltip-in {
  to { opacity: 1; }
}

/* Arrow (اختياري) */
.tooltip::before {
  content: '';
  position: absolute;
  width: 8px;
  height: 8px;
  background: var(--c-surface-3);
  border: 1px solid var(--c-border);
  transform: rotate(45deg);
}

.tooltip-top::before {
  bottom: -5px;
  left: 50%;
  margin-left: -4px;
  border-top: none;
  border-inline-start: none;
}

.tooltip-bottom::before {
  top: -5px;
  left: 50%;
  margin-left: -4px;
  border-bottom: none;
  border-inline-end: none;
}

.tooltip-left::before {
  right: -5px;
  top: 50%;
  margin-top: -4px;
  border-left: none;
  border-bottom: none;
}

.tooltip-right::before {
  left: -5px;
  top: 50%;
  margin-top: -4px;
  border-right: none;
  border-top: none;
}

/* ==========================================
   🎯 POPOVER — النوافذ المنبثقة الصغيرة
   ========================================== */

.popover {
  position: fixed;
  z-index: var(--z-popover);
  min-width: 220px;
  max-width: 360px;
  padding: var(--s-4);
  background: var(--c-surface-2);
  border: 1px solid var(--c-border);
  border-radius: var(--r-md);
  box-shadow: var(--sh-lg);
  opacity: 0;
  transform: translateY(-4px);
  transition: opacity var(--t-fast) var(--ease), transform var(--t-fast) var(--ease);
  backdrop-filter: var(--blur-md);
  -webkit-backdrop-filter: var(--blur-md);
}

.popover.show {
  opacity: 1;
  transform: translateY(0);
}

.popover-title {
  font-size: var(--fs-sm);
  font-weight: var(--fw-bold);
  color: var(--c-text);
  margin-bottom: var(--s-2);
}

.popover-body {
  font-size: var(--fs-sm);
  color: var(--c-text-mut);
  line-height: var(--lh-relaxed);
}

/* ==========================================
   🎛️ ACCORDION — القوائم القابلة للطي
   ========================================== */

.accordion {
  display: flex;
  flex-direction: column;
  gap: var(--s-2);
  width: 100%;
}

.accordion-item {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--r-md);
  overflow: hidden;
  transition: var(--tr-base);
}

.accordion-item.open {
  border-color: var(--c-border-hi);
}

.accordion-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-3);
  width: 100%;
  padding: var(--s-4) var(--s-5);
  background: transparent;
  border: none;
  font-family: inherit;
  font-size: var(--fs-base);
  font-weight: var(--fw-bold);
  color: var(--c-text);
  cursor: pointer;
  text-align: start;
  transition: var(--tr-fast);
}

.accordion-header:hover {
  background: var(--c-surface-2);
}

.accordion-title {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: var(--s-3);
}

.accordion-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--fs-lg);
  line-height: 1;
  color: var(--c-text-mut);
  transition: transform var(--t-base) var(--ease);
  flex-shrink: 0;
}

.accordion-item.open .accordion-icon {
  transform: rotate(180deg);
}

.accordion-body {
  max-height: 0;
  overflow: hidden;
  transition: max-height var(--t-base) var(--ease), padding var(--t-base) var(--ease);
  padding: 0 var(--s-5);
}

.accordion-item.open .accordion-body {
  max-height: 2000px;
  padding: var(--s-4) var(--s-5);
  border-top: 1px solid var(--c-border);
}

.accordion-content {
  font-size: var(--fs-sm);
  color: var(--c-text-mut);
  line-height: var(--lh-relaxed);
}

/* ==========================================
   🎨 COLOR PICKER — منتقي الألوان
   ========================================== */

.color-picker {
  display: flex;
  align-items: center;
  gap: var(--s-2);
}

.color-picker-input {
  width: 44px;
  height: 44px;
  padding: 2px;
  background: var(--c-surface-2);
  border: 1px solid var(--c-border);
  border-radius: var(--r-md);
  cursor: pointer;
  transition: var(--tr-fast);
  appearance: none;
  -webkit-appearance: none;
}

.color-picker-input::-webkit-color-swatch-wrapper {
  padding: 0;
}

.color-picker-input::-webkit-color-swatch {
  border: none;
  border-radius: var(--r-sm);
}

.color-picker-input::-moz-color-swatch {
  border: none;
  border-radius: var(--r-sm);
}

.color-picker-input:hover {
  border-color: var(--c-primary-500);
}

/* Color swatches */
.color-swatches {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s-2);
}

.color-swatch {
  width: 32px;
  height: 32px;
  border-radius: var(--r-circle);
  cursor: pointer;
  border: 2px solid transparent;
  transition: var(--tr-fast);
  position: relative;
}

.color-swatch:hover {
  transform: scale(1.1);
}

.color-swatch.active {
  border-color: var(--c-text);
  box-shadow: 0 0 0 2px var(--c-bg), 0 0 0 4px var(--c-primary-500);
}

.color-swatch.active::after {
  content: '✓';
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #ffffff;
  font-weight: var(--fw-black);
  font-size: var(--fs-xs);
  text-shadow: 0 0 4px rgba(0, 0, 0, 0.8);
}

/* ==========================================
   📅 DATE/TIME INPUTS
   ========================================== */

.date-input,
.time-input {
  position: relative;
  width: 100%;
}

.date-input input,
.time-input input {
  width: 100%;
  padding: 10px 40px 10px var(--input-px);
  background: var(--c-bg-alt);
  border: 1px solid var(--c-border);
  border-radius: var(--r-md);
  font-family: inherit;
  font-size: var(--fs-sm);
  color: var(--c-text);
  transition: var(--tr-base);
  cursor: pointer;
}

.date-input input::-webkit-calendar-picker-indicator,
.time-input input::-webkit-calendar-picker-indicator {
  cursor: pointer;
  opacity: 0.6;
  filter: invert(75%) sepia(15%) saturate(500%) hue-rotate(10deg);
}

.date-input input:hover,
.time-input input:hover {
  border-color: var(--c-border-hi);
}

.date-input input:focus,
.time-input input:focus {
  border-color: var(--c-primary-500);
  box-shadow: 0 0 0 3px rgba(242, 194, 60, 0.15);
  outline: none;
}

/* ==========================================
   🎯 PAGINATION — الترقيم
   ========================================== */

.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--s-2);
  flex-wrap: wrap;
}

.pagination-item {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 36px;
  height: 36px;
  padding: 0 var(--s-3);
  background: transparent;
  border: 1px solid var(--c-border);
  border-radius: var(--r-md);
  font-family: inherit;
  font-size: var(--fs-sm);
  font-weight: var(--fw-medium);
  color: var(--c-text-mut);
  cursor: pointer;
  transition: var(--tr-fast);
  text-decoration: none;
}

.pagination-item:hover:not(.disabled) {
  border-color: var(--c-primary-500);
  color: var(--c-text);
  background: var(--c-surface-2);
}

.pagination-item.active {
  background: var(--c-primary-500);
  border-color: var(--c-primary-500);
  color: var(--c-text-inv);
  font-weight: var(--fw-bold);
}

.pagination-item.disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.pagination-info {
  font-size: var(--fs-sm);
  color: var(--c-text-mut);
  padding: 0 var(--s-2);
}

/* ==========================================
   📋 BREADCRUMB — مسار التنقل
   ========================================== */

.breadcrumb {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--s-1);
  font-size: var(--fs-sm);
}

.breadcrumb-item {
  display: inline-flex;
  align-items: center;
  gap: var(--s-2);
  color: var(--c-text-mut);
  text-decoration: none;
  transition: var(--tr-fast);
  padding: 4px 8px;
  border-radius: var(--r-sm);
}

.breadcrumb-item:hover {
  color: var(--c-primary-400);
  background: var(--c-surface-2);
}

.breadcrumb-item.active {
  color: var(--c-text);
  font-weight: var(--fw-bold);
  pointer-events: none;
}

.breadcrumb-separator {
  color: var(--c-text-dim);
  user-select: none;
  font-size: var(--fs-xs);
}

html[dir="rtl"] .breadcrumb-separator {
  transform: scaleX(-1);
}

/* ==========================================
   🔔 NOTIFICATION BADGE — شارة الإشعارات
   ========================================== */

.notification-badge {
  position: absolute;
  top: -4px;
  inset-inline-end: -4px;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--c-danger);
  color: #ffffff;
  border-radius: var(--r-full);
  font-size: 0.625rem;
  font-weight: var(--fw-black);
  line-height: 1;
  border: 2px solid var(--c-bg);
  box-shadow: 0 0 0 1px var(--c-danger);
  animation: badge-pop var(--t-slow) var(--ease-bounce);
}

@keyframes badge-pop {
  0% { transform: scale(0); }
  50% { transform: scale(1.3); }
  100% { transform: scale(1); }
}

.notification-badge-count {
  min-width: 20px;
  padding: 0 6px;
}

/* Icon button with badge */
.icon-btn-badged {
  position: relative;
}

/* ==========================================
   🎯 AVATAR UPLOAD — رفع صورة شخصية
   ========================================== */

.avatar-upload {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--s-3);
}

.avatar-upload-preview {
  position: relative;
  width: 120px;
  height: 120px;
  border-radius: var(--r-circle);
  overflow: hidden;
  cursor: pointer;
  background: var(--c-surface-2);
  border: 2px dashed var(--c-border);
  transition: var(--tr-base);
}

.avatar-upload-preview:hover {
  border-color: var(--c-primary-500);
}

.avatar-upload-preview:hover .avatar-upload-overlay {
  opacity: 1;
}

.avatar-upload-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.avatar-upload-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #ffffff;
  font-size: var(--fs-2xl);
  opacity: 0;
  transition: opacity var(--t-base);
  pointer-events: none;
}

.avatar-upload input[type="file"] {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

/* ==========================================
   🎯 SEGMENTED CONTROL — تحكم مقسم
   ========================================== */

.segmented {
  display: inline-flex;
  padding: 3px;
  background: var(--c-surface-2);
  border: 1px solid var(--c-border);
  border-radius: var(--r-md);
  gap: 2px;
  position: relative;
}

.segmented-item {
  padding: 6px 16px;
  background: transparent;
  border: none;
  border-radius: var(--r-sm);
  font-family: inherit;
  font-size: var(--fs-sm);
  font-weight: var(--fw-medium);
  color: var(--c-text-mut);
  cursor: pointer;
  transition: var(--tr-fast);
  white-space: nowrap;
  z-index: 1;
  position: relative;
}

.segmented-item:hover:not(.active) {
  color: var(--c-text);
}

.segmented-item.active {
  color: var(--c-text-inv);
  background: var(--c-primary-500);
  font-weight: var(--fw-bold);
  box-shadow: var(--sh-sm);
}

/* ==========================================
   🎯 STEPPER — خطوات
   ========================================== */

.stepper {
  display: flex;
  align-items: center;
  gap: var(--s-3);
}

.stepper-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  background: var(--c-surface-2);
  border: 1px solid var(--c-border);
  border-radius: var(--r-md);
  font-size: var(--fs-lg);
  font-weight: var(--fw-bold);
  color: var(--c-text);
  cursor: pointer;
  transition: var(--tr-fast);
  user-select: none;
}

.stepper-btn:hover {
  border-color: var(--c-primary-500);
  background: var(--c-surface-3);
}

.stepper-btn:active {
  transform: scale(0.95);
}

.stepper-value {
  min-width: 60px;
  text-align: center;
  font-size: var(--fs-base);
  font-weight: var(--fw-bold);
  color: var(--c-text);
}

/* ==========================================
   🎯 KBD — اختصار لوحة المفاتيح
   ========================================== */

.kbd {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 22px;
  height: 22px;
  padding: 0 6px;
  background: var(--c-surface-3);
  border: 1px solid var(--c-border);
  border-bottom-width: 2px;
  border-radius: var(--r-xs);
  font-family: var(--f-mono);
  font-size: var(--fs-2xs);
  font-weight: var(--fw-bold);
  color: var(--c-text);
  line-height: 1;
  white-space: nowrap;
}

/* ==========================================
   🎯 CODE BLOCK
   ========================================== */

.code-block {
  position: relative;
  background: var(--c-bg-alt);
  border: 1px solid var(--c-border);
  border-radius: var(--r-md);
  overflow: hidden;
  font-family: var(--f-mono);
}

.code-block-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--s-2) var(--s-3);
  background: var(--c-surface-2);
  border-bottom: 1px solid var(--c-border);
  font-size: var(--fs-2xs);
  color: var(--c-text-mut);
  text-transform: uppercase;
  letter-spacing: var(--ls-wider);
}

.code-block-copy {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px 8px;
  background: transparent;
  border: 1px solid var(--c-border);
  border-radius: var(--r-sm);
  color: var(--c-text-mut);
  font-size: var(--fs-2xs);
  cursor: pointer;
  transition: var(--tr-fast);
}

.code-block-copy:hover {
  background: var(--c-surface-3);
  color: var(--c-text);
}

.code-block pre {
  padding: var(--s-4);
  margin: 0;
  overflow-x: auto;
  font-size: var(--fs-sm);
  line-height: var(--lh-relaxed);
  color: var(--c-text);
  border: none;
  background: transparent;
  border-radius: 0;
}

/* Inline code */
.inline-code {
  display: inline-block;
  padding: 2px 6px;
  background: var(--c-surface-2);
  border: 1px solid var(--c-border);
  border-radius: var(--r-xs);
  font-family: var(--f-mono);
  font-size: 0.875em;
  color: var(--c-primary-300);
}

/* ==========================================
   🎯 COMMAND PALETTE — لوحة الأوامر
   ========================================== */

.command-palette {
  position: fixed;
  inset: 0;
  z-index: var(--z-max);
  background: var(--backdrop);
  backdrop-filter: var(--blur-md);
  -webkit-backdrop-filter: var(--blur-md);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: 15vh;
  padding-inline: var(--s-4);
  animation: fade-in var(--t-fast) var(--ease);
}

.command-palette-inner {
  width: 100%;
  max-width: 600px;
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--r-lg);
  box-shadow: var(--sh-2xl);
  overflow: hidden;
  animation: scale-in var(--t-base) var(--ease-bounce);
}

.command-palette-input {
  width: 100%;
  padding: var(--s-5);
  background: transparent;
  border: none;
  border-bottom: 1px solid var(--c-border);
  font-family: inherit;
  font-size: var(--fs-lg);
  color: var(--c-text);
  outline: none;
}

.command-palette-input::placeholder {
  color: var(--c-text-dim);
}

.command-palette-results {
  max-height: 400px;
  overflow-y: auto;
  padding: var(--s-2);
}

.command-palette-item {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  padding: var(--s-3) var(--s-4);
  border-radius: var(--r-sm);
  cursor: pointer;
  transition: var(--tr-fast);
  color: var(--c-text);
  text-decoration: none;
}

.command-palette-item:hover,
.command-palette-item.selected {
  background: var(--c-surface-2);
}

.command-palette-item.selected {
  background: var(--c-surface-3);
  color: var(--c-primary-400);
}

.command-palette-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  background: var(--c-surface-2);
  border-radius: var(--r-sm);
  font-size: var(--fs-lg);
  flex-shrink: 0;
}

.command-palette-content {
  flex: 1;
  min-width: 0;
}

.command-palette-title {
  font-size: var(--fs-sm);
  font-weight: var(--fw-bold);
  color: inherit;
}

.command-palette-sub {
  font-size: var(--fs-xs);
  color: var(--c-text-mut);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ==========================================
   🎯 SEARCH RESULTS
   ========================================== */

.search-result-item {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  padding: var(--s-3) var(--s-4);
  border-radius: var(--r-md);
  cursor: pointer;
  transition: var(--tr-fast);
  text-decoration: none;
  color: var(--c-text);
}

.search-result-item:hover {
  background: var(--c-surface-2);
}

.search-result-icon {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--c-surface-2);
  border-radius: var(--r-md);
  font-size: var(--fs-xl);
  flex-shrink: 0;
}

.search-result-content {
  flex: 1;
  min-width: 0;
}

.search-result-title {
  font-size: var(--fs-sm);
  font-weight: var(--fw-bold);
  color: var(--c-text);
  margin-bottom: 2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.search-result-sub {
  font-size: var(--fs-xs);
  color: var(--c-text-mut);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.search-highlight {
  background: rgba(242, 194, 60, 0.3);
  color: var(--c-primary-200);
  padding: 0 2px;
  border-radius: 2px;
  font-weight: var(--fw-bold);
}

/* ==========================================
   🎯 SERVER SELECTOR (اختيار السيرفر)
   ========================================== */

.server-selector {
  position: relative;
  display: inline-flex;
  align-items: center;
}

.server-selector-btn {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  padding: var(--s-2) var(--s-3);
  background: var(--c-surface-2);
  border: 1px solid var(--c-border);
  border-radius: var(--r-md);
  color: var(--c-text);
  font-family: inherit;
  font-size: var(--fs-sm);
  font-weight: var(--fw-medium);
  cursor: pointer;
  transition: var(--tr-fast);
  max-width: 240px;
}

.server-selector-btn:hover {
  border-color: var(--c-border-hi);
  background: var(--c-surface-3);
}

.server-selector-btn .avatar {
  width: 24px;
  height: 24px;
  border-radius: var(--r-sm);
  font-size: var(--fs-2xs);
}

.server-selector-name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-align: start;
}

.server-selector-arrow {
  color: var(--c-text-mut);
  font-size: var(--fs-xs);
  flex-shrink: 0;
  transition: transform var(--t-fast);
}

.server-selector-btn[aria-expanded="true"] .server-selector-arrow {
  transform: rotate(180deg);
}

/* ==========================================
   🎯 CHECKBOX GROUP
   ========================================== */

.checkbox-group {
  display: flex;
  flex-direction: column;
  gap: var(--s-2);
}

.checkbox-group-horizontal {
  flex-direction: row;
  flex-wrap: wrap;
  gap: var(--s-4);
}

/* ==========================================
   🎯 INPUT WITH LABEL & ACTION
   ========================================== */

.field-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: var(--s-3);
  align-items: end;
}

/* ==========================================
   🎯 DIVIDER WITH LABEL
   ========================================== */

.divider-label {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  color: var(--c-text-mut);
  font-size: var(--fs-xs);
  font-weight: var(--fw-medium);
  text-transform: uppercase;
  letter-spacing: var(--ls-wider);
  margin-block: var(--s-4);
}

.divider-label::before,
.divider-label::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--c-border);
}

/* ==========================================
   🎯 MISC HELPERS
   ========================================== */

/* Icon in circle */
.icon-circle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: var(--r-circle);
  background: var(--c-surface-2);
  font-size: var(--fs-lg);
  flex-shrink: 0;
}

.icon-circle-sm { width: 32px; height: 32px; font-size: var(--fs-base); }
.icon-circle-lg { width: 52px; height: 52px; font-size: var(--fs-2xl); }
.icon-circle-xl { width: 72px; height: 72px; font-size: var(--fs-4xl); }

/* Sidebar collapse toggle */
.collapse-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  background: var(--c-surface-2);
  border: 1px solid var(--c-border);
  border-radius: var(--r-sm);
  color: var(--c-text-mut);
  cursor: pointer;
  transition: var(--tr-fast);
}

.collapse-toggle:hover {
  color: var(--c-text);
  border-color: var(--c-border-hi);
  background: var(--c-surface-3);
}

/* ==========================================
   🎯 PREFERS-REDUCED-MOTION
   ========================================== */

@media (prefers-reduced-motion: reduce) {
  .toast,
  .modal,
  .dropdown,
  .popover,
  .tooltip,
  .notification-badge,
  .skeleton,
  .progress-bar::after {
    animation: none !important;
    transition: none !important;
  }
}

/* ==========================================
   🎯 HIGH CONTRAST MODE
   ========================================== */

@media (prefers-contrast: high) {
  .btn,
  .input,
  .select,
  .textarea,
  .card,
  .badge {
    border-width: 2px;
  }

  .toast,
  .modal {
    border-width: 2px;
  }
}

/* ==========================================
   🎯 DARK MODE OVERRIDES
   ========================================== */

[data-theme="light"] .btn-primary {
  color: #1a1305;
}

[data-theme="light"] .toast,
[data-theme="light"] .modal,
[data-theme="light"] .dropdown,
[data-theme="light"] .popover {
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.15);
}

[data-theme="light"] .skeleton {
  background: linear-gradient(
    90deg,
    var(--c-surface-2) 0%,
    var(--c-surface-3) 50%,
    var(--c-surface-2) 100%
  );
}

/* ==========================================
   🎯 PRINT STYLES
   ========================================== */

@media print {
  .toast-container,
  .modal-backdrop,
  .global-loader,
  .notification-badge,
  .dropdown,
  .tooltip,
  .popover,
  .command-palette {
    display: none !important;
  }

  .card,
  .btn {
    box-shadow: none !important;
    border: 1px solid #ccc !important;
  }
}

/* ==========================================
   📝 END OF COMPONENTS
   ============================================
   المجموع: 3 أجزاء
   - Part 1: Buttons, Inputs, Cards, Badges, Avatars, Progress
   - Part 2: Tables, Tabs, Dropdown, Toast, Modal, Skeleton
   - Part 3: Profile, Upload, Tags, Tooltip, Popover, Misc
   ============================================ */