/* Instagram Intelligence — Phase 1 (صفحة الاتصال/الإعدادات فقط).
   تعتمد بالكامل على متغيرات/مكوّنات style.css وdashboard.css الحالية
   (.dash-card، .cd-btn-primary/.cd-btn-ghost من tasks.css عبر dashboard.css
   المُحمَّل مسبقاً) — لا تُعرِّف نظام تصميم جديداً، فقط تخطيط ونمط خاص
   بهذه الصفحة تحديداً (بادئة ig- بنفس اتفاقية ur-/cd- الحالية). */

.ig-no-access {
  margin: 24px;
  padding: 32px;
  text-align: center;
  color: var(--text-2, #555);
  background: var(--panel, #fff);
  border-radius: var(--radius-lg, 12px);
  border: 1px solid var(--border, #e5e5e5);
}

.ig-content {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 20px 24px;
  max-width: 1080px;
}

.ig-status-card .dash-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.ig-status-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 600;
  padding: 4px 12px;
  border-radius: 999px;
  background: var(--border, #e5e5e5);
  color: var(--text-2, #555);
}
/* نقطة حالة ملوّنة قبل النص — بلا أي لمس لـ JS: تعتمد فقط على currentColor
   الموروث من صنف الحالة (ig-connected/ig-disconnected/...) الذي يضبطه
   instagram-settings.js عبر className، فتتلوّن تلقائياً مع كل حالة. */
.ig-status-badge::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
  flex-shrink: 0;
}
.ig-status-badge.ig-connected { background: #d7f4e3; color: #157347; }
.ig-status-badge.ig-disconnected { background: var(--border, #e5e5e5); color: var(--text-2, #555); }
.ig-status-badge.ig-expired,
.ig-status-badge.ig-permission_missing { background: #fdeecb; color: #9a6400; }
.ig-status-badge.ig-sync_failed { background: #fbdada; color: #a02020; }

:root[data-theme="dark"] .ig-status-badge.ig-connected { background: #113826; color: #6fe3a3; }
:root[data-theme="dark"] .ig-status-badge.ig-expired,
:root[data-theme="dark"] .ig-status-badge.ig-permission_missing { background: #3a2c0f; color: #e9bd63; }
:root[data-theme="dark"] .ig-status-badge.ig-sync_failed { background: #3a1414; color: #f0a3a3; }

.ig-status-body {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin: 14px 0;
}

.ig-status-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 8px;
  border-bottom: 1px dashed var(--border, #e5e5e5);
  font-size: 14px;
}
.ig-status-row:last-child { border-bottom: none; padding-bottom: 0; }

.ig-status-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--text-2, #666);
}
.ig-status-row-icon { flex-shrink: 0; }
.ig-error-row .ig-status-row-icon { color: #a02020; }
:root[data-theme="dark"] .ig-error-row .ig-status-row-icon { color: #f0a3a3; }
.ig-status-value { font-weight: 600; }
.ig-error-text { color: #a02020; font-weight: 500; }
:root[data-theme="dark"] .ig-error-text { color: #f0a3a3; }

.ig-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.cd-btn-danger {
  background: transparent;
  border: 1px solid #d9534f;
  color: #d9534f;
  border-radius: var(--radius-md, 8px);
  padding: 9px 16px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}
.cd-btn-danger:hover { background: #d9534f; color: #fff; }

.ig-info-text {
  font-size: 13.5px;
  line-height: 1.9;
  color: var(--text-2, #555);
  margin: 10px 0 0;
}

/* ── Phase 2: Dashboard حساب الشركة ─────────────────────────────────── */

/* تصغير أيقونة .ig-kpi-icon المشتركة (34px، مصمَّمة أصلاً لبطاقة .ig-kpi-card
   الأكبر) لتناسب كثافة .dash-kpi-card الأصغر في هذه الصفحة تحديداً — بلا
   لمس لتعريف .ig-kpi-icon نفسه في instagram-design-system.css. */
.dash-kpi-header .ig-kpi-icon {
  width: 26px;
  height: 26px;
  border-radius: 7px;
}
.dash-kpi-header .ig-kpi-icon svg { width: 14px; height: 14px; }

.ig-toolbar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: space-between;
}

.ig-filter-presets {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.ig-filter-btn {
  border: 1px solid var(--border, #e5e5e5);
  background: var(--panel, #fff);
  color: var(--text-2, #555);
  border-radius: 999px;
  padding: 6px 14px;
  font-size: 13px;
  cursor: pointer;
}
.ig-filter-btn.active {
  background: var(--accent, #2f6f4e);
  border-color: var(--accent, #2f6f4e);
  color: #fff;
}

.ig-filter-select {
  border: 1px solid var(--border, #e5e5e5);
  background: var(--panel, #fff);
  color: var(--text, #1a1a1a);
  border-radius: 8px;
  padding: 6px 10px;
  font-size: 13px;
}

.ig-dash-empty,
.ig-dash-error {
  padding: 32px;
  text-align: center;
  color: var(--text-2, #555);
  background: var(--panel, #fff);
  border-radius: var(--radius-lg, 12px);
  border: 1px solid var(--border, #e5e5e5);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}
.ig-dash-error { color: #a02020; border-color: #f0b8b8; }
:root[data-theme="dark"] .ig-dash-error { color: #f0a3a3; }

.ig-growth-note {
  font-size: 13px;
  color: var(--text-2, #666);
  background: var(--panel, #f7f7f7);
  border: 1px dashed var(--border, #e5e5e5);
  border-radius: 8px;
  padding: 10px 14px;
  white-space: pre-line;
  margin: 0;
}

.ig-empty-inline {
  font-size: 13px;
  color: var(--text-2, #777);
  text-align: center;
  padding: 20px 0 4px;
}

#ig-growth-svg {
  width: 100%;
  height: 160px;
  display: block;
}
.ig-growth-line { fill: none; stroke: var(--accent, #2f6f4e); stroke-width: 2; }
.ig-growth-area { fill: var(--accent, #2f6f4e); opacity: .1; stroke: none; }
.ig-growth-dot { fill: var(--accent, #2f6f4e); }

.ig-best-worst-row { grid-template-columns: 1fr 1fr; }

.ig-post-highlight {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  font-size: 13.5px;
  color: var(--text-2, #555);
}
.ig-post-highlight img {
  width: 64px;
  height: 64px;
  border-radius: 8px;
  object-fit: cover;
  flex-shrink: 0;
  background: var(--border, #eee);
}
.ig-post-highlight-body { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.ig-post-highlight-caption {
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  color: var(--text, #1a1a1a);
  font-weight: 500;
}
.ig-post-highlight-meta { display: flex; gap: 10px; flex-wrap: wrap; font-size: 12.5px; }

.ig-media-row-cell { display: flex; align-items: center; gap: 10px; }
.ig-media-row-cell img {
  width: 40px;
  height: 40px;
  border-radius: 6px;
  object-fit: cover;
  flex-shrink: 0;
  background: var(--border, #eee);
}
.ig-media-row-caption {
  max-width: 260px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.ig-na { color: var(--text-2, #999); }

.ig-pagination {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 10px;
  padding-top: 12px;
  font-size: 13px;
}
.ig-pagination button {
  border: 1px solid var(--border, #e5e5e5);
  background: var(--panel, #fff);
  border-radius: 6px;
  padding: 5px 12px;
  cursor: pointer;
  color: var(--text, #1a1a1a);
}
.ig-pagination button:disabled { opacity: .4; cursor: default; }

@media (max-width: 720px) {
  .ig-best-worst-row { grid-template-columns: 1fr; }
  .ig-media-row-caption { max-width: 140px; }
  .ig-toolbar { flex-direction: column; align-items: stretch; }
}

.ig-toast-wrap {
  position: fixed;
  bottom: 20px;
  inset-inline-end: 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 999;
}
.ig-toast {
  background: var(--panel, #1a1a1a);
  color: #fff;
  padding: 10px 16px;
  border-radius: 8px;
  font-size: 13.5px;
  box-shadow: 0 4px 14px rgba(0,0,0,.18);
  animation: ig-toast-in .18s ease-out;
}
.ig-toast.ig-toast-error { background: #a02020; }
.ig-toast.ig-toast-success { background: #157347; }
@keyframes ig-toast-in {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

@media (max-width: 720px) {
  .ig-content { padding: 16px; max-width: none; }
}
