@import url('https://fonts.googleapis.com/css2?family=Playfair+Display:wght@400;600;700&family=Cairo:wght@300;400;600;700&display=swap');

:root {
  --bg-primary:   #0c0c0c;
  --bg-secondary: #141414;
  --bg-card:      #1c1c1c;
  --gold:         #D4AF37;
  --gold-light:   #f0d060;
  --gold-dark:    #a8882a;
  --text:         #f0ece4;
  --text-muted:   #888;
  --border:       #2a2a2a;
  --danger:       #e53935;
  --danger-dark:  #b71c1c;
  --success:      #43a047;
  --radius:       10px;
  --transition:   0.25s ease;
  --font-heading: 'Playfair Display', serif;
  --font-arabic:  'Cairo', sans-serif;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body {
  background: var(--bg-primary);
  color: var(--text);
  font-family: var(--font-arabic);
  direction: rtl;
  min-height: 100vh;
}
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--bg-secondary); }
::-webkit-scrollbar-thumb { background: var(--gold-dark); border-radius: 3px; }

/* ── LOGIN OVERLAY ──────────────────────────────────────────────────────────── */
#loginOverlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.97);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
}
.login-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 48px 40px;
  width: 360px;
  max-width: 95vw;
  text-align: center;
  box-shadow: 0 20px 60px rgba(0,0,0,0.8);
}
.login-card h2 {
  font-family: var(--font-heading);
  color: var(--gold);
  font-size: 1.6rem;
  margin-bottom: 6px;
}
.login-card p { color: var(--text-muted); font-size: 0.85rem; margin-bottom: 28px; }
.login-card input {
  width: 100%;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 12px 16px;
  border-radius: var(--radius);
  font-family: var(--font-arabic);
  font-size: 1rem;
  direction: ltr;
  text-align: center;
  letter-spacing: 3px;
  outline: none;
  transition: border-color var(--transition);
  margin-bottom: 12px;
}
.login-card input:focus { border-color: var(--gold-dark); }
.login-card .btn-login {
  width: 100%;
  padding: 12px;
  background: var(--gold);
  color: #000;
  border: none;
  border-radius: var(--radius);
  font-family: var(--font-arabic);
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  transition: background var(--transition);
}
.login-card .btn-login:hover { background: var(--gold-light); }
.login-error {
  color: var(--danger);
  font-size: 0.82rem;
  margin-top: 10px;
  display: none;
}

/* ── ADMIN HEADER ───────────────────────────────────────────────────────────── */
.admin-header {
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  padding: 14px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  position: sticky;
  top: 0;
  z-index: 50;
}
.admin-header h1 {
  font-family: var(--font-heading);
  color: var(--gold);
  font-size: 1.3rem;
  white-space: nowrap;
}
.header-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ── STATS BAR ──────────────────────────────────────────────────────────────── */
.stats-bar {
  display: flex;
  gap: 12px;
  padding: 16px 24px;
  flex-wrap: wrap;
  border-bottom: 1px solid var(--border);
  background: var(--bg-secondary);
}
.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 20px;
  text-align: center;
  flex: 1;
  min-width: 120px;
}
.stat-value {
  font-family: var(--font-heading);
  font-size: 1.8rem;
  color: var(--gold);
  line-height: 1;
}
.stat-label { font-size: 0.75rem; color: var(--text-muted); margin-top: 4px; }

/* ── TABS ───────────────────────────────────────────────────────────────────── */
.admin-tabs {
  display: flex;
  border-bottom: 2px solid var(--border);
  padding: 0 24px;
  gap: 4px;
  background: var(--bg-secondary);
}
.tab-btn {
  background: none;
  border: none;
  border-bottom: 3px solid transparent;
  color: var(--text-muted);
  padding: 14px 20px;
  font-family: var(--font-arabic);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
  margin-bottom: -2px;
  white-space: nowrap;
}
.tab-btn:hover { color: var(--text); }
.tab-btn.active { color: var(--gold); border-bottom-color: var(--gold); }

/* ── ADMIN CONTENT ──────────────────────────────────────────────────────────── */
.admin-content { padding: 24px; max-width: 1200px; margin: 0 auto; }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ── PANEL TOOLBAR ──────────────────────────────────────────────────────────── */
.panel-toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.panel-toolbar h3 {
  font-size: 1rem;
  color: var(--text-muted);
  flex: 1;
}
.panel-toolbar select,
.panel-toolbar input[type="text"] {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 8px 14px;
  border-radius: var(--radius);
  font-family: var(--font-arabic);
  font-size: 0.85rem;
  direction: rtl;
  outline: none;
  transition: border-color var(--transition);
}
.panel-toolbar select:focus,
.panel-toolbar input:focus { border-color: var(--gold-dark); }

/* ── CATEGORIES LIST ────────────────────────────────────────────────────────── */
.cat-list { display: flex; flex-direction: column; gap: 8px; }
.cat-row {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 18px;
  display: flex;
  align-items: center;
  gap: 12px;
  transition: border-color var(--transition);
}
.cat-row:hover { border-color: var(--gold-dark); }
.cat-row-icon { font-size: 1.4rem; flex-shrink: 0; }
.cat-row-info { flex: 1; }
.cat-row-info .cat-name-ar { font-weight: 600; font-size: 0.95rem; }
.cat-row-info .cat-name-en { font-size: 0.78rem; color: var(--text-muted); }
.cat-row-count {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 2px 10px;
  font-size: 0.75rem;
  color: var(--text-muted);
}
.cat-row-actions { display: flex; gap: 6px; }

