* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  font-family: 'Cairo', 'Segoe UI', Tahoma, sans-serif;
}

:root {
  --primary: #2ecc71;
  --primary-dark: #27ae60;
  --danger: #e74c3c;
  --warning: #f39c12;
  --bg: #f5f6fa;
  --white: #ffffff;
  --text: #2d3436;
  --text-light: #636e72;
  --border: #dfe6e9;
  --shadow: 0 2px 10px rgba(0,0,0,0.08);
  --radius: 12px;
}

body {
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

/* ========= NAVBAR ========= */
.navbar {
  background: var(--white);
  padding: 0 20px;
  height: 80px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: var(--shadow);
  position: sticky;
  top: 0;
  z-index: 100;
}

.navbar .logo {
  font-size: 22px;
  font-weight: 700;
  color: var(--primary);
  text-decoration: none;
}

.navbar .logo span {
  color: var(--text);
}

.nav-actions {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

/* ========= BUTTONS ========= */
.btn {
  padding: 10px 20px;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  transition: all 0.2s;
  text-decoration: none;
  display: inline-block;
  text-align: center;
}

.btn-primary {
  background: var(--primary);
  color: white;
}

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

.btn-outline {
  background: transparent;
  color: var(--primary);
  border: 2px solid var(--primary);
}

.btn-outline:hover {
  background: var(--primary);
  color: white;
}

.btn-danger {
  background: var(--danger);
  color: white;
}

.btn-warning {
  background: var(--warning);
  color: white;
}

.btn-full { width: 100%; }

.btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

/* ========= FORMS ========= */
.form-container {
  max-width: 420px;
  margin: 60px auto;
  background: var(--white);
  padding: 40px;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.form-container h2 {
  text-align: center;
  margin-bottom: 8px;
  font-size: 24px;
}

.form-container .subtitle {
  text-align: center;
  color: var(--text-light);
  margin-bottom: 30px;
  font-size: 14px;
}

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

.form-group label {
  display: block;
  margin-bottom: 6px;
  font-weight: 600;
  font-size: 14px;
}

.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 12px 16px;
  border: 2px solid var(--border);
  border-radius: 8px;
  font-size: 15px;
  transition: border 0.2s;
  background: var(--white);
  color: var(--text);
}

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

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

.form-switch {
  text-align: center;
  margin-top: 20px;
  font-size: 14px;
  color: var(--text-light);
}

.form-switch a {
  color: var(--primary);
  cursor: pointer;
  font-weight: 600;
  text-decoration: none;
}

/* ========= CARDS ========= */
.page-container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 24px 16px;
}

.page-title {
  font-size: 22px;
  font-weight: 700;
  margin-bottom: 20px;
}

.cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 20px;
}

.card {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s;
}

.card:hover {
  transform: translateY(-3px);
  box-shadow: 0 8px 25px rgba(0,0,0,0.12);
}

.card-body {
  padding: 16px;
}

.card-title {
  font-size: 17px;
  font-weight: 700;
  margin-bottom: 6px;
}

.card-subtitle {
  font-size: 13px;
  color: var(--text-light);
  margin-bottom: 10px;
}

/* ========= متاجر: صور بحجم الثابنية بدون شرائط فارغة (cover) ========= */
.store-card-body {
  display: grid;
  grid-template-columns: minmax(92px, 100px) 1fr;
  gap: 12px;
  align-items: start;
}

.store-card-thumb {
  width: 100%;
  aspect-ratio: 1;
  border-radius: 14px;
  overflow: hidden;
  background: #eef0f3;
}

.store-card-thumb__img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  display: block;
}

.store-card-thumb__fallback {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  font-size: clamp(26px, 8vw, 32px);
}

.store-card-info {
  min-width: 0;
}

.store-header-card {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 16px;
  background: var(--white);
  padding: 20px;
  border-radius: 12px;
  margin-bottom: 24px;
  box-shadow: var(--shadow);
}

.store-header-card__main {
  flex: 1 1 min(100%, 220px);
  min-width: 0;
}

.store-header-card__media {
  flex: 0 0 auto;
  width: clamp(112px, 28vw, 132px);
  aspect-ratio: 1;
  max-height: 140px;
  border-radius: 12px;
  overflow: hidden;
  background: #eef0f3;
}

.store-header-card__media--placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: clamp(34px, 10vw, 44px);
}

.store-header-card__img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  display: block;
}

@media (max-width: 576px) {
  .store-header-card {
    flex-direction: column;
    align-items: stretch;
    gap: 14px;
    padding: 16px;
  }

  .store-header-card__media,
  .store-header-card__media--placeholder {
    order: -1;
    width: 100%;
    aspect-ratio: 4 / 3;
    max-height: min(220px, 42vh);
  }
}

@media (max-width: 768px) {
  .seller-dashboard-store-img {
    width: 52px !important;
    height: 52px !important;
  }
}

