/* ========================================
   MAIN.CSS - Единый файл стилей
   Проект: Grandfather (Мониторинг цен)
   ======================================== */

/* ===== ПЕРЕМЕННЫЕ ===== */
:root {
    /* Основные цвета */
    --primary-color: #0e3835;
    --primary-light: #1a5c57;
    --primary-dark: #0a2a28;
    --primary-hover: #1a5c57;

    /* Текст */
    --text-primary: #444;
    --text-secondary: #666;
    --text-light: #999;
    --text-white: #fff;

    /* Фоны */
    --bg-white: #fff;
    --bg-light: #f9f9f9;
    --bg-gray: #eee;
    --bg-dark: #3F4137;

    /* Границы */
    --border-color: #ccc;
    --border-light: #e0e0e0;
    --border-dark: #ddd;

    /* Статусы */
    --success: #2e7d32;
    --success-light: #e8f5e9;
    --danger: #c62828;
    --danger-light: #ffe6e6;
    --warning: #f9a825;
    --warning-light: #fff3e0;

    /* Размеры */
    --border-radius: 8px;
    --border-radius-sm: 4px;
    --border-radius-lg: 30px;

    /* Тени */
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.08);
    --shadow: 0 2px 8px rgba(0,0,0,0.1);
    --shadow-lg: 0 4px 12px rgba(0,0,0,0.15);
    --shadow-xl: 0 8px 24px rgba(0,0,0,0.2);

    /* Переходы */
    --transition: all 0.3s ease;
    --transition-fast: all 0.15s ease;
    --transition-slow: all 0.5s ease;

    /* Шрифты */
    --font-family: 'Arial', sans-serif;
    --font-size-base: 16px;
    --font-size-small: 14px;
    --font-size-large: 18px;

    /* Отступы */
    --spacing-xs: 4px;
    --spacing-sm: 8px;
    --spacing-md: 16px;
    --spacing-lg: 24px;
    --spacing-xl: 32px;

    /* Шапка */
    --header-height: 60px;

    /* Сайдбар */
    --sidebar-width: 230px;
    --sidebar-min-width: 230px;
}

/* ========================================
   БАЗОВЫЕ СТИЛИ
   ======================================== */

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

html, body {
    font-family: var(--font-family);
    height: 100%;
    width: 100%;
    color: var(--text-primary);
    font-size: var(--font-size-base);
    line-height: 1.6;
}

a {
    color: #0059b2;
    text-decoration: none;
    transition: var(--transition-fast);
}

a:hover {
    color: #CC0000;
    text-decoration: underline;
}

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

.clear {
    clear: both;
}

/* ========================================
   ШАПКА
   ======================================== */

.header {
    background: var(--primary-color);
    height: var(--header-height);
    position: relative;
    z-index: 100;
    box-shadow: var(--shadow-sm);
}

.logo {
    background: url('../images/logo.jpeg') no-repeat center center;
    background-size: contain;
    width: 70px;
    height: var(--header-height);
}

/* ========================================
   МЕНЮ
   ======================================== */

ul.mainmenu {
    list-style: none;
    margin: 0;
    padding: 0;
    height: var(--header-height);
    color: #fdc073;
    font-size: 20px;
    overflow: hidden;
    display: flex;
    align-items: center;
}

ul.mainmenu li {
    margin: 0 20px 0 0;
}

ul.mainmenu li.logo {
    margin: 0 30px 0 0;
}

ul.mainmenu li.last {
    margin-left: auto;
}

ul.mainmenu li a {
    color: #fdc073;
    text-decoration: none;
    white-space: nowrap;
    transition: var(--transition-fast);
}

ul.mainmenu li a:hover {
    color: #FDA83D;
    text-decoration: none;
}

ul.mainmenu li a.active {
    color: #FDA83D;
    font-weight: bold;
}

/* Кнопка выхода */
.logout-button {
    background: none;
    border: none;
    color: #fdc073;
    cursor: pointer;
    padding: 0;
    font: inherit;
    transition: var(--transition-fast);
}

.logout-button:hover {
    color: #FDA83D;
    text-decoration: underline;
}

/* ========================================
   САЙДБАР
   ======================================== */

.left-chapters {
    margin: 0;
    background: var(--bg-gray);
    border-right: 1px solid var(--border-color);
    width: var(--sidebar-width);
    min-width: var(--sidebar-min-width);
    vertical-align: top;
    height: 100%;
}

.left-chapters ul {
    width: 100%;
    margin: 0;
    padding: 20px 15px 10px 20px;
    list-style: none;
    font-size: 18px;
}

.left-chapters ul li {
    margin: 20px 0 0 0;
    color: var(--text-light);
    list-style: none;
}

.left-chapters ul li:first-child {
    margin-top: 0;
}

.left-chapters ul li a {
    color: var(--text-primary);
    text-decoration: none;
    display: block;
    padding: 5px 0;
    transition: var(--transition-fast);
    border-radius: var(--border-radius-sm);
}

.left-chapters ul li a:hover {
    color: #CC0000;
    text-decoration: underline;
}

.left-chapters ul li a.selected {
    color: #0059b2;
    font-weight: bold;
}

.left-chapters ul li.selected {
    color: #0059b2;
    font-weight: bold;
}

/* ========================================
   КОНТЕНТ
   ======================================== */

.table-page {
    width: 100%;
    height: 100%;
    border-collapse: collapse;
}

.table-content {
    width: 100%;
    min-height: 100%;
}

.content {
    padding: 30px 25px 20px 30px;
    width: 100%;
    vertical-align: top;
}

.content-text {
    color: #000;
    font-size: var(--font-size-large);
    line-height: 1.8;
}

