/* public/css/header.css */
/* Шапка R-Insight: 2 уровня (бренд+продукт / инструменты) + панель фильтров */

.app-header {
    max-width: 1280px;
    margin: 16px auto;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    box-shadow: var(--shadow);
    position: sticky;
    top: 16px;
    z-index: 1000;
}

/* ==========================
   TIER 1 — бренд + переключатель продукта
   ========================== */
.header-tier-1 {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 11px 24px;
    border-bottom: 1px solid var(--border);
}

.wordmark {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 16.5px;
    letter-spacing: -0.01em;
    color: var(--text);
    white-space: nowrap;
    text-decoration: none;
}

.wordmark span {
    color: var(--accent);
}

.wordmark .wordmark-ruble {
    color: #E4293D;
    font-size: 1.35em;
    font-weight: 800;
}

.wordmark .wordmark-i {
    color: #E4293D;
}

.product-switch {
    position: relative;
}

.product-switch-btn {
    display: flex;
    align-items: center;
    gap: 7px;
    font-family: var(--font-primary);
    font-size: 13px;
    font-weight: 700;
    background: var(--accent-soft);
    color: var(--accent);
    border: 1px solid transparent;
    border-radius: 8px;
    padding: 6px 10px 6px 12px;
    cursor: pointer;
}

.product-switch-btn svg {
    opacity: 0.8;
}

.product-switch-menu {
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 7px;
    box-shadow: var(--shadow);
    min-width: 220px;
    padding: 6px;
    display: none;
    z-index: 10;
}

.product-switch.open .product-switch-menu {
    display: block;
}

.product-switch-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 10px;
    border-radius: 7px;
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
    cursor: default;
}

.product-switch-item.active {
    background: var(--accent-soft);
    color: var(--accent);
}

.product-switch-item.disabled {
    color: var(--text-faint);
}

.product-switch-item .soon {
    font-family: var(--font-mono);
    font-size: 9.5px;
    font-weight: 700;
    letter-spacing: 0.03em;
    background: var(--neutral-pill);
    color: var(--text-faint);
    padding: 1px 6px;
    border-radius: 999px;
}

.header-tier-1-right {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 14px;
}

.theme-note {
    font-family: var(--font-mono);
    font-size: 11px;
    color: var(--text-faint);
    white-space: nowrap;
}

/* ==========================
   TIER 2 — инструменты
   ========================== */
.header-tier-2 {
    display: flex;
    align-items: center;
    gap: 2px;
    padding: 8px 20px;
    overflow-x: auto;
}

.tool-link {
    font-family: var(--font-primary);
    font-size: 12.5px;
    font-weight: 600;
    color: var(--text-muted);
    text-decoration: none;
    padding: 7px 10px;
    border-radius: 7px;
    white-space: nowrap;
    transition: background-color 0.15s ease, color 0.15s ease;
}

.tool-link:hover {
    background: var(--surface-2);
    color: var(--text);
    text-decoration: none;
}

.tool-link.active {
    background: var(--accent-soft);
    color: var(--accent);
}

/* ==========================
   TOOLBAR — быстрые фильтры
   ========================== */
.app-toolbar {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 20px;
    border-top: 1px solid var(--border);
    flex-wrap: wrap;
}

.chip-row {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    flex: 1;
}

.search-box {
    display: flex;
    align-items: center;
    gap: 7px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 7px 11px;
    min-width: 220px;
    color: var(--text-faint);
    flex-shrink: 0;
}

.search-box input {
    border: none;
    background: none;
    outline: none;
    font-size: 13px;
    color: var(--text);
    width: 100%;
    font-family: var(--font-primary);
}

.search-box input::placeholder {
    color: var(--text-faint);
}

.search-box .search-reset {
    color: var(--text-faint);
    text-decoration: none;
    font-size: 16px;
    line-height: 1;
    padding: 0 2px;
}

.search-box .search-reset:hover {
    color: var(--text);
}

