/**
 * Insights CSS
 * Стили для раздела Уведомления и Рекомендации v3.1
 */

/* ===== SUMMARY COUNTERS ===== */
.insights-summary {
    display: flex;
    gap: 1rem;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
}

.insights-summary-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    background: var(--card-bg);
    border-radius: var(--radius);
    border: 1px solid var(--border-color);
    cursor: pointer;
    transition: all 0.2s ease;
    min-width: 120px;
}

.insights-summary-item:hover {
    border-color: var(--accent);
    transform: translateY(-1px);
}

.insights-summary-item.active {
    border-color: var(--accent);
    background: rgba(var(--accent-rgb), 0.1);
}

.insights-summary-icon {
    font-size: 1.25rem;
}

.insights-summary-count {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
}

.insights-summary-label {
    font-size: 0.75rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* ===== SECTION BLOCKS ===== */
.insights-section {
    margin-bottom: 2rem;
}

.insights-section-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border-color);
}

.insights-section-icon {
    font-size: 1.25rem;
}

.insights-section-title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
}

.insights-section-count {
    background: var(--bg-secondary);
    color: var(--text-secondary);
    padding: 0.125rem 0.5rem;
    border-radius: 10px;
    font-size: 0.75rem;
    font-weight: 500;
}

/* ===== INSIGHT CARDS ===== */
.insights-cards {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.insight-card {
    background: var(--card-bg);
    border-radius: var(--radius);
    border: 1px solid var(--border-color);
    overflow: hidden;
    transition: all 0.2s ease;
}

.insight-card:hover {
    border-color: var(--accent);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

/* Card Header */
.insight-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border-color);
}

.insight-card-title-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.insight-card-icon {
    font-size: 1rem;
}

.insight-card-title {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-primary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.insight-card-amount {
    font-size: 1rem;
    font-weight: 700;
}

.insight-card-amount.positive {
    color: var(--success);
}

.insight-card-amount.negative {
    color: var(--danger);
}

.insight-card-date {
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-left: auto;
    margin-right: 0.5rem;
}

/* Card severity colors */
.insight-card.critical .insight-card-header {
    background: linear-gradient(135deg, rgba(239, 68, 68, 0.15) 0%, rgba(239, 68, 68, 0.05) 100%);
    border-bottom-color: rgba(239, 68, 68, 0.3);
}

.insight-card.warning .insight-card-header {
    background: linear-gradient(135deg, rgba(234, 179, 8, 0.15) 0%, rgba(234, 179, 8, 0.05) 100%);
    border-bottom-color: rgba(234, 179, 8, 0.3);
}

.insight-card.success .insight-card-header {
    background: linear-gradient(135deg, rgba(34, 197, 94, 0.15) 0%, rgba(34, 197, 94, 0.05) 100%);
    border-bottom-color: rgba(34, 197, 94, 0.3);
}

.insight-card.info .insight-card-header {
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.15) 0%, rgba(59, 130, 246, 0.05) 100%);
    border-bottom-color: rgba(59, 130, 246, 0.3);
}

/* Card Body */
.insight-card-body {
    padding: 1rem;
    display: flex;
    gap: 1rem;
}

.insight-creative {
    flex-shrink: 0;
}

.insight-creative-thumbnail {
    width: 80px;
    height: 80px;
    border-radius: 8px;
    object-fit: cover;
    background: var(--bg-secondary);
    cursor: pointer;
    transition: transform 0.2s ease;
}

.insight-creative-thumbnail:hover {
    transform: scale(1.05);
}

.insight-creative-placeholder {
    width: 80px;
    height: 80px;
    border-radius: 8px;
    background: var(--bg-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    font-size: 1.5rem;
}

.insight-details {
    flex: 1;
    min-width: 0;
}

.insight-public-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
    flex-wrap: wrap;
}

.insight-public-name {
    font-weight: 600;
    color: var(--text-primary);
}

.insight-format-badge {
    background: var(--bg-secondary);
    color: var(--text-secondary);
    padding: 0.125rem 0.5rem;
    border-radius: 4px;
    font-size: 0.75rem;
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
}

/* Metrics Grid */
.insight-metrics {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
    gap: 0.5rem;
    margin-bottom: 0.75rem;
}

.insight-metric {
    display: flex;
    flex-direction: column;
    padding: 0.5rem;
    background: var(--bg-secondary);
    border-radius: 6px;
}

.insight-metric-label {
    font-size: 0.625rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 0.125rem;
}

.insight-metric-value {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-primary);
}

.insight-metric-value.success {
    color: var(--success);
}

.insight-metric-value.danger {
    color: var(--danger);
}

.insight-metric-value.warning {
    color: var(--warning);
}

/* Recommendation text */
.insight-recommendation {
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
    padding: 0.75rem;
    background: rgba(var(--accent-rgb), 0.05);
    border-radius: 6px;
    margin-top: 0.75rem;
}

