/* ============================================
   Admin Dashboard Styles — أنماط لوحة الإدارة
   ============================================ */

/* ─── Layout ─── */
.admin-layout { display: flex; min-height: 100vh; }

/* ─── Sidebar ─── */
.sidebar {
  width: var(--sidebar-width);
  background: var(--bg-white);
  border-left: 1px solid var(--border-light);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  z-index: var(--z-sticky);
  transition: transform var(--transition-base);
}

.sidebar-header {
  padding: var(--space-6);
  border-bottom: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.sidebar-logo {
  width: 40px;
  height: 40px;
  background: linear-gradient(135deg, var(--color-primary), var(--color-secondary));
  border-radius: var(--radius-lg);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-weight: var(--font-weight-extra);
  font-size: var(--text-lg);
}

.sidebar-brand h2 { font-size: var(--text-base); line-height: 1.2; }
.sidebar-brand span { font-size: var(--text-xs); color: var(--text-muted); }

.sidebar-nav { flex: 1; padding: var(--space-4); }
.sidebar-nav-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-lg);
  color: var(--text-secondary);
  font-weight: var(--font-weight-semi);
  font-size: var(--text-sm);
  transition: all var(--transition-fast);
  margin-bottom: var(--space-1);
  cursor: pointer;
}
.sidebar-nav-item:hover { background: var(--bg-light); color: var(--text-primary); }
.sidebar-nav-item.active { background: var(--color-primary-light); color: var(--color-primary); }
.sidebar-nav-item svg { width: 20px; height: 20px; flex-shrink: 0; }
.sidebar-nav-badge { margin-right: auto; background: var(--status-urgent); color: white; width: 20px; height: 20px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 11px; font-weight: var(--font-weight-bold); }

.sidebar-footer {
  padding: var(--space-4) var(--space-6);
  border-top: 1px solid var(--border-light);
}

.sidebar-footer a {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  color: var(--text-muted);
  font-size: var(--text-sm);
  transition: color var(--transition-fast);
}
.sidebar-footer a:hover { color: var(--color-primary); }
.sidebar-footer a svg { width: 18px; height: 18px; }

/* ─── Main Content ─── */
.admin-main {
  flex: 1;
  margin-right: var(--sidebar-width);
  min-height: 100vh;
  background: var(--bg-light);
}

/* ─── Top Header ─── */
.admin-header {
  background: var(--bg-white);
  border-bottom: 1px solid var(--border-light);
  padding: var(--space-4) var(--space-8);
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: var(--z-sticky);
}

.admin-header-title h1 { font-size: var(--text-xl); }
.admin-header-title p { font-size: var(--text-sm); color: var(--text-muted); }

.admin-header-actions { display: flex; align-items: center; gap: var(--space-3); }

.mobile-menu-btn {
  display: none;
  width: 40px; height: 40px;
  align-items: center; justify-content: center;
  border-radius: var(--radius-md);
  color: var(--text-primary);
  background: var(--bg-light);
}
.mobile-menu-btn svg { width: 24px; height: 24px; }

/* ─── Stats Cards ─── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--space-5);
  padding: var(--space-8);
}

.stat-card {
  background: var(--bg-white);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-xl);
  padding: var(--space-6);
  transition: all var(--transition-base);
  position: relative;
  overflow: hidden;
}
.stat-card:hover { box-shadow: var(--shadow-lg); transform: translateY(-2px); }
.stat-card::after { content: ''; position: absolute; top: 0; right: 0; left: 0; height: 3px; }
.stat-card.card-total::after { background: var(--color-primary); }
.stat-card.card-new::after { background: var(--status-new); }
.stat-card.card-progress::after { background: var(--status-progress); }
.stat-card.card-resolved::after { background: var(--status-resolved); }

.stat-card-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: var(--space-4); }
.stat-card-icon { width: 44px; height: 44px; border-radius: var(--radius-lg); display: flex; align-items: center; justify-content: center; }
.stat-card.card-total .stat-card-icon { background: var(--color-primary-light); color: var(--color-primary); }
.stat-card.card-new .stat-card-icon { background: var(--status-new-bg); color: var(--status-new); }
.stat-card.card-progress .stat-card-icon { background: var(--status-progress-bg); color: var(--status-progress); }
.stat-card.card-resolved .stat-card-icon { background: var(--status-resolved-bg); color: var(--status-resolved); }
.stat-card-icon svg { width: 22px; height: 22px; }

.stat-card-label { font-size: var(--text-sm); color: var(--text-muted); font-weight: var(--font-weight-semi); }
.stat-card-value { font-size: var(--text-3xl); font-weight: var(--font-weight-extra); margin-top: var(--space-1); }

/* ─── Content Area ─── */
.admin-content { padding: 0 var(--space-8) var(--space-8); }

