/**
 * 👑 Super Admin Panel Styles
 * invite-k v6.0
 */

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: 'Cairo', 'Tajawal', -apple-system, BlinkMacSystemFont, sans-serif;
  background: #f7fafc;
  color: #2d3748;
}

.admin-layout {
  display: grid;
  grid-template-columns: 260px 1fr;
  min-height: 100vh;
}

/* ═══════ الشريط الجانبي ═══════ */
.admin-sidebar {
  background: linear-gradient(180deg, #1a202c 0%, #2d3748 100%);
  color: white;
  padding: 24px 16px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

.admin-brand {
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 0 8px 20px;
  border-bottom: 1px solid rgba(255,255,255,0.1);
  margin-bottom: 20px;
}

.admin-brand img {
  width: 48px;
  height: 48px;
  border-radius: 10px;
  background: white;
  padding: 4px;
}

.admin-brand h3 {
  margin: 0 0 4px;
  font-size: 18px;
}

.badge-admin {
  background: linear-gradient(135deg, #f6ad55, #ed8936);
  color: white;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 700;
}

.admin-nav {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.admin-nav-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  color: #cbd5e0;
  text-decoration: none;
  border-radius: 10px;
  font-weight: 600;
  font-size: 14px;
  transition: all 0.2s;
  position: relative;
}

.admin-nav-link:hover {
  background: rgba(255,255,255,0.06);
  color: white;
}

.admin-nav-link.active {
  background: linear-gradient(135deg, #667eea, #764ba2);
  color: white;
  box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.admin-nav-link span {
  flex: 1;
}

.nav-badge {
  background: #e53e3e;
  color: white;
  border-radius: 10px;
  padding: 2px 8px;
  font-size: 11px;
  font-weight: 700;
  font-style: normal;
  display: none;
}

.admin-user-info {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px;
  background: rgba(255,255,255,0.05);
  border-radius: 10px;
  margin-top: 12px;
}

.admin-user-info .avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: linear-gradient(135deg, #f6ad55, #ed8936);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
}

.admin-user-info b {
  display: block;
  font-size: 14px;
}

.admin-user-info small {
  color: #a0aec0;
  font-size: 11px;
}

.admin-user-info > div:nth-child(2) {
  flex: 1;
  min-width: 0;
  overflow: hidden;
}

.admin-user-info small {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: block;
}

.btn-logout {
  background: transparent;
  color: #cbd5e0;
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: 8px;
  padding: 8px 10px;
  cursor: pointer;
  font-size: 16px;
  transition: all 0.2s;
}

.btn-logout:hover {
  background: #e53e3e;
  color: white;
  border-color: #e53e3e;
}

/* ═══════ المحتوى الرئيسي ═══════ */
.admin-main {
  padding: 32px;
  overflow-x: hidden;
}

.admin-section {
  display: none;
  animation: fadeIn 0.3s ease;
}

.admin-section.active {
  display: block;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.admin-header {
  margin-bottom: 24px;
}

.admin-header h1 {
  margin: 0 0 6px;
  font-size: 28px;
  color: #1a202c;
}

.admin-header p {
  color: #718096;
  margin: 0;
}

/* ═══════ بطاقات الإحصاءات ═══════ */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  background: white;
  border-radius: 14px;
  padding: 20px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.04);
  position: relative;
  overflow: hidden;
  border-right: 4px solid #667eea;
}

.stat-card.stat-success { border-right-color: #48bb78; }
.stat-card.stat-warning { border-right-color: #ed8936; }
.stat-card.stat-info { border-right-color: #4299e1; }
.stat-card.stat-primary { border-right-color: #667eea; }

.stat-icon {
  font-size: 32px;
  margin-bottom: 10px;
}

.stat-value {
  font-size: 28px;
  font-weight: 800;
  color: #1a202c;
  line-height: 1.2;
}

.stat-label {
  color: #718096;
  font-size: 13px;
  margin-top: 4px;
}

/* ═══════ الرسوم البيانية ═══════ */
.charts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(360px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.chart-card {
  background: white;
  border-radius: 14px;
  padding: 20px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.04);
}

.chart-card h3 {
  margin: 0 0 16px;
  font-size: 16px;
  color: #2d3748;
}

.chart-card canvas {
  max-height: 260px;
}

/* ═══════ البطاقات العامة ═══════ */
.card {
  background: white;
  border-radius: 14px;
  padding: 20px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.04);
  margin-bottom: 16px;
  border: 1px solid #e2e8f0;
}

.card h3 {
  margin: 0 0 14px;
  font-size: 18px;
  color: #2d3748;
}

/* ═══════ شريط الأدوات ═══════ */
.toolbar {
  display: flex;
  gap: 10px;
  margin-bottom: 16px;
  flex-wrap: wrap;
  align-items: center;
}

.toolbar input[type="text"],
.toolbar input[type="email"],
.toolbar input[type="tel"],
.toolbar select {
  padding: 10px 14px;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  font-family: inherit;
  font-size: 14px;
  min-width: 200px;
}

.toolbar input:focus,
.toolbar select:focus {
  outline: none;
  border-color: #667eea;
}

/* ═══════ الأزرار ═══════ */
.btn {
  padding: 10px 16px;
  background: linear-gradient(135deg, #667eea, #764ba2);
  color: white;
  border: none;
  border-radius: 8px;
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s;
  text-decoration: none;
  display: inline-block;
}

.btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

.btn-ghost {
  background: white;
  color: #4a5568;
  border: 1px solid #e2e8f0;
}

.btn-ghost:hover {
  background: #f7fafc;
  box-shadow: 0 2px 6px rgba(0,0,0,0.08);
}

.btn-success { background: linear-gradient(135deg, #48bb78, #38a169); }
.btn-danger { background: linear-gradient(135deg, #f56565, #c53030); }
.btn-warning { background: linear-gradient(135deg, #ed8936, #dd6b20); }

.btn-icon {
  background: #f7fafc;
  border: 1px solid #e2e8f0;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.15s;
  font-size: 14px;
  padding: 0;
  margin: 0 2px;
}

.btn-icon:hover {
  background: #667eea;
  color: white;
  border-color: #667eea;
}

.btn-danger-icon:hover {
  background: #f56565;
  border-color: #f56565;
}

/* ═══════ الجداول ═══════ */
.table-wrapper {
  overflow-x: auto;
  border-radius: 10px;
}

.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.admin-table thead {
  background: #f7fafc;
}

.admin-table th {
  padding: 12px;
  text-align: right;
  color: #4a5568;
  font-weight: 700;
  border-bottom: 2px solid #e2e8f0;
  font-size: 13px;
}

.admin-table td {
  padding: 12px;
  border-bottom: 1px solid #edf2f7;
}

.admin-table tr:hover {
  background: #f7fafc;
}

.admin-table .actions-cell {
  white-space: nowrap;
}

.admin-table .muted {
  text-align: center;
  color: #a0aec0;
  padding: 30px !important;
}

/* ═══════ Badges ═══════ */
.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 600;
}

.badge-success { background: #c6f6d5; color: #22543d; }
.badge-danger { background: #fed7d7; color: #c53030; }
.badge-warning { background: #feebc8; color: #7c2d12; }
.badge-info { background: #bee3f8; color: #2a4365; }
.badge-pending { background: #fef5e7; color: #d69e2e; }
.badge-approved { background: #c6f6d5; color: #22543d; }
.badge-rejected { background: #fed7d7; color: #c53030; }

.badge-plan-self { background: #edf2f7; color: #4a5568; }
.badge-plan-silver { background: #e2e8f0; color: #2d3748; }
.badge-plan-gold { background: #fef5e7; color: #975a16; }
.badge-plan-diamond { background: #e0f2ff; color: #2c5282; }

/* ═══════ بطاقات الطلبات ═══════ */
.orders-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(340px, 1fr));
  gap: 16px;
}

.order-card {
  background: white;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  overflow: hidden;
  transition: box-shadow 0.2s;
}

.order-card:hover {
  box-shadow: 0 4px 12px rgba(0,0,0,0.08);
}

.order-header {
  background: linear-gradient(135deg, #667eea, #764ba2);
  color: white;
  padding: 12px 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.order-body {
  padding: 16px;
}

.order-row {
  display: flex;
  justify-content: space-between;
  padding: 6px 0;
  border-bottom: 1px dashed #edf2f7;
  font-size: 14px;
}

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

.order-row span {
  color: #718096;
}

.order-actions {
  display: flex;
  gap: 8px;
  padding: 12px 16px;
  background: #f7fafc;
  border-top: 1px solid #e2e8f0;
}

.order-actions .btn {
  flex: 1;
  font-size: 13px;
  padding: 8px;
}

/* ═══════ الكوبونات ═══════ */
.coupons-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 16px;
}

.coupon-card {
  background: linear-gradient(135deg, #667eea, #764ba2);
  color: white;
  border-radius: 14px;
  padding: 20px;
  position: relative;
  text-align: center;
  transition: transform 0.2s;
}

.coupon-card:hover {
  transform: translateY(-3px);
}

.coupon-card.inactive {
  background: linear-gradient(135deg, #a0aec0, #718096);
  opacity: 0.7;
}

.coupon-discount {
  font-size: 42px;
  font-weight: 900;
  line-height: 1;
}

.coupon-code {
  font-size: 18px;
  margin: 8px 0;
}

.coupon-code code {
  background: rgba(255,255,255,0.2);
  padding: 4px 12px;
  border-radius: 6px;
  color: white;
}

.coupon-info {
  font-size: 13px;
  opacity: 0.9;
  margin-bottom: 10px;
}

.coupon-actions {
  display: flex;
  gap: 6px;
  justify-content: center;
}

.coupon-actions .btn-icon {
  background: rgba(255,255,255,0.2);
  color: white;
  border: 1px solid rgba(255,255,255,0.3);
}

.coupon-actions .btn-icon:hover {
  background: rgba(255,255,255,0.35);
}

/* ═══════ سجل النشاط ═══════ */
.activity-list {
  max-height: 500px;
  overflow-y: auto;
}

.activity-item {
  display: flex;
  gap: 12px;
  padding: 12px;
  border-bottom: 1px solid #edf2f7;
  align-items: flex-start;
}

.activity-item:last-child {
  border-bottom: none;
}

.activity-icon {
  font-size: 24px;
  flex-shrink: 0;
}

.activity-details {
  flex: 1;
}

.activity-details b {
  display: block;
  font-size: 14px;
  color: #2d3748;
}

.activity-details small {
  display: block;
  color: #a0aec0;
  font-size: 12px;
  margin-top: 2px;
}

.activity-details code {
  display: block;
  background: #f7fafc;
  padding: 4px 8px;
  border-radius: 4px;
  margin-top: 4px;
  direction: ltr;
}

/* ═══════ Modal ═══════ */
.modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(26, 32, 44, 0.7);
  backdrop-filter: blur(4px);
}

.modal-content {
  position: relative;
  background: white;
  border-radius: 14px;
  max-width: 580px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 25px 60px rgba(0,0,0,0.3);
}

.modal-header {
  padding: 18px 20px;
  border-bottom: 1px solid #e2e8f0;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-header h3 {
  margin: 0;
  font-size: 20px;
}

.modal-header button {
  background: none;
  border: none;
  font-size: 22px;
  cursor: pointer;
  color: #a0aec0;
  width: 32px;
  height: 32px;
  border-radius: 6px;
}

.modal-header button:hover {
  background: #f7fafc;
  color: #2d3748;
}

.modal-body {
  padding: 20px;
}

.modal-actions {
  display: flex;
  gap: 10px;
  margin-top: 16px;
  justify-content: flex-end;
  flex-wrap: wrap;
}

.settings-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.settings-form input,
.settings-form select,
.settings-form textarea {
  padding: 10px 14px;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  font-family: inherit;
  font-size: 14px;
  width: 100%;
}

.settings-form input:focus,
.settings-form select:focus,
.settings-form textarea:focus {
  outline: none;
  border-color: #667eea;
}

.success-panel {
  text-align: center;
}

.creds-box {
  background: #f7fafc;
  border-radius: 10px;
  padding: 14px;
  margin: 14px 0;
  text-align: right;
}

.creds-box > div {
  padding: 6px 0;
  border-bottom: 1px dashed #e2e8f0;
}

.creds-box > div:last-child {
  border-bottom: none;
}

.creds-box code {
  background: white;
  padding: 2px 8px;
  border-radius: 4px;
  direction: ltr;
  display: inline-block;
  color: #2d3748;
  border: 1px solid #e2e8f0;
}

.success-panel textarea {
  width: 100%;
  padding: 12px;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  font-family: inherit;
  font-size: 13px;
  margin: 10px 0;
  resize: vertical;
  direction: rtl;
}

/* ═══════ حالة فارغة ═══════ */
.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: #718096;
}

.empty-state h3 {
  margin: 16px 0 8px;
}

/* ═══════ استجابة للأجهزة الصغيرة ═══════ */
@media (max-width: 768px) {
  .admin-layout {
    grid-template-columns: 1fr;
  }
  .admin-sidebar {
    position: static;
    height: auto;
    padding: 16px;
  }
  .admin-nav {
    flex-direction: row;
    overflow-x: auto;
    gap: 6px;
  }
  .admin-nav-link {
    flex-shrink: 0;
    white-space: nowrap;
  }
  .admin-nav-link span {
    display: none;
  }
  .admin-user-info {
    margin-top: 0;
  }
  .admin-main {
    padding: 16px;
  }
  .admin-header h1 {
    font-size: 22px;
  }
  .toolbar input,
  .toolbar select {
    min-width: 0;
    flex: 1;
  }
}

.muted {
  color: #a0aec0;
  text-align: center;
  padding: 20px;
}
