/**
 * إتقان الحرفة - ملف التنسيقات الرئيسي (Main CSS)
 * تخصص: نجارة، صيانة وترميم، بديل الرخام والشيبورد، أقفال ذكية
 * موجه للسوق السعودي
 * رقم التواصل: 0565920124
 */

/* ==========================================================================
   متغيرات الألوان والتصميم (CSS Variables)
   ========================================================================== */
:root {
  --primary: #1c1917;         /* خشب غامق / رمادي فحمي فخم */
  --primary-light: #292524;
  --secondary: #d97706;       /* ذهبي عنبري ملكي */
  --secondary-hover: #b45309;
  --secondary-light: #fef3c7;
  --accent: #78350f;          /* بني خشب دافئ */
  --light-bg: #f8fafc;
  --whatsapp-green: #25D366;
  --whatsapp-hover: #1ebd5b;
  --text-main: #1f2937;
  --text-muted: #4b5563;
  --border-color: #e5e7eb;
  --transition-fast: 0.2s ease;
  --transition-normal: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-slow: 0.5s cubic-bezier(0.4, 0, 0.2, 1);
  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
  --shadow-xl: 0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1);
}

/* ==========================================================================
   إعدادات عامة وسلوك الصفحة (Base & Typography)
   ========================================================================== */
html {
  scroll-behavior: smooth;
  scroll-padding-top: 5rem;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: 'Cairo', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  direction: rtl;
  text-align: right;
  background-color: var(--light-bg);
  color: var(--text-main);
  line-height: 1.7;
  overflow-x: hidden;
}

/* تحسين تحديد النصوص */
::selection {
  background-color: var(--secondary);
  color: #ffffff;
}

/* تخصيص شريط التمرير */
::-webkit-scrollbar {
  width: 10px;
}

::-webkit-scrollbar-track {
  background: #f1f5f9;
}

::-webkit-scrollbar-thumb {
  background: var(--secondary);
  border-radius: 5px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--secondary-hover);
}

/* ==========================================================================
   التأثيرات الحركية والسلاسة (Animations & Transitions)
   ========================================================================== */
@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes popIn {
  0% {
    opacity: 0;
    transform: scale(0.92) translateY(15px);
  }
  100% {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

@keyframes pulseGlow {
  0%, 100% {
    transform: scale(1);
    box-shadow: 0 0 0 0 rgba(217, 119, 6, 0.4);
  }
  50% {
    transform: scale(1.03);
    box-shadow: 0 0 0 14px rgba(217, 119, 6, 0);
  }
}

@keyframes pulseWhatsApp {
  0%, 100% {
    transform: scale(1);
    box-shadow: 0 0 0 0 rgba(37, 211, 102, 0.5);
  }
  50% {
    transform: scale(1.05);
    box-shadow: 0 0 0 16px rgba(37, 211, 102, 0);
  }
}

@keyframes floatSlow {
  0%, 100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-8px);
  }
}

@keyframes shimmerLight {
  0% {
    transform: translateX(-100%) rotate(25deg);
  }
  100% {
    transform: translateX(200%) rotate(25deg);
  }
}

.fade-in {
  animation: fadeIn 0.8s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.pulse-slow {
  animation: pulseGlow 2.5s infinite;
}

.whatsapp-pulse {
  animation: pulseWhatsApp 2s infinite;
}

.float-slow {
  animation: floatSlow 4s ease-in-out infinite;
}

/* Scroll Reveal Elements */
.reveal {
  opacity: 0;
  transform: translateY(30px);
  transition: opacity 0.7s cubic-bezier(0.16, 1, 0.3, 1), transform 0.7s cubic-bezier(0.16, 1, 0.3, 1);
  will-change: opacity, transform;
}

.reveal.active {
  opacity: 1;
  transform: translateY(0);
}

/* ==========================================================================
   المكونات المخصصة (Components)
   ========================================================================== */

/* تأثيرات بطاقات الخدمات */
.service-card {
  transition: all var(--transition-normal);
  position: relative;
  overflow: hidden;
}

.service-card:hover {
  transform: translateY(-6px);
  box-shadow: 0 20px 30px -10px rgba(0, 0, 0, 0.12);
}

.service-card::after {
  content: '';
  position: absolute;
  top: 0;
  right: 0;
  width: 100%;
  height: 4px;
  background: linear-gradient(90deg, var(--secondary), transparent);
  opacity: 0;
  transition: opacity var(--transition-normal);
}

.service-card:hover::after {
  opacity: 1;
}

/* ==========================================================================
   معرض الأعمال التفاعلي وتأثيرات الكروت (Enhanced Gallery Effects)
   ========================================================================== */
.gallery-card {
  position: relative;
  overflow: hidden;
  border-radius: 1.5rem;
  background-color: #1c1917;
  box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
  transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.4s cubic-bezier(0.16, 1, 0.3, 1), border-color 0.3s ease;
  border: 1px solid rgba(0, 0, 0, 0.05);
  cursor: pointer;
  display: flex;
  flex-direction: column;
}

.gallery-card.show {
  animation: popIn 0.45s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.gallery-card:hover {
  transform: translateY(-8px) scale(1.02);
  box-shadow: 0 25px 35px -10px rgba(217, 119, 6, 0.25), 0 12px 20px -8px rgba(0, 0, 0, 0.15);
  border-color: rgba(217, 119, 6, 0.4);
}

/* تأثير لمعة النور المتحركة على الكارت عند التحويم (Shimmer Light Effect) */
.gallery-card::before {
  content: '';
  position: absolute;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: linear-gradient(
    to right,
    rgba(255, 255, 255, 0) 0%,
    rgba(255, 255, 255, 0.15) 50%,
    rgba(255, 255, 255, 0) 100%
  );
  transform: rotate(25deg);
  opacity: 0;
  pointer-events: none;
  z-index: 15;
  transition: opacity 0.2s ease;
}

.gallery-card:hover::before {
  opacity: 1;
  animation: shimmerLight 1.2s ease-in-out;
}

.gallery-card img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.7s cubic-bezier(0.16, 1, 0.3, 1), filter 0.5s ease;
}

.gallery-card:hover img {
  transform: scale(1.1);
  filter: brightness(0.92);
}

/* تدرج التراكب للبيانات مع تأثير زجاجي سلس */
.gallery-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(to top, rgba(0, 0, 0, 0.92) 0%, rgba(0, 0, 0, 0.4) 50%, rgba(0, 0, 0, 0.05) 100%);
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  padding: 1.5rem;
  z-index: 10;
  transition: all 0.35s ease;
}

