/* frontend/css/dashboard.css - ПОЛНАЯ ВЕРСИЯ С SPC */

:root {
    --primary-color: #2e8bd5;
    --primary-dark: #2577b8;
    --primary-light: #e8f4f8;
    --secondary-color: #f39c12;
    --danger-color: #e74c3c;
    --success-color: #27ae60;
    --text-dark: #2c3e50;
    --text-gray: #7f8c8d;
    --text-light: #95a5a6;
    --border-color: #ecf0f1;
    --bg-gray: #f5f7fb;
    --white: #ffffff;
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 5px 20px rgba(0, 0, 0, 0.08);
    --shadow-lg: 0 10px 30px rgba(0, 0, 0, 0.1);
    --border-radius: 16px;
    --border-radius-sm: 12px;
    --transition: all 0.3s ease;
}

/* ============================================
   КОНТЕЙНЕР ДАШБОРДА
   ============================================ */
.dashboard-container {
    padding: 0;
    max-width: 100%;
    overflow-x: hidden;
}



/* ============================================
   STATS GRID
   ============================================ */
.dashboard-stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 20px;
    margin-bottom: 28px;
}

.stat-card {
    background: var(--white);
    border-radius: var(--border-radius);
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 16px;
    box-shadow: var(--shadow-sm);
    transition: var(--transition);
    position: relative;
    overflow: hidden;
    cursor: pointer;
    border: 1px solid var(--border-color);
}

.stat-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-md);
    border-color: var(--primary-light);
}

.stat-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: var(--primary-color);
}

.stat-card[data-stat="violations"]::before {
    background: var(--secondary-color);
}

.stat-card[data-stat="incidents"]::before {
    background: var(--danger-color);
}

.stat-card[data-stat="rating"]::before {
    background: var(--success-color);
}

.stat-icon {
    width: 56px;
    height: 56px;
    background: var(--primary-light);
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    color: var(--primary-color);
    transition: var(--transition);
}

.stat-card:hover .stat-icon {
    transform: scale(1.05);
}

.stat-icon.warning {
    background: #fff3e0;
    color: var(--secondary-color);
}

.stat-icon.danger {
    background: #fee2e2;
    color: var(--danger-color);
}

.stat-icon.success {
    background: #e0f7e8;
    color: var(--success-color);
}

.stat-info {
    flex: 1;
}

.stat-info h3 {
    font-size: 32px;
    font-weight: 700;
    color: var(--text-dark);
    margin-bottom: 4px;
    line-height: 1.2;
}

.stat-info p {
    color: var(--text-gray);
    font-size: 13px;
    margin-bottom: 4px;
}

.stat-info small {
    font-size: 11px;
    color: var(--text-light);
}

.stat-progress {
    width: 100%;
    margin-top: 10px;
}

.progress-bar {
    height: 6px;
    background: var(--primary-color);
    border-radius: 3px;
    transition: width 0.6s ease;
}

/* ============================================
   CHARTS ROW
   ============================================ */
.dashboard-charts-row {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 20px;
    margin-bottom: 28px;
}

.chart-card {
    background: var(--white);
    border-radius: var(--border-radius);
    padding: 20px;
    box-shadow: var(--shadow-sm);
    transition: var(--transition);
    border: 1px solid var(--border-color);
}

.chart-card:hover {
    box-shadow: var(--shadow-md);
}

.chart-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border-color);
}

.chart-header h3 {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-dark);
    margin: 0;
}

.chart-header h3 i {
    margin-right: 8px;
    color: var(--primary-color);
}

.period-select {
    padding: 6px 12px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 13px;
    background: var(--white);
    cursor: pointer;
    transition: var(--transition);
    color: var(--text-dark);
}

.period-select:hover {
    border-color: var(--primary-color);
}

.chart-body {
    position: relative;
    min-height: 250px;
}

.chart-body canvas {
    max-height: 250px;
    width: 100%;
}

/* ============================================
   TWO COLUMNS
   ============================================ */
.dashboard-two-columns {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 20px;
}

.dashboard-column {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

/* ============================================
   DATA CARDS
   ============================================ */
.data-card {
    background: var(--white);
    border-radius: var(--border-radius);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
    transition: var(--transition);
    border: 1px solid var(--border-color);
}

.data-card:hover {
    box-shadow: var(--shadow-md);
}

.card-header {
    padding: 16px 20px;
    background: var(--bg-gray);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.card-header h3 {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-dark);
    margin: 0;
}

.card-header h3 i {
    margin-right: 8px;
    color: var(--primary-color);
}

.see-all {
    color: var(--primary-color);
    cursor: pointer;
    font-size: 13px;
    transition: var(--transition);
}

.see-all:hover {
    opacity: 0.8;
    transform: translateX(3px);
}

.card-body {
    padding: 0;
    max-height: 360px;
    overflow-y: auto;
}

/* ============================================
   VIOLATIONS LIST
   ============================================ */
.violations-list,
.actions-list,
.compliance-list {
    padding: 0;
    margin: 0;
}

.violation-item,
.action-item,
.compliance-item {
    padding: 14px 20px;
    border-bottom: 1px solid var(--border-color);
    transition: var(--transition);
    cursor: pointer;
}

.violation-item:hover,
.action-item:hover,
.compliance-item:hover {
    background: var(--bg-gray);
}

.violation-item {
    position: relative;
    padding-left: 52px;
}

.violation-rank {
    position: absolute;
    left: 16px;
    top: 50%;
    transform: translateY(-50%);
    width: 28px;
    height: 28px;
    background: var(--primary-color);
    color: var(--white);
    border-radius: 50%;
    text-align: center;
    line-height: 28px;
    font-size: 12px;
    font-weight: bold;
}

.violation-rank.rank-1 {
    background: var(--danger-color);
}

.violation-rank.rank-2 {
    background: var(--secondary-color);
}

.violation-rank.rank-3 {
    background: var(--primary-color);
}

.violation-text {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-dark);
    margin-bottom: 6px;
    line-height: 1.4;
}

