/* ===== الأساسيات ===== */
:root {
  --primary: #f97316;
  --primary-hover: #ea580c;
  --secondary: #fff8f0;
  --text: #333333;
  --text-light: #555555; /* تم تغييره من #666666 لتحسين التباين */
  --border: #e5e7eb;
  --background: #ffffff;
  --background-light: #f9fafb;
  --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  --radius: 0.5rem;
}

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

body {
  font-family: "Tajawal", sans-serif;
  color: var(--text);
  background-color: var(--secondary) !important;
  direction: rtl;
}

.container { width: 100%; max-width: 1200px; margin: 0 auto; padding: 0 1rem; }
.hidden { display: none !important; }

/* ===== الأزرار ===== */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 0.5rem 1rem; border-radius: var(--radius); font-weight: 500;
  cursor: pointer; transition: all 0.2s; background-color: var(--primary) !important;
  color: #fff; border: none;
}
.btn:hover { background-color: var(--primary-hover) !important; }
.btn-outline { background-color: transparent !important; border: 1px solid var(--border); color: var(--text); }
.btn-outline:hover { background-color: var(--background-light) !important; }
.btn i { margin-left: 0.5rem; }

/* ===== الرأس ===== */
.header { background-color: var(--background) !important; box-shadow: var(--shadow); padding: 1rem 0; }

.header-content {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between;
}

.logo {
  display: flex; align-items: center; justify-content: flex-start; gap: 12px;
}

.logo-icon {
  width: 3rem; height: 3rem; border-radius: 8%; background-color: #fff !important;
  display: flex; align-items: center; justify-content: center; margin-left: 1rem;
}

.logo-icon i { font-size: 1.5rem; color: var(--primary); }

.logo h1 { margin: 0; font-size: 1.5rem; color: var(--primary); white-space: nowrap; }

/* ===== التبويبات ===== */
.tabs { display: flex; margin-top: 1rem; width: 100%; }
@media (min-width: 768px) { .tabs { width: auto; margin-top: 0; } }

.tab-btn {
  flex: 1; padding: 0.75rem 1.5rem; background-color: var(--background-light) !important;
  border: 1px solid var(--border) !important; cursor: pointer !important; font-weight: 500; transition: all 0.2s;
}
.tab-btn:first-child { border-top-right-radius: var(--radius); border-bottom-right-radius: var(--radius); }
.tab-btn:last-child  { border-top-left-radius: var(--radius);  border-bottom-left-radius: var(--radius); }
.tab-btn.active { background-color: var(--primary) !important; color: #fff; border-color: var(--primary); }

.tab-content { display: none; padding: 2rem 0; }
.tab-content.active { display: block; }

/* ===== الفلاتر ===== */
.filters {
  display: flex; flex-wrap: wrap; gap: 1rem; margin-bottom: 1.5rem;
  background-color: var(--background) !important; padding: 1.5rem; border-radius: var(--radius); box-shadow: var(--shadow);
}

.search-container { position: relative; flex: 1 1 100%; }
@media (min-width: 768px) { .search-container { flex: 1; } }

.search-icon { position: absolute; right: 1rem; top: 50%; transform: translateY(-50%); color: var(--text-light); }

#search-input {
  width: 100%; padding: 0.75rem 2.5rem 0.75rem 1rem; border: 1px solid var(--border); border-radius: var(--radius);
  font-family: "Tajawal", sans-serif;
}

.select-container { flex: 1 1 100%; }
@media (min-width: 768px) { .select-container { flex: 0 1 180px; } }

select{
  width: 100%; padding: 0.75rem 1rem; border: 1px solid var(--border); border-radius: var(--radius);
  background-color: var(--background) !important; font-family: "Tajawal", sans-serif; appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%23666'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M19 9l-7 7-7-7'%3E%3C/path%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: left 1rem center; background-size: 1rem;
}

/* ===== عدد المنتجات ===== */
.products-count { font-size: 0.875rem; color: var(--text-light); margin-bottom: 1rem; }

/* ===== شبكة المنتجات ===== */
.products-grid { display: grid; grid-template-columns: repeat(1, 1fr); gap: 1.5rem; }
@media (min-width: 640px) { .products-grid { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 768px) { .products-grid { grid-template-columns: repeat(3, 1fr); } }
@media (min-width: 1024px){ .products-grid { grid-template-columns: repeat(4, 1fr); } }

/* ===== بطاقة المنتج ===== */
.product-card{
  background-color: var(--background) !important; border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow);
  transition: transform 0.3s, box-shadow 0.3s; cursor: pointer;
}
.product-card:hover{ transform: translateY(-5px); box-shadow: 0 10px 15px -3px rgba(0,0,0,.1), 0 4px 6px -2px rgba(0,0,0,.05); }