/* ─── Toolbar ─── */
.toolbar {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin-bottom: var(--space-5);
  flex-wrap: wrap;
}
.toolbar-search {
  flex: 1;
  min-width: 250px;
  position: relative;
}
.toolbar-search svg { position: absolute; right: var(--space-4); top: 50%; transform: translateY(-50%); width: 18px; height: 18px; color: var(--text-muted); pointer-events: none; }
.toolbar-search input { padding-right: var(--space-10); }
.toolbar-filter select { min-width: 150px; }

/* ─── Tickets Table ─── */
.table-card {
  background: var(--bg-white);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-xl);
  overflow: hidden;
}
.table-wrapper { overflow-x: auto; }
.tickets-table { width: 100%; border-collapse: collapse; }
.tickets-table th {
  background: var(--bg-light);
  padding: var(--space-4) var(--space-5);
  text-align: right;
  font-size: var(--text-xs);
  font-weight: var(--font-weight-bold);
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  white-space: nowrap;
  border-bottom: 1px solid var(--border-light);
}
.tickets-table td {
  padding: var(--space-4) var(--space-5);
  font-size: var(--text-sm);
  border-bottom: 1px solid var(--border-light);
  white-space: nowrap;
}
.tickets-table tbody tr { transition: background var(--transition-fast); cursor: pointer; }
.tickets-table tbody tr:hover { background: var(--color-primary-50); }
.tickets-table tbody tr:last-child td { border-bottom: none; }

.table-ticket-number { font-weight: var(--font-weight-bold); color: var(--color-primary); direction: ltr; display: inline-block; }
.table-subscription { display: flex; align-items: center; gap: var(--space-2); }
.table-subscription-icon { font-size: var(--text-lg); }
.table-actions { display: flex; gap: var(--space-2); }

/* ─── Ticket Detail Modal ─── */
.detail-modal .modal { max-width: 700px; }
.detail-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: var(--space-4); margin-bottom: var(--space-6); }
.detail-item label { display: block; font-size: var(--text-xs); color: var(--text-muted); font-weight: var(--font-weight-semi); margin-bottom: var(--space-1); }
.detail-item p { font-size: var(--text-sm); font-weight: var(--font-weight-semi); color: var(--text-primary); }
.detail-description { margin-bottom: var(--space-6); }
.detail-description label { display: block; font-size: var(--text-xs); color: var(--text-muted); font-weight: var(--font-weight-semi); margin-bottom: var(--space-2); }
.detail-description p { background: var(--bg-light); padding: var(--space-4); border-radius: var(--radius-lg); font-size: var(--text-sm); line-height: 1.8; }

.detail-screenshot { margin-bottom: var(--space-6); }
.detail-screenshot label { display: block; font-size: var(--text-xs); color: var(--text-muted); font-weight: var(--font-weight-semi); margin-bottom: var(--space-2); }
.detail-screenshot img { max-width: 100%; border-radius: var(--radius-lg); border: 1px solid var(--border-light); }

