/* =========================================
   ЗАГАЛЬНІ СТИЛІ
   ========================================= */
body {
    font-family: Arial, sans-serif;
    margin: 0;
    padding: 0;
    background-color: #f4f4f4;
    color: #333;
}

main {
    padding: 30px 50px;
    min-height: 60vh;
}

/* =========================================
   ШАПКА ТА ПІДВАЛ (Header & Footer)
   ========================================= */
header {
    background-color: #cc0000;
    color: white;
    padding: 15px 50px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

header .logo h2 {
    margin: 0;
}

nav a {
    color: white;
    text-decoration: none;
    margin-left: 20px;
    font-weight: bold;
    text-transform: uppercase;
    font-size: 13px;
}

nav a:hover {
    color: #f1c40f;
}

footer {
    text-align: center;
    padding: 20px;
    background-color: #333;
    color: #ccc;
    margin-top: 40px;
}

/* =========================================
   ГОЛОВНА СТОРІНКА (Категорії)
   ========================================= */
.hero {
    text-align: center;
    padding-bottom: 30px;
}

.categories-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
}

.categories-grid a {
    text-decoration: none;
    display: flex;
    /* Дозволяє внутрішній картці розтягнутися на всю висоту ряду */
}

.category-card {
    background-color: white;
    padding: 30px;
    text-align: center;
    border-radius: 4px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    font-weight: bold;
    color: #333;
    text-transform: uppercase;
    transition: transform 0.2s, box-shadow 0.2s;
    border-bottom: 3px solid transparent;

    /* Нові налаштування для однакового розміру та центрування */
    width: 100%;
    display: flex;
    align-items: center;
    /* Центрує текст по вертикалі */
    justify-content: center;
    /* Центрує текст по горизонталі */
    min-height: 100px;
    /* Забезпечує однакову базу для всіх карток */
}

.category-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.15);
    border-bottom: 3px solid #cc0000;
}

/* =========================================
   СТОРІНКА КАТАЛОГУ (Сайдбар та Фільтри)
   ========================================= */
.category-layout {
    display: flex;
    gap: 30px;
}

.sidebar {
    width: 260px;
    background-color: #e5e5e5;
    flex-shrink: 0;
}

.sidebar-menu,
.sub-menu {
    list-style: none;
    padding: 0;
    margin: 0;
}

.sidebar-menu>li {
    border-bottom: 1px solid #d4d4d4;
}

.sidebar-menu a {
    display: block;
    padding: 15px 20px;
    text-decoration: none;
    color: #444;
    font-size: 13px;
    text-transform: uppercase;
}

.sidebar-menu>li>a:hover,
.sidebar-menu>li.active>a {
    background-color: #d1d1d1;
    font-weight: bold;
    color: #cc0000;
}

/* Підменю (Фільтри) */
.sub-menu {
    background-color: #f9f9f9;
}

.sub-menu a {
    padding: 10px 20px 10px 40px;
    text-transform: none;
}

.sub-menu li.active-sub a,
.sub-menu a:hover {
    color: #cc0000;
    background-color: #eee;
    font-weight: bold;
}

/* =========================================
   ОСНОВНА ЧАСТИНА З ТОВАРАМИ
   ========================================= */
.main-content {
    flex-grow: 1;
}

.category-title {
    margin-top: 0;
    font-weight: normal;
    border-bottom: 1px solid #ccc;
    padding-bottom: 15px;
    margin-bottom: 20px;
}

.sorting-bar {
    margin-bottom: 25px;
}

.sorting-bar select {
    padding: 8px 12px;
    border: 1px solid #ddd;
    outline: none;
}

/* =========================================
   СІТКА ТОВАРІВ (Products Grid)
   ========================================= */
.products-grid {
    display: grid;
    /* auto-fill забороняє карткам розтягуватися на всю ширину, якщо їх мало */
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 20px;
    align-items: start;
    /* Картки не будуть тягнутися по висоті екрана */
}

.product-card {
    background-color: white;
    padding: 20px;
    border: 1px solid #eee;
    text-align: center;
    display: flex;
    flex-direction: column;
    transition: box-shadow 0.3s;
    min-height: 380px;
    /* Мінімальна висота картки */
}

.product-card:hover {
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
}

.product-image {
    margin-bottom: 15px;
    height: 180px;
    /* Фіксована висота для блоку з фото */
    display: flex;
    align-items: center;
    justify-content: center;
}

.product-image img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    /* Фото буде пропорційно вписуватися в квадрат без обрізки */
}

