/* ==========================================================================
   1. ЗМІННІ ТА ОСНОВА
   ========================================================================== */
:root {
    --main-bg: #f8fafc;
    --card-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -2px rgba(0, 0, 0, 0.04);
    --primary: #4f46e5; 
    --primary-hover: #4338ca;
    --accent: #10b981; 
    --text-main: #1e293b;
    --text-muted: #64748b;
    --white: #ffffff;
    --subcat-bg: #f1f5f9;
    --border-color: #e2e8f0;
    --out-of-stock: #94a3b8;
    --gold: #fb8c00;
}

html {
    width: 100%;
    overflow-x: hidden; /* Критично важливо! */
}

body {
    width: 100%;
    margin: 0;
    padding: 0;
    font-family: system-ui, -apple-system, sans-serif;
    background-color: var(--main-bg);
    color: var(--text-main);
    overflow-x: hidden; /* Критично важливо! */
    position: relative;
}

*, *::before, *::after {
    box-sizing: border-box; /* Обов'язково */
}

img {
    max-width: 100%;
    height: auto;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 15px;
    width: 100%;
}

/* ==========================================================================
   2. HEADER & NAVIGATION
   ========================================================================== */
.header-container {
    max-width: 1200px !important; /* Вписуємо у вікно */
    margin: 0 auto !important;    /* Центруємо */
    padding: 10px 15px;
    display: flex !important;
    flex-direction: row !important; /* В один ряд */
    align-items: center;
    justify-content: space-between !important;
    gap: 20px;
    width: 100%;
}

/* ЛОГОТИП (ХЕДЕР) — ПРИВОДИМО ДО СТИЛЮ ФУТЕРА */
.logo { 
    text-decoration: none !important;
}

.logo-text { 
    font-family: 'Iowan Old Style', 'Palatino Linotype', 'Book Antiqua', serif !important;
    font-size: 26px !important; /* Трохи збільшив для солідності */
    font-weight: 800 !important; 
    color: #1e293b !important; /* Той самий антрацит, що й у футері */
    letter-spacing: -0.5px; 
    margin: 0; 
    text-transform: none !important; /* Щоб не було капслоку */
} 
}

/* Навігація зі скролом (виправлено дублювання) */
.main-nav { 
    order: 3;
    display: flex; 
    align-items: center; 
    gap: 15px; 
    flex-shrink: 0;    /* Меню не заважає пошуку розширюватися */
    width: auto;       /* Прибираємо розтягування меню */
}

.main-nav::-webkit-scrollbar { display: none; }

.nav-link { 
    text-decoration: none; 
    color: var(--text-main); 
    font-weight: 600; 
    font-size: 14px;
    padding: 5px 2px;
    transition: 0.2s;
}
.nav-link:hover, .nav-link.active { color: var(--primary); }
.nav-link.highlight { color: var(--gold); } 
.nav-link.highlight:hover { color: #d97706; }

/* 1. Обгортка пошуку */
.search-wrapper { 
    order: 2;
    position: relative; 
    flex-grow: 1;      /* Розтягує пошук на все вільне місце */
    max-width: 100%;   /* Дозволяємо розширюватися максимально */
    margin: 0 20px;
    z-index: 1001;
}

/* 2. Поле вводу */
#globalSearch { 
    width: 100%; 
    padding: 10px 15px !important; /* Текст тепер точно видно */
    border-radius: 12px; 
    border: 1px solid var(--border-color); 
    background: var(--main-bg);
    box-sizing: border-box; 
    outline: none;
    font-size: 16px;
}

/* 3. Випадаюче вікно - НАЙВАЖЛИВІШЕ */
.search-results-dropdown { 
    position: absolute; 
    top: calc(100% + 5px); 
    left: 0; right: 0; 
    background: #fff; 
    border-radius: 12px; 
    box-shadow: 0 10px 30px rgba(0,0,0,0.15); 
    z-index: 999999 !important; /* Щоб точно було поверх main */
    max-height: 400px; 
    overflow-y: auto;
    display: none;
    border: 1px solid #eee;
}

/* 4. Елемент товару (чистий та рівний) */
.search-result-item {
    display: flex !important;
    align-items: center;
    padding: 10px;
    gap: 15px;
    text-decoration: none !important; /* Прибираємо синє підкреслення */
    color: #333 !important;
    border-bottom: 1px solid #f5f5f5;
    transition: background 0.2s;
}

