/* =========================================================
   BASE.CSS — базовые стили, переменные, хедер, футер, breadcrumbs
   Шрифт: Manrope (Google Fonts, подключён в base.html)
   ========================================================= */

/* ===== ПЕРЕМЕННЫЕ ===== */
:root {
    --accent: #0f766e;
    --accent-hover: #0b5e57;
    --accent-glow: rgba(15, 118, 110, 0.25);
    --accent-light: rgba(15, 118, 110, 0.10);
    --accent-dark: #064e46;

    --bg-primary: #f7f9f8;
    --bg-secondary: #ffffff;
    --bg-tertiary: #eef2f1;
    --bg-card: #ffffff;

    --text-primary: #202122;
    --text-secondary: #3d474b;
    --text-muted: #6b767a;
    --text-dark: #9aa3a7;

    --border: rgba(20, 24, 26, 0.08);
    --border-light: rgba(20, 24, 26, 0.16);

    --radius-sm: 8px;
    --radius: 12px;
    --radius-lg: 16px;
    --radius-xl: 20px;

    --transition: 0.25s cubic-bezier(0.4, 0, 0.2, 1);

    --header-height: 64px;
    --header-height-mobile: 56px;
    --header-offset: var(--header-height);

    --font-sans: 'Manrope', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
}

/* ===== СБРОС ===== */
*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
}

body {
    font-family: var(--font-sans);
    font-weight: 400;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.55;
    min-height: 100vh;
    min-height: -webkit-fill-available;
    padding-top: var(--header-offset);
    padding-bottom: 0;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    -webkit-tap-highlight-color: transparent;
}

/* Manrope чуть шире системного — небольшие корректировки в тексте */
p, li, dd, dt {
    letter-spacing: 0.005em;
}

h1, h2, h3, h4, h5, h6 {
    letter-spacing: -0.02em;
}

/* ===== ХЕДЕР ===== */
.site-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    background: rgba(255, 255, 255, 0.94);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--border);
    height: var(--header-offset);
    padding-top: env(safe-area-inset-top, 0);
    transition: all var(--transition);
}

.header-container {
    max-width: 1280px;
    margin: 0 auto;
    padding: 0 24px;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}
.btn-vk-login {
    display: inline-flex;
    align-items: center;
    padding: 8px 16px;
    background: #0077FF;
    color: #fff;
    border-radius: 8px;
    text-decoration: none;
    font-size: 14px;
    font-weight: 600;
    transition: background 0.2s;
}

.btn-vk-login:hover {
    background: #0061CC;
}
.header-login-btn {
    padding: 8px 18px;
    background: #0f766e;
    color: #fff;
    border-radius: 8px;
    text-decoration: none;
    font-size: 14px;
    font-weight: 600;
    transition: background 0.2s;
}

.header-login-btn:hover {
    background: #0d635c;
}
.header-logo a {
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    color: var(--text-primary);
    font-weight: 800;
    font-size: 1.15rem;
    letter-spacing: -0.04em;
    transition: opacity var(--transition);
}

.header-logo a:hover { opacity: 0.7; }

.header-logo svg {
    color: var(--accent);
    flex-shrink: 0;
}
/* ===== СТИЛИ ДЛЯ АВАТАРА В ХЕДЕРЕ ===== */

/* Контейнер для картинки внутри кнопки */
.header-user-menu__toggle img.header-avatar-img {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
    display: block;
}

/* Заглушка (SVG внутри div), если нет аватара */
.header-avatar-placeholder {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: var(--bg-tertiary);
    color: var(--text-muted);
}

/* Стрелочка в кнопке меню */
.header-arrow {
    color: var(--text-muted);
    flex-shrink: 0;
    margin-left: 6px;
    transition: transform var(--transition);
}

/* Поворот стрелочки при открытом меню (нужно добавить класс .open к кнопке через JS) */
.header-user-menu__toggle.open .header-arrow {
    transform: rotate(180deg);
}