/* ── ITEMS TABLE ────────────────────────────────────────────────────────────── */
.items-table-wrap { overflow-x: auto; border-radius: var(--radius); border: 1px solid var(--border); }
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
  background: var(--bg-card);
}
thead {
  background: var(--bg-secondary);
  position: sticky;
  top: 0;
}
th {
  padding: 12px 14px;
  text-align: right;
  color: var(--text-muted);
  font-weight: 600;
  white-space: nowrap;
  border-bottom: 2px solid var(--border);
}
td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
tr:last-child td { border-bottom: none; }
tr:hover td { background: rgba(255,255,255,0.02); }
.td-img { width: 52px; }
.td-img img {
  width: 48px;
  height: 36px;
  object-fit: cover;
  border-radius: 6px;
  background: var(--bg-secondary);
}
.td-name { min-width: 160px; max-width: 240px; }
.td-name span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.td-desc { 
  max-width: 200px; 
  overflow: hidden; 
  text-overflow: ellipsis; 
  white-space: nowrap; 
  font-size: 0.8rem; 
  color: var(--text-muted);
}
.cat-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 0.72rem;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  color: var(--text-muted);
  white-space: nowrap;
}
.inline-price {
  width: 90px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  color: var(--gold);
  padding: 5px 10px;
  border-radius: 6px;
  font-family: var(--font-heading);
  font-size: 0.95rem;
  font-weight: 700;
  text-align: center;
  direction: ltr;
  outline: none;
  transition: border-color var(--transition);
}
.inline-price:focus { border-color: var(--gold-dark); }
.td-actions { display: flex; gap: 6px; white-space: nowrap; }

/* ── BUTTONS ────────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 7px 14px;
  border-radius: 8px;
  border: none;
  cursor: pointer;
  font-family: var(--font-arabic);
  font-size: 0.82rem;
  font-weight: 600;
  transition: all var(--transition);
}
.btn-gold    { background: var(--gold);    color: #000; }
.btn-gold:hover { background: var(--gold-light); }
.btn-outline { background: transparent; border: 1px solid var(--border); color: var(--text-muted); }
.btn-outline:hover { border-color: var(--gold-dark); color: var(--gold); }
.btn-danger  { background: transparent; border: 1px solid #5a2020; color: #e57373; }
.btn-danger:hover { background: var(--danger-dark); border-color: var(--danger-dark); color: #fff; }
.btn-success { background: var(--success); color: #fff; }
.btn-sm { padding: 5px 10px; font-size: 0.78rem; }

/* ── IMAGE UPLOAD ─────────────────────────────────────────── */
.image-preview {
  margin-top: 10px;
  text-align: center;
}
.preview-img {
  max-width: 100px;
  max-height: 100px;
  border-radius: var(--radius);
  border: 2px solid var(--border);
  object-fit: cover;
}

/* ── MODAL ───────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 500;
  padding: 16px;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition);
}
.modal-overlay.open { opacity: 1; pointer-events: auto; }
.modal {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 14px;
  width: 460px;
  max-width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  padding: 28px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.8);
  transform: translateY(20px);
  transition: transform var(--transition);
}
.modal-overlay.open .modal { transform: translateY(0); }
.modal h3 {
  font-family: var(--font-heading);
  color: var(--gold);
  margin-bottom: 20px;
  font-size: 1.2rem;
}
.form-group { margin-bottom: 16px; }
.form-group label {
  display: block;
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-bottom: 6px;
  font-weight: 600;
}
.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 10px 14px;
  border-radius: var(--radius);
  font-family: var(--font-arabic);
  font-size: 0.9rem;
  direction: rtl;
  outline: none;
  transition: border-color var(--transition);
}
.form-group input:focus,
.form-group select:focus { border-color: var(--gold-dark); }
.form-group input[type="number"] { direction: ltr; text-align: right; }
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 20px; }

/* ── TOAST ──────────────────────────────────────────────────────────────────── */
#toastContainer {
  position: fixed;
  bottom: 24px;
  left: 24px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}
.toast {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-right: 4px solid var(--gold);
  color: var(--text);
  padding: 12px 18px;
  border-radius: var(--radius);
  font-size: 0.85rem;
  max-width: 320px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.5);
  animation: slideInLeft 0.3s ease;
}
.toast.error  { border-right-color: var(--danger); }
.toast.success { border-right-color: var(--success); }
@keyframes slideInLeft {
  from { opacity: 0; transform: translateX(-20px); }
  to   { opacity: 1; transform: translateX(0); }
}

/* ── RESPONSIVE ─────────────────────────────────────────────────────────────── */
@media (max-width: 640px) {
  .admin-header h1 { font-size: 1rem; }
  .admin-content { padding: 16px 12px; }
  .stats-bar { padding: 12px; }
  th:nth-child(4), td:nth-child(4) { display: none; } /* hide category on mobile */
}
