/* ===== PRODUCTS PAGES STYLES ===== */
.products-page {
    padding: 120px 0 60px;
    background: linear-gradient(135deg, #f8f5f0 0%, #ffffff 50%, #f8f5f0 100%);
    min-height: 100vh;
}

/* دکمه برگشت */
.back-btn {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 10px 20px;
    background: white;
    color: var(--primary);
    text-decoration: none;
    border-radius: 25px;
    font-weight: 600;
    transition: all 0.3s ease;
    margin-bottom: 30px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
    border: 2px solid var(--primary);
}

.back-btn:hover {
    background: var(--primary);
    color: white;
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(138, 109, 59, 0.3);
}

/* عنوان صفحه */
.page-title {
    text-align: center;
    margin-bottom: 50px;
}

.page-title h1 {
    font-size: 2.5rem;
    color: var(--primary);
    margin-bottom: 15px;
}

.page-title p {
    font-size: 1.1rem;
    color: #666;
    max-width: 600px;
    margin: 0 auto;
    line-height: 1.6;
}

/* ===== PRODUCT GRID ===== */
.products-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 25px;
    margin-top: 40px;
}

.product-card {
    background: white;
    border-radius: 15px;
    overflow: hidden;
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.08);
    transition: all 0.3s ease;
    position: relative;
}

.product-card:hover {
    transform: translateY(-8px);
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.15);
}

/* ===== عکس محصول ===== */
.product-image {
    position: relative;
    height: 250px;
    overflow: hidden;
    border-radius: 10px 10px 0 0;
    background: #f8f5f0;
}

/* عکس اصلی */
.product-image img:nth-child(1) {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center;
    opacity: 1;
    transition: opacity 0.5s ease;
}

/* عکس هاور - فقط برای دسکتاپ */
.product-image img:nth-child(2) {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center;
    opacity: 0;
    transition: opacity 0.5s ease;
}

@media (hover: hover) and (pointer: fine) {
    /* هاور فقط برای دستگاه‌هایی که هاور دارند */
    .product-card:hover .product-image img:nth-child(1) {
        opacity: 0;
    }
    
    .product-card:hover .product-image img:nth-child(2) {
        opacity: 1;
    }
    
    .product-overlay {
        opacity: 0;
    }
    
    .product-card:hover .product-overlay {
        opacity: 1;
    }
    
    .product-actions {
        transform: translateY(10px);
    }
    
    .product-card:hover .product-actions {
        transform: translateY(0);
    }
}

/* ===== دکمه View Details - همیشه قابل مشاهده در موبایل ===== */
.product-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 60px;
    background: linear-gradient(to top, 
        rgba(138, 109, 59, 0.9) 0%, 
        rgba(138, 109, 59, 0.7) 50%, 
        transparent 100%);
    display: flex;
    align-items: flex-end;
    justify-content: center;
    padding-bottom: 15px;
    z-index: 3;
}

/* برای موبایل و تبلت - دکمه همیشه نمایش داده شود */
@media (max-width: 1024px) {
    .product-overlay {
        opacity: 1 !important;
        background: linear-gradient(to top, 
            rgba(138, 109, 59, 0.95) 0%, 
            rgba(138, 109, 59, 0.8) 100%);
    }
    
    .product-actions {
        transform: translateY(0) !important;
    }
    
    /* در موبایل فقط یک عکس نمایش داده شود */
    .product-image img:nth-child(2) {
        display: none;
    }
}

.product-actions {
    text-align: center;
}

.view-btn {
    padding: 10px 25px;
    background: rgba(255, 255, 255, 0.95);
    color: var(--primary);
    border: none;
    border-radius: 25px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 0.9rem;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
    backdrop-filter: blur(10px);
    min-width: 140px;
}

.view-btn:hover {
    background: white;
    color: var(--primary);
    transform: scale(1.05);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.3);
}

/* ===== PRODUCT INFO ===== */
.product-info {
    padding: 15px;
    text-align: center;
}

.product-info h3 {
    font-size: 1.1rem;
    color: var(--dark);
    margin-bottom: 8px;
    font-weight: 600;
}

.product-info p {
    color: #666;
    line-height: 1.4;
    font-size: 0.85rem;
}

/* ===== MODAL STYLES ===== */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.9);
    backdrop-filter: blur(5px);
    z-index: 10000;
    padding: 20px;
    box-sizing: border-box;
}

