/* ============================================
   CSS VARIABLES FOR EASY REBRANDING
   ============================================ */
:root {
    /* Color Palette - Change these to rebrand instantly */
    --color-primary: #333333;
    --color-secondary: #555555;
    --color-accent: #0066cc;
    --color-background: #ffffff;
    --color-background-alt: #f8f9fa;
    --color-text: #333333;
    --color-text-light: #666666;
    --color-border: #e0e0e0;
    --color-link: #0066cc;
    --color-link-hover: #004499;
    
    /* Typography */
    --font-family: -apple-system, BlinkMacSystemFont, 'Inter', 'Helvetica Neue', 'Helvetica', 'Arial', sans-serif;
    --font-size-base: 16px;
    --line-height-base: 1.6;
    
    /* Spacing */
    --spacing-xs: 0.5rem;
    --spacing-sm: 1rem;
    --spacing-md: 2rem;
    --spacing-lg: 3rem;
    --spacing-xl: 4rem;
    
    /* Container */
    --container-max-width: 1200px;
    --container-padding: 1.5rem;
    
    /* Transitions */
    --transition-speed: 0.3s;
}

/* ============================================
   RESET & BASE STYLES
   ============================================ */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    font-size: var(--font-size-base);
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-family);
    line-height: var(--line-height-base);
    color: var(--color-text);
    background-color: var(--color-background);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ============================================
   TYPOGRAPHY
   ============================================ */
h1, h2, h3, h4, h5, h6 {
    font-weight: 600;
    line-height: 1.3;
    margin-bottom: var(--spacing-sm);
    color: var(--color-primary);
}

h1 {
    font-size: 2.5rem;
    margin-bottom: var(--spacing-md);
}

h2 {
    font-size: 2rem;
    margin-bottom: var(--spacing-md);
}

h3 {
    font-size: 1.5rem;
    margin-top: var(--spacing-md);
}

h4 {
    font-size: 1.25rem;
}

h5 {
    font-size: 1.1rem;
}

h6 {
    font-size: 1rem;
}

p {
    margin-bottom: var(--spacing-sm);
}

a {
    color: var(--color-link);
    text-decoration: none;
    transition: color var(--transition-speed) ease;
}

a:hover {
    color: var(--color-link-hover);
    text-decoration: underline;
}

strong, b {
    font-weight: 600;
}

/* ============================================
   LISTS
   ============================================ */
ul, ol {
    margin-bottom: var(--spacing-md);
    padding-left: var(--spacing-md);
}

li {
    margin-bottom: var(--spacing-xs);
}

ul li {
    list-style-type: disc;
}

ol li {
    list-style-type: decimal;
}

/* ============================================
   LAYOUT COMPONENTS
   ============================================ */
.container {
    max-width: var(--container-max-width);
    margin: 0 auto;
    padding: 0 var(--container-padding);
    width: 100%;
}

.section {
    padding: var(--spacing-xl) 0;
}

.section-alt {
    background-color: var(--color-background-alt);
}

/* ============================================
   HERO BANNER
   ============================================ */
.hero {
    position: relative;
    width: 100%;
    height: 500px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    background-color: var(--color-primary);
}

/* Hero image with object-fit for easy swapping */
.hero-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
}

.hero-image {
    width: 100%;
    height: 100%;
    /* CRITICAL: object-fit preserves aspect ratio for any image */
    object-fit: cover;
    object-position: center;
    display: block;
}

/* Alternative: Use CSS background instead of <img> tag */
/* Uncomment below and comment out .hero-image if you prefer background-image */
/*
.hero-overlay {
    background-image: url('https://images.unsplash.com/photo-1497366216548-37526070297c?w=1920&q=80');
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
}
*/

.hero-content {
    position: relative;
    z-index: 2;
    text-align: center;
    color: #ffffff;
    padding: 0 var(--container-padding);
    max-width: 800px;
    background: rgba(0, 0, 0, 0.5);
    padding: var(--spacing-md);
    border-radius: 8px;
}

.hero-content h1 {
    color: #ffffff;
    font-size: 2.5rem;
    margin-bottom: var(--spacing-sm);
    font-weight: 700;
}

.hero-subtitle {
    font-size: 1.25rem;
    margin-bottom: 0;
    color: #f0f0f0;
}

/* ============================================
   TABLE STYLES
   ============================================ */
.table-wrapper {
    overflow-x: auto;
    margin: var(--spacing-md) 0;
    -webkit-overflow-scrolling: touch;
    border: 1px solid var(--color-border);
    border-radius: 4px;
}

table {
    width: 100%;
    border-collapse: collapse;
    background-color: var(--color-background);
    min-width: 600px; /* Ensures horizontal scroll on mobile */
}

thead {
    background-color: var(--color-background-alt);
}

th {
    text-align: left;
    padding: 1rem;
    font-weight: 600;
    color: var(--color-primary);
    border-bottom: 2px solid var(--color-border);
    white-space: nowrap;
}

