:root { 
    --bg: #050505; 
    --gold: #d4af37; 
    --gold-hover: #f1c40f;
    --text: #ffffff; 
    --text-muted: #888888;
    --border: #1a1a1a; 
    --font: 'Montserrat', sans-serif; 
}

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

body { 
    background: var(--bg); color: var(--text); font-family: var(--font); line-height: 1.6;
    background-image: linear-gradient(to right, #0a0a0a 1px, transparent 1px), linear-gradient(to bottom, #0a0a0a 1px, transparent 1px); 
    background-size: 40px 40px; 
    overflow-x: hidden; /* Защита от горизонтального скролла */
}

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

/* Анимация и Главная */
@keyframes float { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-15px); } }
.floating-logo { width: 320px; max-width: 80%; animation: float 5s ease-in-out infinite; filter: drop-shadow(0 5px 20px rgba(212, 175, 55, 0.3)); }
.hero { height: 100vh; min-height: 500px; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 20px; }
.hero h1 { font-size: 48px; color: var(--gold); text-transform: uppercase; margin: 20px 0; letter-spacing: 2px; font-weight: 900; word-wrap: break-word; }
.hero p { color: var(--text-muted); letter-spacing: 4px; font-size: 14px; margin-bottom: 40px; text-transform: uppercase; }

