/* =========================================
   1. VARIABLES & RESET
   ========================================= */
:root {
    --primary-green: #2e7d32;   /* Основний зелений */
    --dark-green: #1b5e20;      /* Темний зелений (для ховера) */
    --accent-orange: #f57c00;   /* Помаранчевий акцент */
    --text-dark: #263238;       /* Темний текст */
    --text-light: #546e7a;      /* Світлий текст */
    --white: #ffffff;
    --bg-color: #f4f7f6;        /* Фон сторінки */
    --header-height: 80px;      /* Висота шапки */
}

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

html, body {
    width: 100%;
    overflow-x: hidden; 
    position: relative;
}

body {
    font-family: 'Open Sans', sans-serif;
    color: var(--text-dark);
    background-color: var(--bg-color);
    padding-top: var(--header-height);
    min-height: 100vh;
    display: flex; flex-direction: column;
}

main { flex: 1; }
a { text-decoration: none; color: inherit; transition: 0.2s ease; }
ul { list-style: none; }
img { max-width: 100%; display: block; }

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

/* =========================================
   2. HEADER & LOGO
   ========================================= */
.header {
    position: fixed; top: 0; left: 0; width: 100%; height: var(--header-height);
    background: var(--white);
    box-shadow: 0 2px 15px rgba(0,0,0,0.05);
    z-index: 1000;
    display: flex; align-items: center;
    border-bottom: 3px solid var(--primary-green);
}

.header-container {
    display: flex; justify-content: space-between; align-items: center; width: 100%;
}

.logo {
    display: flex; align-items: center; gap: 12px;
    z-index: 1101; /* Поверх меню */
    max-width: 70%;
}

.logo-img { height: 50px; width: auto; }

.logo-text { display: flex; flex-direction: column; line-height: 1.2; }
.logo-text span {
    font-family: 'Montserrat', sans-serif; font-weight: 700; font-size: 1rem;
    color: var(--primary-green); text-transform: uppercase;
}
.logo-text small {
    font-size: 0.7rem; color: var(--text-light); font-weight: 600;
}

/* =========================================
   3. DESKTOP NAVIGATION (PC)
   ========================================= */
.burger, .close-menu-btn, .overlay { display: none; }

.nav-list {
    display: flex; gap: 5px; align-items: center;
}

.nav-link {
    font-family: 'Montserrat', sans-serif; font-weight: 600; font-size: 13px;
    text-transform: uppercase; padding: 10px 14px;
    cursor: pointer; border-radius: 6px;
    display: flex; align-items: center; gap: 5px;
    color: var(--text-dark);
}

.nav-link:hover {
    background-color: #e8f5e9; color: var(--primary-green);
}

.arrow { font-size: 10px; transition: transform 0.3s; }
.nav-item:hover .arrow { transform: rotate(180deg); }

/* Dropdowns (ПК) */
.nav-item { position: relative; }

.dropdown-menu {
    position: absolute; top: 100%; left: 0;
    background: var(--white);
    box-shadow: 0 10px 30px rgba(0,0,0,0.15);
    border-radius: 0 0 8px 8px;
    padding: 20px;
    opacity: 0; visibility: hidden; transform: translateY(15px);
    transition: all 0.2s ease;
    z-index: 999;
    border-top: 4px solid var(--accent-orange);
    min-width: 240px;
}

/* На ПК показуємо при наведенні */
@media (min-width: 769px) {
    .nav-item:hover .dropdown-menu {
        opacity: 1; visibility: visible; transform: translateY(0);
    }
}

/* Mega Menu (ПК) */
.mega-menu {
    display: grid; grid-template-columns: repeat(3, 1fr); gap: 30px;
    width: 700px;
    left: 50%; transform: translateX(-50%) translateY(15px);
}
@media (min-width: 769px) {
    .nav-item:hover .mega-menu { transform: translateX(-50%) translateY(0); }
}

.dropdown-menu h4 {
    color: var(--primary-green); font-size: 0.9rem; text-transform: uppercase;
    margin-bottom: 10px; border-bottom: 1px solid #eee; padding-bottom: 5px;
}

.dropdown-menu a {
    display: block; padding: 8px 10px; font-size: 0.9rem; color: #444; border-radius: 5px;
    transition: 0.2s;
}

.dropdown-menu a:hover {
    background: #f5f5f5; color: var(--primary-green); transform: translateX(5px);
}

/* =========================================
   4. HERO & SECTIONS
   ========================================= */