.content-text h1 {
    font-size: 28px;
    margin-bottom: 20px;
    color: var(--primary-color);
}

/* ========================================
   ФУТЕР
   ======================================== */

#footer {
    background: var(--bg-dark);
    padding: 15px 20px;
    color: #aaa;
    font-size: 13px;
    text-align: center;
}

#footer p {
    margin: 0;
}

/* ========================================
   КНОПКИ
   ======================================== */

.btn {
    display: inline-block;
    padding: 10px 25px;
    background: var(--primary-color);
    color: var(--text-white) !important;
    border: none;
    border-radius: var(--border-radius);
    font-size: 15px;
    font-weight: 500;
    text-decoration: none !important;
    cursor: pointer;
    transition: var(--transition);
    text-align: center;
    min-width: 120px;
}

.btn:hover {
    background: var(--primary-hover);
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
    color: var(--text-white) !important;
    text-decoration: none !important;
}

.btn:active {
    transform: translateY(0);
}

/* Варианты кнопок */
.btn-primary {
    background: var(--primary-color);
    color: var(--text-white);
}

.btn-primary:hover {
    background: var(--primary-hover);
}

.btn-success {
    background: var(--success);
    color: var(--text-white);
}

.btn-success:hover {
    background: #1b5e20;
}

.btn-danger {
    background: var(--danger);
    color: var(--text-white);
}

.btn-danger:hover {
    background: #b71c1c;
}

.btn-warning {
    background: var(--warning);
    color: var(--text-white);
}

.btn-warning:hover {
    background: #f57f17;
}

.btn-outline {
    background: transparent;
    color: var(--primary-color) !important;
    border: 2px solid var(--primary-color);
}

.btn-outline:hover {
    background: var(--primary-color);
    color: var(--text-white) !important;
}

.btn-link {
    background: transparent;
    color: var(--primary-color) !important;
    min-width: auto;
    padding: 0;
}

.btn-link:hover {
    background: transparent;
    box-shadow: none;
    transform: none;
    color: var(--primary-hover) !important;
}

/* Размеры кнопок */
.btn-sm {
    padding: 6px 15px;
    font-size: 13px;
    min-width: 80px;
}

.btn-lg {
    padding: 14px 35px;
    font-size: 18px;
    min-width: 160px;
}

.btn-block {
    display: block;
    width: 100%;
}

/* Специальные кнопки */
.btn-edit {
    display: inline-block;
    padding: 8px 20px;
    background: var(--success);
    color: var(--text-white) !important;
    border-radius: var(--border-radius);
    text-decoration: none;
    transition: var(--transition);
}

.btn-edit:hover {
    background: #1b5e20;
    color: var(--text-white) !important;
    transform: translateY(-2px);
    box-shadow: var(--shadow);
    text-decoration: none;
}

.btn-back {
    display: inline-block;
    padding: 8px 20px;
    background: #616161;
    color: var(--text-white) !important;
    border-radius: var(--border-radius);
    text-decoration: none;
    transition: var(--transition);
}

.btn-back:hover {
    background: #424242;
    color: var(--text-white) !important;
    transform: translateY(-2px);
    box-shadow: var(--shadow);
    text-decoration: none;
}

.btn-back::before {
    content: "← ";
}

.btn-detail {
    display: inline-block;
    padding: 8px 20px;
    background: var(--primary-color);
    color: var(--text-white) !important;
    border-radius: var(--border-radius);
    font-size: 14px;
    text-decoration: none;
    transition: var(--transition);
}

.btn-detail:hover {
    background: var(--primary-hover);
    transform: translateY(-2px);
    box-shadow: var(--shadow);
    color: var(--text-white) !important;
    text-decoration: none;
}

/* ========================================
   КАРТОЧКИ ТОВАРОВ
   ======================================== */

ul.list-articles {
    list-style: none;
    margin: 0;
    padding: 0;
}

ul.list-articles li {
    border-bottom: 1px solid var(--border-color);
    padding: 20px 0;
    overflow: hidden;
    transition: var(--transition-fast);
}

ul.list-articles li:hover {
    background: var(--bg-light);
}

ul.list-articles li:last-child {
    border-bottom: none;
}

.article-panel {
    background: var(--bg-gray);
    padding: 5px 10px;
    overflow: hidden;
    color: #555;
    font-size: var(--font-size-small);
    margin-bottom: 10px;
    border-radius: var(--border-radius-sm);
}

.article-panel p.first {
    float: left;
    margin: 0;
}

.article-panel p.last {
    float: right;
    margin: 0;
}

.link-read-post {
    text-align: right;
    margin: 15px 0 5px 0;
}

/* Разделитель */
.divider-pink {
    height: 2px;
    background: linear-gradient(to right, transparent, #e91e63, transparent);
    margin: 15px 0 0 0;
    opacity: 0.3;
}

/* Информация о товаре */
.product-info {
    margin: 10px 0;
}

.product-info p {
    margin: 5px 0;
}

.product-info .btn {
    min-width: auto;
    padding: 4px 12px;
    font-size: 12px;
}

/* ========================================
   ТАБЛИЦА ИСТОРИИ ЦЕН
   ======================================== */

.price-history-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 20px;
    font-size: 15px;
}

.price-history-table th {
    background: var(--bg-dark);
    color: var(--text-white);
    padding: 12px;
    text-align: left;
    border: 1px solid var(--border-dark);
}

.price-history-table td {
    padding: 10px;
    border: 1px solid var(--border-dark);
}

.price-history-table tr:nth-child(even) {
    background: var(--bg-light);
}

.price-history-table tr:hover {
    background: #f5f5f5;
}