.gallery-card:hover .gallery-overlay {
  background: linear-gradient(to top, rgba(0, 0, 0, 0.96) 0%, rgba(0, 0, 0, 0.5) 60%, rgba(0, 0, 0, 0.15) 100%);
}

/* أزرار العمل السريع عند التحويم */
.gallery-quick-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.75rem;
  opacity: 0.9;
  transform: translateY(4px);
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.gallery-card:hover .gallery-quick-actions {
  opacity: 1;
  transform: translateY(0);
}

/* ==========================================================================
   سلايدر مقارنة قبل وبعد التفاعلي (Interactive Before/After Slider)
   ========================================================================== */
.before-after-wrapper {
  position: relative;
  width: 100%;
  max-width: 900px;
  height: 380px;
  margin: 0 auto 3.5rem auto;
  border-radius: 2rem;
  overflow: hidden;
  box-shadow: 0 25px 40px -15px rgba(0, 0, 0, 0.25);
  border: 2px solid rgba(217, 119, 6, 0.3);
  user-select: none;
  background-color: #1c1917;
}

@media (min-width: 640px) {
  .before-after-wrapper {
    height: 460px;
  }
}

.before-after-img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  pointer-events: none;
}

.before-img-layer {
  position: absolute;
  top: 0;
  right: 0;
  height: 100%;
  width: 50%; /* يتحكم به الجافاسكريبت */
  overflow: hidden;
  border-left: 3px solid #d97706;
  box-shadow: -5px 0 20px rgba(0, 0, 0, 0.4);
  z-index: 5;
}

.before-img-layer img {
  position: absolute;
  top: 0;
  right: 0;
  height: 100%;
  max-width: none;
  object-fit: cover;
}

/* مقبض السحب التفاعلي */
.slider-handle {
  position: absolute;
  top: 0;
  bottom: 0;
  right: 50%; /* يتحكم به الجافاسكريبت */
  width: 4px;
  background: linear-gradient(180deg, #d97706 0%, #f59e0b 50%, #d97706 100%);
  z-index: 10;
  transform: translateX(50%);
  cursor: ew-resize;
}

.slider-handle-button {
  position: absolute;
  top: 50%;
  right: 50%;
  transform: translate(50%, -50%);
  width: 44px;
  height: 44px;
  border-radius: 9999px;
  background: #ffffff;
  color: #1c1917;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.35), 0 0 0 4px rgba(217, 119, 6, 0.7);
  font-size: 14px;
  pointer-events: none;
  transition: transform 0.2s ease, background 0.2s ease;
}

.before-after-wrapper:hover .slider-handle-button {
  transform: translate(50%, -50%) scale(1.1);
  background: #fef3c7;
}

/* شارات قبل وبعد */
.badge-before, .badge-after {
  position: absolute;
  top: 1.25rem;
  z-index: 8;
  padding: 0.4rem 1rem;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 800;
  backdrop-filter: blur(8px);
  pointer-events: none;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
}

.badge-after {
  left: 1.25rem;
  background-color: rgba(37, 211, 102, 0.85);
  color: #ffffff;
}

.badge-before {
  right: 1.25rem;
  background-color: rgba(0, 0, 0, 0.75);
  color: #f3f4f6;
  border: 1px solid rgba(255, 255, 255, 0.2);
}

/* ==========================================================================
   أزرار الفلترة المتطورة (Advanced Filter Buttons)
   ========================================================================== */
.filter-btn {
  position: relative;
  transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  outline: none;
}

.filter-btn:hover {
  border-color: var(--secondary);
  color: var(--secondary);
}

.filter-btn.active-filter {
  background-color: var(--primary) !important;
  color: #ffffff !important;
  border-color: var(--primary) !important;
  box-shadow: 0 8px 16px -4px rgba(28, 25, 23, 0.35);
  transform: translateY(-2px);
}

.filter-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background-color: rgba(217, 119, 6, 0.15);
  color: var(--secondary);
  font-size: 0.75rem;
  font-weight: 800;
  padding: 0.1rem 0.5rem;
  border-radius: 9999px;
  margin-right: 0.35rem;
  transition: all 0.2s ease;
}

