html {
  font-size: 14px;
}

@media (min-width: 768px) {
  html {
    font-size: 16px;
  }
}

.btn:focus, .btn:active:focus, .btn-link.nav-link:focus, .form-control:focus, .form-check-input:focus {
  box-shadow: 0 0 0 0.1rem white, 0 0 0 0.25rem #258cfb;
}

html {
  position: relative;
  min-height: 100%;
}

body {
  margin-bottom: 60px;
}

/* ============================================
   Skeleton loader (يظهر أثناء تحميل الصور)
   ============================================ */
img[loading="lazy"] {
  background: linear-gradient(90deg, #eee 0%, #f5f5f5 50%, #eee 100%);
  background-size: 200% 100%;
  animation: skeleton-shimmer 1.4s ease-in-out infinite;
  min-height: 60px;
}

img[loading="lazy"][data-loaded="1"] {
  background: none;
  animation: none;
}

@keyframes skeleton-shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* بطاقة منتج هيكلية (يمكن استخدامها مع .skeleton-card في المستقبل) */
.skeleton-card {
  background: #fff;
  border-radius: 12px;
  padding: 1rem;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.skeleton-card .skeleton-img,
.skeleton-card .skeleton-line {
  background: linear-gradient(90deg, #eee 0%, #f5f5f5 50%, #eee 100%);
  background-size: 200% 100%;
  animation: skeleton-shimmer 1.4s ease-in-out infinite;
  border-radius: 6px;
}

.skeleton-card .skeleton-img {
  height: 200px;
  margin-bottom: 1rem;
}

.skeleton-card .skeleton-line {
  height: 14px;
  margin-bottom: 0.5rem;
}

.skeleton-card .skeleton-line.short { width: 60%; }
.skeleton-card .skeleton-line.medium { width: 80%; }

/* ============================================
   Dark mode (CSS variables + .dark على html)
   ============================================ */
:root {
  --bg-primary: #ffffff;
  --bg-secondary: #f8f9fa;
  --text-primary: #212529;
  --text-secondary: #6c757d;
  --border-color: #dee2e6;
  --card-bg: #ffffff;
  --shadow-color: rgba(0, 0, 0, 0.05);
}

html.dark {
  --bg-primary: #121212;
  --bg-secondary: #1e1e1e;
  --text-primary: #e9ecef;
  --text-secondary: #adb5bd;
  --border-color: #343a40;
  --card-bg: #1e1e1e;
  --shadow-color: rgba(0, 0, 0, 0.4);
  color-scheme: dark;
}

html.dark body {
  background-color: var(--bg-primary);
  color: var(--text-primary);
}

html.dark .product-card,
html.dark .card,
html.dark .box,
html.dark .skeleton-card {
  background-color: var(--card-bg) !important;
  color: var(--text-primary) !important;
  box-shadow: 0 2px 12px var(--shadow-color);
}

html.dark .bg-light,
html.dark .bg-white {
  background-color: var(--bg-secondary) !important;
}

html.dark .text-muted {
  color: var(--text-secondary) !important;
}

html.dark .navbar,
html.dark .footer {
  background-color: var(--bg-secondary) !important;
}

html.dark img[loading="lazy"]:not([data-loaded="1"]) {
  background: linear-gradient(90deg, #2a2a2a 0%, #333 50%, #2a2a2a 100%);
}

/* ============================================
   Theme switch (احترافي - شكل pill مع ثمب منزلق - داخل الهيدر)
   ============================================ */
.theme-switch {
  display: inline-block;
  vertical-align: middle;
  width: 60px;
  height: 30px;
  padding: 3px;
  border: none;
  border-radius: 999px;
  background: linear-gradient(135deg, #513061 0%, #6d3f80 100%);
  cursor: pointer;
  box-shadow: 0 3px 10px rgba(81, 48, 97, 0.3), inset 0 1px 1px rgba(255, 255, 255, 0.15);
  transition: background 0.4s ease, box-shadow 0.3s ease, transform 0.2s ease;
  outline: none;
  overflow: hidden;
}

.theme-switch:hover {
  transform: scale(1.05);
  box-shadow: 0 5px 14px rgba(81, 48, 97, 0.4), inset 0 1px 1px rgba(255, 255, 255, 0.2);
}

.theme-switch:focus-visible {
  outline: 2px solid #fff;
  outline-offset: 3px;
}

.theme-switch__track {
  position: relative;
  display: block;
  width: 100%;
  height: 100%;
}

.theme-switch__icon {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  font-size: 0.8rem;
  color: rgba(255, 255, 255, 0.85);
  pointer-events: none;
  transition: opacity 0.3s ease, color 0.3s ease;
}

.theme-switch__icon--sun { left: 8px; opacity: 0; }
.theme-switch__icon--moon { right: 8px; opacity: 1; }

.theme-switch__thumb {
  position: absolute;
  top: 0;
  right: 0;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  color: #513061;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.25);
  transition: right 0.4s cubic-bezier(0.4, 0, 0.2, 1), transform 0.4s cubic-bezier(0.4, 0, 0.2, 1), color 0.3s ease;
}

.theme-switch__thumb i {
  transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

html.dark .theme-switch {
  background: linear-gradient(135deg, #1a1a2e 0%, #2d2d44 100%);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.5), inset 0 1px 1px rgba(255, 255, 255, 0.1);
}

html.dark .theme-switch:hover {
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.6), inset 0 1px 1px rgba(255, 255, 255, 0.15);
}

html.dark .theme-switch__icon--sun { opacity: 1; color: #f1c40f; }
html.dark .theme-switch__icon--moon { opacity: 0; }

html.dark .theme-switch__thumb {
  right: 30px;
  background: #f1c40f;
  color: #1a1a2e;
}

html.dark .theme-switch__thumb i { transform: rotate(360deg); }

@media (max-width: 576px) {
  .theme-switch {
    width: 52px;
    height: 26px;
  }
  .theme-switch__thumb { width: 20px; height: 20px; font-size: 0.65rem; }
  .theme-switch__icon { font-size: 0.7rem; }
  .theme-switch__icon--sun { left: 6px; }
  .theme-switch__icon--moon { right: 6px; }
  html.dark .theme-switch__thumb { right: 26px; }
}
