/* ---------- تنظیمات کلی و فونت ---------- */
:root {
    --bg-color-light: #f4f4f9;
    --card-bg-light: #ffffff;
    --text-color-light: #333333;
    --primary-color-light: #005a9c;
    --shadow-light: 0 4px 12px rgba(0,0,0,0.08);
    --bg-color-dark: #1a1a2e;
    --card-bg-dark: #2a2a4e;
    --text-color-dark: #e0e0e0;
    --primary-color-dark: #4d9fff;
    --shadow-dark: 0 4px 12px rgba(0,0,0,0.3);
}

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

html {
    scroll-behavior: smooth;
}

body {
    font-family: 'Vazirmatn', sans-serif;
    direction: rtl;
    transition: background-color 0.3s, color 0.3s;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

/* ---------- مدیریت حالت‌های رنگی ---------- */
body.light-mode {
    background-color: var(--bg-color-light);
    color: var(--text-color-light);
}
body.dark-mode {
    background-color: var(--bg-color-dark);
    color: var(--text-color-dark);
}
body.light-mode .product-card,
body.light-mode #cart,
body.light-mode header {
    background-color: var(--card-bg-light);
    box-shadow: var(--shadow-light);
}
body.dark-mode .product-card,
body.dark-mode #cart,
body.dark-mode header {
    background-color: var(--card-bg-dark);
    box-shadow: var(--shadow-dark);
}
body.light-mode .add-to-cart,
body.light-mode #checkout-btn {
    background-color: var(--primary-color-light);
}
body.dark-mode .add-to-cart,
body.dark-mode #checkout-btn {
    background-color: var(--primary-color-dark);
}


/* * ========================================
 * *** بخش اصلاح شده: هدر ***
 * ========================================
*/
header {
    padding: 10px 0;
    border-bottom: 2px solid var(--primary-color-light);
    position: sticky;
    top: 0;
    z-index: 100;
    background-color: var(--card-bg-light); 
}
body.dark-mode header {
    border-bottom-color: var(--primary-color-dark);
    background-color: var(--card-bg-dark);
}
.header-container {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 25px;
}
.title-wrapper {
    text-align: center;
}
.title-wrapper h1 {
    font-size: 2.2rem;
    color: var(--primary-color-light);
}
.title-wrapper p { 
    font-size: 1.1rem;
}
body.dark-mode .title-wrapper h1 {
    color: var(--primary-color-dark);
}

/* ========================================
 * *** بخش جدید: دکمه سوییچ تم ***
 * ========================================
*/

/* From Uiverse.io by andrew-demchenk0 */
.switch {
  font-size: 17px;
  position: relative;
  display: inline-block;
  width: 64px;
  height: 34px;
  /* اضافه کردن کمی مارجین برای تراز بهتر در هدر */
  margin-top: 8px; 
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: #73C0FC;
  transition: .4s;
  border-radius: 30px;
}

.slider:before {
  position: absolute;
  content: "";
  height: 30px;
  width: 30px;
  border-radius: 20px;
  left: 2px;
  bottom: 2px;
  z-index: 2;
  background-color: #e8e8e8;
  transition: .4s;
}

.sun svg {
  position: absolute;
  top: 6px;
  left: 36px;
  z-index: 1;
  width: 24px;
  height: 24px;
}

.moon svg {
  fill: #73C0FC;
  position: absolute;
  top: 5px;
  left: 5px;
  z-index: 1;
  width: 24px;
  height: 24px;
}

/* .switch:hover */.sun svg {
  animation: rotate 15s linear infinite;
}

@keyframes rotate {
  0% {
    transform: rotate(0);
  }

  100% {
    transform: rotate(360deg);
  }
}

/* .switch:hover */.moon svg {
  animation: tilt 5s linear infinite;
}

@keyframes tilt {
  0% {
    transform: rotate(0deg);
  }

  25% {
    transform: rotate(-10deg);
  }

  75% {
    transform: rotate(10deg);
  }

  100% {
    transform: rotate(0deg);
  }
}

/* سلکتور به ID آپدیت شد */
#toggle:checked + .slider {
  background-color: #183153;
}

#toggle:focus + .slider {
  box-shadow: 0 0 1px #ffffff;
}

#toggle:checked + .slider:before {
  transform: translateX(30px);
}

/* ========================================
 * *** پایان بخش سوییچ تم ***
 * ========================================
*/