.modal-content {
    position: relative;
    background: white;
    margin: 0 auto;
    width: 100%;
    max-width: 1200px;
    max-height: 95vh;
    border-radius: 20px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.close-modal {
    position: absolute;
    top: 15px;
    right: 20px;
    font-size: 2rem;
    color: var(--dark);
    cursor: pointer;
    z-index: 10001;
    transition: all 0.3s ease;
    background: rgba(255, 255, 255, 0.95);
    width: 45px;
    height: 45px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    border: 2px solid var(--primary);
}

.close-modal:hover {
    color: var(--primary);
    background: white;
    transform: scale(1.1);
}

.modal-gallery {
    flex: 1;
    background: #f8f5f0;
    padding: 20px;
    display: flex;
    flex-direction: column;
    min-height: 300px;
}

.main-image {
    flex: 1;
    border-radius: 15px;
    overflow: hidden;
    margin-bottom: 15px;
    background: white;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 250px;
    max-height: 400px;
}

.main-image img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    transition: transform 0.3s ease;
}

.thumbnail-gallery {
    display: flex;
    gap: 10px;
    justify-content: center;
    flex-wrap: wrap;
    padding: 10px 0;
}

.thumbnail-gallery img {
    width: 60px;
    height: 60px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    border: 2px solid transparent;
    object-fit: cover;
    flex-shrink: 0;
}

.thumbnail-gallery img:hover {
    transform: scale(1.1);
    border-color: var(--primary);
}

.thumbnail-gallery img.active {
    border-color: var(--primary);
    transform: scale(1.05);
    box-shadow: 0 5px 15px rgba(138, 109, 59, 0.3);
}

.modal-info {
    flex: 1;
    padding: 25px;
    overflow-y: auto;
    max-height: 50vh;
}

.modal-info h2 {
    font-size: 1.5rem;
    color: var(--primary);
    margin-bottom: 15px;
    line-height: 1.3;
}

.modal-info p {
    color: #666;
    line-height: 1.6;
    margin-bottom: 20px;
    font-size: 1rem;
}

.product-specs {
    margin: 20px 0;
}

.product-specs h3 {
    color: var(--dark);
    margin-bottom: 12px;
    font-size: 1.2rem;
}

.product-specs ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.product-specs li {
    padding: 8px 0;
    border-bottom: 1px solid #eee;
    color: #666;
    font-size: 0.9rem;
}

.contact-btn {
    margin-top: 20px;
    display: inline-block;
    width: 100%;
    text-align: center;
    padding: 12px 20px;
    font-size: 1rem;
}

/* ===== MEDIA QUERIES ===== */

/* دسکتاپ بزرگ */
@media (min-width: 1400px) {
    .products-grid {
        grid-template-columns: repeat(4, 1fr);
    }
}

/* دسکتاپ */
@media (min-width: 1200px) and (max-width: 1399px) {
    .products-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

/* لپتاپ */
@media (min-width: 992px) and (max-width: 1199px) {
    .products-grid {
        grid-template-columns: repeat(3, 1fr);
    }
    
    .product-image {
        height: 220px;
    }
}

/* تبلت بزرگ */
@media (min-width: 992px) {
    .modal-content {
        flex-direction: row;
        height: 80vh;
    }
    
    .modal-gallery {
        min-height: auto;
        max-height: none;
    }
    
    .modal-info {
        max-height: none;
        overflow-y: auto;
    }
    
    .contact-btn {
        width: auto;
    }
}

/* تبلت */
@media (min-width: 768px) and (max-width: 991px) {
    .products-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 20px;
    }
    
    .product-image {
        height: 200px;
    }
    
    .modal-content {
        flex-direction: column;
        max-height: 90vh;
    }
    
    .modal-gallery {
        flex: 0 0 60%;
    }
    
    .main-image {
        min-height: 300px;
        max-height: 350px;
    }
    
    .modal-info {
        flex: 0 0 40%;
        max-height: none;
    }
    
    .contact-btn {
        width: 100%;
    }
}

