/* المكونات: بطاقات، أزرار، شارات، حقول، مفاتيح، جداول */

/* ── البطاقات (Squircle + Bento) ── */
.card {
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-2xl);
  box-shadow: var(--shadow-bento);
  padding: 20px;
}
.card.pad-sm { padding: 14px; }
.card.flush { padding: 0; overflow: hidden; }
.card.interactive { transition: box-shadow var(--duration-fast), border-color var(--duration-fast), transform var(--duration-fast); }
.card.interactive:hover { box-shadow: var(--glow-card-hover); border-color: var(--accent-border); }
.card.hero { background: var(--bg-surface) var(--hero-gradient); padding: 24px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.card-title { display: flex; align-items: center; gap: 8px; font-size: var(--text-md); font-weight: 700; }
.card-title .ic { color: var(--accent-text); }
.card-sub { color: var(--text-secondary); font-size: var(--text-sm); margin-top: 2px; }
.inset { background: var(--bg-subtle); border: 1px solid var(--border-subtle); border-radius: var(--radius-lg); padding: 14px; }

/* ── الأزرار ── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 40px; padding: 0 16px;
  border-radius: var(--radius-lg); border: 1px solid transparent;
  font-size: var(--text-sm); font-weight: 700; white-space: nowrap;
  cursor: pointer; user-select: none;
  background: var(--accent-strong); color: #fff;
  box-shadow: var(--glow-accent);
  transition: background var(--duration-fast), border-color var(--duration-fast), color var(--duration-fast), transform 80ms, box-shadow var(--duration-fast);
}
.btn:hover { background: var(--accent); color: #fff; }
.btn:active { transform: scale(0.98); }
.btn:disabled, .btn[aria-disabled="true"] { opacity: 0.5; cursor: not-allowed; transform: none; }
.btn.secondary { background: var(--bg-subtle); color: var(--text-primary); border-color: var(--border-default); box-shadow: none; }
.btn.secondary:hover { background: var(--bg-muted); border-color: var(--border-strong); }
.btn.ghost { background: transparent; color: var(--text-secondary); box-shadow: none; }
.btn.ghost:hover { background: var(--bg-subtle); color: var(--text-primary); }
.btn.danger { background: var(--err); box-shadow: none; }
.btn.danger:hover { background: #DC2626; }
.btn.danger-soft { background: var(--err-subtle); color: var(--err-text); border-color: var(--err-border); box-shadow: none; }
.btn.danger-soft:hover { background: var(--err); color: #fff; }
.btn.ok-soft { background: var(--ok-subtle); color: var(--ok-text); border-color: var(--ok-border); box-shadow: none; }
.btn.sm { min-height: 32px; padding: 0 12px; border-radius: var(--radius-md); font-size: var(--text-xs); }
.btn.lg { min-height: 48px; padding: 0 24px; font-size: var(--text-base); }
.btn.block { width: 100%; }
.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 40px; height: 40px; border-radius: var(--radius-full);
  border: 1px solid var(--border-default); background: var(--bg-subtle);
  color: var(--text-secondary); cursor: pointer; position: relative;
  transition: background var(--duration-fast), color var(--duration-fast), border-color var(--duration-fast);
}
.icon-btn:hover { background: var(--bg-muted); color: var(--text-primary); border-color: var(--border-strong); }
.icon-btn.sm { width: 32px; height: 32px; }
.icon-btn.plain { border-color: transparent; background: transparent; }
.icon-btn.plain:hover { background: var(--bg-subtle); }
.icon-btn.danger:hover { color: var(--err-text); background: var(--err-subtle); border-color: var(--err-border); }
.icon-btn .dot {
  position: absolute; top: 6px; inset-inline-end: 6px; width: 8px; height: 8px;
  border-radius: 50%; background: var(--err); box-shadow: 0 0 0 2px var(--bg-surface);
}

/* ── الشارات ── */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  height: 22px; padding: 0 9px; border-radius: var(--radius-full);
  font-size: var(--text-2xs); font-weight: 700; white-space: nowrap;
  background: var(--bg-subtle); color: var(--text-secondary); border: 1px solid var(--border-default);
}
.badge.ok { background: var(--ok-subtle); color: var(--ok-text); border-color: var(--ok-border); }
.badge.warn { background: var(--warn-subtle); color: var(--warn-text); border-color: var(--warn-border); }
.badge.err { background: var(--err-subtle); color: var(--err-text); border-color: var(--err-border); }
.badge.info, .badge.live { background: var(--accent-subtle); color: var(--accent-text); border-color: var(--accent-border); }
.badge.purple { background: var(--purple-subtle); color: var(--purple-text); border-color: transparent; }
.badge .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge.live .dot { animation: pulse-ring 1.6s infinite; }
.badge.mono { font-family: var(--font-mono); }
.count {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 22px; height: 20px; padding: 0 6px; border-radius: var(--radius-full);
  font: 600 var(--text-2xs) var(--font-mono);
  background: var(--accent-subtle); color: var(--accent-text); border: 1px solid var(--accent-border);
}
.count.plain { background: var(--bg-subtle); color: var(--text-tertiary); border-color: var(--border-default); }
.kbd {
  display: inline-flex; align-items: center; height: 22px; padding: 0 7px; border-radius: 6px;
  font: 600 var(--text-2xs) var(--font-mono); direction: ltr;
  background: var(--bg-muted); color: var(--text-secondary);
  border: 1px solid var(--border-strong); box-shadow: inset 0 -1px 0 rgba(0, 0, 0, 0.3);
}