/* ---------- چیدمان اصلی (بدون تغییر) ---------- */
main {
    display: flex;
    flex-direction: column; 
    gap: 20px;
    margin-top: 20px; 
}
.menu-grid {
    flex: 3; 
    min-width: 0;
    display: grid;
    gap: 20px;
    grid-template-columns: 1fr;
    align-items: stretch; 
}
.product-card {
    border-radius: 12px;
    overflow: hidden;
    transition: transform 0.3s, box-shadow 0.3s;
    display: flex;
    flex-direction: column;
    height: 100%; 
}
.product-card:hover { transform: translateY(-5px); }
.product-card img {
    width: 100%;
    height: 200px;
    object-fit: cover;
}
.product-card h3 {
    font-size: 1.2rem;
    margin: 15px 15px 10px;
}
.product-card .price {
    font-size: 1.1rem;
    font-weight: bold;
    margin: 0 15px 15px;
    color: var(--primary-color-light);
}
body.dark-mode .product-card .price { color: var(--primary-color-dark); }
.add-to-cart {
    margin-top: auto; 
    display: block;
    width: 90%;
    margin: 15px auto;
    padding: 12px;
    border: none;
    border-radius: 8px;
    color: white;
    font-family: 'Vazirmatn', sans-serif;
    font-size: 1rem;
    font-weight: bold;
    cursor: pointer;
    transition: opacity 0.2s;
}
.add-to-cart:hover { opacity: 0.9; }

/* ---------- سبد خرید (بدون تغییر) ---------- */
#cart {
    flex: 1; 
    padding: 20px;
    border-radius: 12px;
    min-width: 300px;
}
#cart h2 {
    border-bottom: 2px solid;
    padding-bottom: 10px;
    margin-bottom: 15px;
}
#cart-items {
    list-style: none;
    max-height: 400px;
    overflow-y: auto;
    margin-bottom: 20px;
}
#cart-items li {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 0;
    border-bottom: 1px dashed #ccc;
    word-break: break-all; 
    gap: 10px;
}
body.dark-mode #cart-items li { border-bottom-color: #555; }
#cart-items li:last-child { border-bottom: none; }
.cart-item-info {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}
.cart-item-name { font-weight: 500; }
.cart-item-quantity {
    font-size: 0.9rem;
    background: #eee;
    padding: 2px 6px;
    border-radius: 5px;
    margin: 0;
}
body.dark-mode .cart-item-quantity { background: var(--bg-color-dark); }
.cart-item-controls {
    display: flex;
    align-items: center;
    gap: 12px;
}
.cart-item-price {
    font-weight: 500;
    white-space: nowrap;
}
.remove-item {
    font-family: 'Vazirmatn', sans-serif;
    background-color: #e74c3c;
    color: white;
    border: none;
    border-radius: 5px;
    padding: 4px 8px;
    font-size: 0.8rem;
    font-weight: bold;
    cursor: pointer;
    transition: background-color 0.2s;
}
.remove-item:hover { background-color: #c0392b; }
.cart-summary {
    font-size: 1.2rem;
    font-weight: bold;
    display: flex;
    justify-content: space-between;
    margin-bottom: 20px;
}
#checkout-btn {
    width: 100%;
    padding: 15px;
    font-size: 1.1rem;
    font-weight: bold;
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-family: 'Vazirmatn', sans-serif;
}
#checkout-btn:hover { opacity: 0.9; }

/*
========================================
    *** Media Queries (بدون تغییر) ***
========================================
*/

/* ---------- موبایل‌های کوچک (کمتر از 480px) ---------- */
@media (max-width: 480px) {
    .container {
        padding: 10px;
    }
    .header-container {
        gap: 15px;
    }
    .title-wrapper h1 {
        font-size: 1.7rem;
    }
    .title-wrapper p {
        font-size: 0.9rem;
    }
    
    .cart-summary, #checkout-btn {
        font-size: 1rem;
    }
    .cart-item-controls {
        flex-wrap: wrap;
        gap: 8px;
        justify-content: flex-end;
    }
    .cart-item-info {
        justify-content: flex-start;
    }
}

/* ---------- تبلت (600px و بالاتر) ---------- */
@media (min-width: 600px) {
    .menu-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    .title-wrapper h1 {
        font-size: 2.2rem;
    }
    .title-wrapper p {
        font-size: 1.1rem;
    }
}

/* ---------- دسکتاپ (900px و بالاتر) ---------- */
@media (min-width: 900px) {
    main {
        flex-direction: row;
    }
    #cart {
        position: sticky;
        top: 100px; 
        align-self: flex-start;
        min-width: 300px;
    }
    .menu-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

/* ---------- دسکتاپ بزرگ (1200px و بالاتر) ---------- */
@media (min-width: 1200px) {
    .menu-grid {
        grid-template-columns: repeat(4, 1fr);
    }
}