.product-card h3 {
    font-size: 14px;
    font-weight: normal;
    margin: 10px 0;
    color: #333;
    line-height: 1.4;
    flex-grow: 1;
    /* Автоматично штовхає ціну та кнопку в самий низ картки */
}

.product-card .price {
    font-size: 20px;
    font-weight: bold;
    color: #333;
    margin: 15px 0;
}

.product-description {
    font-size: 12px;
    color: #666;
    /* Сірий колір для другорядного тексту */
    margin: 5px 0 10px;
    line-height: 1.4;

    /* Обмежуємо текст рівно до 3 рядків. Зайве обрізається з трикрапкою (...) */
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Сіра кнопка як на скриншоті */
.btn-buy {
    background-color: #6c757d;
    color: white;
    padding: 12px;
    border: none;
    border-radius: 25px;
    /* Трохи заокруглені краї */
    cursor: pointer;
    text-transform: uppercase;
    font-size: 13px;
    font-weight: bold;
    transition: background-color 0.2s;
    width: 100%;
}

.btn-buy:hover {
    background-color: #5a6268;
}

/* =========================================
   АДМІН ПАНЕЛЬ (Додавання товару)
   ========================================= */
.admin-container {
    max-width: 600px;
    margin: 0 auto;
    background-color: white;
    padding: 30px;
    border-radius: 4px;
}

.admin-container h2 {
    margin-top: 0;
    border-bottom: 2px solid #cc0000;
    padding-bottom: 10px;
}

.form-group {
    margin-bottom: 15px;
}

.form-group label {
    display: block;
    margin-bottom: 5px;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 10px;
    border: 1px solid #ccc;
    box-sizing: border-box;
}

.btn-submit {
    background-color: #cc0000;
    color: white;
    padding: 12px;
    border: none;
    width: 100%;
    text-transform: uppercase;
    font-weight: bold;
    cursor: pointer;
}

.alert {
    padding: 10px;
    margin-bottom: 15px;
    border-radius: 4px;
}

.alert-success {
    background-color: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.alert-danger {
    background-color: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

/* Таблиця адмін-панелі */
.admin-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 20px;
}

.admin-table th,
.admin-table td {
    border: 1px solid #ddd;
    padding: 12px;
    text-align: center;
    vertical-align: middle;
}

.admin-table th {
    background-color: #f4f4f4;
    font-size: 14px;
}

.btn-edit {
    background-color: #f39c12;
    color: white;
    padding: 6px 12px;
    text-decoration: none;
    border-radius: 4px;
    font-size: 12px;
    font-weight: bold;
}

.btn-promo {
    background-color: #2ecc71;
    color: white;
    padding: 6px 12px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
    font-weight: bold;
}

.btn-delete {
    background-color: #e74c3c;
    color: white;
    padding: 6px 12px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
    font-weight: bold;
}

.btn-edit:hover {
    background-color: #e67e22;
}

.btn-promo:hover {
    background-color: #27ae60;
}

.btn-delete:hover {
    background-color: #c0392b;
}

/* =========================================
   СТИЛІ ДЛЯ АКЦІЙ (Promo Styles)
   ========================================= */
.product-card {
    position: relative;
    /* Обов'язково, щоб бейдж тримався за картку */
}

.promo-badge {
    position: absolute;
    top: 10px;
    left: 10px;
    background-color: #e74c3c;
    /* Червоний колір */
    color: white;
    padding: 5px 12px;
    font-size: 12px;
    font-weight: bold;
    border-radius: 3px;
    text-transform: uppercase;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
    z-index: 2;
}

.price-container {
    margin: 15px 0;
    display: flex;
    flex-direction: column;
    /* Ставимо ціни одна над одною (або змініть на row для поруч) */
    align-items: center;
    gap: 5px;
}

.old-price {
    text-decoration: line-through;
    color: #999;
    font-size: 14px;
}

.new-price {
    color: #e74c3c;
    font-size: 22px;
    font-weight: bold;
}

/* ПАНЕЛЬ ДОДАВАННЯ (Гармошка) */
.admin-add-panel {
    background: white;
    border: 1px solid #ddd;
    border-radius: 4px;
    margin-bottom: 20px;
}

.admin-add-panel summary {
    padding: 15px 20px;
    font-size: 16px;
    font-weight: bold;
    color: #cc0000;
    cursor: pointer;
    list-style: none;
    outline: none;
    background-color: #f9f9f9;
}

.admin-add-panel summary::-webkit-details-marker {
    display: none;
}

/* Ховаємо стандартний трикутник */
.admin-add-panel .panel-content {
    padding: 20px;
    border-top: 1px solid #ddd;
}

/* ПАНЕЛЬ ПОШУКУ */
.admin-search-bar {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
    background: #f4f4f4;
    padding: 15px;
    border-radius: 4px;
    align-items: center;
}

.admin-search-bar input,
.admin-search-bar select {
    padding: 10px;
    border: 1px solid #ccc;
    border-radius: 4px;
    flex: 1;
    /* Рівномірно розтягує поля */
}

.btn-search {
    background-color: #3498db;
    color: white;
    padding: 10px 20px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-weight: bold;
}

.btn-search:hover {
    background-color: #2980b9;
}

.btn-clear {
    background-color: #95a5a6;
    color: white;
    padding: 10px 20px;
    border-radius: 4px;
    text-decoration: none;
    font-weight: bold;
}

.btn-clear:hover {
    background-color: #7f8c8d;
}

/* =========================================
   СУЧАСНА СТОРІНКА ТОВАРУ
   ========================================= */
.product-wrapper {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px 0;
}

.breadcrumbs {
    font-size: 13px;
    color: #777;
    margin-bottom: 30px;
}

.breadcrumbs a {
    color: #333;
    text-decoration: none;
}

.breadcrumbs a:hover {
    color: #cc0000;
}

.product-main-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 50px;
    background: white;
    padding: 40px;
    border-radius: 16px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.04);
    margin-bottom: 40px;
}

