/* =======================
   BASE STYLES & RTL
======================= */
* {
  box-sizing: border-box;
}

body{
  margin:0;
  font-family:'Segoe UI', 'Tajawal', sans-serif;
  background:#f5f5f5;
  direction:rtl;
  text-align: right;
}

/* =======================
   HEADER
======================= */
#header{
  position:fixed;
  top:0;
  width:100%;
  background:#fff;
  display:flex;
  justify-content:space-between;
  align-items:center;
  padding:12px 20px;
  box-shadow:0 4px 15px rgba(0,0,0,0.08);
  z-index:1000;
  direction: rtl;
}

.logo{
  color:#ff5722;
  margin:0;
  font-size:22px;
  font-weight: bold;
}

.header-buttons{
  display:flex;
  gap:10px;
  align-items: center;
}

.header-buttons a,
.header-buttons button{
  background:#ff5722;
  color:#fff;
  border:none;
  padding:8px 14px;
  border-radius:6px;
  cursor:pointer;
  text-decoration:none;
  font-weight:bold;
  transition: all 0.3s ease;
}

.header-buttons a:hover,
.header-buttons button:hover{
  background: #e64a19;
  transform: translateY(-2px);
}

/* =======================
   SEARCH & FILTER
======================= */
.top-bar{
  margin-top:80px;
  padding: 20px;
  display:flex;
  justify-content:center;
  gap:10px;
  flex-wrap: wrap;
  direction: rtl;
}

.top-bar input,
.top-bar select{
  padding:10px 15px;
  border-radius:6px;
  border:1px solid #ccc;
  font-family: inherit;
  font-size: 14px;
  min-width: 200px;
}

.top-bar input:focus,
.top-bar select:focus{
  outline: none;
  border-color: #ff5722;
  box-shadow: 0 0 0 2px rgba(255, 87, 34, 0.1);
}

/* =======================
   PRODUCTS GRID
======================= */
.products-container{
  display:grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap:25px;
  margin: 20px auto;
  max-width: 1200px;
  padding: 0 20px 100px;
  direction: rtl;
}

.product{
  background:#fff;
  border-radius:12px;
  box-shadow:0 5px 20px rgba(0,0,0,0.08);
  overflow: hidden;
  transition: all 0.3s ease;
  display: flex;
  flex-direction: column;
  text-align: right;
}

.product:hover{
  transform:translateY(-10px);
  box-shadow: 0 15px 30px rgba(0,0,0,0.12);
}

.product img{
  width:100%;
  height:180px;
  object-fit:cover;
}

.product-content{
  padding: 15px;
  flex: 1;
  display: flex;
  flex-direction: column;
}

.product h3{
  margin: 0 0 10px;
  font-size: 18px;
  color: #333;
}

.product p{
  margin: 0 0 10px;
  color: #666;
  font-size: 14px;
  flex: 1;
}

.product-price{
  font-size: 18px;
  font-weight: bold;
  color: #ff5722;
  margin-bottom: 10px;
}

.product button{
  padding:10px 20px;
  border-radius:6px;
  border:none;
  background:#ff5722;
  color:#fff;
  cursor:pointer;
  width:100%;
  font-weight: bold;
  transition: all 0.3s ease;
}

.product button:hover{
  background: #e64a19;
  transform: translateY(-2px);
}

/* =======================
   CART
======================= */
#cartBox{
  position:fixed;
  top:70px;
  right:20px;
  width:320px;
  max-height: calc(100vh - 100px);
  background:#fff;
  border-radius:10px;
  padding:15px;
  box-shadow:0 4px 20px rgba(0,0,0,0.2);
  display:none;
  z-index:1001;
  overflow-y: auto;
  direction: rtl;
  text-align: right;
}

#cartBox h3{
  margin: 0 0 15px;
  padding-bottom: 10px;
  border-bottom: 2px solid #f5f5f5;
}

.cart-item{
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 15px;
  padding: 10px;
  background: #f9f9f9;
  border-radius: 8px;
}

