@import url('https://fonts.googleapis.com/css2?family=Cairo:wght@400;600;700;800;900&display=swap');

:root {
  --primary-red: #dc2626;
  --primary-red-hover: #b91c1c;
  --accent-red: #ef4444;
  --bright-red: #f87171;
  --glow-red: rgba(220, 38, 38, 0.25);

  --bg-dark: #090d16;
  --bg-card: rgba(15, 23, 42, 0.75);
  --bg-card-hover: rgba(30, 41, 59, 0.85);

  --text-main: #ffffff;
  --text-muted: #94a3b8;
  --text-dim: #64748b;

  --border-red: rgba(220, 38, 38, 0.25);
  --border-subtle: rgba(255, 255, 255, 0.08);

  --success: #10b981;
  --warning: #f59e0b;
  --info: #38bdf8;
  --danger: #ef4444;

  --radius-lg: 16px;
  --radius-md: 10px;
  --radius-sm: 6px;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: 'Cairo', system-ui, -apple-system, sans-serif;
}

body {
  background-color: var(--bg-dark);
  background-image:
    radial-gradient(circle at 15% 15%, rgba(220, 38, 38, 0.12) 0%, transparent 45%),
    radial-gradient(circle at 85% 85%, rgba(185, 28, 28, 0.08) 0%, transparent 50%);
  background-attachment: fixed;
  color: var(--text-main);
  min-height: 100vh;
  direction: rtl;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

/* ---------- شاشة تسجيل الدخول ---------- */
.login-body {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  padding: 20px;
}

.login-card {
  background: var(--bg-card);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--border-red);
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.6), 0 0 30px var(--glow-red);
  padding: 40px 36px;
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 440px;
  text-align: center;
  position: relative;
  transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.login-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 30px 60px -12px rgba(0, 0, 0, 0.7), 0 0 40px rgba(220, 38, 38, 0.35);
}

.brand-logo-container {
  display: inline-flex;
  padding: 12px;
  background: rgba(220, 38, 38, 0.1);
  border-radius: 50%;
  border: 1px solid var(--border-red);
  margin-bottom: 16px;
  box-shadow: 0 0 20px var(--glow-red);
}

.brand-logo-img {
  width: 64px;
  height: 64px;
  object-fit: contain;
  filter: drop-shadow(0 4px 8px rgba(220, 38, 38, 0.4));
}

.login-card h1 {
  font-size: 26px;
  font-weight: 800;
  color: var(--text-main);
  letter-spacing: -0.5px;
  margin-bottom: 4px;
}

.login-card .subtitle {
  color: var(--text-muted);
  font-size: 14px;
  margin-bottom: 28px;
}

.form-group {
  text-align: right;
  margin-bottom: 18px;
}

.form-group label {
  display: block;
  font-size: 13px;
  font-weight: 700;
  color: var(--text-muted);
  margin-bottom: 6px;
}

input[type="text"],
input[type="password"],
input[type="number"],
select {
  width: 100%;
  padding: 12px 16px;
  background: rgba(15, 23, 42, 0.8);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  color: var(--text-main);
  font-size: 14px;
  outline: none;
  transition: all 0.2s ease;
}

input:focus,
select:focus {
  border-color: var(--primary-red);
  box-shadow: 0 0 12px var(--glow-red);
  background: rgba(15, 23, 42, 0.95);
}

/* تذكرني checkbox */
.remember-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 24px;
  cursor: pointer;
  user-select: none;
  font-size: 13px;
  color: var(--text-muted);
}

.remember-row input[type="checkbox"] {
  appearance: none;
  -webkit-appearance: none;
  width: 18px;
  height: 18px;
  border: 1px solid var(--border-subtle);
  border-radius: 4px;
  background: rgba(15, 23, 42, 0.8);
  cursor: pointer;
  position: relative;
  transition: all 0.2s ease;
}

