/* ========================================
   AMILANO Dashboard — Premium Dark Theme
   ======================================== */

/* ── Variables ── */
:root {
  --bg-primary: #0a0a0f;
  --bg-secondary: #12121a;
  --bg-card: #1a1a25;
  --bg-card-hover: #22222f;
  --bg-sidebar: #0e0e16;
  --bg-input: #15151f;
  --gold: #c9a84c;
  --gold-light: #e2c97e;
  --gold-dark: #a8873a;
  --gold-glow: rgba(201, 168, 76, 0.15);
  --text-primary: #f0ece4;
  --text-secondary: #a0a0b0;
  --text-muted: #666678;
  --border: #2a2a3a;
  --border-light: #333345;
  --green: #2ecc71;
  --green-bg: rgba(46, 204, 113, 0.1);
  --blue: #3498db;
  --blue-bg: rgba(52, 152, 219, 0.1);
  --orange: #e67e22;
  --orange-bg: rgba(230, 126, 34, 0.1);
  --red: #e74c3c;
  --red-bg: rgba(231, 76, 60, 0.1);
  --sidebar-width: 260px;
  --header-height: 60px;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 4px 24px rgba(0, 0, 0, 0.3);
  --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ── Reset ── */
*,
*::before,
*::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: 'Tajawal', sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  overflow-x: hidden;
}

/* ── Scrollbar ── */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--bg-primary); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--gold-dark); }

/* ══════════════════════════════════════
   SIDEBAR
   ══════════════════════════════════════ */
.sidebar {
  position: fixed;
  right: 0;
  top: 0;
  width: var(--sidebar-width);
  height: 100vh;
  background: var(--bg-sidebar);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  z-index: 100;
  transition: var(--transition);
}

.sidebar-header {
  padding: 28px 24px 20px;
  border-bottom: 1px solid var(--border);
  text-align: center;
}

.sidebar-logo {
  font-size: 1.6rem;
  font-weight: 800;
  letter-spacing: 6px;
  color: var(--gold);
  text-decoration: none;
  display: block;
}

.sidebar-subtitle {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 4px;
  letter-spacing: 2px;
  text-transform: uppercase;
}

.sidebar-nav {
  flex: 1;
  padding: 20px 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 18px;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 0.95rem;
  font-weight: 500;
  transition: var(--transition);
  position: relative;
}

.nav-item:hover {
  background: var(--gold-glow);
  color: var(--gold-light);
}

.nav-item.active {
  background: linear-gradient(135deg, var(--gold-glow), rgba(201, 168, 76, 0.08));
  color: var(--gold);
  font-weight: 700;
}

.nav-item.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 60%;
  background: var(--gold);
  border-radius: 0 3px 3px 0;
}

.nav-icon {
  font-size: 1.2rem;
  width: 28px;
  text-align: center;
}

.nav-badge {
  margin-right: auto;
  background: var(--red);
  color: #fff;
  font-size: 0.7rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 10px;
  min-width: 22px;
  text-align: center;
}

.sidebar-footer {
  padding: 16px 12px;
  border-top: 1px solid var(--border);
}

.back-to-site {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 18px;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.85rem;
  transition: var(--transition);
}

.back-to-site:hover {
  color: var(--gold-light);
  background: var(--gold-glow);
}

/* ── Mobile Header ── */
.mobile-header {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--header-height);
  background: var(--bg-sidebar);
  border-bottom: 1px solid var(--border);
  z-index: 90;
  align-items: center;
  padding: 0 16px;
  gap: 12px;
}

.hamburger {
  background: none;
  border: none;
  color: var(--gold);
  font-size: 1.5rem;
  cursor: pointer;
  padding: 4px;
}

.mobile-title {
  font-size: 0.9rem;
  color: var(--gold);
  font-weight: 700;
  letter-spacing: 2px;
}

.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  z-index: 99;
  backdrop-filter: blur(4px);
}