.filter-link .count {
    font-family: var(--font-mono), var(--font-mono-fallback);
    font-size: 10.5px;
    opacity: 0.75;
}

.filter-link {
    position: relative;
    font-family: var(--font-primary);
    font-size: 12.5px;
    font-weight: 600;
    padding: 6px 12px;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text-muted);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
    text-decoration: none;
    transition: border-color 0.15s ease, color 0.15s ease, background-color 0.15s ease;
}

.filter-link:hover {
    border-color: var(--border-strong);
    color: var(--text);
    text-decoration: none;
}

.filter-link.active {
    background: var(--accent) !important;
    border-color: var(--accent) !important;
    color: var(--accent-contrast) !important;
}

.action-btn {
    font-family: var(--font-primary);
    font-size: 12.5px;
    font-weight: 600;
    color: var(--text-muted);
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 999px;
    padding: 6px 12px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    text-decoration: none;
    transition: border-color 0.15s ease, color 0.15s ease;
    position: relative;
    margin-left: auto;
}

.action-btn:hover {
    border-color: var(--border-strong);
    color: var(--text);
    text-decoration: none;
}

.action-btn.primary {
    background: var(--accent-soft);
    color: var(--accent);
    border-color: transparent;
}

.action-btn.primary:hover {
    border-color: var(--accent);
}

.action-btn.active {
    background: var(--accent);
    color: var(--accent-contrast);
    border-color: var(--accent);
}

/* ==========================
   MAIN CONTENT
   ========================== */
main {
    background: var(--bg);
    min-height: 100vh;
}

/* ==========================
   RESPONSIVE DESIGN
   ========================== */
@media (max-width: 768px) {
    .app-header {
        margin: 8px;
        top: 8px;
    }

    .header-tier-1 {
        padding: 10px 16px;
    }

    .header-tier-2 {
        padding: 6px 16px;
    }

    .app-toolbar {
        padding: 8px 16px;
    }

    .wordmark {
        font-size: 15px;
    }

    .tool-link {
        padding: 6px 8px;
        font-size: 12px;
    }

    .filter-link {
        padding: 5px 10px;
        font-size: 12px;
    }

    .search-box {
        min-width: 0;
        width: 100%;
    }
}

/* ==========================
   UTILITY CLASSES
   ========================== */
.hidden {
    display: none !important;
}

.visible {
    display: block !important;
}

.fade-in {
    animation: fadeIn 0.3s ease-in-out;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Контейнер расширенных фильтров (index.ejs) — вне .index-main-container в
   разметке (сразу в <main>), поэтому без своего max-width расползался на
   всю ширину экрана, а не только на ширину шапки/контента. */
.advanced-filters-container {
    max-width: 1280px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 20px;
    margin: 20px auto;
    box-shadow: var(--shadow);
    transition: all 0.3s ease;
}

.advanced-filters-container[style*="display: block"] {
    animation: slideDown 0.3s ease;
}

@keyframes slideDown {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Индикатор загрузки для быстрых фильтров */
.filter-loading {
    position: relative;
    pointer-events: none;
}

.filter-loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 16px;
    height: 16px;
    margin: -8px 0 0 -8px;
    border: 2px solid transparent;
    border-top: 2px solid var(--accent);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Тултипы у фильтров и кнопки расширенных фильтров */
.filter-link:hover::after,
.action-btn:hover::after {
    content: attr(title);
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    background: var(--text);
    color: var(--bg);
    padding: 14px 18px;
    border-radius: 8px;
    font-size: 12px;
    white-space: pre-line;
    z-index: 1001;
    margin-top: 10px;
    box-shadow: var(--shadow);
    pointer-events: none;
    font-weight: 500;
    min-width: 180px;
    max-width: 260px;
    text-align: center;
    line-height: 1.4;
}

.filter-link:hover::before,
.action-btn:hover::before {
    content: '';
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 6px solid transparent;
    border-bottom-color: var(--text);
    margin-top: -2px;
    z-index: 1002;
    pointer-events: none;
}
