/* Dashboard Styles */
.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.dashboard-card {
    background: linear-gradient(135deg, #ffffff 0%, #f8fafc 100%);
    border-radius: var(--radius);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
    border: 1px solid #e2e8f0;
    overflow: hidden;
    transition: var(--transition);
}

.dashboard-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 30px rgba(99, 102, 241, 0.15);
    border-color: var(--primary);
}

.dashboard-card-header {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: white;
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 15px;
    box-shadow: 0 2px 10px rgba(99, 102, 241, 0.2);
    position: relative;
}

.dashboard-card-header::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 2px;
    background: rgba(255, 255, 255, 0.3);
}

.dashboard-card-header i {
    font-size: 24px;
    opacity: 0.9;
}

.dashboard-card-header h3 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
}

.dashboard-card-content {
    padding: 25px 20px;
}

.metric-row {
    display: flex;
    justify-content: space-between;
    margin-bottom: 20px;
}

.metric-row:last-child {
    margin-bottom: 0;
}

.metric-item {
    text-align: center;
    flex: 1;
}

.metric-value {
    font-size: 28px;
    font-weight: 700;
    color: var(--dark);
    margin-bottom: 5px;
    line-height: 1;
}

.metric-label {
    font-size: 12px;
    color: var(--gray);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Quick Stats */
.quick-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 20px;
}

.quick-stat {
    background: linear-gradient(135deg, #ffffff 0%, #f8fafc 100%);
    border-radius: var(--radius);
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.08);
    border: 1px solid #e2e8f0;
    padding: 25px;
    display: flex;
    align-items: center;
    gap: 20px;
    transition: var(--transition);
    position: relative;
    overflow: hidden;
}

.quick-stat::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 4px;
    height: 100%;
    background: linear-gradient(180deg, var(--primary) 0%, var(--primary-dark) 100%);
}

.quick-stat:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 20px rgba(99, 102, 241, 0.15);
    border-color: var(--primary);
}

.quick-stat i {
    font-size: 32px;
    color: var(--primary);
    opacity: 0.8;
}

.quick-stat-content {
    flex: 1;
}

.quick-stat-title {
    font-size: 14px;
    color: var(--gray);
    margin-bottom: 8px;
}

.quick-stat-value {
    font-size: 24px;
    font-weight: 700;
    color: var(--dark);
}

/* Кнопка экспорта */
.export-dashboard-btn {
    margin: 15px 0 20px 0;
    width: 100%;
    max-width: 200px;
}

/* Responsive Dashboard */
@media (max-width: 768px) {
    .dashboard-grid {
        grid-template-columns: 1fr;
    }
    
    .quick-stats {
        grid-template-columns: 1fr;
    }
    
    .metric-row {
        flex-direction: column;
        gap: 15px;
    }
    
    .metric-item {
        text-align: center;
    }
    
    .quick-stat {
        flex-direction: column;
        text-align: center;
    }
    
    .quick-stat i {
        font-size: 28px;
    }
    
    .export-dashboard-btn {
        width: 100%;
        max-width: 100%;
        margin: 10px 0 20px 0;
    }
}

/* ================================
   РОЗШИРЕНА АНАЛІТИКА
   ================================ */

.dashboard-extended {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 20px;
    margin-top: 30px;
}

.dashboard-cards-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 20px;
    grid-column: span 2;
}

.dashboard-card-wide {
    grid-column: span 2;
}

.loading-placeholder,
.no-data {
    text-align: center;
    color: var(--gray);
    padding: 30px;
    font-style: italic;
}

/* Топ співробітників */
.top-employees-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.top-employee-item {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 12px 15px;
    background: #f8fafc;
    border-radius: 8px;
    border: 1px solid #e2e8f0;
    transition: var(--transition);
}

.top-employee-item:hover {
    background: #f1f5f9;
    border-color: var(--primary);
}

.top-employee-rank {
    width: 32px;
    height: 32px;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 14px;
    flex-shrink: 0;
}