/* موبایل بزرگ */
@media (max-width: 767px) {
    .products-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 15px;
    }
    
    .product-image {
        height: 180px;
    }
    
    .modal {
        padding: 10px;
    }
    
    .modal-content {
        max-height: 95vh;
        border-radius: 15px;
    }
    
    .close-modal {
        top: 10px;
        right: 15px;
        width: 40px;
        height: 40px;
        font-size: 1.5rem;
    }
    
    .modal-gallery {
        padding: 15px;
        min-height: 250px;
    }
    
    .main-image {
        min-height: 200px;
        max-height: 300px;
        margin-bottom: 10px;
    }
    
    .thumbnail-gallery {
        gap: 8px;
        padding: 5px 0;
    }
    
    .thumbnail-gallery img {
        width: 50px;
        height: 50px;
    }
    
    .modal-info {
        padding: 20px;
    }
    
    .modal-info h2 {
        font-size: 1.3rem;
    }
    
    .modal-info p {
        font-size: 0.9rem;
        margin-bottom: 15px;
    }
    
    .product-specs h3 {
        font-size: 1.1rem;
    }
    
    .product-specs li {
        font-size: 0.85rem;
        padding: 6px 0;
    }
    
    .product-overlay {
        height: 50px;
        padding-bottom: 10px;
    }
    
    .view-btn {
        padding: 8px 20px;
        font-size: 0.85rem;
        min-width: 120px;
    }
    
    .page-title h1 {
        font-size: 2rem;
    }
    
    .page-title p {
        font-size: 1rem;
    }
}

/* موبایل کوچک */
@media (max-width: 480px) {
    .products-grid {
        grid-template-columns: 1fr;
        gap: 20px;
    }
    
    .product-image {
        height: 220px;
    }
    
    .product-info {
        padding: 12px;
    }
    
    .product-info h3 {
        font-size: 1rem;
    }
    
    .product-info p {
        font-size: 0.8rem;
    }
    
    .back-btn {
        padding: 8px 16px;
        font-size: 0.9rem;
    }
    
    .view-btn {
        padding: 6px 16px;
        font-size: 0.8rem;
        min-width: 110px;
    }
    
    .modal {
        padding: 5px;
    }
    
    .modal-content {
        max-height: 98vh;
        border-radius: 12px;
    }
    
    .close-modal {
        top: 8px;
        right: 12px;
        width: 35px;
        height: 35px;
        font-size: 1.3rem;
    }
    
    .modal-gallery {
        padding: 12px;
        min-height: 200px;
    }
    
    .main-image {
        min-height: 180px;
        max-height: 250px;
        border-radius: 10px;
    }
    
    .thumbnail-gallery {
        gap: 6px;
    }
    
    .thumbnail-gallery img {
        width: 45px;
        height: 45px;
        border-radius: 6px;
    }
    
    .modal-info {
        padding: 15px;
    }
    
    .modal-info h2 {
        font-size: 1.2rem;
        margin-bottom: 10px;
    }
    
    .modal-info p {
        font-size: 0.85rem;
        line-height: 1.5;
    }
    
    .product-specs {
        margin: 15px 0;
    }
    
    .product-specs h3 {
        font-size: 1rem;
        margin-bottom: 8px;
    }
    
    .product-specs li {
        font-size: 0.8rem;
        padding: 5px 0;
    }
    
    .contact-btn {
        padding: 10px 15px;
        font-size: 0.9rem;
    }
}

/* حالت لنداسکیپ موبایل */
@media (max-height: 500px) and (max-width: 767px) {
    .modal-content {
        flex-direction: row;
        max-height: 95vh;
    }
    
    .modal-gallery {
        flex: 0 0 50%;
    }
    
    .modal-info {
        flex: 0 0 50%;
        max-height: none;
    }
    
    .main-image {
        min-height: 200px;
        max-height: 250px;
    }
}

/* جلوگیری از scroll بدن وقتی مودال بازه */
body.modal-open {
    overflow: hidden;
}

/* ===== RTL SUPPORT ===== */
[dir="rtl"] .back-btn {
    direction: rtl;
}

[dir="rtl"] .product-info {
    text-align: right;
}

[dir="rtl"] .modal-info {
    text-align: right;
}

[dir="rtl"] .close-modal {
    right: auto;
    left: 20px;
}

[dir="rtl"] .product-specs li {
    text-align: right;
}

[dir="rtl"] .thumbnail-gallery {
    direction: ltr;
}

/* برای موبایل RTL */
@media (max-width: 767px) {
    [dir="rtl"] .close-modal {
        left: 15px;
    }
}

@media (max-width: 480px) {
    [dir="rtl"] .close-modal {
        left: 12px;
    }
}
/* برای سایزهای بزرگ (1402px به بالا) */
@media (max-width: 1402px) {
    .product-image {
        height: 340px;
    }
}