/* Цвета изменений */
.price-change-positive {
    color: var(--success) !important;
    font-weight: 600;
}

.price-change-positive::before {
    content: "▲ ";
}

.price-change-negative {
    color: var(--danger) !important;
    font-weight: 600;
}

.price-change-negative::before {
    content: "▼ ";
}

.price-change-neutral {
    color: var(--text-secondary) !important;
}

/* ========================================
   ДЕТАЛИ ТОВАРА
   ======================================== */

.product-detail-container {
    margin: 20px 0;
}

.product-info-block {
    background: var(--bg-light);
    border-radius: var(--border-radius);
    padding: 20px 25px;
    margin: 20px 0 30px 0;
    border-left: 4px solid var(--bg-dark);
    box-shadow: var(--shadow-sm);
}

.product-info-block p {
    margin: 10px 0;
    font-size: var(--font-size-large);
}

.product-info-block strong {
    color: var(--bg-dark);
    min-width: 180px;
    display: inline-block;
}

.product-source-link {
    display: inline-block;
    color: var(--primary-color);
    text-decoration: none;
    transition: var(--transition-fast);
}

.product-source-link:hover {
    color: var(--primary-hover);
    text-decoration: underline;
}

.no-history-message {
    text-align: center;
    padding: 30px;
    color: var(--text-secondary);
    font-size: var(--font-size-large);
}

/* ========================================
   ФОРМЫ
   ======================================== */

.form-container {
    max-width: 100%;
    margin: 20px 0;
}

.form-row {
    display: flex;
    align-items: center;
    margin-bottom: 15px;
    padding: 8px 0;
    border-bottom: 1px solid #f0f0f0;
    flex-wrap: wrap;
}

.form-label {
    width: 180px;
    min-width: 180px;
    padding-right: 15px;
    text-align: right;
    font-weight: 500;
    color: #333;
}

.form-field {
    flex: 1;
    padding-right: 15px;
    min-width: 200px;
}

.form-errors {
    width: 200px;
    min-width: 150px;
    color: var(--danger);
    font-size: 13px;
    padding-left: 10px;
}

.form-field input,
.form-field select,
.form-field textarea {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-sm);
    font-size: 15px;
    box-sizing: border-box;
    background-color: var(--bg-white);
    transition: var(--transition-fast);
}

.form-field input:focus,
.form-field select:focus,
.form-field textarea:focus {
    border-color: var(--primary-color);
    outline: none;
    box-shadow: 0 0 0 3px rgba(14, 56, 53, 0.1);
}

.form-field input[type="checkbox"] {
    width: 20px;
    height: 20px;
    margin: 0;
    cursor: pointer;
}

.form-field textarea {
    height: 80px;
    resize: vertical;
}

.form-error {
    color: var(--danger);
    font-size: 14px;
    margin-bottom: 15px;
    padding: 10px;
    background: var(--danger-light);
    border-radius: var(--border-radius-sm);
    border-left: 3px solid var(--danger);
}

.form-submit {
    margin-top: 25px;
    padding-left: 195px;
}

/* ========================================
   ПАГИНАЦИЯ - ПОЛНОСТЬЮ ПЕРЕРАБОТАННАЯ
   ======================================== */

.list-pages {
    text-align: center;
    margin: 30px 0 20px 0;
    padding: 20px 0;
}

.list-pages ul {
    margin: 0;
    padding: 10px 20px;
    list-style: none;
    display: inline-flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
    gap: 6px;
    background: #ffffff;
    border-radius: 10px;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.12);
    border: 1px solid #d0d0d0;
}

/* ===== ВСЕ КНОПКИ ПАГИНАЦИИ ===== */
.list-pages ul li a,
.list-pages .page-num,
.list-pages .page-num-selected,
.list-pages .page-num-disabled {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 44px;
    height: 44px;
    padding: 0 14px;
    text-align: center;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 500;
    transition: all 0.2s ease;
    text-decoration: none;
    cursor: pointer;
}

/* ===== АКТИВНЫЕ КНОПКИ (кликабельные) ===== */
.list-pages ul li a {
    color: #0e3835;
    background: #f0f4f3;
    border: 2px solid #d0d8d7;
}

.list-pages ul li a:hover {
    background: #0e3835;
    color: #ffffff;
    border-color: #0e3835;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(14, 56, 53, 0.35);
    text-decoration: none;
}

/* ===== ТЕКУЩАЯ СТРАНИЦА ===== */
.list-pages .page-num-selected {
    background: #0e3835;
    color: #ffffff;
    border: 2px solid #0e3835;
    font-weight: 700;
    box-shadow: 0 2px 8px rgba(14, 56, 53, 0.3);
    cursor: default;
}

/* ===== НЕАКТИВНЫЕ КНОПКИ (◀ ▶ когда нельзя нажать) ===== */
.list-pages .page-num-disabled {
    color: #aaaaaa;
    background: #f5f5f5;
    border: 2px solid #e0e0e0;
    cursor: not-allowed;
    opacity: 0.7;
}

/* ===== ОБЫЧНЫЕ НОМЕРА СТРАНИЦ (не выбранные) ===== */
.list-pages .page-num {
    color: #444444;
    background: #f8faf9;
    border: 2px solid #dce2e0;
    cursor: default;
}

/* ===== СТРЕЛКИ ◀ ▶ ===== */
.list-pages .page-num a {
    font-size: 20px;
    font-weight: 700;
    min-width: 44px;
}

.list-pages .page-num a:hover {
    background: #0e3835;
    color: #ffffff;
    border-color: #0e3835;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(14, 56, 53, 0.35);
    text-decoration: none;
}