.remember-row input[type="checkbox"]:checked {
  background: var(--primary-red);
  border-color: var(--primary-red);
  box-shadow: 0 0 8px var(--glow-red);
}

.remember-row input[type="checkbox"]:checked::after {
  content: '✓';
  position: absolute;
  color: white;
  font-size: 12px;
  font-weight: bold;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
}

.btn {
  width: 100%;
  padding: 12px;
  background: linear-gradient(135deg, var(--primary-red) 0%, #991b1b 100%);
  color: var(--text-main);
  border: none;
  border-radius: var(--radius-md);
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.25s ease;
  box-shadow: 0 4px 15px var(--glow-red);
}

.btn:hover {
  background: linear-gradient(135deg, var(--accent-red) 0%, var(--primary-red) 100%);
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(220, 38, 38, 0.4);
}

.btn:active {
  transform: translateY(0);
}

.error-text {
  color: var(--accent-red);
  font-size: 13px;
  margin-top: 14px;
  font-weight: 600;
}

/* ---------- لوحة التحكم الرئسية ---------- */
.topbar {
  background: rgba(9, 13, 22, 0.85);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border-red);
  padding: 14px 28px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
}

.topbar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.topbar-logo {
  width: 40px;
  height: 40px;
  object-fit: contain;
  filter: drop-shadow(0 2px 6px rgba(220, 38, 38, 0.5));
}

.topbar-brand h2 {
  font-size: 20px;
  font-weight: 800;
  color: var(--text-main);
  margin: 0;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.pwa-btn {
  background: rgba(56, 189, 248, 0.15);
  color: var(--info);
  border: 1px solid rgba(56, 189, 248, 0.35);
  padding: 8px 16px;
  border-radius: var(--radius-md);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  display: none;
  align-items: center;
  gap: 6px;
  transition: all 0.2s ease;
}

.pwa-btn:hover {
  background: var(--info);
  color: #000;
  box-shadow: 0 0 15px rgba(56, 189, 248, 0.4);
}

#logoutBtn {
  background: rgba(239, 68, 68, 0.15);
  color: var(--accent-red);
  border: 1px solid rgba(239, 68, 68, 0.35);
  padding: 8px 16px;
  border-radius: var(--radius-md);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s ease;
}

#logoutBtn:hover {
  background: var(--primary-red);
  color: #fff;
  box-shadow: 0 0 15px var(--glow-red);
}

.container {
  max-width: 100%;
  margin: 28px 0;
  padding: 0 32px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.card {
  background: var(--bg-card);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
  transition: border-color 0.2s ease;
  width: 100%;
}

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

.card h3 {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-main);
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.card h3::before {
  content: '';
  display: inline-block;
  width: 4px;
  height: 18px;
  background: var(--primary-red);
  border-radius: 2px;
  box-shadow: 0 0 8px var(--glow-red);
}

.form-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
  margin-bottom: 16px;
}