.hero {
    height: 400px;
    position: relative;
    display: flex; align-items: center; justify-content: center;
    text-align: center; color: var(--white);
    margin-bottom: 40px;
    border-radius: 0 0 30px 30px;
    overflow: hidden;
    box-shadow: 0 10px 20px rgba(46, 125, 50, 0.2);
    background-color: var(--primary-green);
    background-image: linear-gradient(rgba(0, 50, 20, 0.7), rgba(0, 50, 20, 0.6)), url('../img/hero-bg.jpg'); 
    background-size: cover; background-position: center;
}

.hero h1 {
    font-family: 'Montserrat', sans-serif;
    font-size: 2.5rem; margin-bottom: 1rem;
    text-shadow: 0 4px 10px rgba(0,0,0,0.5); padding: 0 10px;
}
.hero p {
    font-size: 1.1rem; font-weight: 600; text-shadow: 0 2px 5px rgba(0,0,0,0.5);
}

.section { padding: 40px 0; }
.page-title {
    text-align: center; margin-bottom: 40px;
    color: var(--text-dark);
    font-family: 'Montserrat', sans-serif; font-size: 2rem;
    position: relative;
}
.page-title::after {
    content: ''; display: block; width: 60px; height: 4px;
    background: var(--accent-orange); margin: 10px auto 0;
}

