/* analytics.css - Стилизация BI Dashboard (Инфоцентр) */

/* ==================== */
/* Loading & Error States */
/* ==================== */

.analytics-loading,
.analytics-error {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 400px;
    padding: 40px;
    text-align: center;
}

.loading-spinner {
    width: 50px;
    height: 50px;
    border: 4px solid #e2e8f0;
    border-top-color: #667eea;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

.analytics-error {
    color: #f56565;
}

.analytics-error .error-icon {
    font-size: 48px;
    margin-bottom: 16px;
}

.analytics-error button {
    margin-top: 20px;
    padding: 10px 24px;
    background: #667eea;
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
}

.analytics-error button:hover {
    background: #5a67d8;
}

/* ==================== */
/* Dashboard Layout */
/* ==================== */

.analytics-dashboard {
    padding: 24px;
    max-width: 1400px;
    margin: 0 auto;
}

/* Header */
.analytics-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 32px;
    padding-bottom: 16px;
    border-bottom: 2px solid #e2e8f0;
}

.analytics-title {
    font-size: 28px;
    font-weight: 700;
    color: #2d3748;
    margin: 0;
}

.analytics-filters {
    display: flex;
    gap: 12px;
    align-items: center;
}

.period-select {
    padding: 8px 16px;
    border: 1px solid #cbd5e0;
    border-radius: 6px;
    font-size: 14px;
    color: #2d3748;
    background: white;
    cursor: pointer;
}

.period-select:hover {
    border-color: #667eea;
}

.refresh-btn,
.export-btn {
    padding: 8px 16px;
    border: 1px solid #667eea;
    background: white;
    color: #667eea;
    border-radius: 6px;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s;
}

.refresh-btn:hover,
.export-btn:hover {
    background: #667eea;
    color: white;
}

/* Blocks */
.analytics-block {
    background: white;
    border-radius: 12px;
    padding: 24px;
    margin-bottom: 24px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.analytics-row {
    display: flex;
    gap: 24px;
    margin-bottom: 24px;
}

.analytics-block.half-width {
    flex: 1;
    margin-bottom: 0;
}

.block-title {
    font-size: 20px;
    font-weight: 600;
    color: #2d3748;
    margin: 0 0 20px 0;
}

/* ==================== */
/* Блок 1: Overview (Сводная панель) */
/* ==================== */

.metrics-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
}

.metric-card {
    background: white;
    border: 1px solid #e5e7eb;
    padding: 20px;
    border-radius: 12px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
    transition: all 0.2s;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.metric-card:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    transform: translateY(-2px);
}

.metric-value {
    font-size: 42px;
    font-weight: 700;
    color: #111827;
    line-height: 1;
    margin-bottom: 4px;
}

.metric-label {
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    color: #6b7280;
    margin-bottom: 12px;
    white-space: nowrap;
}

.metric-change {
    font-size: 13px;
    font-weight: 600;
    padding: 3px 8px;
    border-radius: 12px;
    display: inline-block;
    white-space: nowrap;
}

.metric-change.positive {
    background: #d1fae5;
    color: #065f46;
}

.metric-change.negative {
    background: #fee2e2;
    color: #991b1b;
}

.metric-change.neutral {
    background: #f3f4f6;
    color: #4b5563;
}

.metric-hint {
    font-size: 11px;
    color: #9ca3af;
}

.metric-main {
    flex: 1;
}

.metric-footer {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: auto;
    padding-top: 12px;
    border-top: 1px solid #f3f4f6;
}

/* ==================== */
/* Блок 2: Funnel (Воронка идей) */
/* ==================== */

