/* ============================================================
   ADMIN PANEL & LOGIN STYLES
   ============================================================ */

/* -------------------- LOGIN PAGE -------------------- */
.login-body {
  margin: 0;
  height: 100vh;
  height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: var(--bg);
  position: relative;
  overflow: hidden;
  font-family: 'Tajawal', sans-serif;
}

/* Animated Background */
.login-bg-shapes {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  z-index: 1;
  overflow: hidden;
  background: radial-gradient(circle at top right, var(--brand-50), var(--bg));
}
.login-shape {
  position: absolute;
  border-radius: 50%;
  filter: blur(80px);
  opacity: 0.6;
  animation: float 10s infinite ease-in-out alternate;
}
.login-shape.shape-1 {
  width: 400px; height: 400px;
  background: var(--brand-light);
  top: -100px; right: -100px;
}
.login-shape.shape-2 {
  width: 500px; height: 500px;
  background: var(--accent-glow);
  bottom: -200px; left: -100px;
  animation-delay: -3s;
}
.login-shape.shape-3 {
  width: 300px; height: 300px;
  background: rgba(14, 159, 214, 0.1);
  top: 40%; left: 60%;
  animation-delay: -6s;
}
@keyframes float {
  0% { transform: translateY(0) scale(1); }
  100% { transform: translateY(-30px) scale(1.05); }
}

/* Glass Card Container */
.login-container {
  position: relative;
  z-index: 2;
  width: 100%;
  max-width: 420px;
  margin: 0 20px;
  padding: 48px;
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid rgba(255, 255, 255, 0.6);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xl);
  text-align: center;
  animation: fadeInUp 0.6s var(--ease) forwards;
}

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

.login-header {
  margin-bottom: 35px;
}
.login-logo-wrapper {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 80px;
  height: 80px;
  background: white;
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  margin-bottom: 20px;
}
.login-logo {
  height: 45px;
  object-fit: contain;
}
.login-header h2 {
  color: var(--brand);
  font-size: 1.8rem;
  margin-bottom: 8px;
  font-weight: 800;
}
.login-header p {
  color: var(--text-muted);
  font-size: 1rem;
  margin: 0;
}

/* Modern Inputs with Floating Labels */
.input-modern {
  position: relative;
  margin-bottom: 24px;
  text-align: right;
}
.input-icon {
  position: absolute;
  right: 16px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  transition: color var(--dur);
  z-index: 2;
  width: 20px;
  height: 20px;
}
.input-modern input {
  width: 100%;
  padding: 16px 16px 16px 16px;
  padding-right: 48px;
  background: rgba(255, 255, 255, 0.9);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 1rem;
  font-family: inherit;
  color: var(--text-h);
  transition: all var(--dur);
  direction: ltr;
  text-align: left; 
}
.input-modern input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-glow);
  outline: none;
  background: white;
}
.input-modern input:focus + label,
.input-modern input:not(:placeholder-shown) + label {
  transform: translateY(-38px) scale(0.85);
  background: white;
  padding: 0 8px;
  color: var(--accent);
  right: 12px;
  border-radius: 4px;
}
.input-modern input:focus ~ .input-icon {
  color: var(--accent);
}
.input-modern label {
  position: absolute;
  right: 48px; /* aligned after the icon */
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  pointer-events: none;
  transition: all var(--dur) var(--ease);
  font-size: 1rem;
  transform-origin: right center;
  z-index: 3;
}

/* Custom Submit Button */
.login-submit-btn {
  display: flex !important;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  padding: 16px !important;
  font-size: 1.1rem !important;
  letter-spacing: 0.5px;
  margin-top: 10px;
  box-shadow: var(--shadow-sm);
}
.login-submit-btn:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}
.login-submit-btn .btn-icon {
  transition: transform var(--dur);
  width: 20px;
  height: 20px;
}
.login-submit-btn:hover .btn-icon {
  transform: translateX(-4px);
}