.insight-recommendation-icon {
    flex-shrink: 0;
    font-size: 1rem;
}

.insight-recommendation-text {
    font-size: 0.8125rem;
    color: var(--text-secondary);
    line-height: 1.4;
}

/* Forecast block */
.insight-forecast {
    margin-top: 0.75rem;
    padding: 0.75rem;
    background: var(--bg-secondary);
    border-radius: 6px;
}

.insight-forecast-title {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 0.5rem;
}

.insight-forecast-row {
    display: flex;
    justify-content: space-between;
    font-size: 0.8125rem;
    color: var(--text-secondary);
    padding: 0.25rem 0;
}

.insight-forecast-value {
    font-weight: 600;
    color: var(--text-primary);
}

/* Card Footer (Actions) */
.insight-card-footer {
    display: flex;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    border-top: 1px solid var(--border-color);
    background: var(--bg-secondary);
    flex-wrap: wrap;
}

.insight-action-btn {
    padding: 0.375rem 0.75rem;
    font-size: 0.75rem;
    font-weight: 500;
    border-radius: 6px;
    border: 1px solid var(--border-color);
    background: var(--card-bg);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
}

.insight-action-btn:hover {
    background: var(--accent);
    color: white;
    border-color: var(--accent);
}

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

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

.insight-action-btn.danger {
    background: var(--danger);
    color: white;
    border-color: var(--danger);
}

/* ===== ANALYTICS BLOCK ===== */
.analytics-summary {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 1rem;
    padding: 1rem;
    background: var(--card-bg);
    border-radius: var(--radius);
    border: 1px solid var(--border-color);
    margin-bottom: 1.5rem;
}

.analytics-metric {
    text-align: center;
}

.analytics-metric-value {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 0.25rem;
}

.analytics-metric-label {
    font-size: 0.625rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* TOP Lists */
.analytics-section {
    margin-bottom: 1.5rem;
}

.analytics-section-title {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.75rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.analytics-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.analytics-list-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem 0.75rem;
    background: var(--card-bg);
    border-radius: var(--radius);
    border: 1px solid var(--border-color);
}

.analytics-rank {
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: var(--bg-secondary);
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-secondary);
}

