:root {
    --wood-dark: #5D4037;
    --wood-medium: #8B5A3C;
    --wood-light: #C9A57B;
    --cream: #FAF3E7;
    --beige: #E8DCC4;
    --text: #3E2723;
    --accent: #A0522D;
}

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

body {
    font-family: 'Vazirmatn', Tahoma, sans-serif;
    background: var(--cream);
    color: var(--text);
    line-height: 1.7;
}

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

.site-header {
    background: var(--wood-dark);
    color: var(--cream);
    padding: 15px 0;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}
.site-header .container { display: flex; align-items: center; gap: 30px; flex-wrap: wrap; }

.logo { display: flex; align-items: center; gap: 10px; color: var(--cream); text-decoration: none; font-size: 1.5rem; font-weight: bold; }
.logo img { height: 45px; }

.main-nav { display: flex; gap: 20px; flex: 1; }
.main-nav a { color: var(--cream); text-decoration: none; transition: color .2s; }
.main-nav a:hover { color: var(--wood-light); }

.search-box { display: flex; }
.search-box input { padding: 8px 12px; border: none; border-radius: 0 6px 6px 0; }
.search-box button { background: var(--accent); color: white; border: none; padding: 8px 12px; cursor: pointer; }

.hero { text-align: center; padding: 80px 20px; background: linear-gradient(135deg, var(--wood-medium), var(--wood-dark)); color: var(--cream); margin: 30px -20px; border-radius: 0; }
.hero h1 { font-size: 2.5rem; margin-bottom: 15px; }

.featured-products h2, .categories-section h2 { margin: 40px 0 20px; color: var(--wood-dark); border-bottom: 2px solid var(--wood-light); padding-bottom: 10px; }

.products-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 25px; }
.product-card { background: white; border-radius: 12px; overflow: hidden; text-decoration: none; color: var(--text); transition: transform .3s, box-shadow .3s; border: 1px solid var(--beige); }
.product-card:hover { transform: translateY(-5px); box-shadow: 0 10px 25px rgba(93,64,55,0.15); }
.product-card img { width: 100%; height: 220px; object-fit: cover; }
.product-info { padding: 15px; }
.product-info h3 { font-size: 1.1rem; margin-bottom: 8px; color: var(--wood-dark); }
.price { color: var(--accent); font-weight: bold; font-size: 1.1rem; }

.categories-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 15px; }
.category-card { background: var(--wood-medium); color: var(--cream); padding: 25px; text-align: center; border-radius: 10px; text-decoration: none; font-weight: bold; transition: background .2s; }
.category-card:hover { background: var(--wood-dark); }

.product-detail { display: grid; grid-template-columns: 1fr 1fr; gap: 40px; margin: 40px 0; }
.product-gallery img { width: 100%; max-height: 500px; object-fit: cover; border-radius: 12px; }
.gallery-thumbs { display: flex; gap: 10px; margin-top: 10px; overflow-x: auto; }
.thumb { width: 80px; height: 80px; cursor: pointer; border: 2px solid transparent; border-radius: 8px; overflow: hidden; }
.thumb:hover, .thumb.active { border-color: var(--accent); }
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.media-item { display: none; }
.media-item.active { display: block; }

.order-box { margin-top: 30px; padding: 20px; background: var(--beige); border-radius: 10px; }
.btn { display: inline-block; padding: 12px 24px; border-radius: 8px; text-decoration: none; margin: 5px; font-weight: bold; }
.btn-primary { background: var(--accent); color: white; }
.btn-telegram { background: #0088cc; color: white; }

.contact-page { padding: 50px 0; }
.contact-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: 20px; margin-top: 30px; }
.contact-cards .card { background: white; padding: 30px; border-radius: 12px; text-align: center; border: 2px solid var(--beige); }
.contact-cards .card a { display: block; margin-top: 10px; color: var(--accent); font-weight: bold; text-decoration: none; }

.site-footer { background: var(--wood-dark); color: var(--cream); padding: 30px 0; margin-top: 60px; text-align: center; }
.contact-short { margin-top: 15px; display: flex; justify-content: center; gap: 20px; flex-wrap: wrap; }
.contact-short a { color: var(--wood-light); text-decoration: none; }