/* Error Message Customization */
.error-msg {
  display: flex;
  align-items: center;
  gap: 10px;
  background: #fef2f2;
  border: 1px solid #f87171;
  color: #b91c1c;
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  margin-bottom: 24px;
  font-size: 0.95rem;
  font-weight: 500;
  text-align: right;
  animation: fadeShake 0.4s;
}
@keyframes fadeShake {
  0% { transform: translateX(0); opacity: 0; }
  25% { transform: translateX(5px); }
  50% { transform: translateX(-5px); }
  75% { transform: translateX(5px); opacity: 1; }
  100% { transform: translateX(0); }
}

/* Footer Link */
.login-footer {
  margin-top: 30px;
  padding-top: 20px;
  border-top: 1px solid rgba(0,0,0,0.05);
}
.back-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.95rem;
  font-weight: 500;
  transition: color var(--dur);
}
.back-link:hover {
  color: var(--brand);
}
.back-link:hover svg {
  transform: translateX(3px);
  transition: transform 0.2s;
}


/* تخطيط لوحة الإدارة */
.admin-body {
  background: var(--bg);
  margin: 0;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
}

.admin-layout {
  display: flex;
  height: 100vh;
  height: 100dvh;
}

.sidebar {
  width: 260px;
  background: var(--brand-deep);
  color: white;
  display: flex;
  flex-direction: column;
}

.sidebar-header {
  padding: 24px;
  display: flex;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid rgba(255,255,255,0.1);
}

.sidebar-logo {
  height: 32px;
  background: white;
  padding: 4px;
  border-radius: 6px;
}

.sidebar-nav {
  flex: 1;
  padding: 20px 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.nav-item {
  color: rgba(255,255,255,0.7);
  text-decoration: none;
  padding: 12px 24px;
  font-weight: 500;
  transition: all 0.2s;
}

.nav-item:hover, .nav-item.active {
  color: white;
  background: rgba(255,255,255,0.1);
  border-right: 4px solid var(--accent);
}

.sidebar-footer {
  padding: 24px;
  border-top: 1px solid rgba(255,255,255,0.1);
}

.admin-email {
  font-size: 0.85rem;
  color: rgba(255,255,255,0.7);
  margin-bottom: 12px;
  word-break: break-all;
}

.logout-btn {
  background: transparent;
  border: 1px solid rgba(255,255,255,0.3);
  color: white;
  width: 100%;
  padding: 8px;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.2s;
  font-family: inherit;
}
.logout-btn:hover { background: rgba(255,255,255,0.1); }

.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
}

.top-bar {
  background: var(--surface);
  padding: 20px 30px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-shadow: var(--shadow-xs);
}

.status-badges {
  display: flex;
  gap: 10px;
}