.analytics-rank.gold {
    background: linear-gradient(135deg, #fbbf24 0%, #f59e0b 100%);
    color: #1a1a1a;
}

.analytics-rank.silver {
    background: linear-gradient(135deg, #9ca3af 0%, #6b7280 100%);
    color: white;
}

.analytics-rank.bronze {
    background: linear-gradient(135deg, #cd7f32 0%, #a0522d 100%);
    color: white;
}

.analytics-item-info {
    flex: 1;
    min-width: 0;
}

.analytics-item-name {
    font-weight: 500;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.analytics-item-sub {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.analytics-item-stats {
    display: flex;
    gap: 1rem;
    font-size: 0.8125rem;
}

.analytics-item-stat {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
}

.analytics-stat-value {
    font-weight: 600;
    color: var(--text-primary);
}

.analytics-stat-label {
    font-size: 0.625rem;
    color: var(--text-muted);
    text-transform: uppercase;
}

/* Format Analysis Table */
.format-analysis-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.8125rem;
}

.format-analysis-table th,
.format-analysis-table td {
    padding: 0.5rem 0.75rem;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

.format-analysis-table th {
    font-weight: 500;
    color: var(--text-muted);
    text-transform: uppercase;
    font-size: 0.625rem;
    letter-spacing: 0.5px;
}

.format-analysis-table td {
    color: var(--text-secondary);
}

.format-analysis-table tbody tr:hover {
    background: var(--bg-secondary);
}

/* ===== EMPTY STATE ===== */
.insights-empty {
    text-align: center;
    padding: 2rem;
    color: var(--text-muted);
}

.insights-empty-icon {
    font-size: 2rem;
    margin-bottom: 0.5rem;
}

.insights-empty-text {
    font-size: 0.875rem;
}

/* ===== LOADING STATE ===== */
.insights-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    color: var(--text-muted);
}

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
    .insights-summary {
        gap: 0.5rem;
    }

    .insights-summary-item {
        flex: 1;
        min-width: 80px;
        padding: 0.5rem;
    }

    .insights-summary-count {
        font-size: 1.25rem;
    }

    .insight-card-body {
        flex-direction: column;
    }

    .insight-creative {
        display: flex;
        justify-content: center;
    }

    .insight-metrics {
        grid-template-columns: repeat(2, 1fr);
    }

    .analytics-item-stats {
        flex-direction: column;
        gap: 0.5rem;
        align-items: flex-end;
    }
}

/* ===== DEVIATION PROGRESS BARS ===== */
.insight-deviation {
    margin-top: 0.5rem;
}

.deviation-bar {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.375rem;
}

.deviation-label {
    font-size: 0.625rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    min-width: 35px;
}

.deviation-track {
    flex: 1;
    height: 6px;
    background: var(--bg-secondary);
    border-radius: 3px;
    overflow: hidden;
    position: relative;
}

.deviation-fill {
    height: 100%;
    border-radius: 3px;
    transition: width 0.3s ease;
}

.deviation-fill.success {
    background: linear-gradient(90deg, var(--success) 0%, #4ade80 100%);
}

.deviation-fill.warning {
    background: linear-gradient(90deg, #eab308 0%, #facc15 100%);
}

.deviation-fill.danger {
    background: linear-gradient(90deg, var(--danger) 0%, #f87171 100%);
}

.deviation-value {
    font-size: 0.75rem;
    font-weight: 600;
    min-width: 50px;
    text-align: right;
}

.deviation-value.success {
    color: var(--success);
}

.deviation-value.warning {
    color: #eab308;
}

.deviation-value.danger {
    color: var(--danger);
}

/* ===== FILTERS BAR ===== */
.insights-filters {
    display: flex;
    gap: 0.75rem;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
    align-items: center;
}

.insights-filter-group {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.insights-filter-label {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.insights-filter-select {
    padding: 0.375rem 0.75rem;
    font-size: 0.8125rem;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    background: var(--card-bg);
    color: var(--text-primary);
    cursor: pointer;
    min-width: 120px;
}

.insights-filter-select:focus {
    outline: none;
    border-color: var(--accent);
}

.insights-period-btns {
    display: flex;
    gap: 0.25rem;
    background: var(--bg-secondary);
    padding: 0.25rem;
    border-radius: 8px;
}

.insights-period-btn {
    padding: 0.375rem 0.75rem;
    font-size: 0.75rem;
    font-weight: 500;
    border: none;
    border-radius: 6px;
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s ease;
}

.insights-period-btn:hover {
    color: var(--text-primary);
}

.insights-period-btn.active {
    background: var(--accent);
    color: white;
}

/* ===== ENHANCED CREATIVE THUMBNAILS ===== */
.insight-creative-img {
    width: 80px;
    height: 80px;
    border-radius: 8px;
    object-fit: cover;
    background: var(--bg-secondary);
    cursor: pointer;
    transition: all 0.2s ease;
    border: 1px solid var(--border-color);
}

.insight-creative-img:hover {
    transform: scale(1.05);
    border-color: var(--accent);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

/* Lightbox for full image view */
.insight-lightbox {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.insight-lightbox.active {
    opacity: 1;
    visibility: visible;
}

.insight-lightbox img {
    max-width: 90%;
    max-height: 90%;
    border-radius: 8px;
}

.insight-lightbox-close {
    position: absolute;
    top: 20px;
    right: 20px;
    font-size: 2rem;
    color: white;
    cursor: pointer;
    opacity: 0.7;
    transition: opacity 0.2s ease;
}

.insight-lightbox-close:hover {
    opacity: 1;
}

/* ===== QUICK ACTIONS MODAL ===== */
.insight-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9998;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.insight-modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

.insight-modal {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 1.5rem;
    max-width: 400px;
    width: 90%;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}

.insight-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.insight-modal-title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
}

.insight-modal-close {
    font-size: 1.25rem;
    color: var(--text-muted);
    cursor: pointer;
    transition: color 0.2s ease;
}

.insight-modal-close:hover {
    color: var(--text-primary);
}

.insight-modal-body {
    color: var(--text-secondary);
    font-size: 0.875rem;
    line-height: 1.5;
}

.insight-modal-footer {
    display: flex;
    gap: 0.5rem;
    justify-content: flex-end;
    margin-top: 1.5rem;
}

@media (max-width: 768px) {
    .insights-filters {
        flex-direction: column;
        align-items: stretch;
    }

    .insights-filter-select {
        width: 100%;
    }
}

/* ===== PAGINATION ===== */
.insights-load-more {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    margin-top: 1.5rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border-color);
}

.insights-pagination-info {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.insight-action-btn.load-more {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    padding: 0.5rem 1.5rem;
    color: var(--text-primary);
    width: auto;
    min-width: 150px;
}

.insight-action-btn.load-more:hover {
    background: var(--card-bg-hover);
    border-color: var(--accent);
}
@media (max-width: 380px) {
    .insights-summary-item {
        min-width: 45%;
        padding: 0.5rem;
    }

    .insight-card-body {
        padding: 0.75rem;
    }

    .insight-creative-thumbnail,
    .insight-creative-placeholder, 
    .insight-creative-img {
        width: 60px;
        height: 60px;
        flex-shrink: 0;
    }
    
    .insight-card-title {
        font-size: 0.8rem;
    }
    
    .insight-metrics {
        grid-template-columns: 1fr 1fr; /* Force 2 columns */
    }
}