/* شارة منصة X */
.x-badge {
  display: inline-flex; align-items: center; gap: 5px; height: 22px; padding: 0 8px;
  border-radius: var(--radius-full); font-size: var(--text-2xs); font-weight: 700;
  background: var(--bg-subtle); border: 1px solid var(--border-strong); color: var(--text-primary);
}
.x-logo { width: 12px; height: 12px; fill: currentColor; display: block; }

/* ── الصور الرمزية ── */
.avatar { position: relative; flex-shrink: 0; width: 44px; height: 44px; }
.avatar img {
  width: 100%; height: 100%; border-radius: 50%; object-fit: cover;
  background: var(--bg-muted); border: 1px solid var(--border-default);
}
.avatar.sm { width: 28px; height: 28px; }
.avatar.xs { width: 22px; height: 22px; }
.avatar.lg { width: 64px; height: 64px; }
.avatar .corner {
  position: absolute; bottom: -2px; inset-inline-start: -2px;
  width: 18px; height: 18px; border-radius: 50%;
  background: #000; color: #fff; display: grid; place-items: center;
  box-shadow: 0 0 0 2px var(--bg-surface);
}
.avatar .corner .x-logo { width: 9px; height: 9px; }
.avatar .state {
  position: absolute; top: 0; inset-inline-end: 0; width: 11px; height: 11px;
  border-radius: 50%; box-shadow: 0 0 0 2px var(--bg-surface); background: var(--text-tertiary);
}
.avatar .state.ok { background: var(--ok); }
.avatar .state.warn { background: var(--warn); }
.avatar .state.err { background: var(--err); }
.avatar-stack { display: flex; }
.avatar-stack .avatar { margin-inline-start: -8px; }
.avatar-stack .avatar:first-child { margin-inline-start: 0; }
.avatar-stack .more {
  width: 28px; height: 28px; border-radius: 50%; margin-inline-start: -8px;
  display: grid; place-items: center; font: 600 var(--text-2xs) var(--font-mono);
  background: var(--bg-muted); border: 1px solid var(--border-default); color: var(--text-secondary);
}

/* ── الحقول ── */
.input, .textarea, .select-native {
  width: 100%; min-height: 42px; padding: 9px 14px;
  background: var(--bg-input); color: var(--text-primary);
  border: 1px solid var(--border-default); border-radius: var(--radius-lg);
  transition: border-color var(--duration-fast), box-shadow var(--duration-fast);
}
.input::placeholder, .textarea::placeholder { color: var(--text-tertiary); }
.input:hover, .textarea:hover { border-color: var(--border-strong); }
.input:focus, .textarea:focus, .select-native:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-subtle); }
.textarea { min-height: 120px; resize: vertical; line-height: 1.7; }
.code { font-family: var(--font-mono); font-size: var(--text-sm); direction: ltr; text-align: left; }
.code::placeholder { font-family: var(--font-sans); }
.input-wrap { position: relative; display: flex; align-items: center; }
.input-wrap > .ic { position: absolute; inset-inline-start: 13px; color: var(--text-tertiary); pointer-events: none; }
.input-wrap > .input { padding-inline-start: 38px; }
.input-wrap > .kbd { position: absolute; inset-inline-end: 10px; }
.field { display: flex; flex-direction: column; gap: 7px; font-size: var(--text-sm); font-weight: 600; }
.field .hint { color: var(--text-tertiary); font-weight: 400; font-size: var(--text-xs); }
.field-row { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }

