/* Файл: app/static/style.css - Общие стили */

body {
    font-family: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
    background-color: #f8fafc;
    color: #0f172a;
    margin: 0;
    padding: 0;
}

.modal-dialog.modal-dialog--wide {
    width: min(960px, 95vw);
}

.filters-card.compact {
    padding: 12px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.year-filter {
    display: flex;
    align-items: center;
    gap: 12px;
}

.year-filter label {
    font-weight: 600;
    color: #0f172a;
}

.year-filter select {
    padding: 8px 12px;
    border-radius: 8px;
    border: 1px solid #d0d5dd;
    background: #f9fafb;
    font-family: inherit;
}

.classification-select {
    width: 160px;
    padding: 6px 8px;
    border-radius: 6px;
    border: 1px solid #d0d5dd;
    background: #fff;
    font-family: inherit;
}

.classification-toolbar {
    display: flex;
    justify-content: flex-end;
    margin-bottom: 12px;
}

.ticket-description {
    margin-bottom: 8px;
}

.requalify-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 6px 10px;
    border-radius: 6px;
    border: 1px solid #f97316;
    background: #fff7ed;
    color: #c2410c;
    font-weight: 600;
    cursor: pointer;
    transition: box-shadow 0.15s ease, background 0.15s ease;
}

.requalify-btn:hover:not(:disabled) {
    background: #ffedd5;
    box-shadow: 0 4px 12px rgba(249, 115, 22, 0.25);
}

.requalify-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.secondary-button {
    background: #f1f5f9;
    color: #1f2933;
    border: 1px solid #d0d5dd;
    border-radius: 8px;
    padding: 8px 14px;
    font-weight: 600;
    cursor: pointer;
    transition: box-shadow 0.15s ease, background 0.15s ease;
}

.secondary-button:hover {
    background: #e2e8f0;
    box-shadow: 0 6px 16px rgba(148, 163, 184, 0.35);
}

.classification-actions button {
    padding: 6px 12px;
}

.table-search {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 12px;
    margin-bottom: 12px;
}

.table-search label {
    display: flex;
    flex-direction: column;
    font-size: 0.85rem;
    color: #475467;
    gap: 4px;
}

.table-search input {
    border: 1px solid #d0d5dd;
    border-radius: 8px;
    padding: 8px 10px;
    background: #fff;
    font-family: inherit;
}

.pagination-controls {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 12px;
    margin-top: 12px;
}

.pagination-controls button {
    padding: 6px 12px;
    font-size: 0.9rem;
}

.pagination-info {
    color: #475467;
    font-weight: 600;
}

.toast {
    position: fixed;
    bottom: 20px;
    right: 20px;
    background: #10b981;
    color: #fff;
    padding: 12px 18px;
    border-radius: 8px;
    box-shadow: 0 6px 20px rgba(16, 185, 129, 0.4);
    font-weight: 600;
    z-index: 1001;
}

.modal-backdrop[hidden] {
    display: none !important;
}

.analytics-body {
    font-family: "Inter", "Segoe UI", system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
    background: #f5f7fb;
    color: #1f2933;
    min-height: 100vh;
    padding: 0;
    margin: 0;
}

.analytics-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    padding: 20px 36px 12px;
    border-bottom: 1px solid #e4e7ec;
    background: #ffffff;
}

.analytics-header h1 {
    margin: 0;
    color: #0f172a;
    font-size: 1.0rem;
}

.analytics-header p {
    margin: 4px 0 0;
    color: #64748b;
}

.analytics-header nav a {
    color: #2563eb;
    text-decoration: none;
    font-weight: 500;
}

.analytics-container {
    padding: 28px 48px 60px;
    display: flex;
    flex-direction: column;
    gap: 28px;
}

.filters-card {
    background: #ffffff;
    border: 1px solid #e4e7ec;
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 10px 30px rgba(15, 23, 42, 0.08);
}

.filters-card h2 {
    margin-top: 0;
    color: #0f172a;
}

.filter-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px;
    margin-bottom: 16px;
}

.filter-grid label {
    display: flex;
    flex-direction: column;
    gap: 6px;
    font-size: 0.9rem;
    color: #475467;
}

.filter-grid input,
.filter-grid select {
    background: #f9fafb;
    border: 1px solid #d0d5dd;
    border-radius: 8px;
    color: #1f2933;
    padding: 10px;
    font-family: inherit;
}

.filter-grid select {
    min-height: 90px;
}

.filter-grid .full-width {
    grid-column: 1 / -1;
}

.filter-pair {
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 16px;
}

.filter-pair input[type="text"] {
    border-radius: 6px;
    padding: 8px 10px;
    border: 1px solid #d0d5dd;
    margin-bottom: 6px;
    background: #fff;
    font-size: 0.9rem;
}

.filter-actions {
    display: flex;
    gap: 12px;
}