/* Admin */
.admin-login { background: var(--wood-dark); min-height: 100vh; display: flex; align-items: center; justify-content: center; }
.login-box { background: white; padding: 40px; border-radius: 12px; width: 100%; max-width: 400px; }
.login-box h1 { color: var(--wood-dark); margin-bottom: 20px; text-align: center; }
.login-box input { width: 100%; padding: 12px; margin: 8px 0; border: 2px solid var(--beige); border-radius: 6px; }
.login-box button { width: 100%; padding: 12px; background: var(--accent); color: white; border: none; border-radius: 6px; cursor: pointer; font-size: 1rem; }

.admin-table { width: 100%; border-collapse: collapse; margin-top: 20px; background: white; }
.admin-table th, .admin-table td { padding: 12px; border: 1px solid var(--beige); text-align: right; }
.admin-table th { background: var(--wood-dark); color: white; }

.period-tabs { display: flex; gap: 10px; margin: 20px 0; }
.period-tabs a { padding: 10px 20px; background: var(--beige); text-decoration: none; color: var(--text); border-radius: 6px; }
.period-tabs a.active { background: var(--accent); color: white; }

.alert { padding: 12px; margin: 15px 0; border-radius: 6px; }
.alert-success { background: #d4edda; color: #155724; }
.alert-danger { background: #f8d7da; color: #721c24; }

@media (max-width: 768px) {
    .main-nav { display: none; width: 100%; flex-direction: column; }
    .main-nav.open { display: flex; }
    .mobile-menu { display: block; background: none; border: none; color: var(--cream); font-size: 1.5rem; cursor: pointer; }
    .product-detail { grid-template-columns: 1fr; }
    .hero h1 { font-size: 1.8rem; }
    .products-grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); }
}
@media (min-width: 769px) { .mobile-menu { display: none; } }

.description {
    line-height: 1.9;
}
/* ===== Lightbox ===== */
.lightbox-img {
    cursor: zoom-in;
}

.lightbox {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.92);
    z-index: 9999;
    justify-content: center;
    align-items: center;
}

.lightbox.open {
    display: flex;
}

.lightbox img {
    max-width: 90%;
    max-height: 85vh;
    object-fit: contain;
    border-radius: 8px;
    box-shadow: 0 10px 50px rgba(0, 0, 0, 0.7);
}

.lightbox-close {
    position: absolute;
    top: 20px;
    right: 30px;
    font-size: 45px;
    color: white;
    cursor: pointer;
    z-index: 10000;
    line-height: 1;
    transition: color 0.2s;
}

.lightbox-close:hover {
    color: #C9A57B;
}

.lightbox-prev,
.lightbox-next {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    font-size: 40px;
    color: white;
    cursor: pointer;
    padding: 20px;
    user-select: none;
    z-index: 10000;
    transition: color 0.2s;
}

.lightbox-prev { left: 15px; }
.lightbox-next { right: 15px; }

.lightbox-prev:hover,
.lightbox-next:hover {
    color: #C9A57B;
}

.lightbox-counter {
    position: absolute;
    bottom: 25px;
    left: 50%;
    transform: translateX(-50%);
    color: white;
    font-size: 16px;
    background: rgba(0, 0, 0, 0.5);
    padding: 5px 15px;
    border-radius: 20px;
}

@media (max-width: 768px) {
    .lightbox-prev, .lightbox-next { font-size: 28px; padding: 15px; }
    .lightbox-close { font-size: 35px; top: 15px; right: 20px; }
}

/* ===== Dropdown منوی محصولات ===== */
.nav-dropdown {
    position: relative;
}

.dropdown-toggle {
    display: inline-flex;
    align-items: center;
    gap: 5px;
}

.dd-arrow {
    font-size: 0.7em;
    transition: transform 0.25s;
}

.dropdown-menu {
    position: absolute;
    top: 100%;
    right: 0;
    padding-top: 14px; /* فضای بین - جزء ناحیه hover تا منو بسته نشود */
    opacity: 0;
    visibility: hidden;
    transform: translateY(10px);
    transition: opacity 0.25s ease, visibility 0.25s ease, transform 0.25s ease;
    z-index: 300;
}

.dropdown-menu-inner {
    background: #fff;
    border-radius: 10px;
    box-shadow: 0 6px 25px rgba(93, 64, 55, 0.18);
    min-width: 220px;
    padding: 8px 0;
    position: relative;
}