/* Фото та Лупа */
.product-gallery-modern {
    display: flex;
    align-items: center;
    justify-content: center;
}

.image-zoom-container {
    width: 100%;
    height: 450px;
    position: relative;
    overflow: hidden;
    /* Обрізає все, що виходить за межі при зумі */
    border-radius: 12px;
    background: #fdfdfd;
    cursor: crosshair;
}

.zoom-image {
    width: 100%;
    height: 100%;
    object-fit: contain;
    transition: transform 0.2s ease, transform-origin 0.2s ease;
}

/* Бейджі на фото */
/* Бейджі на фото */
.badges-container {
    position: absolute;
    top: 20px;
    left: 20px;
    /* Чітко фіксуємо в лівому верхньому куті */
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    /* Вирівнюємо бейджі по лівому краю */
    gap: 10px;
    z-index: 10;
}

.modern-badge {
    padding: 8px 16px;
    border-radius: 6px;
    /* Сучасні стильні кути замість овалу */
    font-size: 13px;
    font-weight: 900;
    color: white;
    letter-spacing: 1px;
    text-transform: uppercase;
    box-shadow: 0 5px 15px rgba(220, 20, 60, 0.3);
    /* М'яка кольорова тінь */
}

.promo-badge {
    background: linear-gradient(135deg, #e74c3c, #c0392b);
    /* Насичений і преміальний червоний */
}

.low-stock-badge {
    background: linear-gradient(135deg, #f39c12, #d35400);
    /* Глибокий помаранчевий для залишків */
    box-shadow: 0 5px 15px rgba(211, 84, 0, 0.3);
}

/* Бейджі на фото */
.badges-container {
    position: absolute;
    top: 20px;
    left: 20px;
    /* Надійний відступ від країв, щоб бейдж "дихав" */
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
    z-index: 10;
}

.modern-badge {
    padding: 6px 12px;
    /* Зменшили внутрішні відступи */
    border-radius: 4px;
    /* Більш класичні, акуратні кути */
    font-size: 12px;
    /* Зменшили шрифт для пропорційності */
    font-weight: bold;
    color: white;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
    /* Дуже легка, природна тінь */
}

.promo-badge {
    background-color: #e33939;
    /* Чистий і приємний червоний колір без градієнтів */
}

.low-stock-badge {
    background-color: #f39c12;
    /* Чистий помаранчевий */
}

/* Права колонка: Інфо */
.meta-info {
    display: flex;
    justify-content: space-between;
    font-size: 13px;
    color: #777;
    margin-bottom: 15px;
}

.meta-info a {
    color: #3498db;
    text-decoration: none;
}

.modern-title {
    font-size: 28px;
    line-height: 1.3;
    margin-top: 0;
    color: #222;
}

/* Прогрес бар наявності */
.stock-progress {
    margin: 20px 0;
    background: #f9f9f9;
    padding: 15px;
    border-radius: 8px;
}

.stock-progress .status {
    margin: 0 0 8px 0;
    font-size: 13px;
    font-weight: bold;
}

.status.green {
    color: #27ae60;
}

.status.orange {
    color: #e67e22;
}

.status.red {
    color: #c0392b;
}

.progress-bar {
    height: 6px;
    background: #e0e0e0;
    border-radius: 3px;
    overflow: hidden;
}

.progress-bar .fill {
    height: 100%;
    border-radius: 3px;
    transition: width 0.5s ease;
}

.fill.green {
    background: #27ae60;
}

.fill.orange {
    background: #e67e22;
}

.fill.red {
    background: #c0392b;
}

/* Ціна */
.price-box-modern {
    display: flex;
    align-items: baseline;
    flex-wrap: wrap;
    gap: 15px;
    margin: 30px 0;
}

.price-current {
    font-size: 36px;
    font-weight: 900;
    color: #222;
}

.price-current span {
    font-size: 20px;
    font-weight: normal;
}

.price-current.promo-color {
    color: #e74c3c;
}

.price-old {
    font-size: 20px;
    color: #999;
    text-decoration: line-through;
}

.save-tag {
    background: #e74c3c;
    color: white;
    padding: 4px 10px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: bold;
}

/* Кнопки та кількість */
.action-panel {
    display: flex;
    gap: 15px;
    margin-bottom: 15px;
}

.qty-modern {
    display: flex;
    background: #f4f4f4;
    border-radius: 8px;
    overflow: hidden;
}

.qty-modern button {
    width: 45px;
    border: none;
    background: transparent;
    font-size: 20px;
    cursor: pointer;
    color: #555;
    transition: 0.2s;
}

.qty-modern button:hover {
    background: #e0e0e0;
}

.qty-modern input {
    width: 50px;
    text-align: center;
    border: none;
    background: transparent;
    font-size: 16px;
    font-weight: bold;
    outline: none;
}

.btn-primary-modern {
    flex: 1;
    background: #cc0000;
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: bold;
    cursor: pointer;
    transition: 0.3s;
    box-shadow: 0 4px 15px rgba(204, 0, 0, 0.3);
}

.btn-primary-modern:hover:not(:disabled) {
    background: #a30000;
    transform: translateY(-2px);
}

.btn-primary-modern:disabled {
    background: #ccc;
    box-shadow: none;
    cursor: not-allowed;
}

.btn-secondary-modern {
    width: 100%;
    background: white;
    color: #333;
    border: 2px solid #ddd;
    border-radius: 8px;
    padding: 15px;
    font-size: 15px;
    font-weight: bold;
    cursor: pointer;
    transition: 0.2s;
}

.btn-secondary-modern:hover {
    border-color: #333;
}

/* Переваги (Trust features) */
.trust-features {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 10px;
    margin-top: 30px;
    border-top: 1px solid #eee;
    padding-top: 20px;
}

.feature {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    font-size: 12px;
    color: #666;
    line-height: 1.4;
}

.feature .icon {
    font-size: 24px;
    margin-bottom: 5px;
}

/* Вкладки внизу */
.product-details-tabs {
    background: white;
    border-radius: 16px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.04);
    overflow: hidden;
}

.tab-headers {
    display: flex;
    background: #f9f9f9;
    border-bottom: 1px solid #eee;
}

.tab-btn {
    flex: 1;
    padding: 20px;
    border: none;
    background: transparent;
    font-size: 15px;
    font-weight: bold;
    color: #777;
    cursor: pointer;
    transition: 0.3s;
    border-bottom: 3px solid transparent;
    outline: none;
}

.tab-btn:hover {
    color: #333;
}

.tab-btn.active {
    color: #cc0000;
    border-bottom-color: #cc0000;
    background: white;
}

.tab-body {
    padding: 40px;
}

.tab-content {
    display: none;
    animation: fadeIn 0.4s ease;
}

.tab-content.active {
    display: block;
}

.formatted-text {
    line-height: 1.8;
    color: #555;
    white-space: pre-wrap;
    font-size: 15px;
}

.specs-table {
    width: 100%;
    border-collapse: collapse;
}

.specs-table td {
    padding: 15px;
    border-bottom: 1px solid #eee;
    color: #555;
}

.specs-table td:first-child {
    font-weight: bold;
    color: #333;
    width: 40%;
}

.empty-reviews {
    text-align: center;
    padding: 40px 0;
}

.emoji-big {
    font-size: 48px;
    margin-bottom: 15px;
}

.btn-leave-review {
    margin-top: 15px;
    padding: 10px 20px;
    background: #3498db;
    color: white;
    border: none;
    border-radius: 20px;
    cursor: pointer;
    font-weight: bold;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Приховуємо стандартні стрілочки браузера для полів вводу чисел */
input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

input[type="number"] {
    -moz-appearance: textfield;
    /* Правило для браузера Firefox */
}