/**
 * =========================================================================
 * المتجر الإلكتروني - التنسيقات العامة والـ RTL (Global Styles & Utilities)
 * =========================================================================
 */

:root {
  --font-primary: 'Cairo', system-ui, -apple-system, sans-serif;
  --font-heading: 'Alexandria', 'Cairo', sans-serif;
  --radius-sm: 6px;
  --radius-md: 10px;
  --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.08);
  --shadow-lg: 0 10px 25px rgba(0,0,0,0.12);
  --transition-fast: 0.2s ease;
  --transition-normal: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

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

html {
  font-size: 16px;
  scroll-behavior: smooth;
  direction: rtl;
}

body {
  font-family: var(--font-primary);
  line-height: 1.6;
  color: #1e293b;
  background-color: #f8fafc;
  direction: rtl;
  text-align: right;
  -webkit-font-smoothing: antialiased;
}

a {
  color: inherit;
  text-decoration: none;
  transition: var(--transition-fast);
}

img {
  max-width: 100%;
  height: auto;
  display: block;
}

button, input, select, textarea {
  font-family: inherit;
  font-size: inherit;
}

/* Container */
.container {
  width: 100%;
  max-width: 1280px;
  margin-left: auto;
  margin-right: auto;
  padding-left: 20px;
  padding-right: 20px;
}

