@font-face {
  font-family: 'UKIJ';
  src: url('/fonts/ukij.ttf') format('truetype');
}

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

:root {
  --primary: #1a73e8;
  --primary-dark: #1557b0;
  --danger: #e53935;
  --success: #4caf50;
  --warning: #ff9800;
  --bg: #f0f2f5;
  --card-bg: #ffffff;
  --text: #1a1a2e;
  --text-light: #666;
  --border: #e0e0e0;
  --shadow: 0 2px 12px rgba(0,0,0,0.08);
  --radius: 12px;
  --radius-sm: 8px;
  --sidebar-width: 220px;
}

body {
  font-family: 'UKIJ', 'Noto Sans Arabic', sans-serif;
  background: var(--bg);
  color: var(--text);
  direction: rtl;
  text-align: right;
  line-height: 1.6;
  min-height: 100vh;
}

/* ========== LOGIN PAGE ========== */
.login-container {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.login-box {
  background: white;
  border-radius: var(--radius);
  padding: 40px;
  width: 380px;
  max-width: 90%;
  box-shadow: 0 20px 60px rgba(0,0,0,0.3);
  text-align: center;
}

.login-box .logo {
  font-size: 48px;
  margin-bottom: 8px;
}

.login-box h2 {
  font-size: 22px;
  margin-bottom: 4px;
  color: var(--text);
}

.login-box .subtitle {
  font-size: 13px;
  color: var(--text-light);
  margin-bottom: 24px;
}

.login-box .form-group {
  margin-bottom: 16px;
  text-align: right;
}

.login-box label {
  display: block;
  font-size: 13px;
  font-weight: bold;
  margin-bottom: 4px;
  color: #555;
}

.login-box input {
  width: 100%;
  padding: 12px;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-family: 'UKIJ', 'Noto Sans Arabic', sans-serif;
  outline: none;
  transition: border-color 0.2s;
}

.login-box input:focus {
  border-color: var(--primary);
}

.login-box .btn-login {
  width: 100%;
  padding: 12px;
  background: var(--primary);
  color: white;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 16px;
  font-family: 'UKIJ', 'Noto Sans Arabic', sans-serif;
  cursor: pointer;
  font-weight: bold;
  margin-top: 8px;
  transition: background 0.2s;
}

.login-box .btn-login:hover {
  background: var(--primary-dark);
}

.login-box .error-msg {
  color: var(--danger);
  font-size: 13px;
  margin-top: 8px;
  display: none;
}

/* ========== ADMIN LAYOUT ========== */
.admin-layout {
  display: none;
  min-height: 100vh;
}

/* Sidebar */
.sidebar {
  position: fixed;
  top: 0;
  right: 0;
  width: var(--sidebar-width);
  height: 100vh;
  background: #1a1a2e;
  color: white;
  display: flex;
  flex-direction: column;
  z-index: 100;
  overflow-y: auto;
}

.sidebar-header {
  padding: 20px;
  border-bottom: 1px solid rgba(255,255,255,0.1);
  text-align: center;
}

.sidebar-header .logo-text {
  font-size: 20px;
  font-weight: bold;
}

.sidebar-header .logo-sub {
  font-size: 11px;
  opacity: 0.6;
  margin-top: 2px;
}

.sidebar-menu {
  flex: 1;
  padding: 12px 0;
}

.sidebar-menu .menu-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 20px;
  color: rgba(255,255,255,0.7);
  cursor: pointer;
  transition: all 0.2s;
  font-size: 14px;
  border-right: 3px solid transparent;
}

.sidebar-menu .menu-item:hover {
  background: rgba(255,255,255,0.05);
  color: white;
}

.sidebar-menu .menu-item.active {
  background: rgba(255,255,255,0.1);
  color: white;
  border-right-color: var(--primary);
}

.sidebar-menu .menu-icon {
  font-size: 18px;
  width: 24px;
  text-align: center;
}

.sidebar-footer {
  padding: 16px 20px;
  border-top: 1px solid rgba(255,255,255,0.1);
  font-size: 13px;
}

.sidebar-footer .user-info {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}

.sidebar-footer .user-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: rgba(255,255,255,0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
}

.sidebar-footer .btn-logout {
  width: 100%;
  padding: 8px;
  background: rgba(255,255,255,0.1);
  color: white;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-family: 'UKIJ', 'Noto Sans Arabic', sans-serif;
  font-size: 13px;
  transition: background 0.2s;
}

.sidebar-footer .btn-logout:hover {
  background: rgba(255,0,0,0.3);
}

/* Main Content */
.main-content {
  margin-right: var(--sidebar-width);
  padding: 24px;
  min-height: 100vh;
}

