/**
 * رزقي هب - الأنماط الرئيسية (RTL)
 * @version 1.0
 * @author Rizqy Hub Team
 */

@import url('https://fonts.googleapis.com/css2?family=Almarai:wght@300;400;700;800&family=IBM+Plex+Sans+Arabic:wght@300;400;500;700&display=swap');

:root {
  /* 🎨 لوحة الألوان السعودية */
  --color-primary: #2E7D32;
  --color-primary-light: #4CAF50;
  --color-primary-dark: #1B5E20;
  --color-secondary: #8D6E63;
  --color-secondary-light: #A1887F;
  --color-accent: #FFD54F;
  --color-accent-dark: #FFB300;
  
  /* 🌗 الخلفيات والنصوص */
  --color-bg: #FAFAFA;
  --color-bg-card: #FFFFFF;
  --color-bg-alt: #F5F5F5;
  --color-text: #212121;
  --color-text-secondary: #757575;
  --color-text-muted: #9E9E9E;
  --color-border: #E0E0E0;
  --color-border-light: #EEEEEE;
  
  /* 🚦 ألوان الحالات */
  --color-success: #2E7D32;
  --color-warning: #EF6C00;
  --color-error: #C62828;
  --color-info: #0288D1;
  
  /* 📐 المسافات والظلال */
  --radius-sm: 6px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-full: 9999px;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.08);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.1);
  --shadow-lg: 0 10px 25px rgba(0,0,0,0.12);
  --shadow-hover: 0 8px 20px rgba(46,125,50,0.15);
  
  /* ️ الحركات */
  --transition-fast: 0.15s ease;
  --transition-base: 0.25s ease;
  --transition-slow: 0.4s ease;
}

/* 🔹 إعادة التعيين الأساسية */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: 'Almarai', 'IBM Plex Sans Arabic', system-ui, sans-serif;
  background-color: var(--color-bg);
  color: var(--color-text);
  line-height: 1.6;
  direction: rtl;
  text-align: right;
  overflow-x: hidden;
}

a {
  color: var(--color-primary);
  text-decoration: none;
  transition: color var(--transition-fast);
}

a:hover { color: var(--color-primary-light); }

img, video, svg {
  max-width: 100%;
  height: auto;
  display: block;
}

button, input, select, textarea {
  font-family: inherit;
  font-size: inherit;
  line-height: inherit;
}

/* 🔹 الحاويات والشبكة */
.container {
  width: 100%;
  max-width: 1320px;
  margin-inline: auto;
  padding-inline: 1rem;
}

.grid {
  display: grid;
  gap: 1.5rem;
}

.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
.grid-auto { grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }

.flex { display: flex; }
.flex-center { align-items: center; justify-content: center; }
.flex-between { justify-content: space-between; }
.flex-wrap { flex-wrap: wrap; }
.gap-1 { gap: 0.5rem; }
.gap-2 { gap: 1rem; }
.gap-3 { gap: 1.5rem; }

/* 🔹 الأزرار */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.6rem 1.25rem;
  font-weight: 600;
  font-size: 0.95rem;
  border: 2px solid transparent;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--transition-fast);
  white-space: nowrap;
  user-select: none;
}

.btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none !important;
}

.btn-primary {
  background: var(--color-primary);
  color: #fff;
  border-color: var(--color-primary);
}
.btn-primary:hover:not(:disabled) {
  background: var(--color-primary-light);
  border-color: var(--color-primary-light);
  transform: translateY(-2px);
  box-shadow: var(--shadow-hover);
}

.btn-secondary {
  background: var(--color-secondary);
  color: #fff;
  border-color: var(--color-secondary);
}
.btn-secondary:hover:not(:disabled) {
  background: var(--color-secondary-light);
  border-color: var(--color-secondary-light);
}

.btn-outline {
  background: transparent;
  color: var(--color-primary);
  border-color: var(--color-primary);
}
.btn-outline:hover:not(:disabled) {
  background: var(--color-primary);
  color: #fff;
}

.btn-ghost {
  background: transparent;
  color: var(--color-text-secondary);
  padding: 0.5rem;
  border-radius: var(--radius-sm);
}
.btn-ghost:hover {
  background: var(--color-bg-alt);
  color: var(--color-primary);
}

