:root {
  --primary-color: #6366f1;
  --primary-glow: rgba(99, 102, 241, 0.5);
  --secondary-color: #4f46e5;
  --accent-color: #f59e0b;
  --bg-dark: #0f172a;
  --bg-light: #f8fafc;
  --card-glass: rgba(255, 255, 255, 0.85);
  --text-main: #1e293b;
  --text-muted: #64748b;
  --border-color: rgba(226, 232, 240, 0.5);
  --transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  --glass-shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.15);
}

[dir="rtl"] {
  direction: rtl;
}

body {
  font-family: 'Inter', 'Heebo', sans-serif;
  background: var(--bg-light);
  color: var(--text-main);
  margin: 0;
  min-height: 100vh;
  overflow-x: hidden;
  position: relative;
}

.auth-page {
  display: flex;
  justify-content: center;
  align-items: center;
}

/* Dynamic background decor */
body::before {
  content: "";
  position: absolute;
  top: -10%;
  left: -10%;
  width: 40%;
  height: 40%;
  background: radial-gradient(circle, var(--primary-glow) 0%, transparent 70%);
  z-index: -1;
  filter: blur(80px);
}

body::after {
  content: "";
  position: absolute;
  bottom: -10%;
  right: -10%;
  width: 40%;
  height: 40%;
  background: radial-gradient(circle, rgba(79, 70, 229, 0.3) 0%, transparent 70%);
  z-index: -1;
  filter: blur(80px);
}

.login-card {
  background: white;
  padding: 2.5rem;
  border-radius: 1.25rem;
  box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
  width: 100%;
  max-width: 400px;
}

.login-card h2 {
  margin-top: 0;
  margin-bottom: 1.5rem;
  font-weight: 700;
  color: var(--text-main);
  text-align: center;
}

.form-group {
  margin-bottom: 1.25rem;
}

.form-group label {
  display: block;
  margin-bottom: 0.5rem;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-muted);
}

.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 0.75rem 1rem;
  border: 1px solid var(--border-color);
  border-radius: 0.5rem;
  font-size: 1rem;
  outline: none;
  transition: var(--transition);
  box-sizing: border-box;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.2);
}

.btn-login {
  width: 100%;
  padding: 0.75rem;
  background-color: var(--primary-color);
  color: white;
  border: none;
  border-radius: 0.5rem;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
}

.btn-login:hover {
  background-color: var(--secondary-color);
}

.lang-selector {
  margin-top: 1.5rem;
  text-align: center;
}

.lang-selector a {
  text-decoration: none;
  margin: 0 0.5rem;
  font-size: 0.875rem;
  color: var(--primary-color);
}

.id-card-container {
  perspective: 1500px;
  width: 360px;
  height: 560px;
  margin: 2rem auto;
}

.id-card {
  position: relative;
  width: 100%;
  height: 100%;
  transition: transform 0.8s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  transform-style: preserve-3d;
  cursor: pointer;
}

.id-card.flipped {
  transform: rotateY(180deg);
}

.id-card-side {
  position: absolute;
  width: 100%;
  height: 100%;
  backface-visibility: hidden;
  border-radius: 1.5rem;
  overflow-x: hidden;
  overflow-y: auto;
  box-shadow: var(--glass-shadow);
  background: var(--card-glass);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.4);
  display: flex;
  flex-direction: column;
}

.id-card-front::before {
  content: "";
  position: absolute;
  top: 50px;
  right: -100px;
  width: 300px;
  height: 300px;
  background: var(--primary-color);
  filter: blur(100px);
  opacity: 0.1;
  z-index: -1;
}

.id-card-back {
  transform: rotateY(180deg);
}

.card-header {
  background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
  color: white;
  padding: 1.5rem;
  text-align: center;
  position: relative;
  overflow: hidden;
}

.card-header::after {
  content: "";
  position: absolute;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: radial-gradient(circle, rgba(255, 255, 255, 0.2) 0%, transparent 60%);
  pointer-events: none;
}