/* ══════════════════════════════════════
   MAIN CONTENT
   ══════════════════════════════════════ */
.main-content {
  margin-right: var(--sidebar-width);
  padding: 40px 36px;
  min-height: 100vh;
}

.content-section {
  display: none;
}

.content-section.active {
  display: block;
  animation: fadeIn 0.4s ease;
}

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

/* ── Section Title ── */
.section-title {
  margin-bottom: 32px;
}

.section-title h1 {
  font-size: 1.8rem;
  font-weight: 800;
  color: var(--text-primary);
  margin-bottom: 6px;
}

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

/* ══════════════════════════════════════
   STATS GRID
   ══════════════════════════════════════ */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 20px;
  margin-bottom: 32px;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  display: flex;
  align-items: center;
  gap: 18px;
  transition: var(--transition);
  position: relative;
  overflow: hidden;
}

.stat-card::before {
  content: '';
  position: absolute;
  top: 0;
  right: 0;
  width: 100%;
  height: 3px;
  background: linear-gradient(90deg, var(--gold), var(--gold-dark));
  opacity: 0;
  transition: var(--transition);
}

.stat-card:hover {
  border-color: var(--gold-dark);
  transform: translateY(-2px);
  box-shadow: 0 8px 30px rgba(201, 168, 76, 0.08);
}

.stat-card:hover::before { opacity: 1; }

.stat-icon {
  font-size: 2.2rem;
  width: 56px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--gold-glow);
  border-radius: var(--radius-sm);
}

.stat-number {
  font-size: 1.6rem;
  font-weight: 800;
  color: var(--gold);
}

.stat-label {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 2px;
}

/* ── Overview Grid ── */
.overview-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

.overview-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
}

.overview-card h3 {
  font-size: 1rem;
  color: var(--text-primary);
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}

.recent-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: 300px;
  overflow-y: auto;
}

.recent-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  background: var(--bg-input);
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  transition: var(--transition);
}

.recent-item:hover { background: var(--bg-card-hover); }

.recent-item .name {
  color: var(--text-primary);
  font-weight: 500;
}

.recent-item .meta {
  color: var(--text-muted);
  font-size: 0.75rem;
}

.empty-state {
  text-align: center;
  padding: 32px 16px;
  color: var(--text-muted);
  font-size: 0.9rem;
}

/* ══════════════════════════════════════
   TOOLBAR
   ══════════════════════════════════════ */
.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 24px;
}

.filter-group {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.toolbar-btn {
  padding: 8px 16px;
  border-radius: 20px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-secondary);
  font-family: inherit;
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
}

.toolbar-btn:hover {
  border-color: var(--gold-dark);
  color: var(--gold-light);
}

.toolbar-btn.active {
  background: var(--gold);
  color: var(--bg-primary);
  border-color: var(--gold);
  font-weight: 700;
}

.toolbar-search {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 16px;
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.85rem;
  width: 280px;
  max-width: 100%;
  transition: var(--transition);
}

.toolbar-search:focus {
  outline: none;
  border-color: var(--gold);
  box-shadow: 0 0 0 3px var(--gold-glow);
}

.toolbar-search::placeholder {
  color: var(--text-muted);
}

/* ══════════════════════════════════════
   BUTTONS
   ══════════════════════════════════════ */
.btn {
  padding: 10px 22px;
  border-radius: var(--radius-sm);
  border: none;
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.btn-primary {
  background: linear-gradient(135deg, var(--gold), var(--gold-dark));
  color: var(--bg-primary);
}

.btn-primary:hover {
  background: linear-gradient(135deg, var(--gold-light), var(--gold));
  transform: translateY(-1px);
  box-shadow: 0 4px 16px rgba(201, 168, 76, 0.3);
}

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border);
}

.btn-ghost:hover {
  border-color: var(--text-secondary);
  color: var(--text-primary);
}

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

.btn-danger {
  background: var(--red-bg);
  color: var(--red);
  border: 1px solid transparent;
}

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