.btn-sm { padding: 0.4rem 0.8rem; font-size: 0.85rem; }
.btn-lg { padding: 0.8rem 1.6rem; font-size: 1.1rem; }
.btn-block { width: 100%; }

/* 🔹 النماذج */
.form-group { margin-bottom: 1.25rem; }
.form-label {
  display: block;
  margin-bottom: 0.5rem;
  font-weight: 600;
  color: var(--color-text);
  font-size: 0.95rem;
}

.form-control {
  width: 100%;
  padding: 0.75rem 1rem;
  border: 2px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-bg-card);
  color: var(--color-text);
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.form-control:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 4px rgba(46,125,50,0.12);
}

.form-control::placeholder { color: var(--color-text-muted); }
.form-error { color: var(--color-error); font-size: 0.85rem; margin-top: 0.3rem; }
.form-help { color: var(--color-text-secondary); font-size: 0.85rem; margin-top: 0.3rem; }

textarea.form-control { min-height: 120px; resize: vertical; }

select.form-control {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='%23757575' viewBox='0 0 16 16'%3E%3Cpath d='M8 11L3 6h10l-5 5z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: left 1rem center;
  padding-left: 2.5rem;
}

/* 🔹 البطاقات */
.card {
  background: var(--color-bg-card);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  transition: transform var(--transition-base), box-shadow var(--transition-base);
}

.card:hover { transform: translateY(-4px); box-shadow: var(--shadow-md); }
.card-header {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--color-border-light);
  font-weight: 700;
  font-size: 1.05rem;
}
.card-body { padding: 1.25rem; }
.card-footer {
  padding: 1rem 1.25rem;
  border-top: 1px solid var(--color-border-light);
  background: var(--color-bg-alt);
}

/* 🔹 شريط التنقل */
.navbar {
  position: sticky;
  top: 0;
  z-index: 1000;
  background: rgba(255,255,255,0.95);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--color-border-light);
  padding: 0.75rem 0;
}

.navbar-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.5rem;
}

.navbar-brand {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 1.4rem;
  font-weight: 800;
  color: var(--color-primary);
  letter-spacing: -0.5px;
}

.navbar-brand img {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  object-fit: cover;
}

.navbar-search {
  flex: 1;
  max-width: 480px;
  position: relative;
}

.navbar-search input {
  width: 100%;
  padding: 0.6rem 1rem 0.6rem 2.5rem;
  border: 2px solid var(--color-border);
  border-radius: var(--radius-full);
  background: var(--color-bg-alt);
  transition: all var(--transition-fast);
}

.navbar-search input:focus {
  background: #fff;
  border-color: var(--color-primary);
  box-shadow: var(--shadow-sm);
}

.navbar-search .search-icon {
  position: absolute;
  left: 1rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--color-text-muted);
  pointer-events: none;
}

.navbar-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.nav-icon {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  color: var(--color-text);
  transition: background var(--transition-fast);
}

.nav-icon:hover { background: var(--color-bg-alt); }
.nav-icon .badge {
  position: absolute;
  top: 4px;
  right: 4px;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  font-size: 0.7rem;
  font-weight: 700;
  color: #fff;
  background: var(--color-error);
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
}

.nav-drawer-btn {
  display: none;
  background: none;
  border: none;
  font-size: 1.5rem;
  color: var(--color-text);
  cursor: pointer;
  padding: 0.25rem;
}

/* 🔹 القائمة الجانبية (Drawer) */
.drawer-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  z-index: 1050;
  opacity: 0;
  visibility: hidden;
  transition: all var(--transition-base);
}

.drawer-overlay.active { opacity: 1; visibility: visible; }

.drawer {
  position: fixed;
  top: 0;
  right: -320px;
  width: 300px;
  height: 100vh;
  background: var(--color-bg-card);
  z-index: 1100;
  box-shadow: var(--shadow-lg);
  transition: right var(--transition-base);
  display: flex;
  flex-direction: column;
}

.drawer.active { right: 0; }