.search-result-item:hover { background: #f9f9fb; }

.search-result-item img {
    width: 40px; height: 40px; 
    object-fit: cover; border-radius: 6px; flex-shrink: 0;
}

.search-result-item .info {
    display: flex; flex-direction: column; 
    line-height: 1.4; overflow: hidden;
}

.search-result-item .name {
    font-size: 14px; font-weight: 500;
    white-space: nowrap; text-overflow: ellipsis; overflow: hidden;
}

.search-result-item .price {
    font-size: 13px; color: var(--primary, #4f46e5); font-weight: 700;
}
/* Кошик */
.cart-widget { 
    order: 4;
    flex-shrink: 0;
}

/* ==========================================================================
/* ==========================================================================
   8. CART, CHECKOUT, FOOTER & WIDGETS (ВИПРАВЛЕНО)
   ========================================================================== */

/* Кошик (Бічна панель) */
.cart-drawer, .cart-sidebar { 
    position: fixed; 
    top: 0; 
    right: -100%; 
    width: 100%; 
    max-width: 380px; 
    height: 100%; 
    background: var(--white); 
    z-index: 2001; 
    transition: 0.4s cubic-bezier(0.4, 0, 0.2, 1); 
    display: flex; 
    flex-direction: column; 
    box-shadow: -10px 0 30px rgba(0, 0, 0, 0.1); 
}
.cart-drawer.open, .cart-sidebar.active { right: 0; }

.cart-overlay { 
    position: fixed; 
    inset: 0; 
    background: rgba(15, 23, 42, 0.5); 
    backdrop-filter: blur(4px); 
    z-index: 2000; 
    display: none; 
}
.cart-overlay.active { display: block; }

/* Оформлення замовлення (Checkout) */
.checkout-container { padding: 40px 0; }
.checkout-layout { 
    display: grid; 
    grid-template-columns: 1.5fr 1fr; 
    gap: 30px; 
    align-items: start; 
}

@media (max-width: 992px) {
    .checkout-layout { grid-template-columns: 1fr; }
}

.styled-form { 
    background: var(--white); 
    padding: 30px; 
    border-radius: 20px; 
    box-shadow: var(--card-shadow); 
    border: 1px solid var(--border-color);
}

.summary-card { 
    background: var(--text-main); 
    color: var(--white); 
    padding: 30px; 
    border-radius: 24px; 
    position: sticky; 
    top: 100px; 
}

.btn-submit-order { 
    width: 100%; 
    padding: 18px; 
    background: var(--primary); 
    color: var(--white); 
    border: none; 
    border-radius: 16px; 
    font-size: 18px; 
    font-weight: 700; 
    cursor: pointer; 
    transition: 0.3s; 
}
.btn-submit-order:hover { background: var(--primary-hover); transform: translateY(-2px); }

/* --- ФІКСОВАНА КНОПКА ЧАТУ (Виправлення того, що вона пливе) --- */
.chat-button { 
    position: fixed !important; 
    bottom: 25px; 
    left: 25px; 
    width: 55px; 
    height: 55px; 
    background-color: var(--primary); 
    color: white; 
    border-radius: 50%; 
    display: flex; 
    align-items: center; 
    justify-content: center; 
    z-index: 3000; /* Підняли z-index, щоб була над усім */
    box-shadow: 0 4px 15px rgba(79, 70, 229, 0.4); 
    cursor: pointer;
    transition: 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.chat-button:hover { transform: scale(1.1); }

.chat-button svg {
    width: 26px;
    height: 26px;
    fill: white;
}

/* Вікно чату */
.chat-window {
    position: fixed !important;
    bottom: 90px;
    left: 25px;
    width: 300px;
    background: white;
    border-radius: 20px;
    box-shadow: 0 10px 25px rgba(0,0,0,0.15);
    z-index: 3001;
    display: none;
    border: 1px solid var(--border-color);
    overflow: hidden;
}

/* Адаптація відгуків */
.review-card { 
    background: var(--white) !important; 
    border-radius: 20px !important; 
    border: 1px solid var(--border-color) !important; 
    transition: all 0.3s ease !important; 
    padding: 20px;
}

/* ==========================================================================
   10. MOBILE ADAPTIVE & DESKTOP FIX (НАЙВАЖЛИВІШЕ)
   ========================================================================== */
@media (min-width: 769px) {
    .header-container { 
        flex-direction: row;
        justify-content: space-between;
        align-items: center;
        flex-wrap: nowrap;
    }
    .logo { order: 1; flex-shrink: 0; }
    .search-wrapper { order: 2; width: 100%; margin: 10px 20px; }
    .main-nav { order: 3; flex-shrink: 0; }
    .cart-widget { order: 4; flex-shrink: 0; }
}

@media (max-width: 768px) {
    .header-container { 
        display: flex !important;
        flex-direction: column !important; /* Елементи один під одним */
        align-items: center;
        gap: 12px; /* Відступи між блоками */
    }

    /* 1. Навігація стає самою першою */
    .main-nav {
        order: 1 !important; 
        width: 100%;
        display: flex !important;
        justify-content: center !important;
        flex-wrap: wrap !important; /* Якщо не влізуть в один рядок, м'яко перейдуть на другий */
        gap: 15px !important;
        padding: 5px 0;
    }

    /* 2. Логотип (або кошик) другий */
    .logo { 
        order: 2 !important; 
    }

    .cart-widget { 
        order: 3 !important; 
    }

    /* 3. Пошук стає в самому низу */
    .search-wrapper { 
        order: 4 !important; 
        width: 100% !important; 
        max-width: none !important;
        margin: 0 !important;
    }

    /* Стиль самих посилань, щоб вони були чіткими */
    .nav-link {
        font-size: 15px !important;
        text-decoration: none !important;
        white-space: nowrap;
        font-weight: 500;
    }

    .chat-window { width: calc(100vw - 30px); left: 15px; bottom: 85px; }
}

@media (max-width: 480px) {
    .logo h1 { font-size: 19px; }
    .cart-widget { padding: 6px 10px; }
    .cart-widget span:not(.cart-count) { display: none; }
}/* Адаптація для мобільних */
@media (max-width: 480px) {
    .chat-button {
        width: 50px;
        height: 50px;
        bottom: 20px;
        left: 20px;
    }
    .chat-window {
        bottom: 80px;
        left: 20px;
        width: calc(100vw - 40px);
    }
}/* --- Стилізація вікна чату --- */
.chat-window {
    position: fixed !important;
    bottom: 90px;
    left: 25px;
    width: 320px; /* Трохи розширили для тексту */
    background: var(--white);
    border-radius: 24px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.15);
    z-index: 3001;
    display: none; /* З'являється через JS */
    border: 1px solid var(--border-color);
    overflow: hidden;
    animation: slideInChat 0.3s ease-out;
}

@keyframes slideInChat {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Заголовок чату */
.chat-header {
    padding: 20px;
    background: var(--primary);
    color: white;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.chat-title {
    font-weight: 700;
    font-size: 16px;
}

.chat-close-btn {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: 0.2s;
}

.chat-close-btn:hover {
    background: rgba(255, 255, 255, 0.4);
}

/* Тіло чату та посилання-кнопки */
.chat-body {
    padding: 15px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.chat-link {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 14px;
    background: var(--subcat-bg);
    border-radius: 16px;
    text-decoration: none;
    transition: all 0.2s ease;
    border: 1px solid transparent;
}

.chat-link:hover {
    background: white;
    border-color: var(--primary);
    transform: translateX(5px);
    box-shadow: 0 4px 12px rgba(79, 70, 229, 0.1);
}

.chat-icon {
    font-size: 24px;
}

.chat-link-text {
    display: flex;
    flex-direction: column;
}

.chat-link-label {
    font-weight: 700;
    color: var(--text-main);
    font-size: 14px;
}

.chat-link-desc {
    font-size: 12px;
    color: var(--text-muted);

}/* ==========================================================================
   ОСТРІВНИЙ ФУТЕР (MAIN FOOTER)
   ========================================================================== */
/* ПОВНЕ ВИПРАВЛЕННЯ ФУТЕРА */





/* ==========================================================================
   BACK TO TOP BUTTON
   ========================================================================== */
#backToTop {
    position: fixed;
    bottom: 30px;
    right: 30px;
    width: 50px;
    height: 50px;
    background: #4f46e5;
    color: white;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    opacity: 0;
    transition: opacity 0.3s ease, transform 0.3s ease, background 0.3s ease;
    padding: 0;
    box-shadow: 0 4px 12px rgba(79, 70, 229, 0.3);
}

#backToTop svg {
    width: 24px;
    height: 24px;
    flex-shrink: 0;
}

#backToTop:hover {
    background: #4338ca;
    transform: translateY(-3px);
    box-shadow: 0 6px 16px rgba(79, 70, 229, 0.4);
}

/* When scroll > 300px, show button */
#backToTop[style*="display: flex"] {
    opacity: 1;
}

/* Mobile responsive */
@media (max-width: 768px) {
    #backToTop {
        bottom: 20px;
        right: 20px;
        width: 45px;
        height: 45px;
    }
    
    #backToTop svg {
        width: 20px;
        height: 20px;
    }
}

