/* --- ЗМІННІ КОЛЬОРІВ (СВІТЛА ТЕМА ЗА ЗАМОВЧУВАННЯМ) --- */
:root {
    --primary: #00b359;       /* Темніший зелений для білого фону */
    --primary-text: #ffffff;  /* Текст на зеленій кнопці */
    --bg-color: #f4f6f8;      /* Світлий фон сторінки */
    --card-bg: #ffffff;       /* Білі картки */
    --text: #2c3e50;          /* Темний текст */
    --text-muted: #6c757d;    /* Сірий текст опису */
    --border-color: #ddd;     /* Світлі рамки */
    --modal-overlay: rgba(0, 0, 0, 0.5);
    --input-bg: #ffffff;
    --red: #ff4444;
}

/* --- ТЕМНА ТЕМА (Вмикається класом .dark-mode) --- */
body.dark-mode {
    --primary: #00ff88;       /* Неоновий зелений */
    --primary-text: #121212;
    --bg-color: #121212;
    --card-bg: #1e1e1e;
    --text: #ffffff;
    --text-muted: #b0b0b0;
    --border-color: #333;
    --modal-overlay: rgba(0, 0, 0, 0.85);
    --input-bg: #333;
}

/* --- ЗАГАЛЬНІ СТИЛІ --- */
* { margin: 0; padding: 0; box-sizing: border-box; font-family: 'Segoe UI', sans-serif; -webkit-tap-highlight-color: transparent; }
button, a, input, .product-card, .floating-cart, .close-modal, .theme-btn { touch-action: manipulation; }

body { 
    background-color: var(--bg-color); 
    color: var(--text); 
    overflow-x: hidden; 
    transition: background-color 0.3s, color 0.3s; 
}

/* --- ЛОАДЕР --- */
#loader-wrapper { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: var(--bg-color); z-index: 9999; display: flex; justify-content: center; align-items: center; flex-direction: column; transition: opacity 0.5s ease; }
.battery-loader { width: 80px; height: 40px; border: 3px solid var(--primary); border-radius: 5px; position: relative; padding: 3px; }
.battery-loader::after { content: ''; position: absolute; right: -8px; top: 10px; width: 5px; height: 14px; background: var(--primary); border-radius: 0 3px 3px 0; }
.battery-level { height: 100%; background: var(--primary); width: 0%; border-radius: 2px; animation: charge 2s infinite linear; }
@keyframes charge { 0% { width: 0%; opacity: 1; } 50% { width: 100%; opacity: 1; } 55% { opacity: 0; } 100% { opacity: 0; width: 0; } }
.loading-text { margin-top: 15px; color: var(--primary); letter-spacing: 2px; font-size: 0.9rem; text-transform: uppercase; font-weight: bold; }

/* --- НАВІГАЦІЯ --- */
nav { display: flex; justify-content: space-between; align-items: center; padding: 15px 5%; background: var(--card-bg); position: sticky; top: 0; z-index: 100; border-bottom: 1px solid var(--border-color); transition: background 0.3s; box-shadow: 0 2px 10px rgba(0,0,0,0.05); }
.logo { font-size: 1.5rem; font-weight: bold; color: var(--text); }
.logo span { color: var(--primary); }

.nav-controls { display: flex; align-items: center; gap: 20px; }
.nav-links { display: flex; gap: 20px; }
.nav-links a { color: var(--text-muted); text-decoration: none; transition: 0.3s; font-size: 1rem; padding: 5px; font-weight: 500; }
.nav-links a:hover { color: var(--primary); }

/* Кнопка теми */
.theme-btn { background: none; border: none; font-size: 1.2rem; color: var(--text); cursor: pointer; padding: 5px; transition: 0.3s; }
.theme-btn:hover { color: var(--primary); transform: rotate(15deg); }

@media (max-width: 768px) {
    nav { flex-wrap: wrap; }
    .nav-controls { width: 100%; justify-content: space-between; margin-top: 10px; }
    .nav-links { gap: 15px; font-size: 0.9rem; }
}