.license-key-display {
  background: rgba(220, 38, 38, 0.1);
  border: 1px solid var(--border-red);
  padding: 16px 20px;
  border-radius: var(--radius-md);
  margin-top: 20px;
  display: none;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(-4px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.copy-btn {
  background: rgba(56, 189, 248, 0.2);
  color: var(--info);
  border: 1px solid rgba(56, 189, 248, 0.4);
  padding: 6px 14px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 700;
  transition: all 0.2s ease;
}

.copy-btn:hover {
  background: #0284c7;
  color: white;
}

/* ---------- الجدول المتجاوب للشاشات الكبيرة ---------- */
.table-responsive {
  width: 100%;
  overflow-x: auto;
  border-radius: var(--radius-md);
}

table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0 10px;
  font-size: 14px;
}

th {
  color: var(--text-muted);
  font-weight: 700;
  font-size: 13px;
  padding: 14px 18px;
  text-align: right;
  border-bottom: 1px solid var(--border-subtle);
  background: transparent;
}

tr {
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

tr:hover td {
  background: rgba(30, 41, 59, 0.85);
}

td {
  padding: 16px 18px;
  background: rgba(15, 23, 42, 0.6);
  text-align: right;
  border-top: 1px solid rgba(255, 255, 255, 0.05);
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  transition: background 0.2s ease;
}

td:first-child {
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
  border-right: 1px solid rgba(255, 255, 255, 0.05);
}

td:last-child {
  border-radius: var(--radius-md) 0 0 var(--radius-md);
  border-left: 1px solid rgba(255, 255, 255, 0.05);
}

/* badges */
.badge {
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 700;
  display: inline-block;
}

.badge-active {
  background: rgba(16, 185, 129, 0.2);
  color: #34d399;
  border: 1px solid rgba(16, 185, 129, 0.4);
}

.badge-pending {
  background: rgba(148, 163, 184, 0.2);
  color: #cbd5e1;
  border: 1px solid rgba(148, 163, 184, 0.4);
}

.badge-suspended {
  background: rgba(245, 158, 11, 0.2);
  color: #fbbf24;
  border: 1px solid rgba(245, 158, 11, 0.4);
}

.badge-revoked {
  background: rgba(239, 68, 68, 0.2);
  color: #fca5a5;
  border: 1px solid rgba(239, 68, 68, 0.4);
}

/* أزرار الاجراءات */
.action-btn {
  padding: 6px 14px;
  border-radius: 8px;
  border: none;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  font-family: inherit;
  margin-left: 4px;
  margin-bottom: 4px;
  transition: all 0.15s ease;
}

.action-btn.copy {
  background: rgba(56, 189, 248, 0.2);
  color: #38bdf8;
  border: 1px solid rgba(56, 189, 248, 0.4);
}

.action-btn.copy:hover {
  background: #0284c7;
  color: white;
}

.action-btn.activate {
  background: rgba(16, 185, 129, 0.2);
  color: #34d399;
  border: 1px solid rgba(16, 185, 129, 0.4);
}

.action-btn.activate:hover {
  background: var(--success);
  color: white;
}

.action-btn.suspend {
  background: rgba(245, 158, 11, 0.2);
  color: #fbbf24;
  border: 1px solid rgba(245, 158, 11, 0.4);
}

.action-btn.suspend:hover {
  background: var(--warning);
  color: black;
}

.action-btn.revoke {
  background: rgba(239, 68, 68, 0.2);
  color: #fca5a5;
  border: 1px solid rgba(239, 68, 68, 0.4);
}

.action-btn.revoke:hover {
  background: var(--danger);
  color: white;
}

.action-btn.approve {
  background: rgba(16, 185, 129, 0.25);
  color: #34d399;
  border: 1px solid rgba(16, 185, 129, 0.5);
}

.action-btn.approve:hover {
  background: #10b981;
  color: white;
}

.action-btn.reject {
  background: rgba(239, 68, 68, 0.25);
  color: #fca5a5;
  border: 1px solid rgba(239, 68, 68, 0.5);
}

.action-btn.reject:hover {
  background: #ef4444;
  color: white;
}

.action-btn.delete {
  background: rgba(225, 29, 72, 0.25);
  color: #fda4af;
  border: 1px solid rgba(225, 29, 72, 0.5);
}

.action-btn.delete:hover {
  background: #e11d48;
  color: white;
}

.empty-state {
  color: var(--text-muted);
  text-align: center;
  padding: 32px;
}

/* ---------- مربع التأكيد العصري الابداعي (Custom Confirmation Modal) ---------- */
.modal-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 1000;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.25s ease, visibility 0.25s ease;
  padding: 20px;
}

.modal-backdrop.active {
  opacity: 1;
  visibility: visible;
}

.modal-card {
  background: #0f172a;
  border: 1px solid var(--border-red);
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.9), 0 0 35px var(--glow-red);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 440px;
  padding: 28px 24px;
  text-align: center;
  transform: scale(0.9) translateY(10px);
  transition: transform 0.25s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.modal-backdrop.active .modal-card {
  transform: scale(1) translateY(0);
}

.modal-icon-badge {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  margin: 0 auto 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  background: rgba(220, 38, 38, 0.15);
  border: 1px solid var(--border-red);
  color: var(--accent-red);
  box-shadow: 0 0 20px var(--glow-red);
}

.modal-title {
  font-size: 18px;
  font-weight: 800;
  color: var(--text-main);
  margin-bottom: 8px;
}

.modal-description {
  font-size: 14px;
  color: var(--text-muted);
  margin-bottom: 24px;
  line-height: 1.6;
}

.modal-buttons {
  display: flex;
  gap: 12px;
}

.modal-btn {
  flex: 1;
  padding: 10px;
  border-radius: var(--radius-md);
  font-size: 14px;
  font-weight: 700;
  border: none;
  cursor: pointer;
  transition: all 0.2s ease;
}

.modal-btn-confirm {
  background: linear-gradient(135deg, var(--primary-red) 0%, #991b1b 100%);
  color: white;
  box-shadow: 0 4px 12px var(--glow-red);
}

.modal-btn-confirm:hover {
  background: linear-gradient(135deg, var(--accent-red) 0%, var(--primary-red) 100%);
  box-shadow: 0 6px 16px rgba(220, 38, 38, 0.4);
}

.modal-btn-cancel {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-muted);
  border: 1px solid var(--border-subtle);
}

.modal-btn-cancel:hover {
  background: rgba(255, 255, 255, 0.15);
  color: white;
}

/* ---------- الاستجابة وتحويل الجدول لبطاقات كارتات بالشاشات الصغيرة (Responsive Cards) ---------- */
@media (max-width: 920px) {
  .topbar {
    flex-direction: column;
    gap: 12px;
    padding: 14px 16px;
    text-align: center;
  }

  .topbar-brand {
    justify-content: center;
  }

  .topbar-actions {
    width: 100%;
    justify-content: center;
  }

  .container {
    padding: 0 12px;
    margin: 16px 0;
  }

  .card {
    padding: 18px 14px;
  }

  .form-row {
    grid-template-columns: 1fr;
  }

  /* تحويل الجدول لبطاقات (كارتات) مستقيمة على الجوال */
  .table-responsive {
    overflow-x: visible;
  }

  table,
  tbody,
  tr,
  td {
    display: block;
    width: 100% !important;
  }

  thead {
    display: none;
  }

  tr {
    background: rgba(15, 23, 42, 0.85);
    backdrop-filter: blur(16px);
    border: 1px solid var(--border-red);
    border-radius: var(--radius-lg);
    padding: 18px 16px;
    margin-bottom: 18px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5), 0 0 15px var(--glow-red);
  }

  tr:hover td {
    background: transparent !important;
  }

  td {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 0;
    border: none !important;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08) !important;
    background: transparent !important;
    border-radius: 0 !important;
    text-align: left;
  }

  td:last-child {
    border-bottom: none !important;
    flex-wrap: wrap;
    justify-content: flex-start;
    gap: 8px;
    padding-top: 14px;
  }

  td::before {
    content: attr(data-label);
    font-weight: 700;
    color: var(--text-muted);
    font-size: 13px;
    margin-left: 12px;
  }
}

/* ---------- الاستجابة للتكبير والشاشات الصغيرة (Responsive) ---------- */
@media (max-width: 768px) {
  .topbar {
    flex-direction: column;
    gap: 12px;
    padding: 14px 16px;
    text-align: center;
  }

  .topbar-brand {
    justify-content: center;
  }

  .topbar-actions {
    width: 100%;
    justify-content: center;
  }

  .container {
    padding: 0 12px;
    margin: 16px auto;
  }

  .card {
    padding: 18px 14px;
  }

  .form-row {
    grid-template-columns: 1fr;
  }
}