/* --- متغیرهای رنگی هماهنگ با تم --- */
:root {
    --primary-bg: #1a1a1a;
    --secondary-bg: rgb(26, 50, 77);
    --card-bg: rgba(255, 255, 255, 0.03);
    --text-light: #f0f0f0;
    --text-muted: #D6BCFA;
    --border-color: rgba(92, 205, 246, 0.2);
    --gradient-btn: linear-gradient(45deg, #6B46C1 0%, #9F7AEA 100%);
    --accent-color: #7DD3FC;
    --danger-color: #FF6B6B;
    --success-color: #4ade80;
    --star-color: #facc15;
    --shadow-light: 0 4px 15px rgba(0, 0, 0, 0.3);
    --shadow-hover: 0 6px 20px rgba(107, 70, 193, 0.5);
}

/* --- استایل‌های پایه --- */
* { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
    font-family: 'Vazirmatn', Arial, sans-serif;
    background-color: var(--primary-bg);
    color: var(--text-light);
    line-height: 1.7;
}
.page-wrapper { display: flex; flex-direction: column; min-height: 100vh; }
main.container { flex-grow: 1; max-width: 1400px; margin: 2rem auto; padding: 0 2rem; }
a { text-decoration: none; color: inherit; }

/* --- عنوان و نوار ابزار --- */
.page-title {
    font-size: clamp(2rem, 5vw, 2.8rem);
    font-weight: 700;
    margin-bottom: 2rem;
    text-align: right;
}
.toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1.5rem;
    margin-bottom: 2.5rem;
    flex-wrap: wrap;
}
.search-form {
    position: relative;
    flex: 1 1 300px; /* Responsive flex */
    max-width: 500px;
}
.search-input {
    width: 100%;
    padding: 0.8rem 3.5rem 0.8rem 1rem;
    border-radius: 50px;
    border: 1px solid var(--border-color);
    background: var(--card-bg);
    color: var(--text-light);
    font-family: inherit;
    font-size: 1rem;
    transition: all 0.3s ease;
}
.search-input:focus {
    outline: none;
    border-color: var(--accent-color);
    box-shadow: 0 0 0 3px rgba(125, 211, 252, 0.3);
}
.search-button {
    position: absolute;
    top: 0;
    right: 0;
    height: 100%;
    width: 50px;
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 1.1rem;
}
.actions {
    display: flex;
    gap: 1rem;
    align-items: center;
}
.filter-trigger-btn, .sort-options {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.7rem 1.2rem;
    border-radius: 50px;
    border: 1px solid var(--border-color);
    background: var(--card-bg);
    cursor: pointer;
    transition: all 0.3s ease;
}
.filter-trigger-btn:hover, .sort-options:hover {
    border-color: var(--accent-color);
    color: var(--accent-color);
}
.sort-options select {
    background: transparent;
    border: none;
    color: inherit;
    font-family: inherit;
    font-size: 1rem;
    outline: none;
    -webkit-appearance: none;
    appearance: none;
    cursor: pointer;
}

/* --- گرید محصولات --- */
.products-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 2rem;
}
.product-card {
    background: var(--card-bg);
    border-radius: 15px;
    border: 1px solid var(--border-color);
    transition: all 0.4s ease;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    opacity: 0;
    transform: translateY(20px);
    animation: fadeIn 0.5s forwards;
}
@keyframes fadeIn { to { opacity: 1; transform: translateY(0); } }
.product-card:hover {
    transform: translateY(-10px);
    box-shadow: var(--shadow-hover);
    border-color: var(--accent-color);
}
.product-image-container {
    width: 100%;
    aspect-ratio: 1 / 1;
    padding: 1rem;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}