.dropdown-menu-inner::before {
    content: '';
    position: absolute;
    top: -6px;
    right: 20px;
    width: 12px;
    height: 12px;
    background: #fff;
    transform: rotate(45deg);
    border-radius: 2px;
}

.dropdown-menu-inner a {
    display: block;
    padding: 10px 22px;
    color: var(--text);
    text-decoration: none;
    transition: background 0.15s;
    white-space: nowrap;
}

.dropdown-menu-inner a:hover {
    background: var(--beige);
    color: var(--wood-dark);
}

/* دسکتاپ: نمایش با hover */
@media (min-width: 769px) {
    .nav-dropdown:hover .dropdown-menu {
        opacity: 1;
        visibility: visible;
        transform: translateY(0);
    }
    .nav-dropdown:hover .dd-arrow {
        transform: rotate(180deg);
    }
}

/* موبایل */
@media (max-width: 768px) {
    .dropdown-menu {
        position: static;
        padding-top: 0;
        opacity: 1;
        visibility: visible;
        transform: none;
        transition: none;
        display: none;
    }
    .nav-dropdown.open .dropdown-menu {
        display: block;
    }
    .nav-dropdown.open .dd-arrow {
        transform: rotate(180deg);
    }
    .dropdown-menu-inner {
        background: rgba(255, 255, 255, 0.08);
        box-shadow: none;
        border-radius: 8px;
        min-width: 100%;
        padding: 5px 0;
        margin-top: 8px;
    }
    .dropdown-menu-inner::before { display: none; }
    .dropdown-menu-inner a {
        color: var(--cream);
        padding-right: 30px;
        white-space: normal;
    }
    .dropdown-menu-inner a:hover {
        background: rgba(255, 255, 255, 0.12);
        color: var(--wood-light);
    }
}

/* ===== Layout صفحه محصولات با Sidebar ===== */
.products-layout {
    display: grid;
    grid-template-columns: 240px 1fr;
    gap: 30px;
    margin: 30px 0;
    align-items: start;
}

.category-sidebar {
    background: #fff;
    border-radius: 12px;
    padding: 22px;
    position: sticky;
    top: 95px;
    box-shadow: 0 2px 12px rgba(93, 64, 55, 0.08);
}

.category-sidebar h3 {
    color: var(--wood-dark);
    margin-bottom: 15px;
    font-size: 1.05rem;
    padding-bottom: 12px;
    border-bottom: 2px solid var(--beige);
}

.category-list {
    list-style: none;
}

.category-list li {
    margin-bottom: 4px;
}

.category-list a {
    display: block;
    padding: 10px 14px;
    color: var(--text);
    text-decoration: none;
    border-radius: 8px;
    transition: background 0.15s, color 0.15s;
    font-size: 0.95rem;
}

.category-list a:hover {
    background: var(--beige);
}

.category-list a.active {
    background: var(--accent);
    color: #fff;
    font-weight: bold;
}

.page-title {
    color: var(--wood-dark);
    margin-bottom: 22px;
    font-size: 1.6rem;
}

.no-products {
    color: #999;
    padding: 50px;
    text-align: center;
    grid-column: 1 / -1;
}

/* موبایل: دسته‌بندی‌ها به صورت افقی بالای صفحه */
@media (max-width: 768px) {
    .products-layout {
        grid-template-columns: 1fr;
        gap: 20px;
    }
    .category-sidebar {
        position: static;
        padding: 16px;
    }
    .category-sidebar h3 {
        margin-bottom: 12px;
        padding-bottom: 8px;
    }
    .category-list {
        display: flex;
        flex-wrap: wrap;
        gap: 8px;
    }
    .category-list li {
        margin-bottom: 0;
    }
    .category-list a {
        padding: 8px 14px;
        font-size: 0.88rem;
        background: var(--cream);
        border: 1px solid var(--beige);
    }
    .category-list a.active {
        background: var(--accent);
        border-color: var(--accent);
    }
}

/* ===== صفحه‌بندی ===== */
.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    margin: 40px 0;
    flex-wrap: wrap;
}

.page-btn {
    padding: 10px 18px;
    background: #fff;
    color: var(--wood-dark);
    text-decoration: none;
    border-radius: 8px;
    border: 1px solid var(--beige);
    transition: all 0.2s;
    font-size: 0.95rem;
}