.cart-item img{
  width: 50px;
  height: 50px;
  object-fit: cover;
  border-radius: 6px;
}

.cart-item-details{
  flex: 1;
}

.cart-item-name{
  font-weight: bold;
  margin-bottom: 5px;
}

.cart-item-price{
  color: #ff5722;
  font-weight: bold;
}

.cart-item-controls{
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 5px;
}

.cart-item-controls button{
  width: 25px;
  height: 25px;
  border: none;
  background: #ff5722;
  color: #fff;
  border-radius: 4px;
  cursor: pointer;
  font-size: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.cart-item-controls button:hover{
  background: #e64a19;
}

.cart-remove-btn{
  background: #f44336 !important;
  padding: 5px 10px !important;
  width: auto !important;
  font-size: 14px !important;
}

.cart-total{
  margin-top: 15px;
  padding-top: 15px;
  border-top: 2px solid #f5f5f5;
  font-weight: bold;
  font-size: 18px;
}

.cart-actions{
  margin-top: 15px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.cart-actions button{
  padding: 12px;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-weight: bold;
  transition: all 0.3s ease;
}

.cart-actions button:hover{
  transform: translateY(-2px);
}

.clear-cart-btn{
  background: #f44336;
  color: #fff;
}

.checkout-btn{
  background: #25D366;
  color: #fff;
}

/* =======================
   FOOTER
======================= */
#footer{
  position:fixed;
  bottom:0;
  width:100%;
  background:#1e1e1e;
  color:#fff;
  padding:15px 40px;
  text-align:center;
  z-index: 999;
}

/* =======================
   MODAL
======================= */
#modal{
  display:none;
  position:fixed;
  top:0;
  left:0;
  width:100%;
  height:100%;
  background:rgba(0,0,0,0.6);
  z-index:2000;
  justify-content:center;
  align-items:center;
  padding: 20px;
}

.modal-content{
  background:#fff;
  padding:25px;
  width:90%;
  max-width:450px;
  border-radius:12px;
  direction: rtl;
  text-align: right;
  box-shadow: 0 10px 40px rgba(0,0,0,0.2);
  animation: modalSlideIn 0.3s ease;
}

@keyframes modalSlideIn {
  from {
    transform: translateY(-50px);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

.modal-content h3{
  margin: 0 0 15px;
  color: #333;
}

.modal-content p{
  margin: 0 0 15px;
  color: #666;
  line-height: 1.6;
}

.modal-price{
  font-size: 24px;
  font-weight: bold;
  color: #ff5722;
  margin-bottom: 20px;
  display: block;
}

.modal-actions{
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}

.modal-actions button{
  padding:10px 20px;
  border:none;
  border-radius:6px;
  cursor:pointer;
  font-weight: bold;
  transition: all 0.3s ease;
}

.modal-actions button:hover{
  transform: translateY(-2px);
}

.add-to-cart-btn{
  background:#ff5722;
  color:#fff;
}

.close-modal-btn{
  background:#666;
  color:#fff;
}

/* =======================
   TOAST NOTIFICATION
======================= */
#toast{
  position:fixed;
  bottom:80px;
  right:20px;
  background:#4caf50;
  color:#fff;
  padding:12px 20px;
  border-radius:8px;
  display:none;
  z-index:3000;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
  animation: toastSlideIn 0.3s ease;
}

@keyframes toastSlideIn {
  from {
    transform: translateX(100%);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

/* =======================
   RESPONSIVE
======================= */
@media (max-width: 768px) {
  #header{
    padding: 10px 15px;
  }

  .logo{
    font-size: 18px;
  }

  .header-buttons a,
  .header-buttons button{
    padding: 6px 12px;
    font-size: 14px;
  }

  #cartBox{
    width: 90%;
    right: 5%;
    top: 60px;
  }

  .products-container{
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 15px;
  }

  .product img{
    height: 140px;
  }

  .modal-content{
    width: 95%;
    padding: 20px;
  }

  .modal-actions{
    flex-direction: column;
  }

  .modal-actions button{
    width: 100%;
  }
}