/* --- Адаптив для мобильных: убираем стрелочку на очень маленьких экранах --- */
@media (max-width: 900px) {
    .header-user-menu__toggle {
        padding: 4px;
        border-radius: 50%;
        gap: 0;
    }
    
    .header-user-menu__toggle .header-arrow {
        display: none; /* На мобильном в круглой кнопке стрелочка не нужна */
    }
    
    .header-user-menu__toggle img.header-avatar-img,
    .header-avatar-placeholder {
        width: 36px;
        height: 36px;
    }
}

/* --- Исправление для твоего существующего стиля toggle --- */
/* Твой старый стиль делал круглую иконку через padding и background. 
   Теперь мы делаем круглую картинку. Убираем лишние отступы, если они ломают верстку */
.header-user-menu__toggle > svg:first-child {
    display: none; /* Скрываем старый SVG-аватар, который был у тебя в коде */
}

.logo-text { letter-spacing: -0.04em; }
.logo-accent { color: var(--accent); }

.header-nav {
    display: flex;
    align-items: center;
    gap: 4px;
    flex: 1;
    justify-content: center;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 14px;
    border-radius: 10px;
    color: var(--text-muted);
    text-decoration: none;
    font-size: 0.85rem;
    font-weight: 600;
    letter-spacing: 0.005em;
    transition: all var(--transition);
    background: transparent;
    border: none;
    cursor: pointer;
    font-family: inherit;
}

.nav-link:hover {
    color: var(--text-primary);
    background: var(--bg-tertiary);
}

.nav-link.active {
    color: var(--accent);
    background: var(--accent-light);
}

.nav-link svg { width: 18px; height: 18px; flex-shrink: 0; }
.nav-link span { white-space: nowrap; }

.header-right {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
}

.header-user-menu { position: relative; }

.header-user-menu__toggle {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 4px 12px 4px 4px;
    border-radius: 20px;
    background: var(--bg-tertiary);
    border: none;
    color: var(--text-primary);
    font-family: inherit;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    transition: background var(--transition);
}

.header-user-menu__toggle:hover { background: rgba(20, 24, 26, 0.08); }

.header-user-menu__toggle > svg:first-child {
    width: 32px;
    height: 32px;
    padding: 7px;
    border-radius: 50%;
    background: var(--accent);
    color: #ffffff;
    flex-shrink: 0;
    box-sizing: border-box;
}

.header-user-menu__toggle > svg:last-child {
    color: var(--text-muted);
    flex-shrink: 0;
}

.header-user-menu__dropdown {
    position: absolute;
    top: calc(100% + 10px);
    right: 0;
    min-width: 230px;
    padding: 6px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 14px;
    box-shadow: 0 20px 60px rgba(20, 24, 26, 0.15);
    z-index: 1200;
}

.header-user-menu__dropdown[hidden] { display: none; }

.header-user-menu__dropdown a {
    display: block;
    padding: 10px 14px;
    border-radius: 8px;
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.85rem;
    font-weight: 500;
    white-space: nowrap;
    transition: all var(--transition);
}

.header-user-menu__dropdown a:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.header-user-menu__dropdown hr {
    border: none;
    border-top: 1px solid var(--border);
    margin: 6px 4px;
}

.logout-form { margin: 0; padding: 0; }

.logout-form .dropdown-link {
    width: 100%;
    text-align: left;
    background: transparent;
    border: none;
    font-family: inherit;
    cursor: pointer;
    display: block;
    padding: 10px 14px;
    border-radius: 8px;
    color: #dc2626;
    font-size: 0.85rem;
    font-weight: 500;
    white-space: nowrap;
    transition: background var(--transition);
}

.logout-form .dropdown-link:hover {
    background: rgba(220, 38, 38, 0.08);
}

/* ===== ОВЕРЛЕИ / КОНТЕНТ ===== */
.search-container { display: none; }

.main-content {
    min-height: calc(100vh - var(--header-offset) - 200px);
    padding-bottom: 40px;
}

.container {
    width: 100%;
    max-width: 1280px;
    margin-left: auto;
    margin-right: auto;
    padding-left: 24px;
    padding-right: 24px;
    box-sizing: border-box;
}

/* ===== ХЛЕБНЫЕ КРОШКИ ===== */
.breadcrumbs {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px;
    font-size: 0.82rem;
    line-height: 1.4;
    color: var(--text-muted);
    padding: 20px 0 0;
    margin: 0 0 20px;
}