/* ========================================
   АДАПТИВНАЯ ПАГИНАЦИЯ
   ======================================== */

@media screen and (max-width: 768px) {
    .list-pages ul {
        padding: 8px 12px;
        gap: 4px;
    }

    .list-pages ul li a,
    .list-pages .page-num,
    .list-pages .page-num-selected,
    .list-pages .page-num-disabled {
        min-width: 38px;
        height: 38px;
        padding: 0 10px;
        font-size: 14px;
        border-radius: 6px;
    }
}

@media screen and (max-width: 480px) {
    .list-pages ul {
        padding: 6px 8px;
        gap: 3px;
        border-radius: 8px;
    }

    .list-pages ul li a,
    .list-pages .page-num,
    .list-pages .page-num-selected,
    .list-pages .page-num-disabled {
        min-width: 32px;
        height: 32px;
        padding: 0 6px;
        font-size: 12px;
        border-radius: 4px;
        border-width: 1.5px;
    }

    .list-pages .page-num a {
        font-size: 16px;
        min-width: 32px;
    }
}

/* ========================================
   ПОИСК В ШАПКЕ
   ======================================== */

.search-item {
    margin: 0 15px !important;
    display: flex;
    align-items: center;
}

.search-form {
    display: flex;
    align-items: center;
    background: rgba(255, 255, 255, 0.15);
    border-radius: 20px;
    padding: 0 5px;
    transition: var(--transition);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.search-form:hover,
.search-form:focus-within {
    background: rgba(255, 255, 255, 0.25);
    border-color: rgba(255, 255, 255, 0.3);
    box-shadow: var(--shadow);
}

.search-input {
    background: transparent;
    border: none;
    color: var(--text-white);
    padding: 6px 10px;
    font-size: 14px;
    width: 150px;
    outline: none;
    transition: width var(--transition);
}

.search-input::placeholder {
    color: rgba(255, 255, 255, 0.6);
}

.search-input:focus {
    width: 200px;
}

.search-input:-webkit-autofill {
    -webkit-box-shadow: 0 0 0 30px rgba(14, 56, 53, 0.8) inset !important;
    -webkit-text-fill-color: var(--text-white) !important;
}

.search-button {
    background: transparent;
    border: none;
    color: rgba(255, 255, 255, 0.7);
    cursor: pointer;
    padding: 6px 10px;
    font-size: 16px;
    transition: var(--transition);
    border-radius: 50%;
}

.search-button:hover {
    color: #fdc073;
    transform: scale(1.1);
}

/* ========================================
   РЕЗУЛЬТАТЫ ПОИСКА
   ======================================== */

.search-results-info {
    margin-bottom: 25px;
    padding: 15px 20px;
    background: var(--bg-light);
    border-radius: var(--border-radius);
    border-left: 4px solid var(--primary-color);
}

.search-results-info h2 {
    margin: 0 0 5px 0;
    font-size: 22px;
    color: #333;
}

.search-count {
    margin: 0;
    color: var(--text-secondary);
    font-size: 15px;
}

.no-results {
    text-align: center;
    padding: 40px 20px;
}

.no-results h3 {
    font-size: 24px;
    color: #555;
    margin-bottom: 10px;
}

.no-results p {
    color: #888;
    font-size: 16px;
    margin-bottom: 20px;
}

/* ========================================
   МОБИЛЬНОЕ МЕНЮ
   ======================================== */

.menu-toggle {
    display: none;
    background: none;
    border: none;
    padding: 10px;
    cursor: pointer;
    position: absolute;
    right: 10px;
    top: 10px;
    z-index: 200;
}

.menu-toggle span {
    display: block;
    width: 25px;
    height: 3px;
    background: #fdc073;
    margin: 4px 0;
    transition: var(--transition);
    border-radius: 2px;
}

/* ========================================
   АДАПТИВНОСТЬ
   ======================================== */

/* === ПЛАНШЕТЫ (до 1024px) === */
@media screen and (max-width: 1024px) {
    .content {
        padding: 25px 20px 15px 25px;
    }

    ul.mainmenu {
        font-size: 17px;
    }

    ul.mainmenu li {
        margin: 0 15px 0 0;
    }

    :root {
        --sidebar-width: 200px;
        --sidebar-min-width: 200px;
    }

    .left-chapters ul {
        font-size: 16px;
        padding: 15px 10px 10px 15px;
    }

    .form-label {
        width: 150px;
        min-width: 150px;
    }

    .form-submit {
        padding-left: 165px;
    }
}

/* === МАЛЫЕ ПЛАНШЕТЫ (до 768px) === */
@media screen and (max-width: 768px) {
    body {
        font-size: 15px;
    }

    :root {
        --header-height: auto;
        --font-size-base: 15px;
    }

    .header {
        height: auto;
        min-height: 50px;
        padding: 5px 0;
    }

    /* Скрываем стандартное меню на мобильных */
    ul.mainmenu {
        display: none;
    }

    /* Логотип */
    .logo {
        width: 50px;
        height: 40px;
    }

    /* Скрываем сайдбар */
    .left-chapters {
        display: none;
    }

    .content {
        padding: 15px 12px 10px 15px;
    }

    .content-text {
        font-size: 16px;
    }

    .content-text h1 {
        font-size: 24px;
    }

    /* Кнопки */
    .btn {
        padding: 8px 18px;
        font-size: 14px;
        min-width: 100px;
    }

    .btn-sm {
        width: auto;
        min-width: 60px;
        padding: 4px 12px;
        font-size: 12px;
    }

    /* Формы */
    .form-row {
        flex-direction: column;
        align-items: stretch;
        padding: 10px 0;
    }

    .form-label {
        width: 100%;
        min-width: 100%;
        text-align: left;
        padding-right: 0;
        padding-bottom: 5px;
        font-weight: 600;
    }

    .form-field {
        padding-right: 0;
        padding-bottom: 5px;
        min-width: 100%;
    }

    .form-errors {
        width: 100%;
        min-width: 100%;
        padding-left: 0;
    }

    .form-submit {
        padding-left: 0;
        text-align: center;
    }

    /* Товар */
    .product-info-block {
        padding: 15px;
    }

    .product-info-block p {
        font-size: 15px;
    }

    .product-info-block strong {
        min-width: 100px;
        font-size: 14px;
    }

    .product-info-block img {
        float: none !important;
        margin: 0 0 15px 0 !important;
        max-width: 100% !important;
    }

    ul.list-articles li img {
        float: none !important;
        margin: 0 0 10px 0 !important;
        width: 100% !important;
        max-width: 200px !important;
        height: auto !important;
    }

    ul.list-articles li .product-photo-placeholder {
        float: none !important;
        margin: 0 auto 10px auto !important;
    }

    .article-panel p.first,
    .article-panel p.last {
        float: none;
        text-align: center;
    }

    /* Таблица истории */
    .price-history-table {
        font-size: 13px;
        display: block;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .price-history-table th,
    .price-history-table td {
        padding: 8px 6px;
    }

    /* Пагинация */
    .list-pages ul {
        padding: 5px 5px;
        border-radius: 20px;
    }

    .list-pages ul li {
        margin: 0 2px;
    }

    .list-pages ul li a,
    .list-pages .page-num,
    .list-pages .page-num-selected {
        min-width: 36px;
        height: 36px;
        line-height: 36px;
        padding: 0 8px;
        font-size: 14px;
    }

    .list-pages .page-num-disabled {
        min-width: 36px;
        height: 36px;
        line-height: 36px;
        font-size: 16px;
    }

    #footer {
        font-size: 11px;
        padding: 10px 15px;
    }
}

/* === МОБИЛЬНЫЕ ТЕЛЕФОНЫ (до 480px) === */
@media screen and (max-width: 480px) {
    body {
        font-size: 14px;
    }

    :root {
        --font-size-base: 14px;
    }

    ul.mainmenu {
        font-size: 13px;
    }

    ul.mainmenu li {
        margin: 3px 6px;
    }

    .content-text h1 {
        font-size: 20px;
    }

    .content-text {
        font-size: 14px;
    }

    .btn {
        padding: 8px 15px;
        font-size: 13px;
        min-width: 80px;
    }

    .product-info-block {
        padding: 12px;
    }

    .product-info-block p {
        font-size: 14px;
    }

    .product-info-block strong {
        min-width: 70px;
        font-size: 13px;
        display: inline;
    }

    .price-history-table th,
    .price-history-table td {
        padding: 5px 4px;
        font-size: 11px;
    }

    .form-field input,
    .form-field select,
    .form-field textarea {
        font-size: 14px;
        padding: 6px 10px;
    }

    .list-pages ul li a,
    .list-pages .page-num,
    .list-pages .page-num-selected {
        min-width: 30px;
        height: 30px;
        line-height: 30px;
        padding: 0 5px;
        font-size: 12px;
    }

    .list-pages .page-num-disabled {
        min-width: 30px;
        height: 30px;
        line-height: 30px;
        font-size: 14px;
    }

    #footer {
        font-size: 10px;
        padding: 8px 10px;
    }

    .form-submit button {
        width: 100%;
    }

    .search-input {
        font-size: 13px;
        padding: 6px 10px;
    }

    .search-button {
        font-size: 14px;
        padding: 6px 8px;
    }
}