/* مربع اختيار وزر تبديل */
.check { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; font-size: var(--text-sm); font-weight: 500; }
.check input[type="checkbox"], .check input[type="radio"], input.cb {
  appearance: none; flex-shrink: 0; width: 18px; height: 18px; margin: 0;
  border: 1.5px solid var(--border-strong); border-radius: 6px; background: var(--bg-input);
  display: inline-grid; place-content: center; cursor: pointer;
  transition: background var(--duration-fast), border-color var(--duration-fast);
}
.check input[type="radio"] { border-radius: 50%; }
.check input:checked, input.cb:checked { background: var(--accent-strong); border-color: var(--accent-strong); }
.check input[type="checkbox"]:checked::after, input.cb:checked::after {
  content: ''; width: 10px; height: 6px; margin-top: -2px;
  border: 2px solid #fff; border-top: 0; border-right: 0; transform: rotate(-45deg);
}
.check input[type="radio"]:checked::after { content: ''; width: 8px; height: 8px; border-radius: 50%; background: #fff; }
input.cb:indeterminate { background: var(--accent-strong); border-color: var(--accent-strong); }
input.cb:indeterminate::after { content: ''; width: 9px; height: 2px; background: #fff; }
.switch { position: relative; display: inline-flex; align-items: center; gap: 10px; cursor: pointer; font-size: var(--text-sm); }
.switch input { appearance: none; margin: 0; width: 40px; height: 22px; border-radius: 99px; background: var(--bg-muted); border: 1px solid var(--border-strong); cursor: pointer; position: relative; transition: background var(--duration-fast); flex-shrink: 0; }
.switch input::after { content: ''; position: absolute; top: 2px; inset-inline-start: 2px; width: 16px; height: 16px; border-radius: 50%; background: #fff; box-shadow: var(--shadow-xs); transition: inset-inline-start var(--duration-fast) var(--ease-spring); }
.switch input:checked { background: var(--ok); border-color: var(--ok); }
.switch input:checked::after { inset-inline-start: 20px; }

/* ── المقاطع (Segmented) والتبويبات ── */
.segmented {
  display: inline-flex; gap: 2px; padding: 4px; border-radius: var(--radius-lg);
  background: var(--bg-subtle); border: 1px solid var(--border-default);
}
.segmented button {
  display: inline-flex; align-items: center; gap: 6px;
  height: 32px; padding: 0 12px; border-radius: var(--radius-md); border: 0;
  background: transparent; color: var(--text-secondary); font-size: var(--text-xs); font-weight: 700; cursor: pointer;
}
.segmented button:hover { color: var(--text-primary); }
.segmented button[aria-pressed="true"] { background: var(--bg-surface); color: var(--accent-text); box-shadow: var(--shadow-md); }
.tabs { display: flex; gap: 22px; border-bottom: 1px solid var(--border-default); overflow-x: auto; }
.tabs button {
  display: inline-flex; align-items: center; gap: 7px; padding: 12px 2px; margin-bottom: -1px;
  border: 0; border-bottom: 2px solid transparent; background: none; white-space: nowrap;
  color: var(--text-secondary); font-weight: 700; font-size: var(--text-sm); cursor: pointer;
}
.tabs button:hover { color: var(--text-primary); }
.tabs button[aria-selected="true"] { color: var(--accent-text); border-bottom-color: var(--accent); }

/* ── الإحصاءات ── */
.stats { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); }
.stat {
  background: var(--bg-surface); border: 1px solid var(--border-default); border-radius: var(--radius-2xl);
  padding: 16px 18px; display: flex; flex-direction: column; gap: 10px; box-shadow: var(--shadow-bento);
}
.stat.compact { flex-direction: row; align-items: center; justify-content: space-between; padding: 12px 16px; border-radius: var(--radius-xl); }
.stat-label { display: flex; align-items: center; gap: 7px; color: var(--text-secondary); font-size: var(--text-xs); font-weight: 600; }
.stat-value { font: 700 var(--text-2xl) var(--font-mono); line-height: 1.1; font-variant-numeric: tabular-nums; }
.stat.compact .stat-value { font-size: var(--text-md); }
.stat-foot { color: var(--text-tertiary); font-size: var(--text-xs); }
.tone-accent .ic, .tone-accent .stat-value { color: var(--accent-text); }
.tone-ok .ic, .tone-ok .stat-value { color: var(--ok-text); }
.tone-warn .ic, .tone-warn .stat-value { color: var(--warn-text); }
.tone-err .ic, .tone-err .stat-value { color: var(--err-text); }

/* ── التقدم ── */
.progress { height: 8px; border-radius: 99px; background: var(--bg-muted); overflow: hidden; display: flex; }
.progress > i { height: 100%; transition: width var(--duration-normal) var(--ease-standard); }
.progress > i.ok { background: linear-gradient(90deg, var(--ok), #34D399); }
.progress > i.err { background: var(--err); }
.progress.live > i.ok {
  background-image: linear-gradient(135deg, rgba(255,255,255,.18) 25%, transparent 25%, transparent 50%, rgba(255,255,255,.18) 50%, rgba(255,255,255,.18) 75%, transparent 75%), linear-gradient(90deg, var(--ok), #34D399);
  background-size: 28px 28px, auto; animation: stripes 1s linear infinite;
}
.ring { position: relative; width: 64px; height: 64px; flex-shrink: 0; }
.ring svg { transform: rotate(-90deg); }
.ring b { position: absolute; inset: 0; display: grid; place-items: center; font: 700 var(--text-sm) var(--font-mono); }
.health-bar { display: flex; height: 10px; border-radius: 99px; overflow: hidden; background: var(--bg-muted); }
.health-bar i { height: 100%; }

/* ── الحالات الفارغة والهياكل ── */
.empty { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 10px; padding: 48px 16px; color: var(--text-secondary); }
.empty .empty-icon {
  width: 56px; height: 56px; border-radius: var(--radius-xl); display: grid; place-items: center;
  background: var(--accent-subtle); color: var(--accent-text); border: 1px solid var(--accent-border);
}
.empty h3 { color: var(--text-primary); font-size: var(--text-md); }
.skeleton {
  border-radius: var(--radius-md);
  background: linear-gradient(90deg, var(--bg-subtle) 25%, var(--bg-muted) 37%, var(--bg-subtle) 63%);
  background-size: 400% 100%; animation: shimmer 1.4s ease infinite;
}

/* ── الجداول ── */
.table-wrap { overflow: auto; border: 1px solid var(--border-default); border-radius: var(--radius-xl); max-height: 600px; background: var(--bg-surface); }
table.table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: var(--text-sm); }
.table th, .table td { padding: 10px 14px; text-align: start; border-bottom: 1px solid var(--border-subtle); vertical-align: middle; }
.table th {
  position: sticky; top: 0; z-index: 1; white-space: nowrap;
  background: var(--bg-elevated); color: var(--text-secondary); font-size: var(--text-xs); font-weight: 700;
}
.table th.sortable { cursor: pointer; user-select: none; }
.table th.sortable:hover { color: var(--text-primary); }
.table tbody tr { transition: background var(--duration-fast); }
.table tbody tr:hover td { background: var(--bg-subtle); }
.table tr:last-child td { border-bottom: 0; }
.table td.clip { max-width: 380px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.table td.nowrap, .table td a { white-space: nowrap; }
.table .num { text-align: end; }

/* ── الرسوم ── */
.chart-tip { background: var(--bg-overlay); border: 1px solid var(--border-strong); border-radius: 8px; padding: 4px 10px; font-size: var(--text-xs); box-shadow: var(--shadow-md); z-index: 2; }
.bar-row { display: flex; flex-direction: column; gap: 4px; }
.bar-track { height: 8px; border-radius: 99px; background: var(--bg-muted); overflow: hidden; }
.bar-fill { display: block; height: 100%; border-radius: 99px; transition: width var(--duration-normal) var(--ease-standard); }
.metric-tile { display: flex; flex-direction: column; gap: 3px; padding: 12px 14px; border-radius: var(--radius-lg); background: var(--bg-subtle); border: 1px solid var(--border-subtle); }
.metric-tile b { font: 700 var(--text-lg) var(--font-mono); }
.metric-tile .delta { font-size: var(--text-xs); font-weight: 700; }
.delta.up { color: var(--ok-text); }
.delta.down { color: var(--err-text); }

/* ── خريطة أفضل وقت + بطاقة تغريدة ── */
.heat { display: grid; grid-template-columns: auto repeat(24, 1fr); gap: 2px; font-size: 9px; }
.heat .hlabel { color: var(--text-tertiary); font-size: 9px; display: flex; align-items: center; justify-content: center; padding: 0 4px; white-space: nowrap; }
.heat .cell { aspect-ratio: 1; border-radius: 3px; background: var(--bg-muted); }
.tw-card { border: 1px solid var(--border-subtle); border-radius: var(--radius-lg); padding: 12px 14px; background: var(--bg-subtle); }
.tw-card .tw-text { line-height: 1.7; margin: 6px 0; overflow-wrap: anywhere; }
.tw-metrics { display: flex; gap: 14px; color: var(--text-tertiary); font-size: var(--text-xs); }
.tw-metrics span { display: inline-flex; align-items: center; gap: 4px; }
.compose-preview { border: 1px dashed var(--border-strong); border-radius: var(--radius-lg); padding: 14px; background: var(--bg-canvas); }