.breadcrumbs a {
    color: var(--text-muted);
    text-decoration: none;
    transition: color 0.2s ease;
}

.breadcrumbs a:hover { color: var(--accent); }

.breadcrumbs__sep {
    color: var(--text-dark);
    user-select: none;
    font-weight: 400;
    margin: 0 2px;
}

.breadcrumbs__current {
    color: var(--text-secondary);
    font-weight: 500;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ===== ФУТЕР ===== */
.site-footer {
    background: var(--bg-secondary);
    border-top: 1px solid var(--border);
    padding: 40px 0 30px;
    margin-top: auto;
    padding-bottom: calc(30px + env(safe-area-inset-bottom, 0));
}

.footer-container {
    max-width: 1280px;
    margin: 0 auto;
    padding: 0 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 20px;
}

.footer-info {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.footer-info p {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin: 0;
}

.footer-info__brand {
    font-size: 1rem;
    font-weight: 800;
    letter-spacing: -0.03em;
    color: var(--text-primary);
    margin: 0 0 2px;
}

.footer-info__brand .logo-accent { color: var(--accent); }

.footer-links {
    display: flex;
    gap: 20px;
    flex-wrap: wrap;
}

.footer-links a {
    color: var(--text-muted);
    text-decoration: none;
    font-size: 0.85rem;
    font-weight: 500;
    transition: color var(--transition);
}

.footer-links a:hover { color: var(--text-primary); }

.footer-categories {
    display: flex;
    flex-wrap: wrap;
    gap: 10px 16px;
    justify-content: center;
    width: 100%;
    padding-top: 16px;
    margin-top: 8px;
    border-top: 1px solid var(--border);
}

.footer-categories a {
    color: var(--text-muted);
    text-decoration: none;
    font-size: 0.82rem;
    transition: color var(--transition);
}

.footer-categories a:hover { color: var(--accent); }

/* ===== МОБИЛЬНАЯ НАВИГАЦИЯ ===== */
.mobile-bottom-nav {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    background: rgba(255, 255, 255, 0.96);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-top: 1px solid var(--border);
    padding: 6px 0 calc(6px + env(safe-area-inset-bottom, 0));
    justify-content: space-around;
    align-items: center;
}

.mobile-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    padding: 6px 12px;
    color: var(--text-muted);
    text-decoration: none;
    font-size: 0.6rem;
    font-weight: 600;
    letter-spacing: 0.01em;
    transition: color var(--transition);
    background: none;
    border: none;
    cursor: pointer;
    font-family: inherit;
    position: relative;
    border-radius: 10px;
    -webkit-tap-highlight-color: transparent;
}

.mobile-nav-item.active { color: var(--accent); }

.mobile-nav-item svg { width: 22px; height: 22px; }
.mobile-nav-item span { line-height: 1; }

/* ===== iOS STANDALONE ===== */
@media screen and (display-mode: standalone) {
    :root {
        --header-offset: calc(var(--header-height) + env(safe-area-inset-top, 0));
    }

    body { padding-top: var(--header-offset); }

    .site-header {
        height: var(--header-offset);
        padding-top: env(safe-area-inset-top, 0);
        box-sizing: content-box;
    }

    .search-container.mobile-open { top: var(--header-offset); }
}

/* ===== АДАПТИВ ===== */
@media (max-width: 1024px) {
    .header-container { padding: 0 20px; }
    .nav-link span { display: none; }
    .nav-link { padding: 8px 12px; }
    .nav-link svg { width: 20px; height: 20px; }
}

@media (max-width: 900px) {
    .header-user-menu__toggle span { display: none; }
    .header-user-menu__toggle {
        padding: 4px;
        border-radius: 50%;
        gap: 0;
    }
    .header-user-menu__toggle > svg:last-child { display: none; }
    .header-user-menu__toggle > svg:first-child {
        width: 36px;
        height: 36px;
        padding: 8px;
    }
}

@media (max-width: 768px) {
    :root {
        --header-height: var(--header-height-mobile);
        --header-offset: var(--header-height-mobile);
    }

    body { padding-bottom: 70px; }

    .site-header { height: var(--header-offset); }

    .header-container { padding: 0 16px; }

    .header-nav { display: none !important; }

    .mobile-bottom-nav { display: flex; }

    .search-container:not(.mobile-open) { display: none; }

    .search-container.mobile-open {
        display: block;
        position: fixed;
        top: var(--header-offset);
        left: 0;
        right: 0;
        bottom: 0;
        z-index: 998;
        background: var(--bg-primary);
        overflow-y: auto;
        padding: 0;
        -webkit-overflow-scrolling: touch;
    }

    .header-logo a { font-size: 1rem; }
    .header-logo svg { width: 26px; height: 26px; }

    .footer-container {
        flex-direction: column;
        text-align: center;
        gap: 16px;
        padding: 0 16px;
    }

    .footer-links { justify-content: center; gap: 14px; }
    .footer-info p { font-size: 0.8rem; }

    .breadcrumbs {
        padding-top: 12px;
        margin-bottom: 16px;
        font-size: 0.76rem;
    }

    .container { padding-left: 16px; padding-right: 16px; }
}

@media (max-width: 480px) {
    .header-container { padding: 0 12px; }
    .header-logo a { font-size: 0.9rem; gap: 6px; }
    .header-logo svg { width: 22px; height: 22px; }
    .logo-text { font-size: 0.9rem; }

    .mobile-nav-item {
        padding: 5px 10px;
        font-size: 0.55rem;
    }
    .mobile-nav-item svg { width: 20px; height: 20px; }

    .footer-links { gap: 12px; }
    .footer-links a { font-size: 0.78rem; }

    .footer-categories { gap: 8px 12px; }
    .footer-categories a { font-size: 0.76rem; }

    .container { padding-left: 12px; padding-right: 12px; }
}

@media (max-width: 360px) {
    .header-logo a { font-size: 0.82rem; gap: 5px; }
    .header-logo svg { width: 20px; height: 20px; }
    .logo-text { font-size: 0.82rem; }
    .container { padding-left: 10px; padding-right: 10px; }
}

@supports (-webkit-backdrop-filter: blur(1px)) {
    .site-header,
    .mobile-bottom-nav { background: rgba(255, 255, 255, 0.88); }
}


/* ===== АВАТАР В ХЕДЕРЕ ===== */

/* Кнопка-аватар: круглый контейнер */
.header-user-menu__toggle {
    padding: 0;
    border: none;
    background: transparent;
    cursor: pointer;
    border-radius: 50%;
    width: 36px;
    height: 36px;
    flex-shrink: 0;
    overflow: hidden;
    transition: box-shadow var(--transition);
}

.header-user-menu__toggle:hover {
    box-shadow: 0 0 0 2px var(--accent);
}

/* Картинка-аватар */
.header-avatar-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    border-radius: 50%;
}