/* === ОЧЕНЬ МАЛЕНЬКИЕ ЭКРАНЫ (до 320px) === */
@media screen and (max-width: 320px) {
    ul.mainmenu {
        font-size: 11px;
    }

    ul.mainmenu li {
        margin: 2px 4px;
    }

    .content-text h1 {
        font-size: 18px;
    }

    .price-history-table th,
    .price-history-table td {
        padding: 3px 2px;
        font-size: 9px;
    }
}

/* === АЛЬБОМНАЯ ОРИЕНТАЦИЯ === */
@media screen and (max-height: 500px) and (orientation: landscape) {
    .header {
        min-height: 40px;
    }

    ul.mainmenu {
        font-size: 13px;
    }

    ul.mainmenu li {
        margin: 3px 8px;
    }

    .logo {
        width: 40px;
        height: 30px;
    }

    .content {
        padding: 10px 10px 5px 12px;
    }
}

/* === ТЕМНАЯ ТЕМА === */
@media (prefers-color-scheme: dark) {
    body.dark-theme {
        background: #1a1a1a;
        color: #e0e0e0;
    }

    body.dark-theme .content-text {
        color: #e0e0e0;
    }

    body.dark-theme .left-chapters {
        background: #2a2a2a;
        border-right-color: #444;
    }

    body.dark-theme .left-chapters ul li a {
        color: #ccc;
    }

    body.dark-theme .product-info-block {
        background: #2a2a2a;
        border-left-color: var(--primary-light);
    }

    body.dark-theme .price-history-table td {
        border-color: #444;
    }

    body.dark-theme .price-history-table tr:nth-child(even) {
        background: #2a2a2a;
    }

    body.dark-theme .price-history-table tr:hover {
        background: #333;
    }
}

/* === ДОСТУПНОСТЬ === */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}

