/**
 * 🔥 Team Heatmap Styles
 * Стили для тепловой карты активности команды (темная тема Business1)
 */

/* === ОСНОВНЫЕ КОНТЕЙНЕРЫ === */
.team-heatmap-section {
    margin-top: 0.75rem;
    background: var(--card-bg, #1a1a1a);
    border-radius: 12px;
    padding: 0.75rem;
    border: 1px solid var(--border-color, #333);
}

.team-heatmap-container {
    width: 100%;
}

.heatmap-wrapper {
    min-height: 400px;
    position: relative;
}

/* === ЗАГОЛОВОК И ФИЛЬТРЫ === */
.heatmap-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 16px;
}

.heatmap-title h3 {
    color: var(--text-primary, #fff);
    font-size: 1.1rem;
    font-weight: 600;
    margin: 0 0 2px 0;
    display: flex;
    align-items: center;
    gap: 8px;
}

.heatmap-subtitle {
    color: var(--text-secondary, #888);
    font-size: 0.75rem;
    margin: 0;
    opacity: 0.8;
}

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

.filter-select {
    background: var(--input-bg, #2a2a2a);
    color: var(--text-primary, #fff);
    border: 1px solid var(--border-color, #444);
    border-radius: 6px;
    padding: 8px 12px;
    font-size: 0.9rem;
    min-width: 120px;
    transition: border-color 0.2s ease;
}

.filter-select:focus {
    outline: none;
    border-color: var(--accent-color, #4f46e5);
    box-shadow: 0 0 0 2px var(--accent-color-opacity, rgba(79, 70, 229, 0.1));
}

.filter-select[multiple] {
    min-height: 80px;
    max-height: 120px;
}

/* === ЛЕГЕНДА ПОЛЬЗОВАТЕЛЕЙ === */
.heatmap-legend {
    margin-bottom: 24px;
    background: var(--secondary-bg, #222);
    border-radius: 8px;
    padding: 16px;
    border: 1px solid var(--border-color, #333);
}

.legend-title {
    color: var(--text-primary, #fff);
    font-weight: 600;
    margin-bottom: 12px;
    font-size: 0.95rem;
}

.legend-items {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 8px;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 8px;
    border-radius: 6px;
    transition: background-color 0.2s ease;
    cursor: pointer;
}

.legend-item:hover {
    background: var(--hover-bg, rgba(255, 255, 255, 0.05));
}

.legend-color {
    width: 12px;
    height: 12px;
    border-radius: 2px;
    flex-shrink: 0;
}

.legend-username {
    color: var(--text-primary, #fff);
    font-weight: 500;
    flex: 1;
    font-size: 0.9rem;
}

.legend-count {
    color: var(--text-secondary, #888);
    font-size: 0.85rem;
    font-weight: 500;
    background: var(--badge-bg, rgba(255, 255, 255, 0.1));
    padding: 2px 6px;
    border-radius: 10px;
}

.legend-type {
    font-size: 1rem;
}

/* === ЦВЕТА ПОЛЬЗОВАТЕЛЕЙ === */
.user-color-support {
    background: linear-gradient(135deg, #26a641, #39d353);
}

.user-color-sales {
    background: linear-gradient(135deg, #f85149, #c4320a);
}

.user-color-manager {
    background: linear-gradient(135deg, #58a6ff, #2f81f7);
}

.user-color-member {
    background: linear-gradient(135deg, #6e7681, #484f58);
}

/* === ГРАФИК - ТАБЛИЦА-СЕТКА === */
.heatmap-chart-container {
    margin: 20px 0;
    background: var(--chart-bg, #1a1a1a);
    border-radius: 8px;
    padding: 20px;
    border: 1px solid var(--border-color, #333);
    overflow-x: auto;
}

.heatmap-chart {
    min-height: 300px;
    width: 100%;
}

/* === ТАБЛИЦА-СЕТКА === */
.heatmap-grid-container {
    width: 100%;
    overflow-x: auto;
    border-radius: 8px;
    background: var(--secondary-bg, #222);
}

.heatmap-grid-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 1px;
    background: var(--border-color, #333);
}

.heatmap-grid-table thead {
    background: var(--card-bg, #2a2a2a);
    position: sticky;
    top: 0;
    z-index: 10;
}

.heatmap-grid-table th {
    padding: 8px 4px;
    text-align: center;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-primary, #fff);
    background: var(--card-bg, #2a2a2a);
    border: 1px solid var(--border-color, #444);
}

.member-header {
    min-width: 180px;
    text-align: left !important;
    padding: 8px 12px !important;
    position: sticky;
    left: 0;
    z-index: 11;
    background: var(--card-bg, #2a2a2a) !important;
}

.hour-header {
    min-width: 35px;
    width: 35px;
}

/* === СТРОКИ УЧАСТНИКОВ === */
.member-row {
    background: var(--secondary-bg, #222);
}

.member-name-cell {
    background: var(--card-bg, #2a2a2a);
    padding: 8px 12px;
    border: 1px solid var(--border-color, #444);
    position: sticky;
    left: 0;
    z-index: 9;
    min-width: 180px;
}

.member-info {
    display: flex;
    align-items: center;
    gap: 8px;
    white-space: nowrap;
}

.member-color-indicator {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    flex-shrink: 0;
    border: 1px solid var(--border-color, #555);
}

.member-username {
    font-weight: 600;
    color: var(--text-primary, #fff);
    font-size: 0.9rem;
}

.member-role {
    font-size: 0.75rem;
    color: var(--text-secondary, #888);
    background: var(--badge-bg, rgba(255, 255, 255, 0.1));
    padding: 2px 6px;
    border-radius: 10px;
    font-weight: 500;
}

/* === ЯЧЕЙКИ ЧАСОВ === */
.hour-cell {
    width: 35px;
    height: 35px;
    text-align: center;
    vertical-align: middle;
    position: relative;
    border: 1px solid var(--border-color, #444);
    background: var(--secondary-bg, #222);
    cursor: pointer;
    transition: all 0.2s ease;
}

.hour-cell:hover {
    transform: scale(1.1);
    border-color: var(--accent-color, #4f46e5);
    box-shadow: 0 2px 8px var(--shadow-color, rgba(0, 0, 0, 0.3));
    z-index: 20;
}

.cell-value {
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--text-primary, #fff);
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.7);
    display: inline-block;
    line-height: 1;
}

/* Скрываем значения 0 для чистоты */
.hour-cell[data-value="0"] .cell-value {
    display: none;
}

/* === СТАТИСТИКА === */
.heatmap-stats {
    margin-top: 20px;
    background: var(--secondary-bg, #222);
    border-radius: 8px;
    padding: 20px;
    border: 1px solid var(--border-color, #333);
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 20px;
}

.stat-item {
    text-align: center;
    padding: 12px;
    background: var(--card-bg, #2a2a2a);
    border-radius: 8px;
    border: 1px solid var(--border-color, #444);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.stat-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px var(--shadow-color, rgba(0, 0, 0, 0.3));
}

.stat-value {
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--accent-color, #4f46e5);
    margin-bottom: 4px;
    line-height: 1;
}

.stat-label {
    font-size: 0.85rem;
    color: var(--text-secondary, #888);
    font-weight: 500;
}

/* === СОСТОЯНИЯ ЗАГРУЗКИ И ОШИБОК === */
.heatmap-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 200px;
    color: var(--text-secondary, #888);
    gap: 16px;
}

.heatmap-loading .loading-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--border-color, #333);
    border-top: 3px solid var(--accent-color, #4f46e5);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

.heatmap-error {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 200px;
    color: var(--error-color, #f85149);
    text-align: center;
    gap: 16px;
}

.heatmap-error .error-icon {
    font-size: 2rem;
}

.heatmap-error .error-message {
    font-size: 1rem;
    font-weight: 500;
}

.heatmap-error-fallback {
    text-align: center;
    padding: 40px;
    color: var(--text-secondary, #888);
    background: var(--secondary-bg, #222);
    border-radius: 8px;
    border: 1px solid var(--border-color, #333);
}

.heatmap-error-fallback p {
    font-size: 1rem;
    margin: 0 0 8px 0;
}

.heatmap-error-fallback small {
    font-size: 0.85rem;
    opacity: 0.7;
}

/* === КНОПКИ === */
.btn {
    background: var(--button-bg, #4f46e5);
    color: var(--button-text, #fff);
    border: none;
    border-radius: 6px;
    padding: 8px 16px;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.btn:hover {
    background: var(--button-hover-bg, #3b82f6);
    transform: translateY(-1px);
}

.btn.btn-secondary {
    background: var(--secondary-button-bg, #374151);
    color: var(--secondary-button-text, #d1d5db);
}

.btn.btn-secondary:hover {
    background: var(--secondary-button-hover-bg, #4b5563);
}

/* === АНИМАЦИИ === */
@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

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

.team-heatmap-container {
    animation: fadeIn 0.5s ease-out;
}

/* === АДАПТИВНОСТЬ === */
@media (max-width: 768px) {
    .heatmap-header {
        flex-direction: column;
        align-items: stretch;
    }
    
    .heatmap-filters {
        justify-content: stretch;
    }
    
    .filter-select {
        flex: 1;
        min-width: 0;
    }
    
    .legend-items {
        grid-template-columns: 1fr;
    }
    
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .heatmap-chart-container {
        padding: 12px;
    }
}

@media (max-width: 480px) {
    .team-heatmap-section {
        padding: 16px;
        margin-top: 20px;
    }
    
    .stats-grid {
        grid-template-columns: 1fr;
    }
    
    .heatmap-title h3 {
        font-size: 1.1rem;
    }
}
