/* ==============================================
   Admin Dashboard Styles
   ============================================== */
:root {
  --sidebar-bg: #0B2240;
  --sidebar-hover: #132D52;
  --sidebar-active: #E58200;
}

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

body { font-family: 'Tajawal', 'Inter', system-ui, sans-serif; background: #F1F5F9; color: #334155; direction: rtl; }

/* ========== Login Page ========== */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #001A3F, #0B2240);
}

.login-box {
  background: white;
  padding: 3rem;
  border-radius: 16px;
  width: 100%;
  max-width: 420px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.2);
}

.login-box h1 { text-align: center; margin-bottom: 0.5rem; font-size: 1.5rem; }
.login-box p { text-align: center; color: #64748B; margin-bottom: 2rem; font-size: 0.9rem; }

.login-box .form-group { margin-bottom: 1.25rem; }
.login-box .form-group label { display: block; font-size: 0.9rem; font-weight: 600; color: #0B2240; margin-bottom: 0.35rem; }
.login-box .form-group input { width: 100%; padding: 0.75rem 1rem; border: 1px solid #E2E8F0; border-radius: 8px; font-size: 0.95rem; font-family: inherit; transition: border-color 0.2s; }
.login-box .form-group input:focus { outline: none; border-color: #E58200; box-shadow: 0 0 0 3px rgba(229,130,0,0.1); }

.login-error { color: #EF4444; font-size: 0.85rem; text-align: center; margin-top: 0.75rem; display: none; }

/* ========== Admin Layout ========== */
.admin-layout { display: flex; min-height: 100vh; }

/* Sidebar */
.sidebar {
  width: 260px;
  background: var(--sidebar-bg);
  color: rgba(255,255,255,0.8);
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  z-index: 100;
  display: flex;
  flex-direction: column;
  transition: all 0.3s ease;
}

body.en .sidebar { right: auto; left: 0; }

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

.sidebar-header h2 { color: white; font-size: 1.1rem; font-weight: 800; }
.sidebar-header h2 span { color: #E58200; }

.sidebar-nav { padding: 0.75rem; flex: 1; overflow-y: auto; }

.sidebar-nav .nav-section { margin-bottom: 0.5rem; }

.sidebar-nav .nav-section-title {
  padding: 0.5rem 0.75rem;
  font-size: 0.75rem;
  text-transform: uppercase;
  color: rgba(255,255,255,0.4);
  font-weight: 700;
  letter-spacing: 1px;
}

.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.65rem 0.75rem;
  color: rgba(255,255,255,0.7);
  text-decoration: none;
  border-radius: 8px;
  font-size: 0.9rem;
  transition: all 0.2s ease;
  margin-bottom: 2px;
}

.sidebar-nav a:hover { background: var(--sidebar-hover); color: white; }
.sidebar-nav a.active { background: var(--sidebar-active); color: white; }

.sidebar-nav a .icon {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.9rem;
}

.sidebar-footer {
  padding: 1rem 1.25rem;
  border-top: 1px solid rgba(255,255,255,0.1);
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.sidebar-footer .user-info { flex: 1; }
.sidebar-footer .user-info .name { font-size: 0.85rem; color: white; font-weight: 600; }
.sidebar-footer .user-info .role { font-size: 0.75rem; color: rgba(255,255,255,0.5); }
.sidebar-footer .logout-btn {
  background: rgba(255,255,255,0.1);
  border: none;
  color: rgba(255,255,255,0.6);
  padding: 0.4rem 0.6rem;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.85rem;
  transition: all 0.2s;
}
.sidebar-footer .logout-btn:hover { background: rgba(239,68,68,0.3); color: #EF4444; }

/* Main Content */
.main-content {
  flex: 1;
  margin-right: 260px;
  padding: 1.5rem;
  min-height: 100vh;
}

body.en .main-content { margin-right: 0; margin-left: 260px; }

/* Top Bar */
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
  gap: 1rem;
}

.topbar h1 { font-size: 1.5rem; font-weight: 800; color: #0B2240; }

.topbar-actions { display: flex; gap: 0.75rem; align-items: center; }

/* Stats Cards */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.stat-card {
  background: white;
  border-radius: 12px;
  padding: 1.25rem;
  border: 1px solid #E2E8F0;
  transition: all 0.2s;
}

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

.stat-card .stat-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 0.5rem; }
.stat-card .stat-icon { width: 40px; height: 40px; border-radius: 10px; display: flex; align-items: center; justify-content: center; font-size: 1.1rem; }
.stat-card .stat-label { font-size: 0.8rem; color: #64748B; font-weight: 500; }
.stat-card .stat-value { font-size: 1.75rem; font-weight: 800; color: #0B2240; line-height: 1.2; }
.stat-card .stat-change { font-size: 0.75rem; margin-top: 0.25rem; }
.stat-card .stat-change.up { color: #10B981; }
.stat-card .stat-change.down { color: #EF4444; }

/* Cards */
.card {
  background: white;
  border-radius: 12px;
  border: 1px solid #E2E8F0;
  margin-bottom: 1.5rem;
}

.card-header {
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid #E2E8F0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.card-header h3 { font-size: 1.05rem; font-weight: 700; color: #0B2240; }

.card-body { padding: 1.5rem; }

/* Tables */
.table-responsive { overflow-x: auto; }

table { width: 100%; border-collapse: collapse; font-size: 0.875rem; }

table thead th {
  text-align: right;
  padding: 0.75rem 1rem;
  background: #F8FAFC;
  color: #64748B;
  font-weight: 600;
  font-size: 0.8rem;
  text-transform: uppercase;
  border-bottom: 1px solid #E2E8F0;
  white-space: nowrap;
}

body.en table thead th { text-align: left; }

table tbody td {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid #F1F5F9;
  vertical-align: middle;
}

table tbody tr:hover { background: #F8FAFC; }
table tbody tr:last-child td { border-bottom: none; }

/* Status Badges */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.25rem 0.65rem;
  border-radius: 50px;
  font-size: 0.75rem;
  font-weight: 600;
  white-space: nowrap;
}

.badge-new { background: #DBEAFE; color: #1D4ED8; }
.badge-contacted { background: #FEF3C7; color: #B45309; }
.badge-progress { background: #E0E7FF; color: #4338CA; }
.badge-sent { background: #FCE7F3; color: #BE185D; }
.badge-contracted { background: #D1FAE5; color: #047857; }
.badge-completed { background: #D1FAE5; color: #047857; }
.badge-lost { background: #FEE2E2; color: #B91C1C; }
.badge-cancelled { background: #FEE2E2; color: #B91C1C; }
.badge-pending { background: #FEF3C7; color: #B45309; }
.badge-confirmed { background: #D1FAE5; color: #047857; }
.badge-rejected { background: #FEE2E2; color: #B91C1C; }
.badge-default { background: #F1F5F9; color: #475569; }

/* Action buttons */
.btn-xs { padding: 0.3rem 0.6rem; font-size: 0.75rem; border-radius: 4px; border: none; cursor: pointer; font-family: inherit; font-weight: 600; transition: all 0.2s; }
.btn-xs-primary { background: #0B2240; color: white; }
.btn-xs-primary:hover { background: #132D52; }
.btn-xs-success { background: #10B981; color: white; }
.btn-xs-danger { background: #EF4444; color: white; }
.btn-xs-warning { background: #F59E0B; color: white; }
.btn-xs-outline { background: transparent; color: #64748B; border: 1px solid #E2E8F0; }
.btn-xs-outline:hover { background: #F1F5F9; }

/* Forms inside admin */
.form-input { width: 100%; padding: 0.6rem 0.75rem; border: 1px solid #E2E8F0; border-radius: 6px; font-size: 0.875rem; font-family: inherit; }
.form-input:focus { outline: none; border-color: #E58200; box-shadow: 0 0 0 2px rgba(229,130,0,0.1); }

.form-select { width: 100%; padding: 0.6rem 0.75rem; border: 1px solid #E2E8F0; border-radius: 6px; font-size: 0.875rem; font-family: inherit; background: white; }

/* Modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 1000;
  display: none;
  align-items: center;
  justify-content: center;
}

.modal-overlay.open { display: flex; }

.modal {
  background: white;
  border-radius: 16px;
  width: 100%;
  max-width: 600px;
  max-height: 90vh;
  overflow-y: auto;
  padding: 2rem;
  position: relative;
}

.modal h3 { font-size: 1.25rem; margin-bottom: 1.5rem; }
.modal-close { position: absolute; top: 1rem; left: 1rem; background: none; border: none; font-size: 1.25rem; cursor: pointer; color: #94A3B8; }

/* Loading spinner */
.spinner { display: inline-block; width: 20px; height: 20px; border: 2px solid rgba(255,255,255,0.3); border-radius: 50%; border-top-color: white; animation: spin 0.6s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.loading { display: flex; align-items: center; justify-content: center; padding: 3rem; color: #94A3B8; }

/* Recent Activity */
.activity-list { list-style: none; }
.activity-list li {
  padding: 0.75rem 0;
  border-bottom: 1px solid #F1F5F9;
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  font-size: 0.875rem;
}
.activity-list li:last-child { border-bottom: none; }
.activity-dot { width: 8px; height: 8px; border-radius: 50%; margin-top: 0.5rem; flex-shrink: 0; }

/* Mobile toggle */
.mobile-toggle { display: none; background: none; border: none; font-size: 1.5rem; cursor: pointer; color: #0B2240; }

/* Responsive */
@media (max-width: 768px) {
  .sidebar { right: -260px; }
  .sidebar.open { right: 0; }
  body.en .sidebar { left: -260px; right: auto; }
  body.en .sidebar.open { left: 0; right: auto; }
  .main-content { margin-right: 0; }
  body.en .main-content { margin-left: 0; }
  .mobile-toggle { display: block; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr; }
  .login-box { padding: 2rem 1.5rem; }
}