/* === ПЕЧАТЬ === */
@media print {
    .header,
    .left-chapters,
    #footer,
    .btn,
    .link-read-post,
    .search-item,
    .menu-toggle {
        display: none !important;
    }

    .content {
        padding: 10px;
        width: 100%;
    }

    .content-text {
        font-size: 12px;
    }

    .price-history-table {
        font-size: 10px;
    }

    .price-history-table th {
        background: #333 !important;
        color: #fff !important;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }
}

/* ========================================
   УТИЛИТЫ
   ======================================== */

/* Выравнивание */
.text-center {
    text-align: center;
}
.text-left {
    text-align: left;
}
.text-right {
    text-align: right;
}

/* Отступы */
.mt-1 { margin-top: var(--spacing-sm); }
.mt-2 { margin-top: var(--spacing-md); }
.mt-3 { margin-top: var(--spacing-lg); }
.mt-4 { margin-top: var(--spacing-xl); }

.mb-1 { margin-bottom: var(--spacing-sm); }
.mb-2 { margin-bottom: var(--spacing-md); }
.mb-3 { margin-bottom: var(--spacing-lg); }
.mb-4 { margin-bottom: var(--spacing-xl); }

/* Флекс */
.d-flex {
    display: flex;
}
.align-center {
    align-items: center;
}
.justify-center {
    justify-content: center;
}
.justify-between {
    justify-content: space-between;
}
.flex-wrap {
    flex-wrap: wrap;
}
.gap-1 { gap: var(--spacing-sm); }
.gap-2 { gap: var(--spacing-md); }
.gap-3 { gap: var(--spacing-lg); }

/* Скрытие */
.hidden {
    display: none !important;
}
.visible {
    display: block !important;
}

/* Картинки */
.img-responsive {
    max-width: 100%;
    height: auto;
}
.img-circle {
    border-radius: 50%;
}
.img-thumbnail {
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-sm);
}

/* Контейнер */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 15px;
}
.container-fluid {
    width: 100%;
    padding: 0 15px;
}

/* ===== СТИЛИ ДЛЯ ПОИСКА ТОВАРОВ ===== */

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

.search-form-wrapper {
    background: #f8f9fa;
    border-radius: 12px;
    padding: 25px;
    margin: 20px 0;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.search-form .form-row {
    display: flex;
    gap: 15px;
    align-items: center;
}

.search-form .form-field {
    flex: 1;
}

.search-form input {
    width: 100%;
    padding: 12px 18px;
    font-size: 16px;
    border: 2px solid #ddd;
    border-radius: 8px;
    transition: border-color 0.3s;
}

.search-form input:focus {
    border-color: #0e3835;
    outline: none;
}

.search-results {
    margin-top: 30px;
}

.search-count {
    color: #666;
    font-size: 16px;
    margin-bottom: 20px;
}

.results-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 20px;
}

.product-card {
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    overflow: hidden;
    transition: transform 0.3s, box-shadow 0.3s;
    border: 1px solid #eee;
    position: relative;
}

.product-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 24px rgba(0,0,0,0.15);
}

.product-image {
    height: 200px;
    background: #f5f5f5;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    position: relative;
}

.product-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.no-image {
    color: #999;
    font-size: 48px;
}

.source-badge {
    position: absolute;
    top: 10px;
    right: 10px;
    background: rgba(0,0,0,0.7);
    color: #fff;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 12px;
}

.product-info {
    padding: 16px;
}

.product-info h3 {
    font-size: 16px;
    margin: 0 0 8px 0;
    min-height: 44px;
    line-height: 1.4;
}

.product-price {
    font-size: 20px;
    font-weight: bold;
    color: #0e3835;
    margin: 8px 0;
}

.product-meta {
    font-size: 14px;
    color: #666;
    margin: 4px 0;
}

.product-description {
    font-size: 13px;
    color: #888;
    margin: 8px 0;
    line-height: 1.5;
}

.product-actions {
    display: flex;
    gap: 10px;
    margin-top: 12px;
    flex-wrap: wrap;
}

.product-actions .btn {
    flex: 1;
    min-width: 80px;
    font-size: 13px;
    padding: 6px 12px;
}

.btn-outline {
    background: transparent;
    color: #0e3835 !important;
    border: 1px solid #0e3835;
}

.btn-outline:hover {
    background: #0e3835;
    color: #fff !important;
}

.btn-success {
    background: #2e7d32;
    color: #fff !important;
    border: none;
}

.btn-success:hover {
    background: #1b5e20;
}

.btn-success:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.text-muted {
    color: #999;
}

.no-results {
    text-align: center;
    padding: 60px 20px;
}

.no-results h3 {
    font-size: 24px;
    color: #555;
    margin-bottom: 10px;
}

.no-results p {
    color: #888;
    font-size: 16px;
}

/* Адаптивность для поиска */
@media (max-width: 768px) {
    .search-form .form-row {
        flex-direction: column;
    }

    .results-grid {
        grid-template-columns: 1fr;
    }

    .product-actions .btn {
        flex: 1;
    }
}

@media (max-width: 480px) {
    .search-products-container {
        padding: 10px;
    }

    .search-form-wrapper {
        padding: 15px;
    }

    .product-image {
        height: 150px;
    }

    .product-info h3 {
        font-size: 14px;
        min-height: 36px;
    }

    .product-price {
        font-size: 17px;
    }
}

.regional {
    color: #0e3835;
    font-size: 18px;
    padding: 4px 8px;
    background: #f0f7f6;
    border-radius: 6px;
    display: inline-block;
}

.region-badge {
    font-size: 12px;
    background: #0e3835;
    color: #fff;
    padding: 2px 10px;
    border-radius: 12px;
    margin-left: 5px;
}