.product-image-container img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    transition: transform 0.4s ease;
}
.product-card:hover .product-image-container img { transform: scale(1.1); }
.default-icon { font-size: 4rem; color: var(--text-muted); opacity: 0.5; }
.discount-badge {
    position: absolute; top: 1rem; left: 1rem;
    background: var(--danger-color); color: var(--text-light);
    padding: 4px 10px; border-radius: 50px;
    font-size: 0.8rem; font-weight: 700;
}
.product-info {
    padding: 1rem 1.2rem;
    display: flex; flex-direction: column;
    flex-grow: 1;
    border-top: 1px solid var(--border-color);
}
.product-title {
    font-size: 1.1rem; font-weight: 600;
    line-height: 1.5; height: 3em; /* 2 lines */
    overflow: hidden; margin-bottom: auto;
    padding-bottom: 1rem;
}
.product-price-section {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    padding-top: 1rem;
    border-top: 1px solid var(--border-color);
}
.final-price { font-size: 1.3rem; font-weight: 700; color: var(--accent-color); }
.final-price .currency { font-size: 0.8rem; margin-right: 0.2rem; }
.original-price { font-size: 0.9rem; color: var(--text-muted); text-decoration: line-through; }
.stock-warning-centered { font-weight: bold; color: var(--danger-color); text-align: center; font-size: 1.2rem; padding: 1rem 0; }
.product-footer {
    display: flex; justify-content: space-between;
    align-items: center; font-size: 0.9rem;
    color: var(--text-muted);
    margin-top: 1rem;
}
.product-rating { display: flex; align-items: center; gap: 0.4rem; }
.star-icon { color: var(--star-color); }
.stock-low { color: #f59e0b; font-weight: 500; }
.no-products {
    grid-column: 1 / -1;
    text-align: center; color: var(--text-muted);
    padding: 4rem; background: var(--card-bg);
    border-radius: 15px; font-size: 1.2rem;
}
.no-products i { font-size: 3rem; margin-bottom: 1rem; opacity: 0.5; }
.no-products a { margin-top: 1rem; color: var(--accent-color); display: inline-block; }

/* --- پنل فیلتر (مودال) --- */
.filter-panel-overlay {
    position: fixed; top: 0; left: 0;
    width: 100%; height: 100%;
    background: rgba(0,0,0,0.7);
    z-index: 1999;
    opacity: 0; visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}
.filter-panel {
    position: fixed; top: 50%; left: 50%;
    transform: translate(-50%, -50%) scale(0.95);
    width: 90%; max-width: 450px;
    background: var(--primary-bg);
    border-radius: 15px;
    border: 1px solid var(--border-color);
    box-shadow: 0 10px 30px rgba(0,0,0,0.5);
    z-index: 2000;
    display: flex; flex-direction: column;
    max-height: 90vh;
    opacity: 0; visibility: hidden;
    transition: all 0.3s ease;
}
.filter-panel-overlay.open, .filter-panel.open {
    opacity: 1;
    visibility: visible;
}
.filter-panel.open { transform: translate(-50%, -50%) scale(1); }

.filter-header {
    display: flex; justify-content: space-between; align-items: center;
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--border-color);
}
.filter-header h3 { font-size: 1.3rem; }
.close-filter-btn { background: none; border: none; color: var(--text-light); font-size: 1.8rem; cursor: pointer; }
.filter-body { padding: 1.5rem; overflow-y: auto; }
.filter-section { margin-bottom: 2rem; }
.filter-section label { display: block; font-size: 1.1rem; font-weight: 500; margin-bottom: 1rem; color: var(--text-muted); }
.price-range input[type="range"] { width: 100%; accent-color: var(--accent-color); }
.price-values { display: flex; justify-content: space-between; margin-top: 0.5rem; font-size: 0.9rem; }
.categories-list { max-height: 200px; overflow-y: auto; padding-left: 0.5rem; }
.category-item { display: block; margin-bottom: 0.75rem; cursor: pointer; }
.category-item input { display: none; }
.category-item span { position: relative; padding-right: 30px; transition: color 0.3s ease; }
.category-item span::before, .category-item span::after { transition: all 0.3s ease; }
.category-item span::before { content: ''; position: absolute; right: 0; top: 2px; width: 18px; height: 18px; border: 2px solid var(--border-color); border-radius: 4px; }
.category-item span::after { content: '\f00c'; font-family: 'Font Awesome 6 Free'; font-weight: 900; position: absolute; right: 4px; top: 3px; color: var(--primary-bg); font-size: 12px; transform: scale(0); }
.category-item input:checked + span::before { background: var(--accent-color); border-color: var(--accent-color); }
.category-item input:checked + span::after { transform: scale(1); }
.category-item:hover span { color: var(--accent-color); }

.filter-footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--border-color);
    display: flex;
    gap: 1rem;
}
.apply-filter-btn, .clear-filter-btn {
    flex: 1;
    padding: 0.8rem;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    text-align: center;
    transition: all 0.3s ease;
}
.apply-filter-btn { background: var(--gradient-btn); color: var(--text-light); }
.clear-filter-btn { background: none; border: 1px solid var(--border-color); color: var(--text-muted); }
.apply-filter-btn:hover { transform: translateY(-2px); box-shadow: var(--shadow-hover); }
.clear-filter-btn:hover { border-color: var(--danger-color); color: var(--danger-color); }

/* --- پاسخ‌گویی --- */
@media (max-width: 768px) {
    main.container { padding: 0 1rem; margin-top: 1.5rem; }
    .toolbar { flex-direction: column; align-items: stretch; }
}