/* Extra small devices */
@media (max-width: 480px) {
    #backToTop {
        bottom: 15px;
        right: 15px;
        width: 42px;
        height: 42px;
    }
}
/* Примусове обмеження для всіх розтягнутих секцій */
.reviews-section, 
.oracle-container, 
.recently-viewed, 
.products-grid, 
.category-container, 
.category-layout,
main {
    max-width: 1200px !important;
    margin-left: auto !important;
    margin-right: auto !important;
    width: 100% !important;
}

/* Виправлення сітки товарів у категоріях */
.products-grid {
    display: grid !important;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 20px;
}


/* ============================================================
   ОНОВЛЕНИЙ ФУТЕР — КНИЖКОВИЙ СТИЛЬ (БІЛИЙ)
   ============================================================ */
/* ============================================================
   ПОВНИЙ ФУТЕР — ПЕРЕВІРЕНИЙ ЗАХИСТ ВІД РОЗТЯГУВАННЯ
   ============================================================ */

/* Використовуємо старий селектор .main-footer для повної сумісності */
footer, .main-footer {
    /* СУВОРІ ОБМЕЖЕННЯ зі старого коду */
    max-width: 1200px !important;
    width: calc(100% - 30px) !important;
    margin: 60px auto 20px auto !important;
    border-radius: 24px !important; 
    display: block !important;
    overflow: hidden; /* Щоб фон не вилазив за закруглення */

    /* НОВИЙ ВІЗУАЛ */
    background: #ffffff !important; 
    background-color: #ffffff !important;
    border: 1px solid #e2e8f0 !important; 
    padding: 40px 30px !important;
    color: #475569 !important;
    font-family: 'Palatino Linotype', 'Book Antiqua', serif !important;
}