.retailer-badge {
    font-size: 12px;
    background: #fdc073;
    color: #0e3835;
    padding: 2px 10px;
    border-radius: 12px;
    margin-left: 5px;
}

/* ========================================
   ГРАФИК ИСТОРИИ ЦЕН
   ======================================== */

.price-chart-container {
    margin: 30px 0;
    padding: 20px 25px;
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.price-chart-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 15px;
    margin-bottom: 15px;
}

.price-chart-header h2 {
    margin: 0;
    font-size: 22px;
    color: #0e3835;
}

.price-chart-actions {
    display: flex;
    gap: 12px;
    align-items: center;
    flex-wrap: wrap;
}

/* ===== КНОПКИ-ФИЛЬТРЫ ===== */
.price-chart-filters {
    display: inline-flex;
    background: #f0f4f3;
    border-radius: 8px;
    padding: 4px;
    gap: 4px;
}

.chart-filter {
    background: transparent;
    border: none;
    padding: 8px 16px;
    font-size: 14px;
    color: #0e3835;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
    font-weight: 500;
    font-family: inherit;
}

.chart-filter:hover {
    background: rgba(14, 56, 53, 0.1);
}

.chart-filter.active {
    background: #0e3835;
    color: #fff;
    box-shadow: 0 2px 6px rgba(14, 56, 53, 0.3);
}

/* ===== КНОПКА ЭКСПОРТА PNG ===== */
.chart-export-btn {
    display: inline-block;
    padding: 8px 18px;
    background: #0e3835;
    color: #fff;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    text-decoration: none;
    transition: all 0.2s ease;
    font-family: inherit;
    min-width: 100px;
    text-align: center;
}

.chart-export-btn:hover {
    background: #1a5c57;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(14, 56, 53, 0.3);
    color: #fff;
}

.chart-export-btn:active {
    transform: translateY(0);
}

/* ===== БЛОК ИЗМЕНЕНИЯ % ===== */
.price-chart-change {
    padding: 12px 18px;
    border-radius: 8px;
    font-size: 15px;
    margin-bottom: 15px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
    font-weight: 500;
}

.price-chart-change.positive {
    background: #e8f5e9;
    color: #2e7d32;
    border-left: 4px solid #2e7d32;
}

.price-chart-change.negative {
    background: #ffebee;
    color: #c62828;
    border-left: 4px solid #c62828;
}

.price-chart-change.neutral {
    background: #f5f5f5;
    color: #666;
    border-left: 4px solid #999;
}

.price-chart-change .change-date {
    font-size: 13px;
    color: #666;
    font-weight: normal;
}

/* ===== КОНТЕЙНЕР CANVAS ===== */
.price-chart-canvas-wrap {
    position: relative;
    height: 350px;
}

/* ===== АДАПТИВНОСТЬ ===== */
@media (max-width: 768px) {
    .price-chart-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .price-chart-actions {
        width: 100%;
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
    }

    .price-chart-filters {
        width: 100%;
        display: flex;
        justify-content: space-between;
    }

    .chart-filter {
        flex: 1;
        text-align: center;
        padding: 8px 4px;
        font-size: 13px;
    }

    .chart-export-btn {
        width: 100%;
        padding: 10px;
    }

    .price-chart-canvas-wrap {
        height: 280px;
    }

    .price-chart-change {
        flex-direction: column;
        align-items: flex-start;
        font-size: 14px;
    }
}

@media (max-width: 480px) {
    .price-chart-container {
        padding: 15px 12px;
        margin: 20px 0;
    }

    .price-chart-header h2 {
        font-size: 18px;
    }

    .price-chart-canvas-wrap {
        height: 240px;
    }

    .chart-filter {
        font-size: 12px;
        padding: 7px 4px;
    }
}

/* ========================================
   КНОПКИ ФОРМЫ (Сохранить / Отмена)
   ======================================== */

.btn {
    display: inline-block;
    padding: 10px 22px;
    font-size: 15px;
    font-weight: 500;
    border-radius: 6px;
    border: none;
    cursor: pointer;
    text-decoration: none;
    transition: all 0.2s ease;
    font-family: inherit;
    text-align: center;
    min-width: 120px;
}

.btn-primary {
    background: #0e3835;
    color: #fff;
}

.btn-primary:hover {
    background: #1a5c57;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(14, 56, 53, 0.3);
    color: #fff;
}

.btn-secondary {
    background: #e0e0e0;
    color: #333;
    margin-left: 10px;
}

.btn-secondary:hover {
    background: #d0d0d0;
    color: #000;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

/* Адаптивность */
@media (max-width: 480px) {
    .btn {
        width: 100%;
        margin: 5px 0;
    }

    .btn-secondary {
        margin-left: 0;
    }
}

/* ========================================
   СТРАНИЦА «О ПРОЕКТЕ»
   ======================================== */

.about-page {
    max-width: 900px;
    margin: 0 auto;
    padding: 20px 0 40px;
}

.about-page h1 {
    font-size: 32px;
    color: var(--primary-color);
    margin-bottom: 15px;
}

.about-page h2 {
    font-size: 24px;
    color: var(--primary-color);
    margin: 35px 0 20px;
    padding-bottom: 10px;
    border-bottom: 2px solid var(--border-light);
}

.about-lead {
    font-size: 17px;
    line-height: 1.7;
    color: #444;
    margin-bottom: 25px;
    padding: 15px 20px;
    background: var(--bg-light);
    border-left: 4px solid var(--primary-color);
    border-radius: 6px;
}

/* Категории */
.about-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 15px;
    margin: 20px 0;
}

.about-card {
    background: #fff;
    border: 1px solid var(--border-light);
    border-radius: 10px;
    padding: 20px 15px;
    text-align: center;
    transition: all 0.2s ease;
}