.top-employee-item:first-child .top-employee-rank {
    background: linear-gradient(135deg, #fbbf24 0%, #f59e0b 100%);
}

.top-employee-info {
    flex: 1;
    min-width: 0;
}

.top-employee-name {
    font-weight: 600;
    color: var(--dark);
    margin-bottom: 4px;
}

.top-employee-stats {
    display: flex;
    gap: 15px;
    font-size: 12px;
    color: var(--gray);
}

.top-employee-stats i {
    margin-right: 4px;
    color: var(--primary);
}

.top-employee-progress {
    width: 80px;
    flex-shrink: 0;
}

.progress-bar-mini {
    width: 100%;
    height: 6px;
    background: #e2e8f0;
    border-radius: 3px;
    overflow: hidden;
}

.progress-fill-mini {
    height: 100%;
    border-radius: 3px;
    transition: width 0.3s ease;
}

/* Тренди */
.trends-chart {
    padding: 15px 0;
}

.trends-summary {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 30px;
    margin-bottom: 25px;
    padding: 20px;
    background: linear-gradient(135deg, #f8fafc 0%, #ffffff 100%);
    border-radius: 12px;
    border: 1px solid #e2e8f0;
}

.trend-item {
    text-align: center;
    padding: 15px;
    background: white;
    border-radius: 8px;
    border: 1px solid #e2e8f0;
    transition: var(--transition);
}

.trend-item:hover {
    border-color: var(--primary);
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.1);
    transform: translateY(-2px);
}

.trend-item-current {
    border-left: 3px solid var(--primary);
}

.trend-item-previous {
    border-left: 3px solid var(--gray);
}

.trend-label {
    font-size: 11px;
    color: var(--gray);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    display: block;
    margin-bottom: 6px;
    font-weight: 600;
}

.trend-period-dates {
    font-size: 11px;
    color: var(--gray);
    display: block;
    margin-bottom: 10px;
    font-style: italic;
}

.trend-value {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}

.trend-number {
    font-size: 28px;
    font-weight: 700;
    color: var(--dark);
    line-height: 1;
}

.trend-text {
    font-size: 12px;
    color: var(--gray);
    text-transform: lowercase;
}

.trend-percentage {
    font-size: 16px;
    font-weight: 600;
    color: var(--primary);
    margin-top: 4px;
}

.trend-positive {
    color: var(--success) !important;
}

.trend-negative {
    color: var(--danger) !important;
}

.trends-bars {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    height: 180px;
    gap: 6px;
    padding: 15px 10px;
    background: linear-gradient(to top, #f8fafc 0%, transparent 100%);
    border-radius: 8px;
    margin-bottom: 15px;
}

.trend-bar-group {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    height: 100%;
    cursor: pointer;
    transition: var(--transition);
    padding: 0 2px;
}

.trend-bar-group:hover {
    transform: translateY(-3px);
}

.trend-bar-group:hover .trend-bar {
    opacity: 0.9;
    filter: brightness(1.1);
}

.trend-bar-container {
    flex: 1;
    width: 100%;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    align-items: center;
    gap: 0;
}

.trend-bar-container-dual {
    flex: 1;
    width: 100%;
    display: flex;
    gap: 3px;
    justify-content: center;
    align-items: flex-end;
    margin-bottom: 8px;
}

.trend-bar-wrapper {
    flex: 1;
    max-width: 32px;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    align-items: center;
    height: 100%;
    position: relative;
}

.trend-bar {
    width: 100%;
    border-radius: 6px 6px 0 0;
    min-height: 4px;
    transition: all 0.3s ease;
    position: relative;
    cursor: pointer;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.trend-bar:hover {
    filter: brightness(1.15);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
    z-index: 2;
}

.trend-bar-empty {
    width: 100%;
    height: 4px;
    opacity: 0.3;
}

.trend-bar-completed {
    background: linear-gradient(180deg, var(--success) 0%, #10b981 100%);
}

.trend-bar-overdue {
    background: linear-gradient(180deg, var(--danger) 0%, #dc2626 100%);
}

.trend-bar-info {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    width: 100%;
}

.trend-bar-label {
    font-size: 10px;
    color: var(--gray);
    text-transform: uppercase;
    font-weight: 600;
    letter-spacing: 0.5px;
}

.trend-bar-date {
    font-size: 9px;
    color: var(--gray);
    opacity: 0.7;
}

.trend-bar-value {
    font-size: 14px;
    font-weight: 700;
    color: var(--dark);
    margin-top: 2px;
}

.trend-bar-percentage {
    font-size: 10px;
    color: var(--primary);
    font-weight: 600;
    margin-top: 1px;
}

.trends-legend {
    display: flex;
    justify-content: center;
    gap: 25px;
    margin-top: 15px;
    padding-top: 15px;
    border-top: 1px solid #e2e8f0;
    font-size: 12px;
    color: var(--gray);
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    background: #f8fafc;
    border-radius: 6px;
    font-weight: 500;
}

.legend-color {
    width: 14px;
    height: 14px;
    border-radius: 4px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

/* Теплова карта */
.activity-heatmap {
    width: 100%;
}

.heatmap-container {
    width: 100%;
    padding: 5px 0;
}

.heatmap-row {
    display: flex;
    gap: 2px;
    margin-bottom: 2px;
    width: 100%;
}

.heatmap-header {
    margin-bottom: 4px;
}

.heatmap-day-label {
    width: 30px;
    min-width: 30px;
    font-size: 11px;
    color: var(--gray);
    display: flex;
    align-items: center;
    flex-shrink: 0;
}

.heatmap-hour-label {
    flex: 1;
    font-size: 10px;
    color: var(--gray);
    text-align: center;
}

.heatmap-cell {
    flex: 1;
    min-width: 0;
    aspect-ratio: 1;
    border-radius: 3px;
    cursor: pointer;
    transition: transform 0.2s ease;
}

.heatmap-cell:hover {
    transform: scale(1.2);
    z-index: 1;
}

.heatmap-legend {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    margin-top: 15px;
    font-size: 11px;
    color: var(--gray);
}

.heatmap-legend-gradient {
    width: 100px;
    height: 10px;
    background: linear-gradient(to right, #f1f5f9, #c7d2fe, #a5b4fc, #818cf8, #6366f1);
    border-radius: 5px;
}

/* Популярні та проблемні чек-листи */
.popular-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.popular-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    background: #f8fafc;
    border-radius: 8px;
    border: 1px solid #e2e8f0;
}

.popular-item.problematic {
    background: #fef2f2;
    border-color: #fecaca;
}

.popular-rank {
    width: 28px;
    height: 28px;
    background: var(--primary);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 12px;
    flex-shrink: 0;
}

.problematic-rank {
    background: var(--danger);
}

.popular-info {
    flex: 1;
    min-width: 0;
}

.popular-title {
    font-weight: 500;
    color: var(--dark);
    font-size: 13px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.popular-stats {
    font-size: 11px;
    color: var(--gray);
    margin-top: 2px;
}

/* База знань */
.kb-stats {
    display: flex;
    gap: 20px;
    margin-bottom: 15px;
}

.kb-stat-item {
    flex: 1;
    text-align: center;
    padding: 15px;
    background: #f8fafc;
    border-radius: 8px;
}

.kb-stat-label {
    font-size: 11px;
    color: var(--gray);
    display: block;
    margin-bottom: 5px;
}

.kb-stat-value {
    font-size: 24px;
    font-weight: 700;
    color: var(--dark);
}

.kb-stat-warning {
    color: var(--warning);
}

.kb-unanswered {
    margin-top: 10px;
}

.kb-unanswered-title {
    font-size: 12px;
    color: var(--gray);
    margin-bottom: 8px;
}

.kb-unanswered-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 10px;
    background: #fff7ed;
    border-radius: 6px;
    margin-bottom: 5px;
    border: 1px solid #fed7aa;
}

.kb-query-text {
    font-size: 12px;
    color: var(--dark);
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.kb-query-count {
    font-size: 11px;
    font-weight: 600;
    color: var(--warning);
    background: white;
    padding: 2px 8px;
    border-radius: 10px;
}

/* Завдання що скоро прострочаться */
.upcoming-deadlines-list {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
}

.deadline-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 15px;
    background: #f8fafc;
    border-radius: 8px;
    border: 1px solid #e2e8f0;
    flex: 1 1 300px;
    max-width: 400px;
}

.deadline-critical {
    background: #fef2f2;
    border-color: #fecaca;
}

.deadline-warning {
    background: #fffbeb;
    border-color: #fed7aa;
}

.deadline-time {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 8px 12px;
    background: white;
    border-radius: 6px;
    min-width: 70px;
}

.deadline-critical .deadline-time {
    color: var(--danger);
}

.deadline-warning .deadline-time {
    color: var(--warning);
}

.deadline-time i {
    font-size: 16px;
}

.deadline-time span {
    font-size: 12px;
    font-weight: 600;
}

.deadline-info {
    flex: 1;
    min-width: 0;
}

.deadline-title {
    font-weight: 500;
    color: var(--dark);
    font-size: 13px;
}

.deadline-employee {
    font-size: 12px;
    color: var(--gray);
    margin-top: 2px;
}

.deadline-scheduled {
    font-size: 11px;
    color: var(--gray);
    margin-top: 4px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.deadline-scheduled i {
    font-size: 10px;
    color: var(--primary);
}

/* Responsive */
@media (max-width: 1024px) {
    .dashboard-extended {
        grid-template-columns: 1fr;
    }
    
    .dashboard-cards-row {
        grid-column: span 1;
    }
    
    .dashboard-card-wide {
        grid-column: span 1;
    }
}

@media (max-width: 768px) {
    .trends-summary {
        grid-template-columns: 1fr;
        gap: 15px;
        padding: 15px;
    }
    
    .trends-bars {
        height: 140px;
        gap: 4px;
        padding: 10px 5px;
    }
    
    .trend-bar-wrapper {
        max-width: 24px;
    }
    
    .trend-bar-label,
    .trend-bar-date {
        font-size: 8px;
    }
    
    .trend-bar-value {
        font-size: 11px;
    }
    
    .trend-number {
        font-size: 22px;
    }
    
    .heatmap-container {
        margin: 0 -15px;
        padding: 5px 15px;
    }
    
    .heatmap-cell {
        flex: 1;
        min-width: 0;
        aspect-ratio: 1;
    }
    
    .heatmap-hour-label {
        flex: 1;
        font-size: 8px;
    }
    
    .heatmap-day-label {
        width: 25px;
        min-width: 25px;
        font-size: 10px;
    }
    
    .top-employee-stats {
        flex-wrap: wrap;
        gap: 8px;
    }
    
    .kb-stats {
        flex-direction: column;
        gap: 10px;
    }
    
    .deadline-item {
        flex: 1 1 100%;
        max-width: 100%;
    }
    
    .quick-stats {
        grid-template-columns: 1fr;
    }
}