.btn-edit {
  background: var(--blue-bg);
  color: var(--blue);
  border: 1px solid transparent;
}

.btn-edit:hover {
  background: var(--blue);
  color: #fff;
}

/* ══════════════════════════════════════
   DATA TABLE
   ══════════════════════════════════════ */
.table-wrapper {
  overflow-x: auto;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--bg-card);
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--border);
}

.data-table thead {
  background: var(--bg-input);
}

.data-table th {
  padding: 14px 18px;
  text-align: right;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 1px;
  white-space: nowrap;
}

.data-table td {
  padding: 14px 18px;
  font-size: 0.85rem;
  border-top: 1px solid var(--border);
  color: var(--text-secondary);
  vertical-align: middle;
}

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

.data-table tbody tr:hover {
  background: var(--bg-card-hover);
}

.empty-table {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
  display: none;
}

.empty-icon {
  font-size: 3rem;
  display: block;
  margin-bottom: 12px;
  opacity: 0.4;
}

/* ── Status Badges ── */
.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 600;
}

.status-new {
  background: var(--blue-bg);
  color: var(--blue);
}

.status-processing {
  background: var(--orange-bg);
  color: var(--orange);
}

.status-delivered {
  background: var(--green-bg);
  color: var(--green);
}

.status-cancelled {
  background: var(--red-bg);
  color: var(--red);
}

/* ── Status Dropdown ── */
.status-select {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 4px 8px;
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.75rem;
  cursor: pointer;
}

.status-select:focus {
  outline: none;
  border-color: var(--gold);
}

/* ══════════════════════════════════════
   PRODUCTS ADMIN GRID
   ══════════════════════════════════════ */
.products-admin-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 20px;
}

.product-admin-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  transition: var(--transition);
}

.product-admin-card:hover {
  border-color: var(--gold-dark);
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}

.product-admin-img {
  width: 100%;
  height: 200px;
  object-fit: cover;
  background: var(--bg-input);
  display: block;
}

.product-admin-img-placeholder {
  width: 100%;
  height: 200px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--bg-input), var(--bg-card-hover));
  font-size: 3rem;
  color: var(--text-muted);
}

.product-admin-body {
  padding: 18px;
}

.product-admin-name {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 2px;
}

.product-admin-name-en {
  font-size: 0.7rem;
  color: var(--text-muted);
  letter-spacing: 1.5px;
  text-transform: uppercase;
  margin-bottom: 10px;
}

.product-admin-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}

.product-admin-price {
  font-size: 1rem;
  font-weight: 800;
  color: var(--gold);
}

.product-admin-category {
  font-size: 0.72rem;
  padding: 3px 10px;
  background: var(--gold-glow);
  color: var(--gold-light);
  border-radius: 12px;
}

.product-admin-actions {
  display: flex;
  gap: 8px;
}

.product-admin-actions .btn {
  flex: 1;
  justify-content: center;
}

/* ── New Badge ── */
.product-admin-badge {
  position: absolute;
  top: 12px;
  right: 12px;
  background: var(--gold);
  color: var(--bg-primary);
  font-size: 0.65rem;
  font-weight: 800;
  padding: 3px 10px;
  border-radius: 12px;
}

.product-admin-img-wrapper {
  position: relative;
}

/* ══════════════════════════════════════
   CATEGORIES GRID
   ══════════════════════════════════════ */
.categories-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 16px;
}

.category-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  transition: var(--transition);
  text-align: center;
}

.category-card:hover {
  border-color: var(--gold-dark);
  transform: translateY(-2px);
}

.category-icon {
  font-size: 2.4rem;
  width: 64px;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--gold-glow);
  border-radius: 50%;
}

.category-name {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-primary);
}

.category-key {
  font-size: 0.72rem;
  color: var(--text-muted);
  letter-spacing: 1px;
  font-family: monospace;
}

.category-count {
  font-size: 0.78rem;
  color: var(--text-secondary);
}

