/* Стили для страницы аналитики резюме */

.analytics-page {
    width: 100%;
    max-width: 800px;
    margin: 0 auto;
    padding: 0 0 24px;
}

.analytics-page .breadcrumbs-container {
    margin-bottom: 12px;
}

.analytics-main-title {
    margin: 0 0 12px;
    font-size: var(--fs-32);
    line-height: var(--lh-32);
    letter-spacing: var(--ls-32);
    font-weight: var(--fw-semibold);
    color: var(--text-color);
}

.analytics-main-card {
    background: var(--surface-primary);
    border-radius: 24px;
    padding: 20px 20px 0;
    margin-bottom: 4px;
}

/* Строка с чипами и выбором периода */
.analytics-header-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 16px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--filter-divider);
}

/* Чипы выбора резюме */
.analytics-page .filter-chips {
    flex: 1;
    min-width: 0;
}

.analytics-page .filter-chip {
    border: none;
}

/* Зелёная галочка в dropdown периода */
#periodDropdown .sort-option.selected .sort-check-icon {
    display: flex;
}

/* Wrapper для dropdown периода */
.analytics-period-wrapper {
    position: relative;
    flex-shrink: 0;
}

.analytics-period-wrapper .sort-button {
    padding: 0 8px 0 12px;
    min-width: auto;
}

.analytics-period-wrapper .sort-text {
    margin-right: 4px;
}


/* Контент аналитики */
.analytics-content {
    position: relative;
    min-height: 300px;
}

.analytics-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 300px;
}

.analytics-loading .spinner {
    width: 32px;
    height: 32px;
    border: 3px solid var(--border-color);
    border-top-color: var(--accent-color);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Пустое состояние */
.analytics-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 300px;
    text-align: center;
    padding: 40px 20px;
}

.analytics-empty-text {
    font-size: var(--fs-16);
    color: var(--text-primary);
    margin: 0 0 8px;
}

.analytics-empty-hint {
    font-size: var(--fs-14);
    color: var(--text-muted);
    margin: 0;
}

/* Общее количество просмотров */
.analytics-total {
    margin-bottom: 24px;
}

.analytics-total-label {
    display: block;
    font-size: var(--fs-14);
    color: var(--text-muted);
    margin-bottom: 4px;
}

.analytics-total-value {
    display: block;
    font-size: var(--fs-24);
    font-weight: var(--fw-semibold);
    color: var(--text-primary);
    line-height: 1.2;
}

.analytics-total-row {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
}

@media (max-width: 1279px) {
    .analytics-total {
        margin-bottom: 0;
    }
    .analytics-period-wrapper {
        margin-left: auto;
        align-self: flex-start;
    }
}

/* График */
.analytics-chart-container {
    position: relative;
    height: 130px;
    background: transparent;
}

/* Новая сетка */
.analytics-page-layout {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.analytics-grid-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 4px;
}

@media (max-width: 1279px) {
    .analytics-page {
        max-width: 600px;
        width: 100%;
    }

    .analytics-grid-row {
        grid-template-columns: 1fr;
    }

    .analytics-stats-grid {
        grid-template-columns: 1fr;
    }
}

/* Сетка статистики (старая, можно оставить для совместимости или удалить) */
.analytics-stats-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
}

.analytics-stat-card {
    background: var(--surface-primary);
    border-radius: 24px;
    padding: 20px;
}

.analytics-stat-title {
    font-size: var(--fs-20);
    font-weight: var(--fw-medium);
    color: var(--text-primary);
    margin: 0 0 16px;
}

.analytics-stat-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
    max-height: 348px;
    overflow-y: auto;
    scrollbar-width: none; /* Firefox - скрываем скроллбар */
    -ms-overflow-style: none; /* IE/Edge */
}

/* Скрываем скроллбар для WebKit (Chrome, Safari, мобилки) */
.analytics-stat-list::-webkit-scrollbar {
    display: none;
}

.analytics-stat-list.needs-scroll {
    -webkit-mask-image: linear-gradient(to bottom, black calc(100% - 40px), transparent 100%);
    mask-image: linear-gradient(to bottom, black calc(100% - 40px), transparent 100%);
}

.analytics-stat-list.needs-scroll.scrolled-to-end {
    -webkit-mask-image: none;
    mask-image: none;
}

/* Элемент списка статистики */
.analytics-stat-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 0 12px;
    height: 40px;
    min-height: 40px;
    flex-shrink: 0;
    position: relative;
    border-radius: 8px;
    overflow: hidden;
}

.analytics-stat-bar {
    position: absolute;
    left: 0;
    top: 0;
    height: 40px;
    background: var(--surface-secondary);
    border-radius: 12px;
    z-index: 0;
    transition: width 0.3s ease;
}

.analytics-stat-item > *:not(.analytics-stat-bar) {
    position: relative;
    z-index: 1;
}

.analytics-stat-icon {
    width: 20px;
    height: 20px;
    border-radius: 999px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-primary);
    flex-shrink: 0;
    overflow: hidden;
}

.analytics-stat-icon img {
    width: 20px;
    height: 20px;
    object-fit: contain;
}

.analytics-stat-icon.flag img {
    width: 20px;
    height: 20px;
    border-radius: 999px;
}

.analytics-stat-name {
    flex: 1;
    font-size: var(--fs-16);
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.analytics-stat-count {
    font-size: var(--fs-14);
    font-weight: var(--fw-semibold);
    color: var(--text-secondary);
    flex-shrink: 0;
}

/* Иконки источников */
.analytics-stat-icon.source-direct { background: var(--text-muted); }
.analytics-stat-icon.source-unknown { background: var(--text-muted); }

.analytics-stat-icon svg {
    width: 18px;
    height: 18px;
    color: #fff;
}

.analytics-stat-icon img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 8px;
}

/* Адаптив */
@media (max-width: 1279px) {
    .analytics-main-card {
        padding: 16px 16px 0;
    }

    .analytics-chart-container {
        height: 110px;
    }

    .analytics-stat-card {
        padding: 16px;
    }

    .analytics-page .filter-chips {
        overflow-x: auto;
        flex-wrap: nowrap;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        -ms-overflow-style: none;
    }

    .analytics-page .filter-chips::-webkit-scrollbar {
        display: none;
    }
}

/* Кастомный тултип для графика */
.chart-tooltip {
    position: absolute;
    background: var(--surface-secondary);
    border-radius: 24px;
    padding: 16px;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.15s ease;
    z-index: 100;
    min-width: 150px;
}

.chart-tooltip.visible {
    opacity: 1;
}

.chart-tooltip-date {
    font-size: var(--fs-14);
    font-weight: var(--fw-regular);
    color: var(--text-muted);
    margin-bottom: 8px;
}

.chart-tooltip-views {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
}

.chart-tooltip-label {
    font-size: var(--fs-16);
    font-weight: var(--fw-regular);
    color: var(--text-color);
}

.chart-tooltip-value {
    font-size: var(--fs-16);
    font-weight: var(--fw-medium);
    color: var(--text-color);
}