/* Сітка новин */
.news-grid {
    display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 25px;
}
.news-card {
    background: var(--white); border-radius: 12px; overflow: hidden;
    box-shadow: 0 5px 15px rgba(0,0,0,0.05);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    display: flex; flex-direction: column;
}
.news-card:hover { transform: translateY(-5px); box-shadow: 0 15px 30px rgba(0,0,0,0.1); }
.news-image { height: 200px; width: 100%; object-fit: cover; background-color: #eee; }
.news-content { padding: 20px; flex: 1; display: flex; flex-direction: column; }
.news-date { font-size: 0.85rem; color: #888; margin-bottom: 5px; }
.news-title { font-size: 1.1rem; font-weight: 700; margin-bottom: 10px; color: var(--text-dark); line-height: 1.4; }
.news-excerpt {
    font-size: 0.95rem; color: #555; line-height: 1.6;
    display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
}

/* =========================================
   5. TABLES & DOCS
   ========================================= */
.table-container {
    width: 100%; overflow-x: auto; margin-bottom: 30px; background: white;
    border-radius: 8px; box-shadow: 0 2px 10px rgba(0,0,0,0.05);
}
.styled-table { width: 100%; border-collapse: collapse; min-width: 600px; }
.styled-table th { background: var(--primary-green); color: white; padding: 15px; text-align: left; }
.styled-table td { padding: 12px 15px; border-bottom: 1px solid #eee; }
.styled-table tr:nth-child(even) { background-color: #f8f9fa; }

.links-container { display: flex; flex-direction: column; gap: 15px; max-width: 800px; margin: 0 auto; }
.doc-link {
    background: var(--white); padding: 15px 20px;
    border-left: 5px solid var(--primary-green); border-radius: 8px;
    font-weight: 600; color: var(--text-dark); display: flex; align-items: center; gap: 15px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.05); transition: 0.2s;
}
.doc-link:hover { background: var(--primary-green); color: white; padding-left: 25px; }

/* =========================================
   6. FOOTER
   ========================================= */
.footer {
    background: #263238; color: #cfd8dc; padding: 40px 0; text-align: center; margin-top: auto;
}

/* =========================================
   7. MOBILE ADAPTATION (Фінальний фікс)
   ========================================= */
@media (max-width: 768px) {
    /* Кнопка бургер */
    .burger {
        display: block; cursor: pointer; width: 30px; z-index: 1102;
    }
    .burger span {
        display: block; height: 3px; background: var(--text-dark); margin: 6px 0; transition: 0.3s;
    }

    /* Меню (бічний слайдер) */
    .nav {
        position: fixed; top: 0; left: -100%; /* Сховано ліворуч */
        width: 85%; height: 100vh;
        background: var(--white);
        z-index: 1100;
        padding: 80px 20px 40px;
        transition: 0.3s ease-in-out;
        overflow-y: auto;
        box-shadow: 5px 0 15px rgba(0,0,0,0.1);
    }
    
    .nav.active { left: 0; } /* Виїжджає */

    .nav-list { flex-direction: column; align-items: stretch; gap: 0; }
    
    .nav-item {
        width: 100%; border-bottom: 1px solid #eee;
    }

    .nav-link {
        font-size: 1.1rem; padding: 15px 0; justify-content: space-between;
    }

    /* Затемнення */
    .overlay {
        position: fixed; top: 0; left: 0; width: 100%; height: 100%;
        background: rgba(0,0,0,0.5); z-index: 1050;
        opacity: 0; visibility: hidden; transition: 0.3s;
    }
    .overlay.active { opacity: 1; visibility: visible; }

    /* Кнопка закрити всередині меню */
    .close-menu-btn {
        display: block; position: absolute; top: 20px; right: 20px;
        font-size: 2rem; cursor: pointer; color: #888;
    }

    /* --- ВИПРАВЛЕННЯ ВИПАДАЮЧИХ СПИСКІВ --- */
    
    /* 1. Скидаємо стилі absolute, робимо список частиною потоку (static) */
    .dropdown-menu, .mega-menu {
        position: static;
        width: 100%;
        transform: none;
        opacity: 1; visibility: visible;
        box-shadow: none;
        border: none;
        background: #f9f9f9;
        padding: 0;
        display: none; /* Сховано за замовчуванням */
        padding-left: 15px;
    }

    /* 2. Mega Menu перетворюємо в стовпчик */
    .mega-menu {
        display: none; /* Перебиваємо grid */
        grid-template-columns: 1fr;
    }

    .mega-column { margin-bottom: 20px; }

    /* 3. Показуємо, коли JS додає клас .open батьківському елементу */
    .nav-item.open .dropdown-menu {
        display: block;
        animation: fadeIn 0.3s;
    }

    /* Стрілочка крутиться */
    .nav-item.open .arrow { transform: rotate(180deg); }

    @keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
}
/* =========================================
   FIX: КНОПКА "НА ГОЛОВНУ" ДЛЯ ВНУТРІШНІХ СТОРІНОК
   ========================================= */

/* За замовчуванням кнопка "На головну" схована */
.mobile-back-btn {
    display: none;
}

/* ТІЛЬКИ ДЛЯ МОБІЛЬНИХ */
@media (max-width: 768px) {
    
    /* Якщо у body є клас "inner-page" (внутрішня сторінка) */
    body.inner-page .burger {
        display: none !important; /* Ховаємо бургер */
    }

    body.inner-page .mobile-back-btn {
        display: flex; /* Показуємо кнопку назад */
        align-items: center;
        gap: 5px;
        font-family: 'Montserrat', sans-serif;
        font-weight: 700;
        font-size: 14px;
        color: var(--primary-green);
        text-transform: uppercase;
        margin-left: auto; /* Притискаємо вправо, де був бургер */
        padding: 10px;
        border: 2px solid var(--primary-green);
        border-radius: 8px;
        background: #f1f8e9;
    }

    body.inner-page .mobile-back-btn:hover {
        background: var(--primary-green);
        color: white;
    }
}
/* =========================================
   ЛОГІКА ДЛЯ ВНУТРІШНІХ СТОРІНОК (МОБІЛЬНИЙ)
   ========================================= */

/* 1. За замовчуванням кнопка "На головну" СХОВАНА (щоб її не було на ПК і на index.html) */
.mobile-back-btn {
    display: none;
}

/* 2. Налаштування тільки для телефонів */
@media (max-width: 768px) {
    
    /* Якщо у body є клас "inner-page", то ХОВАЄМО бургер */
    body.inner-page .burger {
        display: none !important;
    }

    /* І ПОКАЗУЄМО кнопку "На головну" */
    body.inner-page .mobile-back-btn {
        display: flex; /* Робимо видимим */
        align-items: center;
        justify-content: center;
        font-family: 'Montserrat', sans-serif;
        font-weight: 700;
        font-size: 14px;
        color: var(--primary-green);
        text-transform: uppercase;
        padding: 8px 15px;
        border: 2px solid var(--primary-green);
        border-radius: 6px;
        background: #fff;
        margin-left: auto; /* Притискаємо вправо */
        text-decoration: none;
    }
}
/* =========================================
   ПРИХОВУВАННЯ СКРОЛБАРУ (СМУГИ ПРОКРУТКИ)
   ========================================= */

/* Для Chrome, Safari, Edge, Opera */
::-webkit-scrollbar {
    width: 0; /* Ширина скролбару 0 пікселів */
    background: transparent; /* Прозорий фон */
}

/* Для Firefox */
html {
    scrollbar-width: none; /* Прибирає смугу */
}