.category-actions {
  display: flex;
  gap: 8px;
  margin-top: 4px;
}

/* ══════════════════════════════════════
   MODAL
   ══════════════════════════════════════ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(6px);
  z-index: 200;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal-overlay.active {
  display: flex;
  animation: fadeIn 0.3s ease;
}

.modal {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  width: 100%;
  max-width: 680px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

.modal-sm {
  max-width: 440px;
}

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

.modal-header h2 {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--gold);
}

.modal-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.4rem;
  cursor: pointer;
  transition: var(--transition);
  padding: 4px;
}

.modal-close:hover { color: var(--red); }

/* ── Form ── */
.modal-form {
  padding: 24px 28px 28px;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.form-group {
  margin-bottom: 18px;
}

.form-group label {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 10px 14px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.85rem;
  transition: var(--transition);
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--gold);
  box-shadow: 0 0 0 3px var(--gold-glow);
}

.form-group textarea {
  resize: vertical;
}

.form-group input::placeholder,
.form-group textarea::placeholder {
  color: var(--text-muted);
}

.form-group select option {
  background: var(--bg-card);
  color: var(--text-primary);
}

.form-actions {
  display: flex;
  gap: 12px;
  margin-top: 8px;
  justify-content: flex-start;
}

.notes-section {
  margin-top: 12px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

.notes-section h3 {
  font-size: 0.95rem;
  color: var(--gold);
  margin-bottom: 14px;
}

/* ── Order Products Select ── */
.order-products-select {
  max-height: 200px;
  overflow-y: auto;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.order-product-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 6px;
  cursor: pointer;
  transition: var(--transition);
}

.order-product-item:hover {
  background: var(--bg-card-hover);
}

.order-product-item input {
  accent-color: var(--gold);
  width: 16px;
  height: 16px;
}

.order-product-item label {
  cursor: pointer;
  font-size: 0.85rem;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
}

.order-product-item .price-tag {
  color: var(--gold);
  font-size: 0.75rem;
  font-weight: 600;
}

/* ══════════════════════════════════════
   TOAST NOTIFICATION
   ══════════════════════════════════════ */
.toast-container {
  position: fixed;
  bottom: 24px;
  left: 24px;
  z-index: 300;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.toast {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px 20px;
  color: var(--text-primary);
  font-size: 0.85rem;
  font-weight: 500;
  box-shadow: var(--shadow);
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 260px;
  animation: slideInToast 0.4s ease;
}

.toast.success { border-color: var(--green); }
.toast.error { border-color: var(--red); }
.toast.info { border-color: var(--blue); }

@keyframes slideInToast {
  from { opacity: 0; transform: translateX(-30px); }
  to { opacity: 1; transform: translateX(0); }
}

@keyframes slideOutToast {
  from { opacity: 1; transform: translateX(0); }
  to { opacity: 0; transform: translateX(-30px); }
}

/* ══════════════════════════════════════
   RESPONSIVE
   ══════════════════════════════════════ */
@media (max-width: 900px) {
  .sidebar {
    transform: translateX(100%);
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .sidebar-overlay.active {
    display: block;
  }

  .mobile-header {
    display: flex;
  }

  .main-content {
    margin-right: 0;
    padding: 80px 16px 32px;
  }

  .overview-grid {
    grid-template-columns: 1fr;
  }

  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .form-row {
    grid-template-columns: 1fr;
  }

  .toolbar {
    flex-direction: column;
    align-items: stretch;
  }

  .toolbar-search {
    width: 100%;
  }

  .filter-group {
    overflow-x: auto;
    padding-bottom: 4px;
  }

  .products-admin-grid {
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  }

  .categories-grid {
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  }
}

@media (max-width: 480px) {
  .stats-grid {
    grid-template-columns: 1fr;
  }

  .products-admin-grid {
    grid-template-columns: 1fr;
  }

  .modal {
    max-height: 95vh;
    border-radius: var(--radius-sm);
  }
}