.analytics-container button {
    background: #2563eb;
    border: 1px solid #1d4ed8;
    color: #ffffff;
    font-weight: 600;
    padding: 9px 18px;
    border-radius: 8px;
    cursor: pointer;
    transition: box-shadow 0.15s ease;
}

.analytics-container button:hover {
    box-shadow: 0 8px 20px rgba(37, 99, 235, 0.35);
}

.summary-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 16px;
}

.summary-card {
    background: #ffffff;
    border: 1px solid #e4e7ec;
    border-radius: 12px;
    padding: 18px;
    min-height: 120px;
    box-shadow: 0 6px 18px rgba(15, 23, 42, 0.05);
}

.summary-label {
    margin: 0 0 6px;
    font-size: 0.85rem;
    color: #64748b;
}

.summary-value {
    margin: 0;
    font-size: 2rem;
    color: #0f172a;
}

.summary-value.small {
    font-size: 1rem;
    word-break: break-word;
}

.summary-sub {
    margin: 8px 0 0;
    color: #10b981;
}

.comparison-card {
    border-color: #c7d2fe;
}

.analytics-module {
    background: #ffffff;
    border: 1px solid #e4e7ec;
    border-radius: 12px;
    padding: 18px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    box-shadow: 0 6px 18px rgba(15, 23, 42, 0.05);
}

.analytics-module header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.analytics-module h2 {
    margin: 0 0 4px;
    color: #0f172a;
}

.analytics-module p {
    margin: 0;
    color: #64748b;
}

.module-content.split {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 16px;
}

.table-wrapper,
.chart-wrapper {
    background: #f8fafc;
    border: 1px solid #e4e7ec;
    border-radius: 10px;
    padding: 12px;
    overflow-x: auto;
}

.table-wrapper.scrollable {
    max-height: 480px;
    overflow: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

table thead {
    background: #f1f5f9;
}

table th,
table td {
    padding: 8px 12px;
    border-bottom: 1px solid #e4e7ec;
    text-align: left;
}

.pivot-table thead th,
.pivot-table tbody td {
    white-space: nowrap;
}

.pivot-table thead th {
    position: sticky;
    top: 0;
    background: #f1f5f9;
}

.pivot-table tfoot td {
    font-weight: 600;
    background: #eef2ff;
}

table tbody tr:hover {
    background: #eff6ff;
}

.analytics-module.muted {
    border: 1px dashed #d0d5dd;
    color: #94a3b8;
    background: #fdfdfd;
}

#heatmap-module .heatmap-content {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.heatmap-legend {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 0.9rem;
    color: #475467;
}

.legend-scale {
    display: flex;
    gap: 4px;
}

.legend-swatch {
    width: 18px;
    height: 18px;
    border-radius: 4px;
    background: #e2e8f0;
}