.violation-stats {
    display: flex;
    gap: 16px;
    font-size: 12px;
    color: var(--text-gray);
}

.violation-stats i {
    margin-right: 4px;
    width: 14px;
}

/* ТОП-3 нарушений: номер — обычный элемент строки, а не наложение.
   Привязка к #topViolationsList нужна, потому что audit.css (подключён глобально,
   после этого файла) задаёт свой .violation-item с другими отступами */
#topViolationsList .violation-item {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 20px;
}

#topViolationsList .violation-rank {
    position: static;
    transform: none;
    flex-shrink: 0;
}

#topViolationsList .violation-text {
    flex: 1;
    min-width: 0;
    margin-bottom: 0;
}

#topViolationsList .violation-stats {
    flex-shrink: 0;
}

@media (max-width: 700px) {
    #topViolationsList .violation-item {
        flex-wrap: wrap;
    }

    #topViolationsList .violation-stats {
        width: 100%;
        padding-left: 42px;
    }
}

/* ============================================
   ACTION ITEMS
   ============================================ */
.action-title {
    font-weight: 500;
    font-size: 14px;
    color: var(--text-dark);
    margin-bottom: 6px;
    line-height: 1.4;
}

.action-details {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    font-size: 12px;
    color: var(--text-gray);
}

.action-details i {
    margin-right: 4px;
    width: 12px;
}

.action-deadline {
    color: var(--danger-color);
    font-weight: 500;
}

/* ============================================
   COMPLIANCE ITEMS
   ============================================ */
.compliance-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.compliance-name {
    font-size: 14px;
    color: var(--text-dark);
    font-weight: 500;
    min-width: 110px;
}

.compliance-rate {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 1;
}

.compliance-bar {
    flex: 1;
    height: 8px;
    background: var(--border-color);
    border-radius: 4px;
    overflow: hidden;
}

.compliance-bar-fill {
    height: 100%;
    background: var(--success-color);
    border-radius: 4px;
    transition: width 0.5s ease;
}

.compliance-bar-fill.warning {
    background: var(--secondary-color);
}

.compliance-bar-fill.danger {
    background: var(--danger-color);
}

.compliance-percent {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-dark);
    min-width: 45px;
    text-align: right;
}

/* ============================================
   SPC КАРТА
   ============================================ */
.spc-card {
    background: var(--white);
    border-radius: var(--border-radius);
    margin-top: 20px;
    overflow: hidden;
    border: 1px solid var(--border-color);
}

/* У .card-body по умолчанию max-height: 360px с внутренней прокруткой (нужно
   другим карточкам со списками) — SPC-карточке это не подходит, там график
   и статистика, которым нужно показываться целиком без пролистывания. */
.spc-card .card-body {
    max-height: none;
    overflow: visible;
}

.spc-controls {
    display: flex;
    gap: 12px;
    align-items: center;
}

.spc-select {
    padding: 6px 12px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 12px;
    background: var(--white);
    cursor: pointer;
}

.spc-chart-container {
    padding: 16px;
    border-bottom: 1px solid var(--border-color);
}

.spc-stats {
    display: flex;
    flex-wrap: wrap;
    gap: 24px;
    padding: 16px 20px;
    background: var(--bg-gray);
    border-bottom: 1px solid var(--border-color);
}

.spc-stat-item {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.spc-stat-label {
    font-size: 11px;
    color: var(--text-light);
    text-transform: uppercase;
}

.spc-stat-value {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-dark);
}

.spc-violations {
    padding: 12px 20px;
    border-bottom: 1px solid var(--border-color);
}

.violation-badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    margin: 4px 8px 4px 0;
    border-radius: 8px;
    font-size: 12px;
}

.violation-badge.critical {
    background: #fdecea;
    color: #c62828;
}

.violation-badge.high {
    background: #fff3e0;
    color: #e65100;
}

.violation-badge.medium {
    background: #fff8e1;
    color: #f39c12;
}

.spc-recommendation {
    padding: 16px 20px;
    background: var(--primary-light);
    margin: 12px 20px;
    border-radius: 12px;
    font-size: 14px;
    font-weight: 500;
}

