/* Top Rating Charts DV — v1.4.6 */

.trc-wrapper {
    border-radius: 22px;
    padding: 28px;
    margin: 40px 0;
    box-shadow: 0 12px 40px rgba(0,0,0,0.22);
    overflow: hidden;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

/* ── Тёмная тема ────────────────────────────────────────── */
.trc-theme-dark {
    background: linear-gradient(180deg, #111827 0%, #0f172a 100%);
}
.trc-theme-dark .trc-title    { color: #ffffff; }
.trc-theme-dark .trc-item     { background: rgba(255,255,255,0.05); border: 1px solid rgba(255,255,255,0.08); }
.trc-theme-dark .trc-rank     { color: #94a3b8; }
.trc-theme-dark .trc-name     { color: #ffffff; }
.trc-theme-dark .trc-bar-wrap { background: rgba(255,255,255,0.07); }

/* ── Светлая тема ───────────────────────────────────────── */
.trc-theme-light {
    background: linear-gradient(180deg, #f8fafc 0%, #f1f5f9 100%);
    box-shadow: 0 6px 30px rgba(0,0,0,0.08);
}
.trc-theme-light .trc-title    { color: #1e293b; }
.trc-theme-light .trc-item     { background: #ffffff; border: 1px solid #e2e8f0; }
.trc-theme-light .trc-rank     { color: #64748b; }
.trc-theme-light .trc-name     { color: #1e293b; }
.trc-theme-light .trc-bar-wrap { background: #e2e8f0; }

/* ── Заголовок ──────────────────────────────────────────── */
.trc-header { margin-bottom: 22px; }
.trc-title {
    margin: 0;
    font-size: 24px;
    font-weight: 700;
    line-height: 1.2;
}

/* ── Canvas ─────────────────────────────────────────────── */
.trc-chart-container {
    position: relative;
    height: 400px;
    margin-bottom: 28px;
}

/* Пока скелетон активен — canvas скрыт, виден только плейсхолдер */
.trc-chart-loading canvas {
    opacity: 0;
}
/* После снятия скелетона — плавное появление */
.trc-chart-container:not(.trc-chart-loading) canvas {
    opacity: 1;
    transition: opacity 0.3s ease;
}

/* ── Скелетон — пока Chart.js грузится ─────────────────── */
.trc-chart-loading {
    border-radius: 12px;
    overflow: hidden;
    background: linear-gradient(
        90deg,
        rgba(255,255,255,0.03) 25%,
        rgba(255,255,255,0.08) 50%,
        rgba(255,255,255,0.03) 75%
    );
    background-size: 200% 100%;
    animation: trc-shimmer 1.4s infinite;
}
.trc-theme-light .trc-chart-loading {
    background: linear-gradient(
        90deg,
        rgba(0,0,0,0.04) 25%,
        rgba(0,0,0,0.09) 50%,
        rgba(0,0,0,0.04) 75%
    );
    background-size: 200% 100%;
}
@keyframes trc-shimmer {
    0%   { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* ── Список ─────────────────────────────────────────────── */
.trc-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

/* ── Айтем: верхняя строка — грид, описание — отдельная ── */
.trc-item {
    display: flex;
    flex-direction: column;
    gap: 0;
    border-radius: 14px;
    padding: 12px 16px;
    transition: transform 0.15s;
}
.trc-item:hover { transform: translateX(4px); }

/* Верхняя строка с основными элементами */
.trc-item-row {
    display: grid;
    grid-template-columns: 46px 1fr 1fr 90px;
    align-items: center;
    gap: 14px;
    width: 100%;
}

/* С картинкой */
.trc-item:has(.trc-image) .trc-item-row {
    grid-template-columns: 52px 46px 1fr 1fr 90px;
}
/* С кнопкой */
.trc-item:has(.trc-action) .trc-item-row {
    grid-template-columns: 46px 1fr 1fr 90px 110px;
}
.trc-item:has(.trc-image):has(.trc-action) .trc-item-row {
    grid-template-columns: 52px 46px 1fr 1fr 90px 110px;
}

/* ── Картинка ───────────────────────────────────────────── */
.trc-image {
    width: 48px;
    height: 48px;
    border-radius: 8px;
    overflow: hidden;
    flex-shrink: 0;
}
.trc-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

/* ── Позиция / бейдж ────────────────────────────────────── */
.trc-rank {
    font-weight: 700;
    font-size: 16px;
    text-align: center;
    min-width: 36px;
}
.trc-badge { font-size: 24px; line-height: 1; }

/* ── Название ───────────────────────────────────────────── */
.trc-name {
    font-size: 15px;
    font-weight: 600;
}

/* ── Особенность товара — отдельная строка на всю ширину ── */
.trc-description-row {
    display: none; /* скрыта по умолчанию, показывается когда есть контент */
    width: 100%;
    /* отступ слева = иконка (46px) + gap (14px), чтобы выровнять с названием */
    padding-left: calc(46px + 14px);
    padding-top: 6px;
    box-sizing: border-box;
}

/* Если есть картинка — смещаем ещё на ширину картинки + gap */
.trc-item:has(.trc-image) .trc-description-row {
    padding-left: calc(52px + 14px + 46px + 14px);
}

.trc-description-row:not(:empty) {
    display: block;
}

.trc-description {
    font-size: 13px;
    font-weight: 400;
    line-height: 1.5;
    white-space: normal;
    word-break: break-word;
}
.trc-theme-dark  .trc-description { color: #94a3b8; }
.trc-theme-light .trc-description { color: #64748b; }

/* ── Градиентный бар (цвет задаётся inline из PHP) ──────── */
.trc-bar-wrap {
    height: 10px;
    border-radius: 999px;
    overflow: hidden;
}
.trc-bar {
    height: 100%;
    border-radius: 999px;
    transition: width 0.6s ease;
}

/* ── Оценка (цвет задаётся inline из PHP) ───────────────── */
.trc-score {
    text-align: right;
    font-weight: 700;
    font-size: 15px;
    white-space: nowrap;
}

/* ── Кнопка «Купить» ────────────────────────────────────── */
.trc-btn {
    display: inline-block;
    padding: 8px 14px;
    border-radius: 10px;
    color: #ffffff !important;
    text-decoration: none !important;
    font-size: 13px;
    font-weight: 700;
    text-align: center;
    white-space: nowrap;
    transition: opacity 0.2s, transform 0.15s;
}
.trc-btn:hover {
    opacity: 0.88;
    transform: scale(1.03);
}

/* ── Адаптив ────────────────────────────────────────────── */
@media (max-width: 768px) {
    .trc-wrapper { padding: 18px; }
    .trc-chart-container { height: 260px; }

    .trc-item-row,
    .trc-item:has(.trc-image) .trc-item-row,
    .trc-item:has(.trc-action) .trc-item-row,
    .trc-item:has(.trc-image):has(.trc-action) .trc-item-row {
        grid-template-columns: 36px 1fr 70px;
    }

    .trc-image    { display: none; }
    .trc-bar-wrap { display: none; }
    .trc-action   { grid-column: span 3; text-align: right; }
    .trc-name     { font-size: 13px; }
    .trc-score    { font-size: 13px; }

    .trc-description-row {
        padding-left: calc(36px + 14px);
    }
    .trc-description { font-size: 12px; }
}