.funnel-container {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.funnel-stage {
    display: flex;
    align-items: center;
    gap: 12px;
}

.funnel-label {
    flex: 0 0 150px;
    font-size: 14px;
    font-weight: 500;
    color: #4a5568;
}

.funnel-bar-container {
    flex: 1;
    height: 32px;
    background: #f7fafc;
    border-radius: 6px;
    overflow: hidden;
}

.funnel-bar {
    height: 100%;
    transition: width 0.3s ease;
    border-radius: 6px;
}

.funnel-rate {
    flex: 0 0 60px;
    text-align: right;
    font-weight: 600;
    color: #2d3748;
}

.funnel-hint {
    margin-top: 12px;
    font-size: 12px;
    color: #718096;
    text-align: center;
}

/* ==================== */
/* Блок 3: Financial Impact */
/* ==================== */

.financial-summary {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-bottom: 20px;
}

.financial-box {
    background: #f7fafc;
    padding: 20px;
    border-radius: 8px;
    text-align: center;
}

.financial-label {
    font-size: 12px;
    color: #718096;
    margin-bottom: 8px;
}

.financial-value {
    font-size: 24px;
    font-weight: 700;
    color: #2d3748;
}

.financial-value.green {
    color: #48bb78;
}

.roi-indicator {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    font-size: 18px;
    font-weight: 600;
    padding: 16px;
    border-radius: 8px;
    text-align: center;
    margin-bottom: 20px;
}

.breakdown-title {
    font-size: 16px;
    font-weight: 600;
    color: #2d3748;
    margin: 0 0 16px 0;
}

.breakdown-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.breakdown-item {
    display: grid;
    grid-template-columns: 150px 1fr 100px 60px;
    gap: 12px;
    align-items: center;
}

.breakdown-label {
    font-size: 14px;
    color: #4a5568;
}

.breakdown-bar-container {
    height: 24px;
    background: #f7fafc;
    border-radius: 4px;
    overflow: hidden;
}

.breakdown-bar {
    height: 100%;
    transition: width 0.3s ease;
}

.breakdown-value {
    font-size: 14px;
    font-weight: 600;
    color: #2d3748;
    text-align: right;
}

.breakdown-percentage {
    font-size: 12px;
    color: #718096;
    text-align: right;
}

/* ==================== */
/* Блок 4: Projects Status */
/* ==================== */

.projects-summary {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    margin-bottom: 24px;
}

.project-stat {
    background: #f7fafc;
    padding: 16px;
    border-radius: 8px;
    text-align: center;
    border-left: 4px solid #cbd5e0;
}

.project-stat.active {
    background: #e6fffa;
    border-left-color: #38b2ac;
}

.project-stat.completed {
    background: #f0fff4;
    border-left-color: #48bb78;
}

.project-stat.paused {
    background: #fffaf0;
    border-left-color: #ed8936;
}

.stat-value {
    font-size: 28px;
    font-weight: 700;
    color: #2d3748;
    display: block;
    margin-bottom: 4px;
}

.stat-label {
    font-size: 12px;
    color: #718096;
}

.phase-title {
    font-size: 16px;
    font-weight: 600;
    color: #2d3748;
    margin: 0 0 16px 0;
}

.phase-distribution {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.phase-item {
    display: grid;
    grid-template-columns: 120px 1fr 50px;
    gap: 12px;
    align-items: center;
}

.phase-label {
    font-size: 14px;
    color: #4a5568;
}

.phase-bar-container {
    height: 24px;
    background: #f7fafc;
    border-radius: 4px;
    overflow: hidden;
}

.phase-bar {
    height: 100%;
    background: linear-gradient(90deg, #667eea 0%, #764ba2 100%);
    transition: width 0.3s ease;
}

.phase-count {
    font-size: 16px;
    font-weight: 600;
    color: #2d3748;
    text-align: right;
}

/* ==================== */
/* Блок 5: People Engagement */
/* ==================== */

.leaderboard {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 24px;
}

.leaderboard-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    background: #f7fafc;
    border-radius: 8px;
    transition: transform 0.2s;
}

.leaderboard-item:hover {
    transform: translateX(4px);
    background: #edf2f7;
}

.leaderboard-item.top-3 {
    background: linear-gradient(135deg, #fef5e7 0%, #fdebd0 100%);
    border-left: 4px solid #f6ad55;
}

.author-rank {
    font-size: 18px;
    font-weight: 700;
    color: #2d3748;
    width: 40px;
    text-align: center;
}

.author-info {
    flex: 1;
}

.author-name {
    font-size: 14px;
    font-weight: 600;
    color: #2d3748;
    margin-bottom: 2px;
}

.author-dept {
    font-size: 12px;
    color: #718096;
}

.author-stats {
    display: flex;
    gap: 16px;
    align-items: center;
}

.author-ideas {
    font-size: 14px;
    font-weight: 600;
    color: #667eea;
}

.author-points {
    font-size: 12px;
    color: #718096;
    background: #e2e8f0;
    padding: 4px 8px;
    border-radius: 12px;
}

.dept-title {
    font-size: 16px;
    font-weight: 600;
    color: #2d3748;
    margin: 0 0 16px 0;
}

.department-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.dept-item {
    display: grid;
    grid-template-columns: 120px 1fr 60px 60px;
    gap: 12px;
    align-items: center;
}

.dept-name {
    font-size: 14px;
    color: #4a5568;
    font-weight: 500;
}

.dept-bar-container {
    height: 20px;
    background: #f7fafc;
    border-radius: 4px;
    overflow: hidden;
}

.dept-bar {
    height: 100%;
    background: linear-gradient(90deg, #48bb78 0%, #38a169 100%);
    transition: width 0.3s ease;
}

.dept-count {
    font-size: 14px;
    font-weight: 600;
    color: #2d3748;
    text-align: right;
}

.dept-percentage {
    font-size: 12px;
    color: #718096;
    text-align: right;
}

/* ==================== */
/* Блок 6: Trends */
/* ==================== */

.trends-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
    margin-bottom: 24px;
}

.trend-item {
    background: #f7fafc;
    padding: 20px;
    border-radius: 8px;
}

.trend-label {
    font-size: 14px;
    color: #718096;
    margin-bottom: 12px;
}

.trend-sparkline {
    font-size: 32px;
    letter-spacing: 2px;
    line-height: 1;
    margin-bottom: 12px;
    color: #667eea;
    font-family: monospace;
}

.trend-current {
    font-size: 20px;
    font-weight: 700;
    color: #2d3748;
}

.forecast-title {
    font-size: 16px;
    font-weight: 600;
    color: #2d3748;
    margin: 0 0 16px 0;
}

.forecast-box {
    background: linear-gradient(135deg, #edf2f7 0%, #e2e8f0 100%);
    padding: 20px;
    border-radius: 8px;
    margin-bottom: 24px;
}

.forecast-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 0;
    border-bottom: 1px solid #cbd5e0;
}

.forecast-item:last-child {
    border-bottom: none;
}

.forecast-label {
    font-size: 14px;
    color: #4a5568;
}

.forecast-value {
    font-size: 16px;
    font-weight: 600;
    color: #667eea;
}

.trends-details {
    margin-top: 20px;
}

.trends-details summary {
    cursor: pointer;
    font-size: 14px;
    color: #667eea;
    font-weight: 600;
    padding: 12px;
    background: #f7fafc;
    border-radius: 6px;
    user-select: none;
}

.trends-details summary:hover {
    background: #edf2f7;
}

.trends-table {
    width: 100%;
    margin-top: 16px;
    border-collapse: collapse;
}

.trends-table thead {
    background: #f7fafc;
}

.trends-table th {
    padding: 12px;
    text-align: left;
    font-size: 12px;
    font-weight: 600;
    color: #718096;
    text-transform: uppercase;
}

.trends-table td {
    padding: 12px;
    border-bottom: 1px solid #e2e8f0;
    font-size: 14px;
    color: #2d3748;
}

.trends-table tbody tr:hover {
    background: #f7fafc;
}

/* ==================== */
/* Responsive Design */
/* ==================== */

@media (max-width: 1024px) {
    .analytics-row {
        flex-direction: column;
    }

    .analytics-block.half-width {
        margin-bottom: 24px;
    }

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

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

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

@media (max-width: 768px) {
    .analytics-header {
        flex-direction: column;
        gap: 16px;
        align-items: flex-start;
    }

    .analytics-filters {
        width: 100%;
        justify-content: space-between;
    }

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

    .financial-summary {
        grid-template-columns: 1fr;
    }

    .breakdown-item {
        grid-template-columns: 1fr;
        gap: 8px;
    }

    .projects-summary {
        grid-template-columns: 1fr;
    }

    .phase-item,
    .dept-item {
        grid-template-columns: 1fr;
        gap: 8px;
    }
}

/* ==================== */
/* Tabs System */
/* ==================== */

.analytics-tabs {
    display: flex;
    gap: 8px;
    margin: 24px 0 32px 0;
    border-bottom: 2px solid #e2e8f0;
}

.tab-btn {
    padding: 12px 24px;
    background: transparent;
    border: none;
    border-bottom: 3px solid transparent;
    color: #718096;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    margin-bottom: -2px;
}

.tab-btn:hover {
    color: #2d3748;
    background: #f7fafc;
}

.tab-btn.active {
    color: #667eea;
    border-bottom-color: #667eea;
    background: transparent;
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
    animation: fadeIn 0.3s;
}

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

/* ==================== */
/* ROI Analytics */
/* ==================== */

#roi-analytics-container {
    padding: 20px 0;
}

.roi-summary {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
    margin-bottom: 32px;
}

.roi-card {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 12px;
    padding: 24px;
    color: white;
    display: flex;
    align-items: center;
    gap: 16px;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.2);
}

.roi-card-icon {
    font-size: 40px;
    opacity: 0.9;
}

.roi-card-content {
    flex: 1;
}

.roi-card-value {
    font-size: 28px;
    font-weight: 700;
    margin-bottom: 4px;
}

.roi-card-label {
    font-size: 13px;
    opacity: 0.9;
}

.roi-section {
    background: white;
    border-radius: 12px;
    padding: 24px;
    margin-bottom: 24px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.section-title {
    font-size: 20px;
    font-weight: 700;
    color: #2d3748;
    margin: 0 0 20px 0;
}

/* Top Projects */
.roi-top-projects {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.top-project-card {
    display: grid;
    grid-template-columns: 60px 1fr auto auto;
    gap: 20px;
    align-items: center;
    padding: 20px;
    background: #f7fafc;
    border-radius: 8px;
    border-left: 4px solid #667eea;
}

.project-rank {
    font-size: 32px;
    font-weight: 700;
    color: #667eea;
    text-align: center;
}

.project-info {
    flex: 1;
}

.project-name {
    font-size: 16px;
    font-weight: 600;
    color: #2d3748;
    margin-bottom: 4px;
}

.project-owner {
    font-size: 13px;
    color: #718096;
}

.project-savings,
.project-actual {
    text-align: right;
}

.savings-expected,
.savings-actual {
    font-size: 18px;
    font-weight: 700;
    color: #2d3748;
}

.savings-label {
    font-size: 12px;
    color: #718096;
    margin-top: 2px;
}

/* ROI Table */
.roi-table-container {
    overflow-x: auto;
}

.roi-table {
    width: 100%;
    border-collapse: collapse;
}

.roi-table thead tr {
    background: #f7fafc;
    border-bottom: 2px solid #e2e8f0;
}

.roi-table th {
    padding: 12px 16px;
    text-align: left;
    font-size: 13px;
    font-weight: 600;
    color: #4a5568;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.roi-table td {
    padding: 14px 16px;
    border-bottom: 1px solid #e2e8f0;
    font-size: 14px;
    color: #2d3748;
}

.roi-table td.number {
    text-align: right;
    font-weight: 600;
}

.roi-table tbody tr:hover {
    background: #f7fafc;
}

.roi-table a {
    color: #667eea;
    text-decoration: none;
    font-weight: 600;
}

.roi-table a:hover {
    text-decoration: underline;
}

.achievement-high {
    color: #48bb78;
}

.achievement-medium {
    color: #ed8936;
}

.achievement-low {
    color: #f56565;
}

.status-badge {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
}

.status-upcoming {
    background: #bee3f8;
    color: #2c5282;
}

.status-active {
    background: #c6f6d5;
    color: #22543d;
}

.status-completed {
    background: #e2e8f0;
    color: #4a5568;
}

/* Category Cards */
.roi-categories {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 20px;
}

.category-card {
    background: #f7fafc;
    border-radius: 8px;
    padding: 20px;
    border-left: 4px solid #667eea;
}

.category-name {
    font-size: 16px;
    font-weight: 700;
    color: #2d3748;
    margin-bottom: 16px;
}

.category-stats {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.stat {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.stat-label {
    font-size: 13px;
    color: #718096;
}

.stat-value {
    font-size: 15px;
    font-weight: 600;
    color: #2d3748;
}

/* Responsive */
@media (max-width: 768px) {
    .top-project-card {
        grid-template-columns: 50px 1fr;
        gap: 12px;
    }

    .project-rank {
        font-size: 24px;
    }

    .project-savings,
    .project-actual {
        grid-column: 1 / -1;
        text-align: left;
        margin-left: 62px;
    }

    .roi-table {
        font-size: 12px;
    }

    .roi-table th,
    .roi-table td {
        padding: 10px 8px;
    }
}


/* ==================== */
/* Kaizen Pulse Tab     */
/* ==================== */

.pulse-daily-chart {
    display: flex;
    align-items: flex-end;
    gap: 3px;
    height: 200px;
    overflow-x: auto;
    padding-bottom: 4px;
}

.pulse-participation-chart {
    height: 160px;
}

.pulse-day-col {
    display: flex;
    flex-direction: column;
    align-items: center;
    flex: 1;
    min-width: 22px;
    height: 100%;
    justify-content: flex-end;
}

.pulse-day-value {
    font-size: 10px;
    color: #718096;
    margin-bottom: 4px;
    font-weight: 600;
}

.pulse-day-bar-wrap {
    width: 100%;
    height: 140px;
    display: flex;
    align-items: flex-end;
}

.pulse-participation-chart .pulse-day-bar-wrap {
    height: 100px;
}

.pulse-day-bar {
    width: 100%;
    border-radius: 3px 3px 0 0;
    min-height: 3px;
    transition: height 0.4s ease;
}

.pulse-day-label {
    font-size: 9px;
    color: #a0aec0;
    margin-top: 4px;
    white-space: nowrap;
}

/* Muda Pareto */
.pulse-muda-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.pulse-muda-item {
    display: flex;
    align-items: center;
    gap: 10px;
}

.pulse-muda-label {
    width: 170px;
    font-size: 13px;
    color: #2d3748;
    flex-shrink: 0;
}

.pulse-muda-bar-wrap {
    flex: 1;
    height: 20px;
    background: #edf2f7;
    border-radius: 4px;
    overflow: hidden;
}

.pulse-muda-bar {
    height: 100%;
    background: linear-gradient(90deg, #667eea, #764ba2);
    border-radius: 4px;
    transition: width 0.5s ease;
}

.pulse-muda-count {
    font-weight: 700;
    font-size: 14px;
    color: #2d3748;
    min-width: 28px;
    text-align: right;
}

.pulse-muda-pct {
    font-size: 12px;
    color: #718096;
    min-width: 40px;
    text-align: right;
}

/* Period comparison */
.pulse-comparison {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 32px;
}

.pulse-period-card {
    text-align: center;
    padding: 24px 32px;
    background: #f7fafc;
    border-radius: 12px;
    min-width: 160px;
}

.pulse-period-label {
    font-size: 13px;
    color: #718096;
    margin-bottom: 8px;
}

.pulse-period-value {
    font-size: 42px;
    font-weight: 700;
    line-height: 1;
}

.pulse-period-hint {
    font-size: 12px;
    color: #a0aec0;
    margin-top: 8px;
}

.pulse-period-delta {
    font-size: 32px;
    font-weight: 700;
}

/* Weekly grid */
.pulse-weekly-grid {
    display: flex;
    gap: 12px;
    overflow-x: auto;
    padding-bottom: 4px;
}

.pulse-week-card {
    text-align: center;
    padding: 14px 18px;
    background: #f7fafc;
    border-radius: 10px;
    min-width: 90px;
    border: 1px solid #e2e8f0;
    transition: box-shadow 0.2s;
}

.pulse-week-card:hover {
    box-shadow: 0 4px 12px rgba(0,0,0,0.08);
}

.pulse-week-label {
    font-size: 11px;
    color: #718096;
    font-weight: 600;
}

.pulse-week-value {
    font-size: 28px;
    font-weight: 700;
    margin: 6px 0;
    line-height: 1;
}

.pulse-week-count {
    font-size: 11px;
    color: #a0aec0;
}

/* Responsive */
@media (max-width: 768px) {
    .pulse-muda-label {
        width: 120px;
        font-size: 11px;
    }
    .pulse-comparison {
        flex-direction: column;
        gap: 16px;
    }
    .pulse-period-delta {
        transform: rotate(90deg);
    }
    .pulse-period-card {
        min-width: 120px;
        padding: 16px 20px;
    }
    .metrics-grid {
        grid-template-columns: repeat(2, 1fr) !important;
    }
}