.badge {
  font-size: 0.8rem;
  padding: 4px 10px;
  border-radius: var(--radius-pill);
  font-weight: 600;
}
.n8n-status { background: #dcfce7; color: #15803d; }
.wa-status { background: #dbeafe; color: #1d4ed8; }

.content-wrapper {
  padding: 30px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 20px;
}

.stat-card {
  background: var(--surface);
  padding: 24px;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
}
.stat-card h3 { color: var(--text-muted); font-size: 0.9rem; font-weight: 500; margin-bottom: 10px;}
.stat-value { font-size: 2rem; font-weight: 800; color: var(--brand); }

.actions-panel, .data-panel {
  background: var(--surface);
  padding: 24px;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
}

.actions-panel h3, .data-panel h3 { margin-bottom: 20px; color: var(--text-h); }

.action-buttons {
  display: flex;
  gap: 15px;
}

.btn-action {
  background: var(--bg-alt);
  color: var(--brand);
  border: 1px solid var(--brand-light);
  padding: 10px 20px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-weight: 600;
  transition: all 0.2s;
  font-family: inherit;
}
.btn-action:hover { background: var(--brand); color: white; }

.data-table {
  width: 100%;
  border-collapse: collapse;
}

.data-table th, .data-table td {
  padding: 12px 16px;
  text-align: right;
  border-bottom: 1px solid var(--border);
}

.data-table th {
  color: var(--text-muted);
  font-weight: 600;
  font-size: 0.9rem;
  background: var(--bg);
}

.data-table td {
  color: var(--text);
}

/* ---- Table Responsive ---- */
.table-responsive {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

/* ---- Sidebar Toggle Button (hidden on desktop) ---- */
.sidebar-toggle {
  display: none;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-h);
  border-radius: var(--radius-sm);
  padding: 7px;
  cursor: pointer;
  flex-shrink: 0;
}
.sidebar-toggle:hover {
  background: var(--bg-alt);
}

/* ---- Top-bar start group ---- */
.top-bar-start {
  display: flex;
  align-items: center;
  gap: 12px;
}

/* ---- Sidebar Overlay ---- */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  z-index: 999;
}
.sidebar-overlay.active {
  display: block;
}

/* ============================================================
   RESPONSIVE — MOBILE & SMALL SCREENS
   ============================================================ */
@media (max-width: 768px) {

  /* Allow page to scroll */
  .admin-body {
    overflow: auto;
    height: auto;
    min-height: 100vh;
    min-height: 100dvh;
  }

  .admin-layout {
    display: block;
    min-height: 100vh;
    min-height: 100dvh;
  }

  /* Sidebar slides in as fixed overlay from the right (RTL) */
  .sidebar {
    position: fixed;
    top: 0;
    right: -280px;
    width: 260px;
    height: 100vh;
    height: 100dvh;
    z-index: 1000;
    transition: right 0.3s ease;
    overflow: hidden;        /* الـ sidebar نفسه لا يتمرر */
    display: flex;
    flex-direction: column;
  }
  .sidebar.open {
    right: 0;
  }

  /* فقط روابط القائمة تتمرر — الـ footer يبقى دائماً ظاهراً */
  .sidebar-nav {
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    min-height: 0;           /* ضروري لعمل التمرير داخل flex */
    flex: 1;
  }

  /* الـ footer لا يتقلص أبداً */
  .sidebar-footer {
    flex-shrink: 0;
  }

  /* Show hamburger */
  .sidebar-toggle {
    display: flex;
  }

  /* Main content takes full width */
  .main-content {
    width: 100%;
    min-height: 100vh;
    min-height: 100dvh;
    overflow-y: auto;
  }

  /* Top bar wraps on small screens */
  .top-bar {
    padding: 14px 16px;
    flex-wrap: wrap;
    gap: 10px;
  }
  .top-bar h2 {
    font-size: 1rem;
  }

  /* Status badges wrap */
  .status-badges {
    flex-wrap: wrap;
  }
  .badge {
    font-size: 0.75rem;
    padding: 3px 8px;
  }

  /* Content padding reduced */
  .content-wrapper {
    padding: 16px;
    gap: 16px;
  }

  /* Stats grid single column */
  .stats-grid {
    grid-template-columns: 1fr 1fr;
    gap: 12px;
  }

  /* Action buttons wrap */
  .action-buttons {
    flex-wrap: wrap;
    gap: 10px;
  }
  .btn-action {
    flex: 1 1 calc(50% - 5px);
    min-width: 130px;
    text-align: center;
    font-size: 0.9rem;
    padding: 9px 12px;
  }

  /* Table smaller text */
  .data-table th,
  .data-table td {
    padding: 10px 10px;
    font-size: 0.85rem;
    white-space: nowrap;
  }
}

@media (max-width: 480px) {
  .stats-grid {
    grid-template-columns: 1fr;
  }
  .btn-action {
    flex: 1 1 100%;
  }
  .top-bar h2 {
    font-size: 0.95rem;
  }
}