/* Заглушка */
.header-avatar-placeholder {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--accent);
    color: #fff;
}

/* Блок с именем и email в выпадающем меню */
.header-user-info {
    padding: 10px 14px 6px;
}

.header-user-name {
    display: block;
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--text-primary);
    word-break: break-word;
}
.auth-consent {
    margin: 4px 0;
}

.auth-consent__label {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    cursor: pointer;
    font-size: 0.85rem;
    line-height: 1.5;
    color: var(--text-secondary);
}

.auth-consent__label input[type="checkbox"] {
    margin-top: 3px;
    width: 18px;
    height: 18px;
    flex-shrink: 0;
    accent-color: var(--accent, #0f766e);
    cursor: pointer;
}

.auth-consent__text {
    min-width: 0;
}

.auth-consent__text a {
    color: var(--accent, #0f766e);
    text-decoration: underline;
    text-decoration-color: rgba(15, 118, 110, 0.3);
    text-underline-offset: 2px;
}

.auth-consent__text a:hover {
    text-decoration-color: var(--accent, #0f766e);
}

.header-user-email {
    display: block;
    font-size: 0.78rem;
    color: var(--text-muted);
    margin-top: 2px;
    word-break: break-all;
}

/* Убираем старый стиль для SVG внутри toggle */
.header-user-menu__toggle > svg:first-child {
    width: auto;
    height: auto;
    padding: 0;
    background: transparent;
}