.main-header {
  background: white;
  border-radius: var(--radius);
  padding: 16px 24px;
  margin-bottom: 24px;
  box-shadow: var(--shadow);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.main-header h1 {
  font-size: 20px;
}

.main-header .breadcrumb {
  font-size: 13px;
  color: var(--text-light);
}

.main-header .breadcrumb a {
  color: var(--primary);
  text-decoration: none;
}

/* ========== PANELS ========== */
.panel {
  display: none;
}

.panel.active {
  display: block;
}

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

.stat-card {
  background: white;
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
  display: flex;
  align-items: center;
  gap: 16px;
}

.stat-card .stat-icon {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
}

.stat-card .stat-icon.blue { background: #e3f2fd; }
.stat-card .stat-icon.green { background: #e8f5e9; }
.stat-card .stat-icon.orange { background: #fff3e0; }
.stat-card .stat-icon.purple { background: #f3e5f5; }

.stat-card .stat-info h3 {
  font-size: 24px;
  font-weight: bold;
}

.stat-card .stat-info p {
  font-size: 12px;
  color: var(--text-light);
}

/* Card Section */
.card-section {
  background: white;
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow);
  margin-bottom: 24px;
}

.card-section h3 {
  font-size: 17px;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 2px solid var(--primary);
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Forms */
.form-row {
  display: flex;
  gap: 12px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.form-group {
  margin-bottom: 12px;
  flex: 1;
  min-width: 180px;
}

.form-group label {
  display: block;
  font-size: 13px;
  font-weight: bold;
  margin-bottom: 4px;
  color: #555;
}

.form-group input,
.form-group textarea,
.form-group select {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-family: 'UKIJ', 'Noto Sans Arabic', sans-serif;
  outline: none;
  transition: border-color 0.2s;
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
  border-color: var(--primary);
}

.form-group textarea {
  min-height: 80px;
  resize: vertical;
}

/* Buttons */
.btn {
  padding: 10px 20px;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-family: 'UKIJ', 'Noto Sans Arabic', sans-serif;
  cursor: pointer;
  font-weight: bold;
  transition: opacity 0.2s;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.btn:hover { opacity: 0.85; }

.btn-primary { background: var(--primary); color: white; }
.btn-danger { background: var(--danger); color: white; }
.btn-success { background: var(--success); color: white; }
.btn-warning { background: var(--warning); color: white; }
.btn-outline { background: white; color: var(--primary); border: 2px solid var(--primary); }
.btn-sm { padding: 6px 12px; font-size: 12px; }

/* Image Preview */
.image-preview {
  width: 100%;
  height: 120px;
  border-radius: var(--radius-sm);
  background: #f0f0f0;
  margin-top: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  border: 2px dashed var(--border);
}

.image-preview img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

/* Tables */
.table-wrap {
  overflow-x: auto;
  margin-top: 16px;
}

.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.admin-table th,
.admin-table td {
  padding: 10px 8px;
  border-bottom: 1px solid var(--border);
  text-align: right;
}

.admin-table th {
  background: #f8f9fa;
  font-weight: bold;
  font-size: 12px;
  white-space: nowrap;
}

.admin-table tr:hover {
  background: #fafafa;
}

.admin-table img {
  width: 50px;
  height: 35px;
  object-fit: cover;
  border-radius: 4px;
}

.action-btns {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}

/* Status badges */
.badge {
  font-size: 11px;
  padding: 3px 8px;
  border-radius: 10px;
  display: inline-block;
}

.badge-active { background: #e8f5e9; color: #2e7d32; }
.badge-inactive { background: #ffebee; color: #c62828; }
.badge-free { background: #e3f2fd; color: #1565c0; }

/* Checkbox row */
.check-row {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.check-row label {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 13px;
  cursor: pointer;
}

/* Toast */
.toast {
  position: fixed;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  padding: 10px 24px;
  border-radius: 24px;
  font-size: 13px;
  z-index: 1000;
  animation: fadeIn 0.3s ease;
  font-family: 'UKIJ', 'Noto Sans Arabic', sans-serif;
  color: white;
  box-shadow: 0 4px 12px rgba(0,0,0,0.2);
}

.toast.success { background: var(--success); }
.toast.error { background: var(--danger); }
.toast.info { background: var(--primary); }

@keyframes fadeIn {
  from { opacity: 0; transform: translateX(-50%) translateY(-10px); }
  to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* Loading */
.loading {
  text-align: center;
  padding: 40px;
  color: var(--text-light);
}

.spinner {
  display: inline-block;
  width: 30px;
  height: 30px;
  border: 3px solid #e0e0e0;
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* Modal */
.modal-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.5);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal {
  background: white;
  border-radius: var(--radius);
  padding: 24px;
  width: 90%;
  max-width: 500px;
  box-shadow: 0 10px 40px rgba(0,0,0,0.2);
}

.modal h3 {
  font-size: 17px;
  margin-bottom: 16px;
}

/* Mobile sidebar toggle */
.mobile-toggle {
  display: none;
  position: fixed;
  top: 12px;
  right: 12px;
  z-index: 110;
  background: var(--primary);
  color: white;
  border: none;
  width: 40px;
  height: 40px;
  border-radius: 8px;
  font-size: 20px;
  cursor: pointer;
}

/* Responsive */
@media (max-width: 768px) {
  .sidebar {
    transform: translateX(100%);
    transition: transform 0.3s;
  }
  .sidebar.open {
    transform: translateX(0);
  }
  .main-content {
    margin-right: 0;
    padding: 16px;
  }
  .mobile-toggle {
    display: block;
  }
  .stats-row {
    grid-template-columns: 1fr 1fr;
  }
  .form-row {
    flex-direction: column;
  }
}