/* Root CSS variables - Modern Dark Color Palette with HSL */
:root {
  --font-ar: 'Tajawal', sans-serif;
  --font-en: 'Outfit', sans-serif;
  
  --bg-color: #0b0f19;
  --panel-bg: rgba(20, 27, 45, 0.55);
  --panel-border: rgba(255, 255, 255, 0.07);
  --panel-glow: rgba(139, 92, 246, 0.15);
  
  --text-main: #f3f4f6;
  --text-muted: #9ca3af;
  
  --primary: #8b5cf6;
  --primary-hover: #7c3aed;
  --primary-glow: rgba(139, 92, 246, 0.4);
  
  --secondary: #4b5563;
  --secondary-hover: #374151;
  
  --accent-blue: #3b82f6;
  --accent-green: #10b981;
  --accent-red: #ef4444;
  --accent-yellow: #f59e0b;
  
  --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  --border-radius: 16px;
}

/* Base Styles */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-ar);
  background-color: var(--bg-color);
  color: var(--text-main);
  min-height: 100vh;
  overflow-x: hidden;
  background-image: 
    radial-gradient(circle at 10% 20%, rgba(59, 130, 246, 0.08) 0%, transparent 40%),
    radial-gradient(circle at 90% 80%, rgba(139, 92, 246, 0.08) 0%, transparent 40%);
  background-attachment: fixed;
}

/* Typography Helpers for English fields */
code, pre, .key-code-text, #keys-output-textarea, .english-field {
  font-family: var(--font-en) !important;
  direction: ltr !important;
  display: inline-block;
}

/* Background Glowing Spheres */
.glow-sphere {
  position: absolute;
  width: 400px;
  height: 400px;
  border-radius: 50%;
  filter: blur(120px);
  z-index: 0;
  pointer-events: none;
  opacity: 0.5;
}

.sphere-1 {
  background: radial-gradient(circle, var(--primary) 0%, transparent 70%);
  top: -100px;
  right: -100px;
}

.sphere-2 {
  background: radial-gradient(circle, var(--accent-blue) 0%, transparent 70%);
  bottom: -100px;
  left: -100px;
}

/* Glassmorphism Panel Utility */
.glass-panel {
  background: var(--panel-bg);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--panel-border);
  border-radius: var(--border-radius);
  box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
  transition: var(--transition);
}

.glass-panel:hover {
  border-color: rgba(255, 255, 255, 0.12);
  box-shadow: 0 12px 40px 0 rgba(139, 92, 246, 0.05);
}

/* Hidden Utility */
.hidden {
  display: none !important;
}

/* Alerts */
.alert {
  padding: 12px 16px;
  border-radius: 8px;
  margin-bottom: 16px;
  font-size: 0.9rem;
  display: flex;
  align-items: center;
  gap: 8px;
}

.alert-danger {
  background-color: rgba(239, 68, 68, 0.15);
  border: 1px solid rgba(239, 68, 68, 0.3);
  color: #fca5a5;
}

.alert-success {
  background-color: rgba(16, 185, 129, 0.15);
  border: 1px solid rgba(16, 185, 129, 0.3);
  color: #a7f3d0;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 20px;
  border-radius: 10px;
  font-size: 0.95rem;
  font-weight: 500;
  cursor: pointer;
  border: none;
  transition: var(--transition);
  font-family: inherit;
}

.btn-primary {
  background-color: var(--primary);
  color: #fff;
  box-shadow: 0 4px 14px 0 var(--primary-glow);
}

.btn-primary:hover {
  background-color: var(--primary-hover);
  box-shadow: 0 6px 20px 0 var(--primary-glow);
  transform: translateY(-2px);
}

.btn-secondary {
  background-color: var(--secondary);
  color: var(--text-main);
}

.btn-secondary:hover {
  background-color: var(--secondary-hover);
  transform: translateY(-2px);
}

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

.btn-danger:hover {
  background-color: var(--accent-red);
  color: #fff;
  transform: translateY(-2px);
}

.btn-sm {
  padding: 6px 12px;
  font-size: 0.8rem;
  border-radius: 6px;
}

.btn-block {
  width: 100%;
}

/* Login Wrapper & Card */
.login-wrapper {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  position: relative;
  z-index: 10;
}

.login-card {
  width: 420px;
  padding: 40px;
  z-index: 10;
}

.brand-header {
  text-align: center;
  margin-bottom: 30px;
}

.brand-logo {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  width: 70px;
  height: 70px;
  border-radius: 20px;
  background-color: rgba(139, 92, 246, 0.15);
  border: 1px solid rgba(139, 92, 246, 0.3);
  color: var(--primary);
  font-size: 2.2rem;
  margin-bottom: 16px;
  box-shadow: inset 0 0 15px rgba(139, 92, 246, 0.2);
  animation: logoPulse 3s infinite alternate;
}

@keyframes logoPulse {
  0% { transform: scale(1); box-shadow: 0 0 10px rgba(139, 92, 246, 0.2); }
  100% { transform: scale(1.05); box-shadow: 0 0 25px rgba(139, 92, 246, 0.5); }
}