.drawer-header {
  padding: 1.25rem;
  border-bottom: 1px solid var(--color-border-light);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.drawer-close {
  background: none;
  border: none;
  font-size: 1.5rem;
  color: var(--color-text-secondary);
  cursor: pointer;
}

.drawer-body {
  flex: 1;
  overflow-y: auto;
  padding: 1rem;
}

.drawer-footer {
  padding: 1rem;
  border-top: 1px solid var(--color-border-light);
}

.drawer-nav a {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  color: var(--color-text);
  border-radius: var(--radius-md);
  font-weight: 500;
  transition: all var(--transition-fast);
}

.drawer-nav a:hover, .drawer-nav a.active {
  background: rgba(46,125,50,0.08);
  color: var(--color-primary);
}

/* 🔹 بطاقات المنتجات */
.product-card {
  display: flex;
  flex-direction: column;
  height: 100%;
  background: var(--color-bg-card);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  transition: all var(--transition-base);
}

.product-card:hover {
  transform: translateY(-6px);
  box-shadow: var(--shadow-md);
}

.product-image {
  position: relative;
  aspect-ratio: 4/3;
  overflow: hidden;
  background: var(--color-bg-alt);
}

.product-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform var(--transition-slow);
}

.product-card:hover .product-image img { transform: scale(1.05); }

.product-badges {
  position: absolute;
  top: 0.75rem;
  right: 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.25rem 0.6rem;
  font-size: 0.75rem;
  font-weight: 700;
  border-radius: var(--radius-full);
  backdrop-filter: blur(4px);
}