/* برای سایزهای کوچک (1000px به پایین) */
@media (max-width: 1000px) {
    .product-image {
        height:340px;
    }
}
@media (max-width: 600px) {
    .product-image {
        height:300px !important;
    }
}
/* برای سایزهای کوچک (800px به پایین) */
@media (max-width: 800px) {
    .products-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 20px;
    }
    
    .product-image {
        height: 250px;
    }
}


/* برای موبایل کوچک (480px به پایین) */
@media (max-width: 600px) {
    .products-grid {
        grid-template-columns: 1fr;
        gap: 20px;
        max-width: 400px;
        margin-left: auto;
        margin-right: auto;
    }
    
    .product-image {
        height: 365px !important;
    }
}
@media (max-width:432px) {
 
    
    .product-image {
        height: 300px !important;
    }
}
@media (max-width:378px) {
 
    
    .product-image {
        height: 250px !important;
    }
}
/* ===== MEDIA QUERIES FOR MODAL ===== */
@media (max-width: 768px) {
    .modal {
        padding: 5px;
    }
    
    .modal-content {
        max-height: 98vh;
        border-radius: 10px;
        flex-direction: column;
    }
    
    .close-modal {
        top: 8px;
        right: 12px;
        font-size: 1.3rem;
        width: 35px;
        height: 35px;
    }
    
    .modal-gallery {
        padding: 10px;
        min-height: 300px; /* افزایش ارتفاع */
        flex: 2; /* سهم بیشتر از فضای مودال */
    }
    
    .main-image {
        min-height: 250px; /* افزایش ارتفاع */
        max-height: 400px; /* افزایش ارتفاع */
        margin-bottom: 10px;
        border-radius: 10px;
    }
    
    .thumbnail-gallery {
        gap: 8px;
        padding: 5px 0;
    }
    
    .thumbnail-gallery img {
        width: 50px;
        height: 50px;
        border-radius: 6px;
    }
    
    .modal-info {
        padding: 15px;
        max-height: 30vh; /* کاهش ارتفاع اطلاعات برای عکس بیشتر */
        flex: 1; /* سهم کمتر از فضای مودال */
    }
    
    .modal-info h2 {
        font-size: 1.3rem;
        margin-bottom: 10px;
    }
    
    .modal-info p {
        font-size: 0.9rem;
        margin-bottom: 15px;
    }
    
    .product-specs {
        margin: 15px 0;
    }
    
    .product-specs h3 {
        font-size: 1.1rem;
        margin-bottom: 8px;
    }
    
    .product-specs li {
        font-size: 0.85rem;
        padding: 6px 0;
    }
}

@media (max-width: 480px) {
    .modal {
        padding: 2px;
    }
    
    .modal-content {
        max-height: 99vh;
        border-radius: 8px;
    }
    
    .close-modal {
        top: 5px;
        right: 8px;
        font-size: 1.1rem;
        width: 30px;
        height: 30px;
    }
    
    .modal-gallery {
        padding: 8px;
        min-height: 250px; /* افزایش ارتفاع */
        flex: 3; /* سهم بیشتر از فضای مودال */
    }
    
    .main-image {
        min-height: 200px; /* افزایش ارتفاع */
        max-height: 350px; /* افزایش ارتفاع */
        margin-bottom: 8px;
    }
    
    .thumbnail-gallery img {
        width: 40px;
        height: 40px;
        border-radius: 4px;
    }
    
    .modal-info {
        padding: 12px;
        max-height: 25vh; /* کاهش بیشتر ارتفاع اطلاعات */
        flex: 1; /* سهم کمتر از فضای مودال */
    }
    
    .modal-info h2 {
        font-size: 1.1rem;
    }
    
    .modal-info p {
        font-size: 0.8rem;
    }
    
    .product-specs h3 {
        font-size: 1rem;
    }
    
    .product-specs li {
        font-size: 0.8rem;
    }
}

/* مدیا کوئری برای حالت عمودی (پورتریت) */
@media (max-width: 768px) and (orientation: portrait) {
    .modal-gallery {
        min-height: 350px;
        flex: 3;
    }
    
    .main-image {
        min-height: 280px;
        max-height: 450px;
    }
    
    .modal-info {
        max-height: 25vh;
        flex: 1;
    }
}