.brand-header h2 {
  font-size: 1.6rem;
  font-weight: 700;
  margin-bottom: 8px;
}

.brand-header p {
  font-size: 0.9rem;
  color: var(--text-muted);
}

/* Form Styles */
.form-group {
  margin-bottom: 20px;
}

.form-group label {
  display: block;
  font-size: 0.9rem;
  font-weight: 500;
  margin-bottom: 8px;
  color: var(--text-muted);
}

.form-group input, .form-group select, .form-group textarea {
  width: 100%;
  padding: 12px 16px;
  border-radius: 10px;
  background-color: rgba(0, 0, 0, 0.25);
  border: 1px solid var(--panel-border);
  color: var(--text-main);
  font-family: inherit;
  font-size: 0.95rem;
  transition: var(--transition);
}

.form-group input:focus, .form-group select:focus, .form-group textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.25);
  background-color: rgba(0, 0, 0, 0.4);
}

/* Dashboard Wrapper Layout */
.dashboard-wrapper {
  display: grid;
  grid-template-columns: 280px 1fr;
  min-height: 100vh;
  z-index: 10;
  position: relative;
}

/* Sidebar Styling */
.sidebar {
  margin: 16px;
  display: flex;
  flex-direction: column;
  height: calc(100vh - 32px);
  position: sticky;
  top: 16px;
  z-index: 20;
}

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

.logo-icon {
  font-size: 2rem;
  color: var(--primary);
}

.sidebar-brand-name h3 {
  font-size: 1.1rem;
  font-weight: 700;
}

.sidebar-brand-name span {
  font-size: 0.75rem;
  color: var(--text-muted);
  display: block;
}

.sidebar-nav {
  flex-grow: 1;
  padding: 24px 16px;
}

.sidebar-nav ul {
  list-style: none;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-radius: 10px;
  font-size: 0.95rem;
  color: var(--text-muted);
  cursor: pointer;
  transition: var(--transition);
  margin-bottom: 8px;
}

.nav-item:hover {
  background-color: rgba(255, 255, 255, 0.04);
  color: var(--text-main);
  transform: translateX(-4px);
}

body[dir="ltr"] .nav-item:hover {
  transform: translateX(4px);
}

.nav-item.active {
  background-color: rgba(139, 92, 246, 0.15);
  border-right: 4px solid var(--primary);
  color: var(--text-main);
}

body[dir="ltr"] .nav-item.active {
  border-right: none;
  border-left: 4px solid var(--primary);
}

.sidebar-footer {
  padding: 24px 16px;
  border-top: 1px solid var(--panel-border);
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.admin-profile {
  display: flex;
  align-items: center;
  gap: 12px;
}

.avatar-icon {
  font-size: 2.2rem;
  color: var(--text-muted);
  background-color: rgba(255, 255, 255, 0.05);
  padding: 6px;
  border-radius: 50%;
}

.admin-profile h4 {
  font-size: 0.9rem;
  font-weight: 600;
}

.admin-profile span {
  font-size: 0.75rem;
  color: var(--accent-green);
}

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

.btn-logout:hover {
  background-color: var(--accent-red);
  color: #fff;
}

/* Content Area Layout */
.content-area {
  padding: 16px 24px 24px 24px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  overflow-y: auto;
  height: 100vh;
}

.top-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 24px;
}

.top-bar-title h2 {
  font-size: 1.25rem;
  font-weight: 700;
}

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 30px;
  font-size: 0.8rem;
  font-weight: 600;
}

.badge-success {
  background-color: rgba(16, 185, 129, 0.15);
  color: #34d399;
  border: 1px solid rgba(16, 185, 129, 0.3);
}

.badge-danger {
  background-color: rgba(239, 68, 68, 0.15);
  color: #fca7a7;
  border: 1px solid rgba(239, 68, 68, 0.3);
}

.badge-info {
  background-color: rgba(59, 130, 246, 0.15);
  color: #60a5fa;
  border: 1px solid rgba(59, 130, 246, 0.3);
}

/* Pulse Dot Animation for active badge */
.pulse-dot {
  width: 8px;
  height: 8px;
  background-color: var(--accent-green);
  border-radius: 50%;
  display: inline-block;
  box-shadow: 0 0 8px var(--accent-green);
  animation: pulse 1.5s infinite;
}

@keyframes pulse {
  0% { transform: scale(0.9); opacity: 0.6; }
  50% { transform: scale(1.2); opacity: 1; box-shadow: 0 0 12px var(--accent-green); }
  100% { transform: scale(0.9); opacity: 0.6; }
}

/* Grid Layouts */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 20px;
}

.stats-card {
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 24px;
}

.stats-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 50px;
  height: 50px;
  border-radius: 12px;
  font-size: 1.5rem;
}

.icon-blue { background-color: rgba(59, 130, 246, 0.15); color: var(--accent-blue); }
.icon-purple { background-color: rgba(139, 92, 246, 0.15); color: var(--primary); }
.icon-yellow { background-color: rgba(245, 158, 11, 0.15); color: var(--accent-yellow); }
.icon-green { background-color: rgba(16, 185, 129, 0.15); color: var(--accent-green); }