.legend-swatch[data-level="0"] { background: #e2e8f0; }
.legend-swatch[data-level="1"] { background: #c6f6d5; }
.legend-swatch[data-level="2"] { background: #9ae6b4; }
.legend-swatch[data-level="3"] { background: #68d391; }
.legend-swatch[data-level="4"] { background: #38a169; }
.legend-swatch[data-level="5"] { background: #047857; }

.heatmap-container {
    overflow-x: auto;
}

.heatmap-grid {
    display: flex;
    flex-direction: column;
    gap: 10px;
    min-width: 640px;
}

.heatmap-months {
    display: grid;
    gap: 4px;
    font-size: 0.75rem;
    color: #475467;
    font-weight: 600;
    margin-left: 56px;
}

.heatmap-body {
    display: flex;
    gap: 12px;
}

.heatmap-weekday-labels {
    display: grid;
    grid-template-rows: repeat(7, 24px);
    gap: 4px;
    font-size: 0.8rem;
    color: #475467;
    text-align: right;
    min-width: 48px;
}

.heatmap-week-columns {
    display: grid;
    gap: 4px;
    grid-auto-flow: column;
}

.heatmap-week-column {
    display: grid;
    grid-template-rows: repeat(7, 24px);
    gap: 4px;
}

.heatmap-cell {
    width: 24px;
    height: 24px;
    border-radius: 6px;
    background: #e2e8f0;
    transition: transform 0.1s ease, box-shadow 0.1s ease;
}

.heatmap-cell.empty {
    opacity: 0.15;
}

.heatmap-cell[data-level="1"] { background: #c6f6d5; }
.heatmap-cell[data-level="2"] { background: #9ae6b4; }
.heatmap-cell[data-level="3"] { background: #68d391; }
.heatmap-cell[data-level="4"] { background: #38a169; }
.heatmap-cell[data-level="5"] { background: #047857; }

.heatmap-cell:hover {
    transform: scale(1.1);
    box-shadow: 0 4px 12px rgba(56, 161, 105, 0.4);
}

.heatmap-tooltip {
    position: fixed;
    background: rgba(15, 23, 42, 0.92);
    color: #f8fafc;
    padding: 6px 10px;
    border-radius: 6px;
    font-size: 0.8rem;
    pointer-events: none;
    z-index: 999;
    box-shadow: 0 6px 18px rgba(15, 23, 42, 0.4);
    white-space: nowrap;
}

.heatmap-placeholder {
    padding: 20px;
    text-align: center;
    color: #94a3b8;
}

.modal-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(15, 23, 42, 0.45);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    z-index: 1000;
}

.modal-dialog {
    background: #ffffff;
    border-radius: 16px;
    width: min(640px, 90vw);
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    border: 1px solid #e4e7ec;
    box-shadow: 0 20px 50px rgba(15, 23, 42, 0.25);
}

.modal-dialog header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding: 20px 24px 10px;
    border-bottom: 1px solid #e4e7ec;
}

.modal-dialog header h3 {
    margin: 0;
}

.modal-dialog header p {
    margin: 4px 0 0;
    color: #64748b;
}

#modal-close {
    border: none;
    background: transparent;
    font-size: 1.4rem;
    cursor: pointer;
    color: #475467;
}

.modal-body {
    padding: 16px 24px 24px;
    overflow-y: auto;
}

.analytics-footer {
    text-align: center;
    padding: 26px 48px 40px;
    border-top: 1px solid #e4e7ec;
    background: #ffffff;
}

h1 {
    text-align: center;
    color: #0f172a;
    text-shadow: none;
    margin-bottom: 30px;
    border-bottom: 1px solid #e2e8f0;
    padding-bottom: 10px;
}

/* Убираем task-grid, используем обертку */
.rows-wrapper {
    max-width: 1200px;
    margin: 20px auto;
}

.task-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 20px;
    margin-bottom: 20px;
}

.task-card {
    background-color: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    transition: box-shadow 0.3s ease;
}

.task-card h2 {
    margin-top: 0;
    margin-bottom: 15px;
    font-size: 1.1rem; 
    color: #0f172a;
    border-bottom: 1px solid #e2e8f0;
    padding-bottom: 5px;
}

.task-card button {
    width: 100%;
    padding: 10px 15px;
    font-size: 0.9rem;
    font-weight: 600;
    color: #ffffff;
    background-color: #4f46e5;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: inherit;
}

.task-card button:hover {
    background-color: #4338ca;
    transform: translateY(-1px);
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.task-card button:disabled {
    background-color: #94a3b8;
    color: #ffffff;
    cursor: not-allowed;
    opacity: 0.6;
}

.status {
    margin-top: 15px;
    font-size: 0.85rem;
    color: #64748b;
}
.status p {
    margin: 4px 0;
}
.status .last-stats {
    font-style: normal;
    color: #0f172a;
    font-weight: 500;
}

/* Статусы */
.task-card.status-success {
    border-left: 4px solid #10b981;
}
.task-card.status-failed {
    border-left: 4px solid #ef4444;
    box-shadow: 0 4px 6px rgba(239, 68, 68, 0.1);
}
.task-card.status-running {
    border-left: 4px solid #f59e0b;
    box-shadow: 0 4px 6px rgba(245, 158, 11, 0.1);
}

.task-card .last-status {
    font-weight: 600;
    text-transform: uppercase;
}
.task-card.status-success .last-status {
    color: #10b981;
}
.task-card.status-failed .last-status {
    color: #ef4444;
}
.task-card.status-running .last-status {
    color: #f59e0b;
}

/* Футер */
.footer {
    text-align: center;
    margin-top: 40px;
    padding-top: 20px;
    border-top: 1px solid #e2e8f0;
    font-size: 0.875rem;
    color: #64748b;
}
.footer a {
    color: #4f46e5;
    text-decoration: none;
    font-weight: 500;
}
.footer a:hover {
    text-decoration: underline;
    color: #4338ca;
}

/* Дашборды проблемных объектов */
.dashboard-table {
    width: 100%;
    border-collapse: collapse;
}

.dashboard-table th {
    background: #f8fafc;
    padding: 12px 16px;
    text-align: left;
    font-weight: 600;
    color: #475467;
    font-size: 0.875rem;
    border-bottom: 2px solid #e4e7ec;
}

.dashboard-table td {
    padding: 12px 16px;
    border-bottom: 1px solid #f1f5f9;
}

.dashboard-table tbody tr:hover {
    background: #f8fafc;
}

.dashboard-table a {
    color: #4f46e5;
    text-decoration: none;
    font-weight: 500;
}

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

.category-dashboard {
    margin-bottom: 32px;
}

.category-dashboard:last-child {
    margin-bottom: 0;
}

.category-dashboard h3 {
    margin: 0 0 16px;
    color: #0f172a;
    font-size: 1.125rem;
    font-weight: 600;
    padding-bottom: 8px;
    border-bottom: 2px solid #e4e7ec;
}

#dashboard-category-container,
#dashboard-problem-type-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(350px, 1fr));
    gap: 24px;
    padding: 20px;
}

@media (min-width: 1400px) {
    #dashboard-category-container,
    #dashboard-problem-type-container {
        grid-template-columns: repeat(3, 1fr);
    }
}