.card-header h3 {
  margin: 0;
  font-size: 0.9rem;
  letter-spacing: 2px;
  font-weight: 700;
  text-transform: uppercase;
}

.card-info {
  padding: 0.5rem;
  flex-grow: 1;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
}

.info-row {
  margin-bottom: 1.25rem;
  animation: fadeInUp 0.5s ease backwards;
}

.info-label {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 0.25rem;
  display: block;
}

.info-value {
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--text-main);
}

/* Subtle hint that card is scrollable */
.scroll-hint {
  position: sticky;
  bottom: 0.35rem;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin: 0.75rem auto 0.25rem auto;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.06);
  color: var(--text-muted);
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  backdrop-filter: blur(8px);
}

.scroll-icon {
  font-size: 0.9rem;
  animation: scrollBounce 1.4s ease-in-out infinite;
}

@keyframes scrollBounce {
  0%, 100% { transform: translateY(0); opacity: 0.7; }
  50% { transform: translateY(4px); opacity: 1; }
}

.status-check {
  width: 20px;
  height: 20px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: #10b981;
  color: white;
  font-size: 12px;
  margin-right: 8px;
}

[dir="rtl"] .status-check {
  margin-right: 0;
  margin-left: 8px;
}

@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(10px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Tagging System */
.tag-container {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.5rem;
}

.tag-badge {
  background: var(--primary-color);
  color: white;
  padding: 0.25rem 0.75rem;
  border-radius: 2rem;
  font-size: 0.75rem;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  box-shadow: 0 2px 4px rgba(99, 102, 241, 0.2);
  transition: var(--transition);
}

.tag-badge:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 8px rgba(99, 102, 241, 0.3);
}

.tag-remove {
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
  opacity: 0.7;
  transition: var(--transition);
}

.tag-remove:hover {
  opacity: 1;
}

.tag-editor {
  width: 100%;
  padding: 0.75rem 1rem;
  border: 1px solid var(--border-color);
  border-radius: 0.5rem;
  background: white;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  min-height: 45px;
  box-sizing: border-box;
}

.tag-editor input {
  border: none !important;
  outline: none !important;
  padding: 0 !important;
  flex-grow: 1;
  min-width: 80px;
  font-size: 0.875rem;
  background: transparent;
}

.tag-editor:focus-within {
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.2);
}

.table-tag {
  font-size: 0.65rem;
  padding: 2px 8px;
  background: #e0e7ff;
  color: #4338ca;
  border-radius: 10px;
  font-weight: 600;
}

/* Dashboard Layout */
.dashboard-container {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: 280px;
  background: var(--bg-dark);
  color: white;
  padding: 2rem 1.5rem;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  transition: var(--transition);
  z-index: 100;
}

.sidebar-brand {
  font-size: 1.5rem;
  font-weight: 800;
  margin-bottom: 3rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  color: white;
  text-decoration: none;
}

.sidebar-nav {
  list-style: none;
  padding: 0;
  margin: 0;
  flex-grow: 1;
}

.sidebar-nav li {
  margin-bottom: 0.5rem;
}

.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.875rem 1rem;
  color: rgba(255, 255, 255, 0.7);
  text-decoration: none;
  border-radius: 0.75rem;
  font-weight: 500;
  transition: var(--transition);
}

.sidebar-nav a:hover,
.sidebar-nav a.active {
  background: rgba(255, 255, 255, 0.1);
  color: white;
}

.main-content {
  flex-grow: 1;
  padding: 2rem 3rem;
  max-width: 1400px;
  margin: 0 auto;
}

.top-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 2.5rem;
}

.page-title h1 {
  margin: 0;
  font-size: 1.875rem;
  font-weight: 800;
  color: var(--text-main);
}

.page-title p {
  margin: 0.25rem 0 0 0;
  color: var(--text-muted);
}

.user-nav {
  display: flex;
  align-items: center;
  gap: 1.5rem;
}

.lang-toggle {
  display: flex;
  background: white;
  padding: 0.25rem;
  border-radius: 0.5rem;
  border: 1px solid var(--border-color);
}