/* Стара сітка для колонок */
.footer-grid {
    display: grid !important;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)) !important;
    gap: 40px !important;
    text-align: left;
}

/* Заголовки розділів (з вашим шрифтом) */
footer h4, footer h5, .footer-links h4 {
    font-family: 'Iowan Old Style', serif !important;
    font-weight: 800 !important;
    color: #1e293b !important;
    font-size: 1.15rem !important;
    margin-bottom: 20px !important;
    background: none !important; /* Прибираємо можливі заливки заголовків */
}

/* Посилання (зберігаємо структуру списків) */
.footer-links ul {
    list-style: none !important;
    padding: 0 !important;
}

footer a, .footer-links a {
    color: #64748b !important;
    text-decoration: none !important;
    transition: all 0.2s ease !important;
    font-size: 0.95rem !important;
    display: inline-block;
    margin-bottom: 10px;
}

footer a:hover, .footer-links a:hover {
    color: #1e293b !important;
    transform: translateX(3px);
}

/* Нижня панель */
.footer-bottom {
    margin-top: 40px !important;
    padding-top: 25px !important;
    border-top: 1px solid #f1f5f9 !important;
    color: #94a3b8 !important;
    font-size: 0.85rem !important;
    text-align: center;
    background: transparent !important;
}

/* МОБІЛЬНА АДАПТАЦІЯ */
@media (max-width: 768px) {
    footer, .main-footer {
        width: calc(100% - 20px) !important;
        margin: 40px auto 10px auto !important;
        padding: 30px 20px !important;
    }
    
    .footer-grid {
        display: flex !important;
        flex-direction: column !important;
        gap: 30px !important;
        text-align: center;
    }

    footer a, .footer-links a {
        display: block;
        padding: 8px 0;
    }
}
/* СТИЛЬ ДЛЯ КНОПКИ TELEGRAM (Зв'язок) */
.btn-telegram {
    display: inline-block !important;
    margin-top: 10px;
    padding: 8px 16px !important;
    background-color: #f1f5f9 !important; /* Дуже світлий сірий фон */
    color: #64748b !important;           /* Спокійний сірий колір тексту */
    border: 1px solid #e2e8f0 !important; /* Тонка рамка */
    border-radius: 8px !important;
    text-decoration: none !important;
    font-family: 'Palatino Linotype', serif !important;
    font-size: 0.9rem !important;
    transition: all 0.3s ease !important;
}

/* Ефект при наведенні */
.btn-telegram:hover {
    background-color: #e2e8f0 !important; /* Трохи темніший сірий при наведенні */
    color: #1e293b !important;           /* Текст стає майже чорним */
    border-color: #cbd5e1 !important;
    transform: translateY(-2px);         /* Легке підняття вгору */
}
.logo-text {
    white-space: nowrap;
    overflow: hidden;
}

.typewriter {
    width: 0;
    border-right: 2px solid #000;
    animation: typing 2s steps(10) forwards,
               blink 0.8s infinite;
    animation-play-state: paused;
}

.typewriter.active {
    animation-play-state: running;
}

@keyframes typing {
    from { width: 0; }
    to { width: 100%; }
}

@keyframes blink {
    0%,100% { border-color: #000; }
    50% { border-color: transparent; }
}