.badge-organic { background: rgba(46,125,50,0.9); color: #fff; }
.badge-featured { background: rgba(255,179,0,0.9); color: #000; }
.badge-new { background: rgba(2,136,209,0.9); color: #fff; }

.product-info {
  padding: 1rem;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.product-title {
  font-size: 1.05rem;
  font-weight: 700;
  line-height: 1.4;
  color: var(--color-text);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.product-family {
  font-size: 0.85rem;
  color: var(--color-text-secondary);
  display: flex;
  align-items: center;
  gap: 0.3rem;
}

.product-rating {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.85rem;
}

.stars { color: var(--color-accent-dark); letter-spacing: -1px; }
.rating-num { font-weight: 600; }
.rating-count { color: var(--color-text-muted); }

.product-price {
  font-size: 1.2rem;
  font-weight: 800;
  color: var(--color-primary);
  margin-top: auto;
}

.product-actions {
  padding: 0.75rem 1rem;
  border-top: 1px solid var(--color-border-light);
  display: flex;
  gap: 0.5rem;
}

/* 🔹 التقييمات */
.review-card {
  padding: 1rem;
  border-bottom: 1px solid var(--color-border-light);
}
.review-card:last-child { border-bottom: none; }
.review-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.5rem;
}
.review-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  object-fit: cover;
}
.review-meta { flex: 1; }
.review-name { font-weight: 600; font-size: 0.95rem; }
.review-date { font-size: 0.8rem; color: var(--color-text-muted); }
.review-comment { font-size: 0.9rem; line-height: 1.5; color: var(--color-text-secondary); }

/* 🔹 الدردشة */
.chat-layout {
  display: grid;
  grid-template-columns: 320px 1fr;
  height: calc(100vh - 140px);
  background: var(--color-bg-card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  overflow: hidden;
}

.chat-list {
  border-left: 1px solid var(--color-border-light);
  overflow-y: auto;
}

.chat-list-header {
  padding: 1rem;
  border-bottom: 1px solid var(--color-border-light);
  font-weight: 700;
}

.chat-item {
  padding: 1rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  cursor: pointer;
  transition: background var(--transition-fast);
  border-bottom: 1px solid var(--color-border-light);
}

.chat-item:hover, .chat-item.active { background: rgba(46,125,50,0.06); }

.chat-item-avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
}

.chat-item-info { flex: 1; min-width: 0; }
.chat-item-name { font-weight: 600; font-size: 0.95rem; margin-bottom: 0.2rem; }
.chat-item-last {
  font-size: 0.85rem;
  color: var(--color-text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat-item-meta {
  text-align: left;
  font-size: 0.75rem;
  color: var(--color-text-muted);
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.3rem;
}

.chat-item-unread {
  width: 20px;
  height: 20px;
  background: var(--color-primary);
  color: #fff;
  font-size: 0.7rem;
  font-weight: 700;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.chat-window {
  display: flex;
  flex-direction: column;
}

.chat-window-header {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--color-border-light);
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  background: var(--color-bg);
}

.message {
  max-width: 75%;
  padding: 0.75rem 1rem;
  border-radius: var(--radius-lg);
  font-size: 0.95rem;
  line-height: 1.5;
  position: relative;
}

.message.sent {
  align-self: flex-end;
  background: var(--color-primary);
  color: #fff;
  border-bottom-right-radius: 4px;
}

.message.received {
  align-self: flex-start;
  background: var(--color-bg-card);
  color: var(--color-text);
  border-bottom-left-radius: 4px;
  box-shadow: var(--shadow-sm);
}

.message-time {
  font-size: 0.7rem;
  opacity: 0.7;
  margin-top: 0.3rem;
  text-align: left;
}

.chat-input-area {
  padding: 1rem;
  border-top: 1px solid var(--color-border-light);
  display: flex;
  gap: 0.75rem;
  align-items: flex-end;
}

.chat-input-area textarea {
  flex: 1;
  min-height: 44px;
  max-height: 120px;
  padding: 0.75rem 1rem;
  border: 2px solid var(--color-border);
  border-radius: var(--radius-md);
  resize: none;
  background: var(--color-bg);
}

.chat-input-area textarea:focus {
  border-color: var(--color-primary);
  outline: none;
}

.chat-send-btn {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--color-primary);
  color: #fff;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background var(--transition-fast);
}

.chat-send-btn:hover { background: var(--color-primary-light); }

/* 🔹 التذييل */
.footer {
  background: var(--color-secondary);
  color: #fff;
  padding: 3rem 0 1.5rem;
  margin-top: 4rem;
}

.footer-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 2rem;
  margin-bottom: 2rem;
}

.footer-brand { font-size: 1.5rem; font-weight: 800; margin-bottom: 1rem; }
.footer-desc { color: rgba(255,255,255,0.8); font-size: 0.9rem; line-height: 1.6; }

.footer-title {
  font-weight: 700;
  font-size: 1.1rem;
  margin-bottom: 1rem;
  position: relative;
  padding-bottom: 0.5rem;
}

.footer-title::after {
  content: '';
  position: absolute;
  bottom: 0;
  right: 0;
  width: 40px;
  height: 3px;
  background: var(--color-accent);
  border-radius: 2px;
}

.footer-links { list-style: none; }
.footer-links li { margin-bottom: 0.6rem; }
.footer-links a {
  color: rgba(255,255,255,0.8);
  font-size: 0.9rem;
  transition: color var(--transition-fast);
}
.footer-links a:hover { color: #fff; text-decoration: underline; }

.footer-bottom {
  text-align: center;
  padding-top: 1.5rem;
  border-top: 1px solid rgba(255,255,255,0.15);
  color: rgba(255,255,255,0.6);
  font-size: 0.85rem;
}

/* 🔹 الإشعارات المؤقتة (Toast) */
.toast-container {
  position: fixed;
  bottom: 1.5rem;
  left: 1.5rem;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.toast {
  min-width: 280px;
  padding: 1rem 1.25rem;
  background: var(--color-bg-card);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  gap: 0.75rem;
  animation: slideInLeft 0.3s ease;
}

.toast-success { border-right: 4px solid var(--color-success); }
.toast-error { border-right: 4px solid var(--color-error); }
.toast-warning { border-right: 4px solid var(--color-warning); }

@keyframes slideInLeft {
  from { transform: translateX(-100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

/* 🔹 حالات التحميل */
.skeleton {
  background: linear-gradient(90deg, #eee 25%, #f5f5f5 50%, #eee 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: var(--radius-sm);
}

@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* 🔹 الوصول والأداء */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

:focus-visible {
  outline: 3px solid var(--color-primary);
  outline-offset: 2px;
  border-radius: 4px;
}

/* 🔹 أدوات مساعدة */
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-left { text-align: left; }
.text-muted { color: var(--color-text-secondary); }
.text-success { color: var(--color-success); }
.text-error { color: var(--color-error); }
.text-warning { color: var(--color-warning); }

.hidden { display: none !important; }
.visible { display: block !important; }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0,0,0,0); border: 0;
}