@media (max-width: 480px) {
  .store-card-body {
    grid-template-columns: minmax(84px, 92px) 1fr;
    gap: 10px;
  }

  .seller-dashboard-store-img {
    width: 48px !important;
    height: 48px !important;
  }

  /* Store edit form image preview */
  .form-container img {
    max-width: 100px !important;
    max-height: 100px !important;
  }
}

/* ========= BADGES ========= */
.badge {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
}

.badge-green { background: #d5f5e3; color: #1e8449; }
.badge-orange { background: #fdebd0; color: #a04000; }
.badge-blue { background: #d6eaf8; color: #1a5276; }
.badge-red { background: #fadbd8; color: #922b21; }
.badge-gray { background: #eaecee; color: #555; }
.badge-warning { background: #fef9e7; color: #d4ac0d; }

/* ========= STATUS COLORS ========= */
.status-pending { color: var(--warning); }
.status-preparing { color: #3498db; }
.status-ready { color: var(--primary); }
.status-completed { color: #7f8c8d; }
.status-cancelled { color: var(--danger); }

/* ========= ALERT ========= */
.alert {
  padding: 12px 16px;
  border-radius: 8px;
  margin-bottom: 16px;
  font-size: 14px;
  font-weight: 500;
}

.alert-error { background: #fadbd8; color: #922b21; }
.alert-success { background: #d5f5e3; color: #1e8449; }

/* ========= LOADING ========= */
.loading {
  text-align: center;
  padding: 60px;
  color: var(--text-light);
  font-size: 16px;
}

.spinner {
  width: 40px;
  height: 40px;
  border: 4px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 0 auto 16px;
}

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

/* ========= EMPTY STATE ========= */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-light);
}

.empty-state .icon {
  font-size: 48px;
  margin-bottom: 16px;
}

.empty-state p {
  font-size: 16px;
}

/* ========= CART ========= */
.cart-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--primary);
  color: white;
  padding: 14px 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-shadow: 0 -4px 20px rgba(0,0,0,0.15);
  z-index: 200;
  cursor: pointer;
}

.cart-bar.hidden { display: none; }

.cart-bar .cart-info { font-size: 15px; font-weight: 600; }
.cart-bar .cart-total { font-size: 17px; font-weight: 700; }

/* ========= ORDER STATUS ========= */
.order-timeline {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin: 24px 0;
  position: relative;
}

.order-timeline::before {
  content: '';
  position: absolute;
  top: 20px;
  right: 10%;
  left: 10%;
  height: 3px;
  background: var(--border);
  z-index: 0;
}

.timeline-step {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  z-index: 1;
}

.timeline-step .dot {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  transition: all 0.3s;
}

.timeline-step.active .dot { background: var(--primary); }
.timeline-step.done .dot { background: var(--primary-dark); }

.timeline-step span {
  font-size: 12px;
  color: var(--text-light);
  font-weight: 600;
}

/* ========= RESPONSIVE (MOBILE & TOUCH) ========= */
@media (max-width: 768px) {
  .navbar {
    flex-direction: column;
    height: auto;
    padding: 8px 12px;
    gap: 8px;
  }

  .nav-actions {
    width: 100%;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 6px;
  }

  .nav-actions .btn {
    flex: 1;
    text-align: center;
    padding: 6px 8px;
    font-size: 12px;
  }

  .page-container {
    padding: 12px 10px;
  }

  .cards-grid {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .card .card-body {
    padding: 12px;
  }

  .card-title {
    font-size: 16px;
  }

  .form-container {
    margin: 20px 16px;
    padding: 20px;
  }

  .form-group input,
  .form-group select,
  .form-group textarea {
    padding: 10px 12px;
  }

  .cart-bar {
    flex-direction: column;
    text-align: center;
    gap: 8px;
    padding: 12px;
  }

  /* تحسين الفلاتتر: جعلها قابلة للتمرير أفقياً أو التفاف */
  .filters-container {
    display: flex;
    flex-wrap: nowrap;
    overflow-x: auto;
    gap: 8px;
    padding-bottom: 8px;
    -webkit-overflow-scrolling: touch;
    margin-bottom: 16px;
  }

  .filters-container .btn {
    flex: 0 0 auto;
    white-space: nowrap;
  }

  /* تأثير اللمس للأزرار والبطاقات */
  .btn:active,
  .card:active {
    transform: scale(0.97);
    transition: transform 0.05s;
  }


  /* تحسين إحصائيات لوحة التحكم (صف واحد) */
@media (max-width: 768px) {
  .stats-grid {
    display: flex !important;
    flex-direction: row !important;
    flex-wrap: nowrap !important;
    overflow-x: auto !important;
    gap: 8px !important;
    margin-bottom: 20px !important;
    padding-bottom: 4px;
    -webkit-overflow-scrolling: touch;
  }

  .stat-card {
    flex: 1 0 auto !important;
    min-width: 70px !important;
    background: var(--white);
    padding: 8px 6px !important;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    text-align: center;
    font-size: 12px !important;
  }

  .stat-card .stat-icon {
    font-size: 18px !important;
    margin-bottom: 2px;
  }

  .stat-card .stat-count {
    font-size: 18px !important;
    font-weight: 700;
    line-height: 1.2;
  }

  .stat-card .stat-label {
    font-size: 10px !important;
    white-space: nowrap;
  }

  /* تصغير زر الخروج في النافبار */
  .nav-actions .btn-danger {
    padding: 4px 10px !important;
    font-size: 12px !important;
  }

  /* تقليل عرض اسم المستخدم */
  .nav-actions span {
    font-size: 12px !important;
  }
}




}

/* للأجهزة الصغيرة جداً (عرض أقل من 480px) */
@media (max-width: 480px) {
  .navbar .logo {
    font-size: 18px;
  }

  .btn {
    padding: 6px 12px;
    font-size: 12px;
  }

  .filters-container {
    gap: 6px;
  }
}


/* تنسيق كروت المنتجات في لوحة البائع */
.product-card {
  transition: transform 0.1s;
}
.product-card:active {
  transform: scale(0.99);
}
@media (max-width: 480px) {
  .product-card {
    margin-bottom: 10px;
  }
  .product-card [style*="flex-shrink:0"] {
    width: 60px !important;
    height: 60px !important;
  }
  .product-name {
    font-size: 14px !important;
  }
  .product-price {
    font-size: 14px !important;
  }
}

/* تحسين كروت المنتجات للمشتري */
@media (max-width: 480px) {
  .product-card [style*="flex-shrink:0"] {
    width: 60px !important;
    height: 60px !important;
  }
  .product-name {
    font-size: 14px !important;
  }
  .product-price {
    font-size: 14px !important;
  }
  .btn-outline, .btn-primary {
    padding: 4px 8px !important;
    font-size: 12px !important;
  }
}


/* أيقونات شريط التنقل */
.btn-icon {
  background: transparent;
  border: none;
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  font-size: 18px;
  color: var(--text);
  cursor: pointer;
  padding: 4px 4px;
  border-radius: 4px;
  transition: background 0.2s;
}
.btn-icon .nav-label {
  font-size: 10px;
  font-weight: 500;
}
.btn-icon:active {
  background: rgba(0,0,0,0.05);
}
.btn-danger-icon {
  color: var(--danger);
}
@media (max-width: 480px) {
  .btn-icon {
    font-size: 16px;
    padding: 2px 6px;
  }
  .btn-icon .nav-label {
    font-size: 10px;
  }
}
/* ---------- Modal للمنتج ---------- */
.product-modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0,0,0,0.8);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
  visibility: hidden;
  opacity: 0;
  transition: visibility 0.2s, opacity 0.2s;
}
.product-modal.active {
  visibility: visible;
  opacity: 1;
}
.modal-content {
  background: var(--white);
  max-width: 90%;
  width: 400px;
  border-radius: 20px;
  padding: 20px;
  position: relative;
  text-align: center;
}
.modal-content img {
  max-width: 100%;
  max-height: 300px;
  object-fit: contain;
  border-radius: 12px;
  margin-bottom: 16px;
}
.modal-close {
  position: absolute;
  top: 12px;
  left: 12px;
  background: none;
  border: none;
  font-size: 24px;
  cursor: pointer;
  color: var(--text-light);
}
.modal-product-name {
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 8px;
}
.modal-product-price {
  font-size: 22px;
  font-weight: 700;
  color: var(--primary);
  margin-bottom: 12px;
}
.modal-product-desc {
  font-size: 14px;
  color: var(--text-light);
  margin-bottom: 20px;
}
@media (max-width: 480px) {
  .modal-content {
    width: 85%;
    padding: 16px;
  }
  .modal-content img {
    max-height: 200px;
  }
}

.password-toggle {
  background: rgba(0,0,0,0.05);
  padding: 4px 8px;
  border-radius: 20px;
  font-size: 12px;
  user-select: none;
}
.password-toggle:hover {
  background: rgba(0,0,0,0.1);
}

/* تحسين مظهر الكارت القابل للنقر */
.stat-card-clickable {
  cursor: pointer;
  transition: transform 0.1s ease, background-color 0.2s ease;
}

/* تأثير عند الضغط (click) */
.stat-card-clickable:active {
  transform: scale(0.96);
  background-color: #f0f0f0;
}

/* تأثير عند تمرير الماوس (hover) للكروت القابلة للنقر فقط */
.stat-card-clickable:hover {
  background-color: #f9f9f9;
  box-shadow: 0 4px 12px rgba(0,0,0,0.12);
}