.about-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    border-color: var(--primary-color);
}

.about-card-icon {
    font-size: 36px;
    margin-bottom: 10px;
}

.about-card h3 {
    margin: 0 0 5px 0;
    font-size: 15px;
    color: var(--primary-color);
    font-weight: 600;
}

.about-card-count {
    margin: 0;
    font-size: 13px;
    color: #888;
}

/* Источники */
.about-sources {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.about-source {
    display: flex;
    gap: 20px;
    align-items: flex-start;
    background: #fff;
    border-radius: 10px;
    padding: 20px;
    border: 1px solid var(--border-light);
    transition: all 0.2s ease;
}

.about-source:hover {
    box-shadow: 0 4px 12px rgba(0,0,0,0.08);
}

.about-source-icon {
    font-size: 36px;
    min-width: 50px;
    text-align: center;
}

.about-source h3 {
    margin: 0 0 8px 0;
    font-size: 17px;
    color: var(--primary-color);
}

.about-source p {
    margin: 5px 0;
    font-size: 15px;
    line-height: 1.6;
}

.about-source-meta {
    font-size: 13px !important;
    color: #888;
    font-weight: 500;
}

/* Шаги */
.about-steps {
    padding-left: 20px;
    margin: 20px 0;
}

.about-steps li {
    margin: 12px 0;
    font-size: 15px;
    line-height: 1.7;
    color: #444;
}

.about-steps li strong {
    color: var(--primary-color);
}

/* Технологии */
.about-tech {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin: 20px 0;
}

.about-tech-item {
    background: var(--primary-color);
    color: #fff;
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 14px;
    font-weight: 500;
}

/* Футер */
.about-footer {
    margin-top: 50px;
    padding-top: 20px;
    border-top: 1px solid var(--border-light);
    text-align: center;
    font-size: 13px;
    color: #888;
}

.about-footer-meta {
    font-size: 12px !important;
    margin-top: 5px;
}

/* Адаптивность */
@media (max-width: 768px) {
    .about-page h1 { font-size: 24px; }
    .about-page h2 { font-size: 20px; }
    .about-lead { font-size: 15px; }

    .about-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .about-source {
        flex-direction: column;
        gap: 10px;
    }

    .about-source-icon { font-size: 28px; min-width: auto; }
}

/* ========================================
   ДАШБОРД СТАТИСТИКИ
   ======================================== */

.dashboard-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
    margin: 20px 0 30px;
}

.stat-card {
    background: #fff;
    border-radius: 12px;
    padding: 20px;
    text-align: center;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    transition: all 0.2s;
}

.stat-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 16px rgba(0,0,0,0.12);
}

.stat-icon { font-size: 32px; margin-bottom: 8px; }
.stat-value { font-size: 32px; font-weight: 700; margin-bottom: 4px; }
.stat-label { font-size: 13px; color: #888; text-transform: uppercase; }

.stat-card-blue { border-top: 4px solid #2196f3; }
.stat-card-blue .stat-value { color: #2196f3; }
.stat-card-green { border-top: 4px solid #2e7d32; }
.stat-card-green .stat-value { color: #2e7d32; }
.stat-card-purple { border-top: 4px solid #7b1fa2; }
.stat-card-purple .stat-value { color: #7b1fa2; }
.stat-card-red { border-top: 4px solid #c62828; }
.stat-card-red .stat-value { color: #c62828; }

.dashboard-charts {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 30px;
}

.dashboard-chart {
    background: #fff;
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}

.dashboard-chart-wide {
    grid-column: 1 / -1;
}

.dashboard-chart h2 {
    margin: 0 0 15px 0;
    font-size: 18px;
    color: #0e3835;
}

.chart-container {
    position: relative;
    height: 280px;
}

.dashboard-table {
    width: 100%;
    border-collapse: collapse;
    background: #fff;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}

.dashboard-table th {
    background: #0e3835;
    color: #fff;
    padding: 12px;
    text-align: left;
    font-size: 14px;
}

.dashboard-table td {
    padding: 10px 12px;
    border-bottom: 1px solid #eee;
    font-size: 14px;
}

.dashboard-table tr:last-child td { border-bottom: none; }
.dashboard-table tr:hover { background: #f9f9f9; }

.status-badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
    color: #fff;
}

.status-success { background: #2e7d32; }
.status-error { background: #c62828; }
.status-partial { background: #f9a825; }
.status-running { background: #2196f3; }

@media (max-width: 768px) {
    .dashboard-charts { grid-template-columns: 1fr; }
    .dashboard-table { font-size: 12px; }
    .dashboard-table th, .dashboard-table td { padding: 8px 6px; }
}

/* ========================================
   ОБРАТНАЯ СВЯЗЬ
   ======================================== */
.contact-container {
    max-width: 700px;
    margin: 0 auto;
}
.contact-intro {
    font-size: 16px;
    color: #555;
    margin-bottom: 25px;
    padding: 12px 18px;
    background: #f9f9f9;
    border-left: 4px solid #0e3835;
    border-radius: 4px;
}
.contact-form .form-input {
    width: 100%;
    padding: 10px;
    border: 1px solid #ccc;
    border-radius: 6px;
    font-family: inherit;
}
.contact-form .form-input:focus {
    border-color: #0e3835;
    outline: none;
}
.alert {
    padding: 12px 18px;
    border-radius: 6px;
    margin-bottom: 20px;
}
.alert-success { background: #e8f5e9; color: #2e7d32; border: 1px solid #2e7d32; }
.alert-warning { background: #fff3e0; color: #f9a825; border: 1px solid #f9a825; }