.stats-info h3 {
  font-size: 0.85rem;
  color: var(--text-muted);
  font-weight: 500;
  margin-bottom: 4px;
}

.stats-info p {
  font-size: 1.6rem;
  font-weight: 800;
  font-family: var(--font-en);
}

.grid-2col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

@media(max-width: 900px) {
  .grid-2col {
    grid-template-columns: 1fr;
  }
}

/* Panel Sections */
.panel-section {
  padding: 24px;
}

.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  border-bottom: 1px solid var(--panel-border);
  padding-bottom: 12px;
}

.section-header h3 {
  font-size: 1.1rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 10px;
}

.section-header h3 i {
  color: var(--primary);
}

/* Data Tables */
.table-container {
  overflow-x: auto;
  border-radius: 10px;
  border: 1px solid var(--panel-border);
}

.max-height-400 {
  max-height: 400px;
  overflow-y: auto;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  text-align: right;
  font-size: 0.9rem;
}

body[dir="ltr"] .data-table {
  text-align: left;
}

.data-table th, .data-table td {
  padding: 14px 18px;
  border-bottom: 1px solid var(--panel-border);
}

.data-table th {
  background-color: rgba(0, 0, 0, 0.2);
  color: var(--text-muted);
  font-weight: 600;
  font-size: 0.85rem;
  letter-spacing: 0.5px;
}

.data-table tbody tr {
  transition: var(--transition);
}

.data-table tbody tr:hover {
  background-color: rgba(255, 255, 255, 0.02);
}

.data-table tbody tr:last-child td {
  border-bottom: none;
}

.text-center {
  text-align: center !important;
}

/* Action Bar */
.action-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 24px;
  gap: 16px;
  flex-wrap: wrap;
}

.search-box {
  position: relative;
  flex-grow: 1;
  max-width: 450px;
}

.search-icon {
  position: absolute;
  right: 16px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
}

body[dir="ltr"] .search-icon {
  right: auto;
  left: 16px;
}

.search-box input {
  padding-right: 44px;
}

body[dir="ltr"] .search-box input {
  padding-right: 16px;
  padding-left: 44px;
}

.width-300 {
  max-width: 300px;
}

/* Keys Output Container */
.keys-output-container textarea {
  width: 100%;
  padding: 16px;
  background-color: rgba(0, 0, 0, 0.3);
  border: 1px solid var(--panel-border);
  border-radius: 10px;
  color: var(--text-main);
  resize: none;
  font-family: var(--font-en);
  font-size: 0.9rem;
  line-height: 1.5;
}

/* File Upload custom styling */
.file-upload-wrapper {
  margin-top: 8px;
}

.file-info-label {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-weight: normal;
  margin-right: 4px;
}

.file-upload-status {
  display: block;
  margin-top: 8px;
  font-size: 0.8rem;
  color: var(--accent-blue);
  word-break: break-all;
}

/* Modals */
.modal-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background-color: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(8px);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 100;
  transition: var(--transition);
}

.modal-card {
  width: 500px;
  max-width: 90%;
  padding: 30px;
  max-height: 90vh;
  overflow-y: auto;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--panel-border);
  padding-bottom: 16px;
  margin-bottom: 24px;
}

.modal-header h3 {
  font-size: 1.2rem;
  font-weight: 700;
}

.btn-close {
  background: none;
  border: none;
  font-size: 1.8rem;
  color: var(--text-muted);
  cursor: pointer;
  transition: var(--transition);
  line-height: 1;
}

.btn-close:hover {
  color: var(--accent-red);
  transform: rotate(90deg);
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  border-top: 1px solid var(--panel-border);
  padding-top: 16px;
  margin-top: 24px;
}

/* Toast Notifications */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

body[dir="ltr"] .toast-container {
  right: auto;
  left: 24px;
}

.toast {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 20px;
  border-radius: 10px;
  background-color: var(--panel-bg);
  backdrop-filter: blur(12px);
  border: 1px solid var(--panel-border);
  color: var(--text-main);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
  animation: slideIn 0.3s ease-out forwards;
  min-width: 250px;
  max-width: 380px;
}

.toast-success {
  border-left: 4px solid var(--accent-green);
}
body[dir="ltr"] .toast-success {
  border-left: none;
  border-right: 4px solid var(--accent-green);
}

.toast-error {
  border-left: 4px solid var(--accent-red);
}
body[dir="ltr"] .toast-error {
  border-left: none;
  border-right: 4px solid var(--accent-red);
}

@keyframes slideIn {
  from { transform: translateY(100%); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

/* Animations */
.animate-zoom {
  animation: zoomIn 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes zoomIn {
  from { transform: scale(0.9); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

/* General classes */
.margin-top-20 { margin-top: 20px; }
.margin-top-10 { margin-top: 10px; }

/* Scrollbars styling */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: rgba(0, 0, 0, 0.15);
}

::-webkit-scrollbar-thumb {
  background: var(--panel-border);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: rgba(139, 92, 246, 0.4);
}