td {
    padding: 1rem;
    border-bottom: 1px solid var(--color-border);
}

tbody tr:hover {
    background-color: var(--color-background-alt);
    transition: background-color var(--transition-speed) ease;
}

tbody tr:last-child td {
    border-bottom: none;
}

/* ============================================
   FOOTER
   ============================================ */
footer {
    background-color: var(--color-primary);
    color: #ffffff;
    padding: var(--spacing-md) 0;
    margin-top: var(--spacing-xl);
}

footer .container {
    text-align: center;
}

footer p {
    margin-bottom: var(--spacing-sm);
}

footer nav {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: var(--spacing-sm);
}

footer a {
    color: #ffffff;
    opacity: 0.9;
    text-decoration: none;
}

footer a:hover {
    opacity: 1;
    text-decoration: underline;
}

/* ============================================
   BACK TO TOP BUTTON
   ============================================ */
.back-to-top {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    background-color: var(--color-accent);
    color: #ffffff;
    border: none;
    border-radius: 50%;
    width: 50px;
    height: 50px;
    font-size: 1.5rem;
    cursor: pointer;
    display: none;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    transition: all var(--transition-speed) ease;
    z-index: 1000;
}

.back-to-top:hover {
    background-color: var(--color-link-hover);
    transform: translateY(-3px);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.2);
}

.back-to-top.visible {
    display: flex;
}

/* ============================================
   RESPONSIVE DESIGN - MOBILE FIRST
   ============================================ */

/* Small devices (iPhone SE and similar) */
@media (max-width: 375px) {
    :root {
        --font-size-base: 14px;
        --container-padding: 1rem;
        --spacing-lg: 2rem;
        --spacing-xl: 2.5rem;
    }
    
    h1 {
        font-size: 1.75rem;
    }
    
    h2 {
        font-size: 1.5rem;
    }
    
    .hero {
        height: 350px;
    }
    
    .hero-content h1 {
        font-size: 1.75rem;
    }
    
    .hero-subtitle {
        font-size: 1rem;
    }
}

/* Mobile devices */
@media (max-width: 768px) {
    h1 {
        font-size: 2rem;
    }
    
    h2 {
        font-size: 1.75rem;
    }
    
    h3 {
        font-size: 1.3rem;
    }
    
    .hero {
        height: 400px;
    }
    
    .hero-content h1 {
        font-size: 2rem;
    }
    
    .hero-subtitle {
        font-size: 1.1rem;
    }
    
    .back-to-top {
        bottom: 1rem;
        right: 1rem;
        width: 45px;
        height: 45px;
    }
    
    footer nav {
        flex-direction: column;
        gap: var(--spacing-xs);
    }
}

/* Tablet and up */
@media (min-width: 769px) {
    .hero {
        height: 600px;
    }
}

/* Desktop and up */
@media (min-width: 1024px) {
    :root {
        --spacing-xl: 5rem;
    }
    
    h1 {
        font-size: 3rem;
    }
    
    h2 {
        font-size: 2.25rem;
    }
    
    .hero-content h1 {
        font-size: 3rem;
    }
}

img {
    max-width: 100%;
    height: auto;
}

/* 2. Виправлення контейнера, щоб він не розширювався */
.container {
    width: 100%;
    max-width: var(--container-max-width);
    margin: 0 auto;
    padding: 0 var(--container-padding);
    overflow-x: hidden; /* Це заблокує горизонтальну прокрутку */
}

/* 3. Оновлений стиль для картинок у тексті */
.content-image {
    width: 100%; /* Займає всю ширину на мобільних */
    max-width: 800px; /* Але не більше 800px на комп'ютері */
    height: auto;
    display: block;
    margin: var(--spacing-md) auto;
    border-radius: 8px;
}
.main-article-img {
    display: block;       /* Робимо блочним, щоб працювали відступи */
    width: 100%;          /* На телефоні займе всю ширину */
    max-width: 100%;      /* ГАРАНТІЯ, що не вилізе за межі */
    height: auto;         /* Зберігає пропорції (не сплющує) */
    margin: 20px auto;    /* Центрування та відступи зверху/знизу */
    border-radius: 8px;   /* Красиві кути */
}

/* Спеціально для великих екранів, щоб фото не було на весь монітор */
@media (min-width: 1024px) {
    .main-article-img {
        max-width: 700px; /* Обмежуємо ширину на ПК */
    }
}

/* ============================================
   UTILITY CLASSES
   ============================================ */
.text-center {
    text-align: center;
}

.mt-0 { margin-top: 0; }
.mb-0 { margin-bottom: 0; }

/* ============================================
   PRINT STYLES
   ============================================ */
@media print {
    .back-to-top {
        display: none !important;
    }
    
    .hero {
        height: 300px;
    }
    
    a {
        text-decoration: underline;
    }
}