/* ── Trends Tab ─────────────────────────────────────────────────────────── */

#trends-container {
    width: 100%;
    padding: calc(var(--navbar-offset, 96px) + 32px) 24px 40px;
    display: none;
    flex-direction: column;
    align-items: stretch;
    background-color: var(--primary-color);
    min-height: 100vh;
}

/* ── Header + Filters ───────────────────────────────────────────────────── */
.trends-header {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 24px;
}

.trends-header h2 {
    color: #fff;
    font-size: 1.6rem;
    font-weight: 700;
    margin: 0;
    letter-spacing: -0.01em;
}

.trends-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
}

.trends-filters select,
.trends-filters input[type="date"],
.trends-filters button {
    background: #2c2c2c;
    border: 1px solid #444;
    color: #e0e0e0;
    border-radius: 6px;
    padding: 7px 12px;
    font-size: 0.85rem;
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s;
}

.trends-filters input[type="date"]::-webkit-calendar-picker-indicator {
    filter: invert(0.7);
    cursor: pointer;
}

.trends-filters select:hover,
.trends-filters select:focus,
.trends-filters input[type="date"]:hover,
.trends-filters input[type="date"]:focus {
    border-color: #ff4d4d;
    outline: none;
}

.trends-filters button {
    background: #ff4d4d;
    border-color: #ff4d4d;
    color: #fff;
    font-weight: 600;
    padding: 7px 18px;
}

.trends-filters button:hover {
    background: #e03030;
    border-color: #e03030;
}

.trends-filter-label {
    color: #888;
    font-size: 0.8rem;
    align-self: center;
}

/* ── Loading / Error states ─────────────────────────────────────────────── */
.trends-loading {
    display: flex;
    align-items: center;
    gap: 12px;
    color: #aaa;
    font-size: 1rem;
    padding: 48px 0;
}

.trends-spinner {
    width: 22px;
    height: 22px;
    border: 3px solid #444;
    border-top-color: #ff4d4d;
    border-radius: 50%;
    animation: trends-spin 0.7s linear infinite;
}

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

.trends-error {
    background: #2a1a1a;
    border: 1px solid #8b2020;
    border-radius: 8px;
    color: #f88;
    padding: 16px 20px;
    font-size: 0.9rem;
}

/* ── AI Insights card ───────────────────────────────────────────────────── */
.trends-insights-card {
    background: linear-gradient(135deg, #1e2a1e, #1a2218);
    border: 1px solid #3a5a3a;
    border-left: 4px solid #4caf50;
    border-radius: 10px;
    padding: 20px 24px;
    margin-bottom: 28px;
}

.trends-insights-card h3 {
    color: #4caf50;
    font-size: 0.85rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    margin: 0 0 12px 0;
}

.trends-insights-text {
    color: #ccc;
    font-size: 0.92rem;
    line-height: 1.7;
}

.trends-insights-loading {
    color: #888;
    font-size: 0.88rem;
    font-style: italic;
}

/* ── Metric cards grid ──────────────────────────────────────────────────── */
.trends-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 16px;
    margin-bottom: 32px;
}

.trends-pitch-card {
    background: #222;
    border: 1px solid #333;
    border-radius: 10px;
    padding: 16px 18px;
    transition: border-color 0.15s;
}

.trends-pitch-card:hover {
    border-color: #555;
}

.trends-pitch-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
}

.trends-pitch-name {
    font-size: 1rem;
    font-weight: 700;
    color: #fff;
}

.trends-pitch-count {
    font-size: 0.78rem;
    color: #666;
    background: #2c2c2c;
    padding: 2px 8px;
    border-radius: 20px;
}

.trends-metric-row {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    padding: 4px 0;
    border-bottom: 1px solid #2a2a2a;
    font-size: 0.85rem;
}

.trends-metric-row:last-child {
    border-bottom: none;
}

.trends-metric-label {
    color: #888;
}

.trends-metric-value {
    color: #e0e0e0;
    font-variant-numeric: tabular-nums;
}

.trends-delta {
    font-size: 0.76rem;
    margin-left: 6px;
    font-variant-numeric: tabular-nums;
}

.trends-delta.pos { color: #4caf50; }
.trends-delta.neg { color: #f44336; }
.trends-delta.neu { color: #888; }

/* ── Summary bar ────────────────────────────────────────────────────────── */
.trends-summary-bar {
    background: #1e1e1e;
    border: 1px solid #2c2c2c;
    border-radius: 8px;
    padding: 10px 18px;
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    margin-bottom: 24px;
    font-size: 0.82rem;
    color: #777;
}

.trends-summary-bar span strong {
    color: #bbb;
}

/* ── Window comparison label ────────────────────────────────────────────── */
.trends-window-label {
    font-size: 0.78rem;
    color: #555;
    margin-bottom: 16px;
}

/* ── Card click hint ────────────────────────────────────────────────────── */
.trends-pitch-card[data-pt] {
    cursor: pointer;
}

.trends-pitch-card[data-pt]:hover {
    border-color: #ff4d4d;
}

.trends-card-hint {
    color: #555;
    font-size: 0.7rem;
    margin-left: 4px;
    transition: color 0.15s;
}

.trends-pitch-card[data-pt]:hover .trends-card-hint {
    color: #ff4d4d;
}

/* ── Modal ──────────────────────────────────────────────────────────────── */
#trends-modal {
    position: fixed;
    inset: 0;
    z-index: 9000;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.2s ease;
}

#trends-modal.trends-modal-open {
    opacity: 1;
}

.trends-modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.75);
}

.trends-modal-box {
    position: relative;
    z-index: 1;
    background: #1a1a1a;
    border: 1px solid #333;
    border-radius: 12px;
    width: 94vw;
    height: 88vh;
    max-width: 1400px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transform: translateY(16px);
    transition: transform 0.2s ease;
    box-shadow: 0 24px 64px rgba(0,0,0,0.7);
}

#trends-modal.trends-modal-open .trends-modal-box {
    transform: translateY(0);
}

.trends-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 24px;
    border-bottom: 1px solid #2c2c2c;
    flex-shrink: 0;
}

.trends-modal-header h2 {
    color: #fff;
    font-size: 1.3rem;
    font-weight: 700;
    margin: 0;
}

.trends-modal-close {
    background: none;
    border: 1px solid #444;
    color: #aaa;
    font-size: 1rem;
    border-radius: 6px;
    padding: 4px 10px;
    cursor: pointer;
    transition: border-color 0.15s, color 0.15s;
}

.trends-modal-close:hover {
    border-color: #ff4d4d;
    color: #ff4d4d;
}

.trends-modal-body {
    flex: 1;
    padding: 24px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.trends-modal-loading {
    display: flex;
    align-items: center;
    gap: 12px;
    color: #aaa;
    font-size: 1rem;
    margin: auto;
}

.trends-modal-chart-wrap {
    flex: 1;
    position: relative;
    min-height: 0;
}

.trends-modal-chart-wrap canvas {
    width: 100% !important;
    height: 100% !important;
}

/* ── Responsive ─────────────────────────────────────────────────────────── */
@media (max-width: 768px) {
    .trends-header {
        flex-direction: column;
        align-items: flex-start;
    }

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