/* Flex & Grid Utilities */
.flex { display: flex; }
.inline-flex { display: inline-flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.justify-center { justify-content: center; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.gap-4 { gap: 16px; }
.gap-6 { gap: 24px; }
.gap-8 { gap: 32px; }

.grid { display: grid; }
.grid-cols-2 { grid-template-columns: repeat(2, 1fr); }
.grid-cols-3 { grid-template-columns: repeat(3, 1fr); }
.grid-cols-4 { grid-template-columns: repeat(4, 1fr); }

@media (max-width: 1024px) {
  .grid-cols-4 { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 768px) {
  .grid-cols-4, .grid-cols-3 { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 480px) {
  .grid-cols-4, .grid-cols-3, .grid-cols-2 { grid-template-columns: 1fr; }
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 24px;
  font-weight: 700;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  cursor: pointer;
  transition: var(--transition-normal);
  text-align: center;
}

.btn-sm { padding: 8px 16px; font-size: 0.875rem; }
.btn-lg { padding: 16px 32px; font-size: 1.125rem; }
.btn-block { width: 100%; display: flex; }

/* Status Badges */
.status-badge {
  display: inline-block;
  padding: 4px 12px;
  border-radius: var(--radius-full);
  font-size: 0.75rem;
  font-weight: 700;
}
.badge-new { background: #dbeafe; color: #1e40af; }
.badge-confirmed { background: #e0e7ff; color: #3730a3; }
.badge-processing { background: #fef3c7; color: #92400e; }
.badge-shipped { background: #e0f2fe; color: #0369a1; }
.badge-delivered, .badge-completed, .badge-success { background: #dcfce7; color: #166534; }
.badge-cancelled, .badge-danger { background: #fee2e2; color: #991b1b; }
.badge-refunded, .badge-secondary { background: #f1f5f9; color: #475569; }
.badge-warning { background: #fef3c7; color: #b45309; }

/* Form Controls */
.form-group {
  margin-bottom: 18px;
}
.form-label {
  display: block;
  font-size: 0.875rem;
  font-weight: 600;
  margin-bottom: 6px;
  color: #334155;
}
.form-control {
  width: 100%;
  padding: 12px 16px;
  border: 1px solid #cbd5e1;
  border-radius: var(--radius-md);
  background-color: #ffffff;
  color: #1e293b;
  font-size: 0.95rem;
  transition: var(--transition-fast);
  outline: none;
}
.form-control:focus {
  border-color: #6366f1;
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}
textarea.form-control {
  min-height: 100px;
  resize: vertical;
}

/* Toast Notifications */
#store-toast-container {
  position: fixed;
  bottom: 24px;
  left: 24px;
  z-index: 99999;
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
}
.store-toast {
  pointer-events: auto;
  min-width: 280px;
  max-width: 420px;
  padding: 14px 20px;
  border-radius: var(--radius-md);
  background: #ffffff;
  color: #1e293b;
  box-shadow: 0 10px 30px rgba(0,0,0,0.15);
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 0.9rem;
  font-weight: 600;
  animation: slideInLeft 0.3s ease forwards;
  border-right: 4px solid #6366f1;
}
.store-toast.toast-success { border-right-color: #10b981; }
.store-toast.toast-error { border-right-color: #ef4444; }
.store-toast.toast-warning { border-right-color: #f59e0b; }

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

/* Floating WhatsApp Button */
.whatsapp-float {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 58px;
  height: 58px;
  background-color: #25d366;
  color: #ffffff;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 6px 20px rgba(37, 211, 102, 0.4);
  z-index: 9999;
  transition: transform 0.25s ease, box-shadow 0.25s ease;
  text-decoration: none;
}
.whatsapp-float:hover {
  transform: scale(1.08) translateY(-3px);
  box-shadow: 0 10px 25px rgba(37, 211, 102, 0.5);
  color: #ffffff;
}
.whatsapp-float svg {
  width: 32px;
  height: 32px;
  fill: currentColor;
}

/* =========================================================================
   Universal Cart Drawer & Quick View Modal (Used Across All Themes)
   ========================================================================= */

/* Backdrops */
.cart-drawer-overlay,
.cart-drawer-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.65);
  backdrop-filter: blur(5px);
  z-index: 99998;
  display: none;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.cart-drawer-overlay.active,
.cart-drawer-overlay.open,
.cart-drawer-backdrop.active,
.cart-drawer-backdrop.open {
  display: block;
  opacity: 1;
}

/* Off-canvas Cart Drawer */
.cart-drawer,
.mod-cart-drawer {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: 420px;
  max-width: 90vw;
  background: #ffffff;
  z-index: 99999;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.25);
  transform: translateX(-100%);
  transition: transform 0.35s cubic-bezier(0.16, 1, 0.3, 1);
  display: flex;
  flex-direction: column;
}

.cart-drawer.active,
.cart-drawer.open,
.mod-cart-drawer.active,
.mod-cart-drawer.open {
  transform: translateX(0);
}

.cart-drawer-header,
.drawer-header {
  padding: 16px 20px;
  border-bottom: 1px solid #edf2f7;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.cart-drawer-body,
.drawer-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.cart-drawer-footer,
.drawer-footer {
  padding: 18px 20px;
  border-top: 1px solid #edf2f7;
  background: #f8fafc;
}

/* Items rendered inside Cart Drawer */
.drawer-cart-item {
  display: flex;
  gap: 12px;
  padding-bottom: 12px;
  border-bottom: 1px solid rgba(0, 0, 0, 0.06);
}

.drawer-cart-item .item-thumb {
  width: 64px;
  height: 76px;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid #e2e8f0;
  flex-shrink: 0;
}

.drawer-cart-item .item-details {
  flex: 1;
  min-width: 0;
}

.drawer-cart-item .item-name {
  font-size: 0.9rem;
  font-weight: 700;
  margin: 0 0 4px 0;
  line-height: 1.3;
}

.drawer-cart-item .item-variants {
  font-size: 0.75rem;
  color: #64748b;
  margin-bottom: 4px;
}

.drawer-cart-item .item-price {
  font-size: 0.95rem;
  font-weight: 800;
  color: #0f172a;
  margin-bottom: 8px;
}

.drawer-cart-item .item-quantity-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.drawer-cart-item .quantity-stepper {
  display: inline-flex;
  align-items: center;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  background: #ffffff;
  overflow: hidden;
}

.drawer-cart-item .stepper-btn {
  background: transparent;
  border: none;
  padding: 4px 10px;
  font-weight: bold;
  cursor: pointer;
  color: inherit;
  font-size: 0.9rem;
}

.drawer-cart-item .stepper-btn:hover {
  background: rgba(0, 0, 0, 0.05);
}

.drawer-cart-item .stepper-val {
  padding: 0 8px;
  font-size: 0.85rem;
  font-weight: 700;
}

.drawer-cart-item .item-remove-btn {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 14px;
  color: #ef4444;
  padding: 4px;
}

/* Quick View Modal & Overlay */
.quick-view-backdrop {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(15, 23, 42, 0.7);
  backdrop-filter: blur(6px);
  z-index: 100000;
  display: none;
}

.quick-view-modal {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0.95);
  width: 780px;
  max-width: 92vw;
  max-height: 88vh;
  background: #ffffff;
  border-radius: 16px;
  z-index: 100001;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.3);
  overflow-y: auto;
  display: none;
  transition: transform 0.25s ease, opacity 0.25s ease;
}

.quick-view-modal.open {
  display: block;
  transform: translate(-50%, -50%) scale(1);
}

.quick-view-close-btn {
  position: absolute;
  top: 14px;
  left: 14px;
  width: 34px;
  height: 34px;
  background: #f1f5f9;
  border: none;
  border-radius: 50%;
  font-size: 16px;
  cursor: pointer;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #334155;
  transition: all 0.2s ease;
}

.quick-view-close-btn:hover {
  background: #e2e8f0;
  color: #0f172a;
}

/* Luxury Theme Adaptations */
body.theme-luxury .lux-cart-drawer {
  background: #141618 !important;
  color: #f5f5f7 !important;
  border-right: 1px solid #282a30 !important;
}
body.theme-luxury .lux-cart-drawer .drawer-cart-item {
  border-bottom-color: #282a30;
}
body.theme-luxury .lux-cart-drawer .item-thumb {
  border-color: #282a30;
}
body.theme-luxury .lux-cart-drawer .item-price {
  color: #d4af37 !important;
}
body.theme-luxury .lux-cart-drawer .quantity-stepper {
  background: #1c1e22;
  border-color: #282a30;
  color: #fff;
}
body.theme-luxury .lux-quick-view-modal {
  background: #141618 !important;
  color: #f5f5f7 !important;
  border: 1px solid #282a30;
}
body.theme-luxury .lux-quick-view-modal .quick-view-close-btn {
  background: #282a30;
  color: #c5a880;
}

/* Boutique Theme Adaptations */
body.theme-boutique .btq-cart-drawer {
  background: #fffdfc !important;
  border-radius: 24px 0 0 24px !important;
}
body.theme-boutique .btq-cart-drawer .item-price {
  color: #b87a78 !important;
}
body.theme-boutique .btq-cart-drawer .quantity-stepper {
  border-color: #f5dedd;
  background: #fdf5f4;
}
body.theme-boutique .btq-quick-view-modal {
  border-radius: 24px;
}