.detail-status-section { margin-bottom: var(--space-6); }
.detail-status-section label { display: block; font-size: var(--text-xs); color: var(--text-muted); font-weight: var(--font-weight-semi); margin-bottom: var(--space-2); }
.status-buttons { display: flex; gap: var(--space-2); flex-wrap: wrap; }
.status-btn {
  padding: var(--space-2) var(--space-4);
  border-radius: var(--radius-full);
  font-size: var(--text-xs);
  font-weight: var(--font-weight-semi);
  border: 2px solid transparent;
  transition: all var(--transition-fast);
  cursor: pointer;
}
.status-btn.status-new { background: var(--status-new-bg); color: var(--status-new); border-color: var(--status-new-bg); }
.status-btn.status-progress { background: var(--status-progress-bg); color: var(--status-progress); border-color: var(--status-progress-bg); }
.status-btn.status-resolved { background: var(--status-resolved-bg); color: var(--status-resolved); border-color: var(--status-resolved-bg); }
.status-btn.active { border-color: currentColor; box-shadow: 0 0 0 3px rgba(0,0,0,0.05); }
.status-btn:hover { transform: scale(1.05); }

/* ─── Admin Notes ─── */
.admin-notes { margin-bottom: var(--space-6); }
.admin-notes label { display: block; font-size: var(--text-xs); color: var(--text-muted); font-weight: var(--font-weight-semi); margin-bottom: var(--space-2); }
.admin-notes textarea { min-height: 100px; }

/* ─── Timeline in Modal ─── */
.detail-timeline { margin-bottom: var(--space-4); }
.detail-timeline label { display: block; font-size: var(--text-xs); color: var(--text-muted); font-weight: var(--font-weight-semi); margin-bottom: var(--space-3); }
.timeline-list { position: relative; padding-right: var(--space-6); }
.timeline-list::before { content: ''; position: absolute; right: 8px; top: 4px; bottom: 4px; width: 2px; background: var(--border-light); }
.timeline-entry { position: relative; padding-bottom: var(--space-4); padding-right: var(--space-6); }
.timeline-entry::before { content: ''; position: absolute; right: 0; top: 4px; width: 18px; height: 18px; background: var(--color-primary-light); border: 2px solid var(--color-primary); border-radius: 50%; z-index: 1; }
.timeline-entry:last-child { padding-bottom: 0; }
.timeline-action { font-size: var(--text-sm); font-weight: var(--font-weight-semi); margin-bottom: var(--space-1); }
.timeline-meta { font-size: var(--text-xs); color: var(--text-muted); }

/* ─── Chart Section ─── */
.chart-section {
  background: var(--bg-white);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-xl);
  padding: var(--space-6);
  margin-top: var(--space-5);
}
.chart-title { font-size: var(--text-lg); margin-bottom: var(--space-5); }
.chart-container { display: flex; align-items: center; justify-content: center; gap: var(--space-8); flex-wrap: wrap; }
.pie-chart-wrapper { width: 200px; height: 200px; position: relative; }
.chart-legend { display: flex; flex-direction: column; gap: var(--space-3); }
.legend-item { display: flex; align-items: center; gap: var(--space-2); font-size: var(--text-sm); }
.legend-color { width: 12px; height: 12px; border-radius: var(--radius-sm); }
.legend-count { color: var(--text-muted); font-size: var(--text-xs); margin-right: auto; }

/* ─── Mobile Overlay ─── */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: var(--bg-overlay);
  z-index: calc(var(--z-sticky) - 1);
}

/* ─── Responsive ─── */
@media (max-width: 1024px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 768px) {
  .sidebar { transform: translateX(100%); }
  .sidebar.open { transform: translateX(0); }
  .sidebar-overlay.active { display: block; }
  .admin-main { margin-right: 0; }
  .admin-header { padding: var(--space-4); }
  .mobile-menu-btn { display: flex; }
  .stats-grid { grid-template-columns: 1fr 1fr; padding: var(--space-4); gap: var(--space-3); }
  .admin-content { padding: 0 var(--space-4) var(--space-4); }
  .toolbar { flex-direction: column; }
  .toolbar-search { min-width: 100%; }
  .detail-grid { grid-template-columns: 1fr; }
}

@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr; }
  .stat-card { padding: var(--space-4); }
  .stat-card-value { font-size: var(--text-2xl); }
}