.filter-btn.active-filter .filter-badge {
  background-color: var(--secondary);
  color: #ffffff;
}

/* ==========================================================================
   أكورديون الأسئلة الشائعة (FAQ Accordion)
   ========================================================================== */
.faq-item {
  border-radius: 1rem;
  border: 1px solid var(--border-color);
  background-color: #ffffff;
  overflow: hidden;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.faq-item.active {
  border-color: var(--secondary);
  box-shadow: 0 8px 20px -6px rgba(217, 119, 6, 0.15);
}

.faq-header {
  width: 100%;
  padding: 1.25rem 1.5rem;
  text-align: right;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-weight: 700;
  color: var(--primary);
  background: none;
  border: none;
  cursor: pointer;
  transition: color var(--transition-fast);
}

.faq-header:hover {
  color: var(--secondary);
}

.faq-icon {
  transition: transform var(--transition-normal);
  color: var(--secondary);
  font-size: 1rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.faq-item.active .faq-icon {
  transform: rotate(180deg);
}

.faq-body {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.35s cubic-bezier(0.4, 0, 0.2, 1), padding 0.35s ease;
  padding: 0 1.5rem;
  color: var(--text-muted);
  font-size: 0.925rem;
  line-height: 1.8;
}

.faq-item.active .faq-body {
  max-height: 250px;
  padding-bottom: 1.25rem;
  border-top: 1px solid #f3f4f6;
  padding-top: 1rem;
}

/* ==========================================================================
   لايتبوكس تكبير الصور (Lightbox Modal)
   ========================================================================== */
.lightbox-modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  background-color: rgba(0, 0, 0, 0.94);
  backdrop-filter: blur(10px);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  animation: fadeIn 0.25s ease-out;
}

.lightbox-modal.active {
  display: flex;
}

.lightbox-nav-btn {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  background-color: rgba(255, 255, 255, 0.15);
  color: #ffffff;
  width: 3.25rem;
  height: 3.25rem;
  border-radius: 9999px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  cursor: pointer;
  transition: background-color var(--transition-fast), transform var(--transition-fast);
  border: none;
  z-index: 110;
}

.lightbox-nav-btn:hover {
  background-color: var(--secondary);
  transform: translateY(-50%) scale(1.1);
}

.lightbox-prev {
  right: 1.5rem;
}

.lightbox-next {
  left: 1.5rem;
}

.lightbox-close-btn {
  position: absolute;
  top: 1.5rem;
  left: 1.5rem;
  background-color: rgba(255, 255, 255, 0.15);
  color: #ffffff;
  width: 3.25rem;
  height: 3.25rem;
  border-radius: 9999px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  cursor: pointer;
  transition: background-color var(--transition-fast), transform var(--transition-fast);
  border: none;
  z-index: 110;
}

.lightbox-close-btn:hover {
  background-color: #ef4444;
  transform: scale(1.1);
}

/* زر الصعود للأعلى (Back to Top) */
.back-to-top {
  position: fixed;
  bottom: 6.5rem;
  left: 1.5rem;
  z-index: 39;
  background-color: var(--primary);
  color: #ffffff;
  width: 3rem;
  height: 3rem;
  border-radius: 9999px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  box-shadow: var(--shadow-lg);
  opacity: 0;
  visibility: hidden;
  transform: translateY(20px);
  transition: all var(--transition-normal);
  border: 1px solid rgba(255, 255, 255, 0.1);
  cursor: pointer;
}

.back-to-top.visible {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.back-to-top:hover {
  background-color: var(--secondary);
  color: #ffffff;
  transform: translateY(-4px);
}

/* ==========================================================================
   التوافق مع الشاشات والأجهزة المختلفة (Responsive Tweaks)
   ========================================================================== */
@media (max-width: 640px) {
  .lightbox-nav-btn {
    width: 2.5rem;
    height: 2.5rem;
    font-size: 1rem;
  }
  .lightbox-prev {
    right: 0.5rem;
  }
  .lightbox-next {
    left: 0.5rem;
  }
  .lightbox-close-btn {
    top: 0.75rem;
    left: 0.75rem;
    width: 2.5rem;
    height: 2.5rem;
  }
  .back-to-top {
    bottom: 6rem;
    left: 1rem;
    width: 2.5rem;
    height: 2.5rem;
    font-size: 0.85rem;
  }
}

/* طباعة نظيفة */
@media print {
  header, footer, .floating-cta, #estimator, .filter-btn, .back-to-top, .before-after-wrapper {
    display: none !important;
  }
  body {
    background: #ffffff;
    color: #000000;
  }
}