.lang-toggle a {
  padding: 0.375rem 0.75rem;
  border-radius: 0.375rem;
  text-decoration: none;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-muted);
}

.lang-toggle a.active {
  background: var(--primary-color);
  color: white;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 1.5rem;
  margin-bottom: 3rem;
}

.stat-card {
  background: white;
  padding: 1.5rem;
  border-radius: 1.25rem;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
  display: flex;
  flex-direction: column;
  gap: 1rem;
  position: relative;
  overflow: hidden;
  border: 1px solid var(--border-color);
}

.stat-icon {
  width: 48px;
  height: 48px;
  background: #f1f5f9;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--primary-color);
}

.stat-info .value {
  font-size: 2.25rem;
  font-weight: 800;
  color: var(--text-main);
}

.action-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 1.5rem;
}

.action-card {
  background: white;
  padding: 2rem;
  border-radius: 1.25rem;
  text-decoration: none;
  border: 1px solid var(--border-color);
  transition: var(--transition);
  display: flex;
  align-items: flex-start;
  gap: 1.5rem;
}

.action-card:hover {
  transform: translateY(-5px);
  border-color: var(--primary-color);
  box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
}

.action-icon {
  width: 56px;
  height: 56px;
  background: #f1f5f9;
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--primary-color);
}

/* Shared UI Components */
.card-box {
  background: white;
  padding: 2rem;
  border-radius: 1.25rem;
  border: 1px solid var(--border-color);
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
  margin-bottom: 2rem;
}

.data-table-wrapper {
  background: white;
  border-radius: 1.25rem;
  border: 1px solid var(--border-color);
  overflow: hidden;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
  margin-bottom: 2rem;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
}

.data-table th {
  background: #f8fafc;
  padding: 1rem 1.5rem;
  text-align: left;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border-color);
}

[dir="rtl"] .data-table th {
  text-align: right;
}

.data-table td {
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--border-color);
  color: var(--text-main);
}

/* Table actions buttons */
.table-actions {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}

.action-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.35rem 0.9rem;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 600;
  border: none;
  cursor: pointer;
  text-decoration: none;
  transition: var(--transition);
  background: #e5e7eb;
  color: #111827;
}

.action-btn i {
  width: 14px;
  height: 14px;
}

.action-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 8px rgba(15, 23, 42, 0.15);
}

.action-btn--view {
  background: #e0f2fe;
  color: #0369a1;
}

.action-btn--view:hover {
  background: #bae6fd;
}

.action-btn--edit {
  background: #fef3c7;
  color: #92400e;
}

.action-btn--edit:hover {
  background: #fde68a;
}

.action-btn--delete {
  background: #fee2e2;
  color: #b91c1c;
}

.action-btn--delete:hover {
  background: #fecaca;
}

.alert {
  padding: 1rem 1.5rem;
  border-radius: 0.75rem;
  margin-bottom: 1.5rem;
  font-size: 0.875rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.alert-success {
  background: #f0fdf4;
  color: #166534;
  border: 1px solid #bbf7d0;
}

.alert-error {
  background: #fef2f2;
  color: #991b1b;
  border: 1px solid #fecaca;
}

.qr-preview-card {
  background: white;
  border-radius: 1.25rem;
  border: 1px solid var(--border-color);
  padding: 1.5rem;
  text-align: center;
  transition: var(--transition);
}

.qr-image {
  width: 160px;
  height: 160px;
  margin: 0 auto 1.5rem;
  padding: 1rem;
  background: #f8fafc;
  border-radius: 1rem;
  border: 1px solid var(--border-color);
}

.qr-image img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

/* RTL Specifics */
[dir="rtl"] .sidebar {
  border-left: 1px solid rgba(255, 255, 255, 0.1);
}

@media (max-width: 1024px) {
  .dashboard-container {
    flex-direction: column;
  }

  .sidebar {
    width: 100%;
    height: auto;
    position: static;
    padding: 1rem;
  }

  .sidebar-nav {
    display: flex;
    overflow-x: auto;
    gap: 0.5rem;
  }

  .main-content {
    padding: 1.5rem;
  }
}