.page-btn:hover {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
}

.page-btn.disabled {
    opacity: 0.4;
    cursor: not-allowed;
    pointer-events: none;
}

.page-numbers {
    display: flex;
    gap: 6px;
    align-items: center;
}

.page-num {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 40px;
    height: 40px;
    padding: 0 8px;
    background: #fff;
    color: var(--text);
    text-decoration: none;
    border-radius: 8px;
    border: 1px solid var(--beige);
    transition: all 0.2s;
}

.page-num:hover {
    border-color: var(--accent);
    color: var(--accent);
}

.page-num.active {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
    font-weight: bold;
}

.page-dots {
    color: #999;
    padding: 0 4px;
}

@media (max-width: 768px) {
    .pagination { gap: 5px; }
    .page-btn { padding: 8px 12px; font-size: 0.85rem; }
    .page-num { min-width: 36px; height: 36px; }
}

/* ===== مدیریت رسانه در پنل ادمین ===== */
.current-media-section {
    background: #fff;
    padding: 30px;
    border-radius: 12px;
    margin-top: 25px;
}

.current-media-section h3 {
    color: var(--wood-dark);
    margin-bottom: 10px;
}

.media-hint {
    color: #888;
    font-size: 0.9rem;
    margin-bottom: 20px;
}

.current-media-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 160px));
    gap: 15px;
}

.media-card {
    background: var(--cream);
    border-radius: 10px;
    overflow: hidden;
    border: 1px solid var(--beige);
    transition: transform 0.2s, box-shadow 0.2s;
}

.media-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 4px 12px rgba(93, 64, 55, 0.15);
}

.media-preview {
    position: relative;
    width: 100%;
    height: 120px;
    background: #eee;
    overflow: hidden;
}

.media-preview img,
.media-preview video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.media-type-badge {
    position: absolute;
    top: 6px;
    right: 6px;
    background: rgba(93, 64, 55, 0.85);
    color: #fff;
    padding: 2px 8px;
    border-radius: 20px;
    font-size: 0.7rem;
}

.media-type-badge.video {
    background: rgba(160, 82, 45, 0.85);
}

.media-actions {
    padding: 10px;
}

.media-filename {
    display: block;
    font-size: 0.72rem;
    color: #888;
    margin-bottom: 6px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    direction: ltr;
    text-align: right;
}

.btn-small {
    padding: 6px 10px;
    border-radius: 6px;
    border: none;
    cursor: pointer;
    font-size: 0.82rem;
    font-family: inherit;
}

.btn-delete {
    background: #e74c3c;
    color: #fff;
}

.btn-delete:hover {
    background: #c0392b;
}

@media (max-width: 768px) {
    .current-media-grid {
        grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
        gap: 10px;
    }
    .media-preview {
        height: 100px;
    }
}


/* ===== عکس اصلی در فرم ویرایش ===== */
.main-image-preview {
    display: inline-block;
    margin-bottom: 10px;
}

.main-image-preview img {
    width: 120px;
    height: 120px;
    object-fit: cover;
    border-radius: 8px;
    display: block;
    margin-bottom: 8px;
    border: 2px solid var(--beige);
}

/* دکمه حذف فقط در بخش گالری (media grid) تمام عرض باشد */
.media-actions .btn-delete {
    width: 100%;
}

/* دکمه‌های ویرایش و حذف در جدول لیست محصولات کنار هم بمانند */
.admin-table td form {
    display: inline-block;
    margin: 0;
}

.admin-table .btn-small {
    display: inline-block;
    width: auto;
}

/* ===== وضعیت محصول ===== */
.status-badge {
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 0.8rem;
    display: inline-block;
}

.status-badge.active {
    background: #d4edda;
    color: #155724;
}

.status-badge.inactive {
    background: #f8d7da;
    color: #721c24;
}

/* دکمه‌های toggle */
.btn-toggle-off {
    background: #ffc107;
    color: #333;
}
.btn-toggle-off:hover {
    background: #e0a800;
}

.btn-toggle-on {
    background: #28a745;
    color: #fff;
}
.btn-toggle-on:hover {
    background: #218838;
}

/* سلول عملیات در جدول */
.actions-cell {
    white-space: nowrap;
}

.actions-cell form {
    display: inline-block;
    margin: 0 2px;
}