/* --- ГЕРОЙ --- */
header { text-align: center; padding: 100px 20px; background: linear-gradient(rgba(0,0,0,0.6), rgba(0,0,0,0.6)), url('https://images.unsplash.com/photo-1558449028-b53a39d100fc?ixlib=rb-1.2.1&auto=format&fit=crop&w=1350&q=80'); background-size: cover; background-position: center; color: white; /* Завжди білий текст на фото */ }
header h1 { font-size: 3rem; margin-bottom: 15px; line-height: 1.2; text-shadow: 0 2px 5px rgba(0,0,0,0.5); }
header p { color: #ddd; max-width: 600px; margin: 0 auto 30px; font-size: 1.1rem; }
.hero-btn { display: inline-block; padding: 15px 35px; background: var(--primary); color: var(--primary-text); text-decoration: none; border-radius: 30px; font-weight: bold; font-size: 1.1rem; transition: transform 0.2s; box-shadow: 0 4px 15px rgba(0, 179, 89, 0.3); }
.hero-btn:active { transform: scale(0.95); }
@media (max-width: 600px) { header h1 { font-size: 2rem; } header { padding: 60px 20px; } }

/* --- МАГАЗИН --- */
.container { max-width: 1200px; margin: 50px auto; padding: 0 20px; }
.section-title { text-align: center; margin-bottom: 30px; font-size: 2rem; color: var(--text); }
.filter-buttons { display: flex; justify-content: center; flex-wrap: wrap; gap: 10px; margin-bottom: 40px; }
.filter-btn { background: var(--card-bg); border: 1px solid var(--border-color); color: var(--text); padding: 12px 24px; border-radius: 30px; cursor: pointer; transition: 0.3s; font-size: 0.95rem; font-weight: 500; }
.filter-btn:hover, .filter-btn.active { background: var(--primary); color: var(--primary-text); border-color: var(--primary); }
.products-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 30px; }