/* Кнопки */
.btn-gold { 
    background: linear-gradient(135deg, #d4af37, #a68a2d); color: #000; padding: 12px 30px; 
    text-decoration: none; font-weight: 900; text-transform: uppercase; border: none; cursor: pointer;
    clip-path: polygon(0 0, 100% 0, 95% 100%, 0% 100%); transition: 0.3s; display: inline-block; text-align: center;
}
.btn-gold:hover { transform: scale(1.05); background: var(--gold-hover); }
.btn-outline { background: transparent; border: 1px solid var(--border); color: #fff; padding: 10px 20px; cursor: pointer; font-weight: 700; transition: 0.3s; text-decoration: none; display: inline-block; text-align: center; }
.btn-outline:hover, .btn-outline.active { border-color: var(--gold); color: var(--gold); }

/* Кнопки мессенджеров */
.product-actions { display: flex; gap: 15px; flex-wrap: wrap; }
.btn-telegram, .btn-whatsapp { display: inline-flex; justify-content: center; align-items: center; color: #fff; text-decoration: none; padding: 10px 20px; font-size: 14px; font-weight: 700; border-radius: 4px; flex-grow: 1; text-align: center; transition: 0.3s; }
.btn-telegram { background: #0088cc; }
.btn-whatsapp { background: #25d366; }
.btn-telegram:hover, .btn-whatsapp:hover { transform: scale(1.02); filter: brightness(1.1); }

/* Выпадающее меню */
.dropdown { position: relative; display: inline-block; }
.dropdown-content { 
    display: none; position: absolute; background-color: #0a0a0a; min-width: 220px; 
    box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.9); z-index: 1000; border: 1px solid var(--border); border-top: 3px solid var(--gold); top: 100%; left: 0;
}
.dropdown-content a { color: #fff; padding: 12px 16px; text-decoration: none; display: block; border-bottom: 1px solid #111; transition: 0.3s; }
.dropdown-content a:hover { background-color: #111; color: var(--gold); padding-left: 20px; }
.dropdown:hover .dropdown-content { display: block; }

/* ПРЕМИАЛЬНЫЕ КАРТОЧКИ ТОВАРОВ */
.product-grid { 
    display: grid; 
    /* Немного уменьшили минимальную ширину для планшетов */
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); 
    gap: 30px; 
}
.product-card { 
    background: linear-gradient(145deg, #111111, #0a0a0a);
    border: 1px solid #1f1f1f; 
    transition: all 0.4s ease; 
    display: flex; 
    flex-direction: column; 
    height: 100%;
    position: relative;
    overflow: hidden; /* Чтобы ничего не выпирало */
}
.product-card::before {
    content: '';
    position: absolute;
    top: 0; left: 0; width: 100%; height: 2px;
    background: linear-gradient(90deg, transparent, var(--gold), transparent);
    opacity: 0;
    transition: 0.4s ease;
    z-index: 10;
}
.product-card:hover { 
    border-color: #333; 
    transform: translateY(-5px); 
    box-shadow: 0 15px 30px rgba(0,0,0,0.8); 
}
.product-card:hover::before { opacity: 1; }

.card-image-wrap { 
    max-height: 240px; 
    overflow: hidden; 
    background: #000; 
    position: relative;
    padding: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
}
.card-image-wrap img { 
    width: 100%; 
    height: 220px; /* Фиксируем высоту для ровной сетки */
    object-fit: contain; 
    transition: transform 0.7s ease, opacity 0.3s ease;
    opacity: 1; 
}
.product-card:hover .card-image-wrap img { 
    transform: scale(1.08); 
    opacity: 1; 
}

.card-badge {
    position: absolute;
    top: 15px; left: 15px;
    background: rgba(0,0,0,0.8);
    color: var(--gold);
    padding: 5px 10px;
    font-size: 10px;
    font-weight: 900;
    letter-spacing: 1px;
    text-transform: uppercase;
    border: 1px solid var(--gold);
    z-index: 2;
}

.card-info { 
    padding: 20px; 
    display: flex; 
    flex-direction: column; 
    flex-grow: 1; 
    justify-content: space-between; 
}
.card-info h3 {
    font-size: 16px;
    font-weight: 800;
    text-transform: uppercase;
    margin-bottom: 15px;
    line-height: 1.4;
    word-break: break-word; /* Если название слишком длинное */
}
.card-info h3 a { color: #fff; text-decoration: none; transition: 0.3s; }
.card-info h3 a:hover { color: var(--gold); }
.card-action {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-top: 1px solid #1f1f1f;
    padding-top: 15px;
    margin-top: auto;
    flex-wrap: wrap;
    gap: 10px;
}
.product-price { color: var(--gold); font-weight: 900; font-size: 18px; }

.btn-buy-mini {
    background: transparent;
    color: var(--gold);
    border: 1px solid var(--gold);
    padding: 8px 15px;
    font-size: 10px;
    font-weight: 900;
    text-transform: uppercase;
    text-decoration: none;
    transition: 0.3s;
    white-space: nowrap;
}
.btn-buy-mini:hover { background: var(--gold); color: #000; }

/* Страница Категории и Фильтр */
.category-layout { display: grid; grid-template-columns: 280px 1fr; gap: 40px; align-items: start; }
.sidebar-filter { background: #0a0a0a; padding: 25px; border: 1px solid var(--border); border-top: 3px solid var(--gold); border-radius: 4px; position: sticky; top: 100px; }
.filter-label { color: var(--gold); font-size: 11px; font-weight: 800; margin-bottom: 8px; display: block; text-transform: uppercase; letter-spacing: 1px; }
.filter-select { width: 100%; background: #000; color: #fff; border: 1px solid #222; padding: 12px; margin-bottom: 20px; font-family: var(--font); outline: none; transition: 0.3s; }
.filter-select:focus { border-color: var(--gold); }

/* Детальная страница товара */
.product-layout { display: grid; grid-template-columns: 1fr 1fr; gap: 50px; }
.main-img-view img { width: 100%; max-height: 500px; object-fit: contain; border: 1px solid var(--border); background: #000; }
.product-media-showcase .main-img-view { border-radius: 4px; overflow: hidden; }
.gallery-thumbs-strip {
    display: flex;
    flex-wrap: nowrap;
    align-items: center;
    gap: 10px;
    margin-top: 16px;
    max-height: 80px;
    overflow-x: auto;
    overflow-y: hidden;
    padding-bottom: 8px;
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
    flex-shrink: 0;
}
.gallery-thumb {
    flex: 0 0 auto;
    padding: 0;
    margin: 0;
    border: 2px solid var(--border);
    background: #0a0a0a;
    cursor: pointer;
    border-radius: 4px;
    overflow: hidden;
    scroll-snap-align: start;
    transition: border-color 0.25s, box-shadow 0.25s;
}
.gallery-thumb img { width: 88px; height: 66px; object-fit: cover; display: block; vertical-align: middle; opacity: 0.85; transition: opacity 0.25s; }
.gallery-thumb:hover img, .gallery-thumb.active img { opacity: 1; }
.gallery-thumb.active { border-color: var(--gold); box-shadow: 0 0 0 1px rgba(212, 175, 55, 0.35); }

/* Модальное окно */
.modal-overlay { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.9); z-index: 10000; overflow-y: auto; padding: 20px; display: flex; align-items: center; justify-content: center; }
.modal-content { 
    background: #111; padding: 40px; border: 1px solid #1a1a1a; max-width: 500px; width: 100%; 
    position: relative; margin: auto;
}
.modal-close { position: absolute; top: 10px; right: 15px; color: var(--gold); font-size: 24px; cursor: pointer; }

/* Админка */
.admin-panel { background: #111; padding: 30px; border: 1px solid var(--border); margin-bottom: 30px; }
.form-control { width: 100%; padding: 12px; background: #000; border: 1px solid var(--border); color: #fff; margin-bottom: 15px; font-family: var(--font); }
.form-control:focus { border-color: var(--gold); outline: none; }
table { width: 100%; border-collapse: collapse; margin-top: 15px; }
th { background: #1a1a1a; padding: 12px; text-align: left; color: var(--gold); font-size: 12px; }
td { padding: 12px; border-bottom: 1px solid #1a1a1a; word-break: break-word; }

/* СТАТУСЫ НАЛИЧИЯ (ТОЧКИ) */
.status-badge { 
    display: inline-flex; align-items: center; gap: 8px; font-size: 11px; font-weight: 800; 
    text-transform: uppercase; padding: 6px 12px; border-radius: 4px; border: 1px solid var(--border); 
    background: #0a0a0a; margin-bottom: 15px; letter-spacing: 1px;
}
.dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; box-shadow: 0 0 8px currentColor; }
.dot-in_stock { background: #25d366; color: #25d366; }
.dot-in_transit { background: #f1c40f; color: #f1c40f; }
.dot-on_order { background: #0088cc; color: #0088cc; }

/* Калькулятор ползунки */
.range-slider { width: 100%; margin: 10px 0 25px; accent-color: var(--gold); }
.calc-result-box { background: #000; border: 1px solid var(--gold); padding: 20px; margin-top: 20px; text-align: center; }

/* ========================================= */
/* АДАПТИВНОСТЬ (RESPONSIVE DESIGN)          */
/* ========================================= */

/* Планшеты (до 900px) */
@media (max-width: 900px) {
    .category-layout, .product-layout { grid-template-columns: 1fr; }
    .sidebar-filter { position: static; margin-bottom: 30px; }
    .hero h1 { font-size: 36px; }
}

/* Мобильные телефоны (до 600px) */
@media (max-width: 600px) {
    /* Фикс карточек: на мобилке карточка занимает 100% ширины, чтобы ничего не съезжало */
    .product-grid { grid-template-columns: 1fr; gap: 20px; }
    
    .hero h1 { font-size: 28px; }
    .hero p { font-size: 11px; letter-spacing: 2px; }
    
    /* Шапка сайта: выстраиваем элементы в колонку */
    header .container { 
        flex-direction: column; 
        gap: 15px; 
        text-align: center;
    }
    header form { 
        margin: 0 !important; 
        width: 100%; 
        max-width: 100% !important; 
    }
    header nav { 
        flex-wrap: wrap; 
        justify-content: center; 
        gap: 15px; 
    }
    
    /* Кнопка телефона в шапке */
    .btn-outline { font-size: 12px; padding: 8px 15px; }
    
    /* Подвал сайта: центруем текст и убираем сдвиг вправо */
    footer .container { 
        grid-template-columns: 1fr; 
        text-align: center; 
        gap: 30px; 
    }
    footer .container > div { text-align: center !important; }
    
    /* Детальная страница товара */
    .product-details h1 { font-size: 24px; }
    .product-price { font-size: 26px; }
    .btn-gold, .btn-outline { width: 100%; box-sizing: border-box; }

    /* Пагинация: номера страниц не должны растягиваться на 100% */
    .pagination-wrap .btn-outline,
    .pagination-wrap .page-current {
        width: auto;
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }
    
    /* Админка на мобилке */
    .admin-tabs { display: flex; flex-direction: column; gap: 5px; }
    .admin-panel { padding: 15px; }
    .modal-content { padding: 20px; }
}
/* ========================================= */
/* ПЛИТКА КАТЕГОРИЙ (МОДАЛЬНОЕ ОКНО)         */
/* ========================================= */
.catalog-modal-content { 
    max-width: 1000px !important; 
    width: 95% !important; 
    background: #0a0a0a; 
    border: 1px solid var(--gold); 
    max-height: 90vh;
    overflow-y: auto;
}
.category-tiles { 
    display: grid; 
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); 
    gap: 20px; 
}
.cat-tile-card { 
    display: block; 
    background: #111; 
    border: 1px solid var(--border); 
    text-decoration: none; 
    transition: 0.3s; 
    position: relative; 
    overflow: hidden; 
    border-radius: 4px; 
    height: 180px;
}
.cat-tile-card img { 
    width: 100%; 
    height: 100%; 
    object-fit: cover; 
    transition: 0.5s; 
    opacity: 0.6; 
}
.cat-tile-card:hover { 
    border-color: var(--gold); 
    transform: translateY(-5px); 
    box-shadow: 0 10px 20px rgba(0,0,0,0.8);
}
.cat-tile-card:hover img { 
    transform: scale(1.1); 
    opacity: 1; 
}
.cat-tile-name { 
    position: absolute; 
    bottom: 0; 
    left: 0;
    width: 100%; 
    padding: 20px 15px 15px; 
    text-align: center; 
    color: #fff; 
    font-weight: 900; 
    font-size: 14px; 
    text-transform: uppercase; 
    background: linear-gradient(to top, rgba(0,0,0,1), transparent); 
    z-index: 2;
}

@media (max-width: 600px) {
    .category-tiles { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }
    .cat-tile-card { height: 120px; }
    .cat-tile-name { font-size: 11px; padding: 10px; }
}
/* Улучшения для детальной страницы товара */
.product-media { display: flex; flex-direction: column; }
.specs-block { 
    background: rgba(255,255,255,0.02); 
    padding: 20px; 
    border-left: 2px solid var(--gold);
}

/* Адаптивность для мобилок */
@media (max-width: 600px) {
    /* Ограничиваем высоту картинки, чтобы она не занимала весь экран */
    .main-img-view img { 
        max-height: 320px; 
        object-fit: contain;
        background: #000;
        border: none;
    }
    
    /* Убираем лишние отступы в сетке */
    .product-layout { gap: 25px; }
    
    /* Делаем галерею миниатюр компактнее */
    .gallery-thumb img {
        width: 64px;
        height: 48px;
    }

    /* Название товара на мобилке делаем чуть компактнее */
    .product-top-header h1 {
        font-size: 26px !important;
    }
    
    /* Кнопки мессенджеров во всю ширину */
    .btn-telegram, .btn-whatsapp {
        padding: 12px 5px;
        font-size: 12px;
    }
}
.product-top-header { margin-bottom: 30px; }
.product-media { display: flex; flex-direction: column; }
.specs-block { background: rgba(255,255,255,0.02); padding: 20px; border-left: 2px solid #d4af37; }
@media (max-width: 600px) {
    .main-img-view img { max-height: 320px; object-fit: contain; background: #000; border: none; }
    .product-layout { gap: 25px; }
    .gallery-thumb img { width: 60px; height: 45px; }
    .product-top-header h1 { font-size: 26px !important; }
    .btn-telegram, .btn-whatsapp { padding: 12px 5px; font-size: 12px; }
}

/* Редактор галереи (админка) */
/* Не использовать width/height:0 — браузеры могут не отправлять такой file input */
.pg-hidden-files {
    position: absolute !important;
    left: -9999px !important;
    top: 0 !important;
    width: 1px !important;
    height: 1px !important;
    opacity: 0 !important;
    overflow: hidden !important;
}
.pg-dropzone {
    border: 2px dashed #333;
    border-radius: 8px;
    padding: 24px 16px;
    text-align: center;
    background: linear-gradient(145deg, #0d0d0d, #080808);
    margin-bottom: 16px;
    transition: border-color 0.25s, background 0.25s;
    cursor: pointer;
    outline: none;
}
.pg-dropzone:focus-visible { border-color: var(--gold); }
.pg-dropzone.pg-dz-active { border-color: var(--gold); background: #111; }
.pg-dropzone-inner .pg-dz-text { display: block; color: #888; font-size: 13px; margin-bottom: 4px; }
.pg-list {
    list-style: none;
    margin: 0;
    padding: 4px 4px 8px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-height: min(480px, 55vh);
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
}
.pg-item {
    display: grid;
    grid-template-columns: 36px 100px 1fr 36px;
    align-items: center;
    gap: 12px;
    background: #0a0a0a;
    border: 1px solid #222;
    border-radius: 6px;
    padding: 10px 12px;
    transition: box-shadow 0.2s;
}
.pg-item.pg-dragging { opacity: 0.6; box-shadow: 0 8px 24px rgba(0,0,0,0.6); }
.pg-handle {
    color: #666;
    cursor: grab;
    font-size: 14px;
    user-select: none;
    text-align: center;
}
.pg-thumb-wrap {
    width: 100px;
    height: 75px;
    border-radius: 4px;
    overflow: hidden;
    border: 1px solid #333;
    background: #000;
}
.pg-thumb { width: 100%; height: 100%; object-fit: cover; display: block; }
.pg-badge {
    font-size: 11px;
    font-weight: 800;
    color: var(--gold);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.pg-del {
    width: 32px;
    height: 32px;
    border: 1px solid #444;
    background: #111;
    color: #c62828;
    border-radius: 4px;
    cursor: pointer;
    font-size: 18px;
    line-height: 1;
    padding: 0;
    transition: 0.2s;
}
.pg-del:hover { border-color: #c62828; background: #1a0a0a; }
.pg-counter { font-size: 12px; color: #666; margin: 8px 0 0; }