.product-image{
  height: 200px; background-color: #fff !important; display: flex; align-items: center; justify-content: center; overflow: hidden;
}
.product-image img{ max-width: 100%; max-height: 100%; object-fit: contain; padding: 1rem; transition: transform 0.3s; }
.product-card:hover .product-image img{ transform: scale(1.05); }

.product-info{ padding: 1rem; }

.product-title{
  font-weight: 700; color: var(--primary); margin-bottom: 0.5rem; min-height: 3rem; line-height: 1.5;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.product-subtitle{
  font-size: 0.875rem; color: var(--text); margin-bottom: 1rem; min-height: 2.5rem; line-height: 1.4;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}

.product-tags{ display: flex; flex-wrap: wrap; gap: 0.5rem; margin-bottom: 1rem; }

.product-tag{ font-size: 0.75rem; padding: 0.25rem 0.5rem; border-radius: 9999px; font-weight: 500; }
.tag-brand{ background-color: #fff3e0; color: #d97706; border: 1px solid #fcd34d; }
.tag-category{ background-color: #ecfdf5; color: #047857; border: 1px solid #a7f3d0; }

.product-price{ font-size: 1.25rem; font-weight: 700; color: var(--primary); }

/* ===== لا توجد منتجات ===== */
.no-products{ text-align: center; padding: 3rem 0; }
.info-icon{ display: inline-flex; align-items: center; justify-content: center; width: 4rem; height: 4rem; border-radius: 50%; background-color: #fff3e0; margin-bottom: 1rem; }
.info-icon i{ font-size: 2rem; color: var(--primary); }
.no-products h3{ font-size: 1.25rem; margin-bottom: 0.5rem; }
.no-products p{ color: var(--text-light); margin-bottom: 1rem; }

/* ===== قسم عن الشركة ===== */
.about-card{ background-color: var(--background); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
.about-header{ text-align: center; padding: 2rem; background: linear-gradient(to bottom right, #fff3e0, #ffedd5); }
.about-header h2{ font-size: 2rem; color: var(--primary); margin-bottom: 0.5rem; }
.about-header p{ font-size: 1.25rem; color: var(--text-light); }
.about-content{ padding: 2rem; line-height: 1.6; }
.about-content p{ margin-bottom: 1.5rem; }

.company-tabs{ margin: 2rem 0; }
.company-tabs-header{ display: flex; border-bottom: 1px solid var(--border); }

.company-tab-btn{
  padding: 0.75rem 1.5rem; background: none; border: none; border-bottom: 2px solid transparent;
  cursor: pointer; font-weight: 500; transition: all 0.2s;
}
.company-tab-btn.active{ color: var(--primary); border-bottom-color: var(--primary); }

.company-tab-content{ display: none; padding: 1.5rem 0; }
.company-tab-content.active{ display: block; }

.company-tab-content h3{ font-size: 1.5rem; color: var(--primary); margin-bottom: 1rem; }

.product-lines{ display: grid; grid-template-columns: repeat(1, 1fr); gap: 1rem; margin: 1.5rem 0; }
@media (min-width: 768px){ .product-lines{ grid-template-columns: repeat(2, 1fr); } }

.product-line-card{ background-color: var(--background-light) !important; border-radius: var(--radius); padding: 1.5rem; border: 1px solid var(--border); }
.product-line-card h4{ color: var(--primary); margin-bottom: 0.5rem; }

.company-tab-content h4{ font-size: 1.25rem; margin: 1.5rem 0 0.5rem; }
.company-tab-content ul{ padding-right: 1.5rem; }
.company-tab-content li{ margin-bottom: 0.5rem; }

.final-note{ background-color: #fff3e0; border: 1px solid #fcd34d; border-radius: var(--radius); padding: 1.5rem; margin-top: 2rem; }
.final-note h3{ color: var(--primary); margin-bottom: 0.5rem; }

/* ===== التذييل ===== */
.footer{ background-color: var(--background) !important; border-top: 1px solid var(--border); padding: 1.5rem 0; text-align: center; }
.footer p{ color: var(--text-light); font-size: 0.875rem; }
.contact{ margin-top: 0.5rem; }
.contact-link{ display: inline-flex; align-items: center; color: var(--primary); text-decoration: none; transition: color 0.2s; }
.contact-link:hover{ color: var(--primary-hover); }
.contact-link i{ margin-left: 0.5rem; }

/* ===== النافذة المنبثقة ===== */
.modal{
  display: none; position: fixed; z-index: 1000; left: 0; top: 0; width: 100%; height: 100%;
  overflow: auto; background-color: rgba(0,0,0,.5) !important;
}
.modal-content{
  background-color: var(--background) !important; margin: 5% auto; padding: 2rem; border-radius: var(--radius);
  max-width: 800px; width: 90%; position: relative; max-height: 90vh; overflow-y: auto;
  box-shadow: 0 10px 25px rgba(0,0,0,.2);
}
.close-modal{
  position: absolute; top: 1rem; left: 1rem; font-size: 1.5rem; cursor: pointer; color: var(--text); transition: color 0.2s;
  width: 30px; height: 30px; display: flex; align-items: center; justify-content: center; border-radius: 50%;
  background-color: #f1f1f1;
}
.close-modal:hover, .close-modal:focus{ color: var(--primary); background-color: #e5e5e5; }

.modal-product{ display: grid; grid-template-columns: 1fr; gap: 2rem; }
@media (min-width: 768px){ .modal-product{ grid-template-columns: 1fr 1fr; } }

.modal-product-image{
  height: 300px; background-color: #fff !important; border-radius: var(--radius);
  display: flex; align-items: center; justify-content: center; overflow: hidden;
}
.modal-product-image img{ max-width: 100%; max-height: 100%; object-fit: contain; padding: 1rem; }

.modal-product-info h2{ font-size: 1.5rem; color: var(--primary); margin-bottom: 0.5rem; }
.modal-product-info h3{ font-size: 1.25rem; color: var(--text-light); margin-bottom: 1rem; font-weight: 400; }

.modal-product-tags{ display: flex; flex-wrap: wrap; gap: 0.5rem; margin-bottom: 1.5rem; }
.modal-product-tag{ font-size: 0.875rem; padding: 0.375rem 0.75rem; border-radius: 9999px; font-weight: 500; }

.modal-product-price{ font-size: 1.75rem; font-weight: 700; color: var(--primary); margin-bottom: 1.5rem; }

.modal-product-details{ margin-top: 1.5rem; }
.modal-product-details h4{ font-size: 1.125rem; color: var(--primary); margin-bottom: 0.5rem; }
.modal-product-details p{ margin-bottom: 1rem; line-height: 1.6; }

/* خط الأساس للعناصر */
body, h1, h2, h3, h4, h5, h6, input, select, button, p, a, span, div {
  font-family: "Tajawal", sans-serif !important;
}

/* تحسين الاستجابة للأجهزة المختلفة */
@media (max-width: 480px){
  .modal-content{ width: 95%; padding: 1rem; }
  .product-card{ min-height: 300px; }
  .product-image{ height: 150px; }
  .filters{ padding: 1rem; }
  .tab-btn{ padding: 0.5rem 1rem; font-size: 0.9rem; }
  .logo h1{ font-size: 1.2rem; }
}

/* ===== إصلاح الهيدر على الشاشات الصغيرة ومنع التراكب ===== */
@media (max-width: 640px){
  .header-content{
    flex-direction: column;   /* سطر للوغو+العنوان وتحتو التبويبات */
    align-items: stretch;
    gap: 8px;
  }

  .logo{
    width: 100%;
    justify-content: flex-start;
    align-items: center;
    flex-wrap: nowrap;        /* لا يلف */
    gap: 8px;
    margin-bottom: 10px;
    position: relative;
    z-index: 1;
  }

  /* إطار اللوغو */
  .logo-icon{
    width: 60px;              /* قياس واضح للموبايل */
    height: auto;
    margin-left: 6px;
    overflow: visible;
    flex: 0 0 auto;
  }

  /* كسر قاعدة 100px المعرّفة داخل <style> في HTML */
  .logo-icon img.logo{
    width: 100% !important;
    height: auto !important;
    display: block;
  }

  /* العنوان يبقى بجانب اللوغو مع ellipsis */
  .logo h1{
    white-space: nowrap;
    font-size: 1.2rem;
    min-width: 0;                             /* مهم داخل flex */
    max-width: calc(100% - 48px - 8px);       /* طرح عرض اللوغو + gap */
    overflow: hidden;
    text-overflow: ellipsis;
    margin: 0;
  }

  .tabs{
    order: 2;
    width: 100%;
    margin-top: 0;
    position: relative;
    z-index: 0;
  }

  .tab-btn{ flex: 1; }
}

/* شاشات أصغر جداً */
@media (max-width: 360px){
  .logo h1{ font-size: 1.1rem; }
}

/* تحسين التركيز للوصول عبر لوحة المفاتيح */
:focus{ outline: 3px solid var(--primary); outline-offset: 2px; }
.product-card:focus{
  transform: translateY(-5px);
  box-shadow: 0 10px 15px -3px rgba(0,0,0,.1), 0 4px 6px -2px rgba(0,0,0,.05);
  outline: 3px solid var(--primary);
}

/* تاغ التوفر */
.product-tag.tag-availability, .modal-product-tag.tag-availability{
  color: #fff; padding: 2px 6px; border-radius: 4px; font-size: 0.85em;
}
.tag-availability{ color: #fff; padding: 2px 6px; border-radius: 4px; font-size: 0.85em; border: 1px solid; }