/* --- КАРТКА --- */
.product-card { background: var(--card-bg); border-radius: 15px; overflow: hidden; transition: transform 0.3s ease; border: 1px solid var(--border-color); opacity: 0; animation: fadeIn 0.5s forwards; display: flex; flex-direction: column; cursor: pointer; box-shadow: 0 5px 15px rgba(0,0,0,0.05); }
.product-card:hover { transform: translateY(-5px); border-color: var(--primary); box-shadow: 0 10px 25px rgba(0,0,0,0.1); }
@keyframes fadeIn { to { opacity: 1; } }
.card-img { width: 100%; height: 200px; object-fit: cover; background: #eee; }
.card-body { padding: 20px; flex-grow: 1; display: flex; flex-direction: column; justify-content: space-between; }
.category-tag { font-size: 0.8rem; color: var(--primary); text-transform: uppercase; letter-spacing: 1px; margin-bottom: 5px; font-weight: bold; }
.card-title { font-size: 1.2rem; margin-bottom: 10px; line-height: 1.4; color: var(--text); }
.card-price { font-size: 1.4rem; font-weight: bold; margin-bottom: 20px; display: block; color: var(--text); }
.buy-btn { width: 100%; padding: 14px; background: transparent; border: 2px solid var(--primary); color: var(--primary); border-radius: 8px; cursor: pointer; transition: 0.2s; font-weight: bold; font-size: 1rem; text-transform: uppercase; }
.buy-btn:hover { background: var(--primary); color: var(--primary-text); }

/* --- МОДАЛЬНІ ВІКНА --- */
.modal { display: none; position: fixed; z-index: 1000; left: 0; top: 0; width: 100%; height: 100%; overflow: auto; background-color: var(--modal-overlay); backdrop-filter: blur(5px); justify-content: center; align-items: center; }
.modal-content { background-color: var(--card-bg); margin: auto; padding: 0; border: 1px solid var(--border-color); width: 90%; max-width: 800px; border-radius: 15px; position: relative; animation: slideDown 0.3s; box-shadow: 0 10px 40px rgba(0,0,0,0.2); }
@keyframes slideDown { from { transform: translateY(-50px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
.close-modal { color: var(--text-muted); float: right; font-size: 28px; font-weight: bold; position: absolute; right: 20px; top: 10px; z-index: 10; cursor: pointer; transition: 0.3s; }
.close-modal:hover { color: var(--primary); }

.modal-body { display: flex; flex-wrap: wrap; }
.modal-img-container { flex: 1; min-width: 300px; height: 400px; background: #eee; }
#modal-img { width: 100%; height: 100%; object-fit: cover; }
.modal-info { flex: 1; padding: 30px; min-width: 300px; display: flex; flex-direction: column; }
#modal-title { font-size: 1.8rem; margin-bottom: 5px; color: var(--text); }
#modal-category { color: var(--primary); font-size: 0.9rem; text-transform: uppercase; margin-bottom: 15px; font-weight: bold; }
#modal-desc { color: var(--text-muted); line-height: 1.5; margin-bottom: 20px; }
.specs-list { margin-bottom: 20px; background: var(--bg-color); padding: 15px; border-radius: 10px; border: 1px solid var(--border-color); }
.spec-item { display: flex; justify-content: space-between; padding: 5px 0; border-bottom: 1px solid var(--border-color); color: var(--text-muted); font-size: 0.9rem; }
.spec-item b { color: var(--text); }
.modal-footer { margin-top: auto; display: flex; align-items: center; justify-content: space-between; gap: 20px; }
.modal-price { font-size: 1.8rem; font-weight: bold; color: var(--primary); }
.modal-buy-btn { background: var(--primary); color: var(--primary-text); border: none; }

/* Кошик */
.cart-content { max-width: 500px; padding: 20px; }
.cart-items-container { max-height: 60vh; overflow-y: auto; margin-bottom: 20px; }
.cart-item { display: flex; align-items: center; background: var(--bg-color); padding: 10px; border-radius: 10px; margin-bottom: 10px; border: 1px solid var(--border-color); }
.cart-item img { width: 60px; height: 60px; object-fit: cover; border-radius: 5px; margin-right: 15px; }
.cart-item-details { flex-grow: 1; }
.cart-item-title { font-size: 1rem; color: var(--text); margin-bottom: 5px; }
.cart-item-price { color: var(--primary); font-weight: bold; }
.remove-btn { color: var(--red); background: none; border: none; cursor: pointer; font-size: 1.2rem; padding: 10px; transition: 0.3s; }
.remove-btn:hover { transform: scale(1.2); }
.cart-footer { border-top: 1px solid var(--border-color); padding-top: 15px; }
.cart-total { display: flex; justify-content: space-between; font-size: 1.5rem; font-weight: bold; margin-bottom: 20px; color: var(--text); }
.checkout-btn { background: var(--primary); color: var(--primary-text); font-size: 1.2rem; border: none; }

/* Форма */
.form-input { width: 100%; padding: 12px; margin-bottom: 10px; background: var(--input-bg); border: 1px solid var(--border-color); border-radius: 8px; color: var(--text); font-size: 1rem; outline: none; transition: 0.3s; }
.form-input:focus { border-color: var(--primary); box-shadow: 0 0 0 2px rgba(0, 179, 89, 0.2); }

/* Плаваючий кошик */
.floating-cart { position: fixed; bottom: 30px; right: 30px; width: 60px; height: 60px; background: var(--primary); border-radius: 50%; display: flex; justify-content: center; align-items: center; box-shadow: 0 5px 20px rgba(0, 0, 0, 0.2); cursor: pointer; z-index: 900; transition: transform 0.3s; }
.floating-cart:hover { transform: scale(1.1); }
.cart-icon { position: relative; font-size: 1.5rem; color: var(--primary-text); }
#cart-count { position: absolute; top: -10px; right: -10px; background: var(--red); color: white; font-size: 0.8rem; font-weight: bold; padding: 2px 6px; border-radius: 50%; border: 2px solid var(--primary); }

/* TOAST */
.toast { visibility: hidden; min-width: 250px; background-color: #333; color: #fff; border-left: 5px solid var(--primary); text-align: center; border-radius: 4px; padding: 16px; position: fixed; z-index: 1001; right: 30px; top: 30px; font-size: 1rem; box-shadow: 0 5px 15px rgba(0,0,0,0.5); opacity: 0; transition: opacity 0.5s, top 0.5s; }
.toast.show { visibility: visible; opacity: 1; top: 90px; }

/* Про нас */
.info-section { padding: 80px 20px; background: var(--bg-color); border-top: 1px solid var(--border-color); margin-top: 50px; }
.info-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 50px; max-width: 1200px; margin: 0 auto; }
.info-title { font-size: 2rem; margin-bottom: 20px; color: var(--text); }
.about-text { color: var(--text-muted); line-height: 1.6; }
.contact-item { margin-bottom: 20px; display: flex; align-items: center; color: var(--text-muted); font-size: 1.05rem; }
.contact-item span { color: var(--primary); margin-right: 15px; font-size: 1.2rem; }
.contact-item a { color: var(--text-muted); text-decoration: none; }
footer { text-align: center; padding: 30px; background: var(--card-bg); color: var(--text-muted); border-top: 1px solid var(--border-color); font-size: 0.9rem; }


/* --- ГАЛЕРЕЯ З МІНІАТЮРАМИ В МОДАЛЬНОМУ ВІКНІ --- */
.modal-gallery {
    display: flex;
    flex-direction: column;
    width: 100%;
    height: 100%;
    padding: 10px;
}

/* Головне велике фото */
.modal-main-image {
    width: 100%;
    height: calc(100% - 90px); /* Залишаємо місце знизу для мініатюр */
    object-fit: contain;
    margin-bottom: 15px;
    transition: opacity 0.3s ease;
}

/* Контейнер для маленьких фото */
.modal-thumbnails {
    display: flex;
    gap: 12px;
    height: 75px;
    overflow-x: auto;
    justify-content: center; /* Центруємо мініатюри */
    padding-bottom: 5px;
    scrollbar-width: thin; /* Тонка смуга прокрутки, якщо фоток дуже багато */
}

/* Сама мініатюра */
.modal-thumbnail {
    flex: 0 0 70px;
    width: 70px;
    height: 100%;
    object-fit: contain;
    background: #fff;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    opacity: 0.6; /* Напівпрозорі, поки не активні */
}

/* Активна мініатюра та наведення мишкою */
.modal-thumbnail.active {
    border-color: var(--primary);
    opacity: 1;
    transform: translateY(-2px); /* Трохи піднімається */
}

.modal-thumbnail:hover {
    opacity: 1;
    border-color: var(--primary);
}

/* Стилі мініатюр для темної теми */
body.dark-mode .modal-thumbnail {
    background: #2a2a2a;
}