.spc-recommendation.critical {
    background: #fdecea;
    color: #c62828;
}

.spc-recommendation.warning {
    background: #fff3e0;
    color: #e65100;
}

/* ============================================
   RECOMMENDATIONS
   ============================================ */
.recommendations-card {
    background: var(--white);
    border-radius: var(--border-radius);
    margin-top: 20px;
    overflow: hidden;
    border: 1px solid var(--border-color);
}

.recommendation-item {
    padding: 14px 20px;
    border-bottom: 1px solid var(--border-color);
    font-size: 14px;
    color: var(--text-dark);
    line-height: 1.4;
}

.recommendation-item:last-child {
    border-bottom: none;
}

.recommendation-item i {
    margin-right: 8px;
}

/* ============================================
   REPORT LINK
   ============================================ */
.report-link-container {
    margin-top: 20px;
    text-align: right;
}

.report-link {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    background: var(--primary-light);
    color: var(--primary-color);
    text-decoration: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    transition: var(--transition);
}

.report-link:hover {
    background: var(--primary-color);
    color: white;
}

/* ============================================
   EMPTY STATE
   ============================================ */
.empty-state {
    text-align: center;
    padding: 48px 20px;
    color: var(--text-light);
}

.empty-state i {
    font-size: 48px;
    margin-bottom: 12px;
    opacity: 0.5;
}

.empty-state p {
    font-size: 14px;
    margin: 0;
}

/* ============================================
   ERROR STATE
   ============================================ */
.dashboard-error {
    text-align: center;
    padding: 60px 20px;
    background: var(--white);
    border-radius: var(--border-radius);
}

.dashboard-error i {
    font-size: 64px;
    color: var(--danger-color);
    margin-bottom: 20px;
}

.btn-retry {
    padding: 10px 24px;
    background: var(--primary-color);
    color: var(--white);
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: var(--transition);
}

.btn-retry:hover {
    background: var(--primary-dark);
}

/* ============================================
   SCROLLBAR
   ============================================ */
.card-body::-webkit-scrollbar {
    width: 5px;
}

.card-body::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 3px;
}

.card-body::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 3px;
}

/* frontend/css/dashboard.css - добавить в конец файла */

/* SPC КАРТА */
.spc-card {
    background: var(--white);
    border-radius: var(--border-radius);
    margin-top: 20px;
    overflow: hidden;
    border: 1px solid var(--border-color);
}

.spc-controls {
    display: flex;
    gap: 12px;
    align-items: center;
}

.spc-select {
    padding: 6px 12px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 12px;
    background: var(--white);
    cursor: pointer;
}

.spc-chart-container {
    padding: 16px;
    border-bottom: 1px solid var(--border-color);
}

.spc-stats {
    display: flex;
    flex-wrap: wrap;
    gap: 24px;
    padding: 16px 20px;
    background: var(--bg-gray);
    border-bottom: 1px solid var(--border-color);
}

.spc-stat-item {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.spc-stat-label {
    font-size: 11px;
    color: var(--text-light);
    text-transform: uppercase;
}

.spc-stat-value {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-dark);
}

.spc-violations {
    padding: 12px 20px;
    border-bottom: 1px solid var(--border-color);
}

.violation-badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    margin: 4px 8px 4px 0;
    border-radius: 8px;
    font-size: 12px;
}

.violation-badge.critical {
    background: #fdecea;
    color: #c62828;
}

.violation-badge.high {
    background: #fff3e0;
    color: #e65100;
}

.violation-badge.medium {
    background: #fff8e1;
    color: #f39c12;
}

.spc-recommendation {
    padding: 16px 20px;
    background: var(--primary-light);
    margin: 12px 20px;
    border-radius: 12px;
    font-size: 14px;
    font-weight: 500;
}

.spc-recommendation.critical {
    background: #fdecea;
    color: #c62828;
}

.spc-recommendation.warning {
    background: #fff3e0;
    color: #e65100;
}

/* ============================================
   АДАПТИВНОСТЬ
   ============================================ */
@media (max-width: 1200px) {
    .dashboard-stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 992px) {
    .dashboard-charts-row {
        grid-template-columns: 1fr;
    }

    .dashboard-two-columns {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .dashboard-welcome {
        flex-direction: column;
        text-align: center;
        gap: 15px;
        padding: 24px;
    }

    .dashboard-stats-grid {
        grid-template-columns: 1fr;
    }

    .stat-card {
        padding: 16px;
    }

    .spc-stats {
        gap: 12px;
    }

    .spc-stat-value {
        font-size: 14px;
    }
}

/* ============================================
   АНИМАЦИИ
   ============================================ */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.stat-card,
.chart-card,
.data-card,
.spc-card,
.recommendations-card {
    animation: fadeInUp 0.4s ease forwards;
}

.stat-card:nth-child(1) {
    animation-delay: 0.05s;
}

.stat-card:nth-child(2) {
    animation-delay: 0.1s;
}

.stat-card:nth-child(3) {
    animation-delay: 0.15s;
}

.stat-card:nth-child(4) {
    animation-delay: 0.2s;
}