/* 
 * Общие стили для сервиса чеклистов.
 * Стараемся сделать интерфейс аккуратным и приятным без перегрузки.
 */

*,
*::before,
*::after {
    box-sizing: border-box;
}

body {
    margin: 0;
    padding: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, "Fira Sans", "Droid Sans", "Helvetica Neue", sans-serif;
    background: #f4f5f7;
    color: #222;
}

.container {
    max-width: 1100px;
    margin: 0 auto;
    padding: 20px;
}

.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.header h1 {
    margin: 0;
    font-size: 26px;
}

.subtitle {
    margin: 4px 0 0;
    color: #666;
    font-size: 14px;
}

.section {
    background: #ffffff;
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 20px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
}

.section h2 {
    margin-top: 0;
    font-size: 20px;
}

.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    font-weight: 600;
    margin-bottom: 6px;
}

.form-group input[type="text"],
.form-group textarea,
.form-group select {
    width: 100%;
    padding: 8px 10px;
    border-radius: 4px;
    border: 1px solid #ccc;
    font-size: 14px;
}

.form-group textarea {
    resize: vertical;
}

.form-actions {
    margin-top: 16px;
}

.btn {
    display: inline-block;
    padding: 8px 14px;
    border-radius: 4px;
    border: none;
    text-decoration: none;
    cursor: pointer;
    font-size: 14px;
    line-height: 1.2;
    transition: background-color 0.2s ease, box-shadow 0.2s ease, transform 0.1s ease;
}

.btn-primary {
    background-color: #007bff;
    color: #ffffff;
}

.btn-primary:hover {
    background-color: #0069d9;
    box-shadow: 0 2px 6px rgba(0, 123, 255, 0.4);
}

.btn-secondary {
    background-color: #6c757d;
    color: #ffffff;
}

.btn-secondary:hover {
    background-color: #5a6268;
}

.btn-small {
    font-size: 12px;
    padding: 4px 8px;
    background-color: #e2e6ea;
    color: #333;
}

.btn-small:hover {
    background-color: #d6d8db;
}

.actions {
    margin-bottom: 10px;
}

.table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

.table th,
.table td {
    padding: 8px 10px;
    border-bottom: 1px solid #e0e0e0;
    text-align: left;
}

.table th {
    background-color: #f8f9fa;
    font-weight: 600;
}

.alert {
    padding: 10px 12px;
    border-radius: 4px;
    margin-bottom: 16px;
}

.alert-error {
    background-color: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

.help-text {
    margin-top: 0;
    color: #666;
    font-size: 13px;
}

.status-message {
    margin-top: 12px;
    padding: 8px 10px;
    border-radius: 4px;
    font-size: 13px;
}

.status-message.success {
    background-color: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.status-message.error {
    background-color: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

/* --- Редактор шаблонов --- */

.items-root {
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    padding: 10px;
    background-color: #fafbfc;
}

.items-list {
    list-style: none;
    padding-left: 18px;
    margin: 0;
}

.items-list > .item + .item {
    margin-top: 8px;
}

.item-content {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    padding: 6px 8px;
    background-color: #ffffff;
    border-radius: 4px;
    border: 1px solid #dee2e6;
}

.item-title {
    flex: 1 1 180px;
}

.item-description {
    flex: 2 1 250px;
}

.item-actions {
    display: flex;
    align-items: center;
    gap: 4px;
}

.drag-handle {
    cursor: grab;
    font-size: 16px;
    padding: 0 6px 0 0;
    color: #888;
    user-select: none;
}

.item.dragging .item-content {
    opacity: 0.7;
    border-style: dashed;
}

.item-placeholder {
    margin: 4px 0;
    padding: 12px 8px;
    border-radius: 4px;
    border: 2px dashed #b0b5bd;
    background-color: #f8f9fa;
}

/* --- Страница работы: чеклист --- */

.job-notes {
    margin-bottom: 16px;
    padding: 10px 12px;
    border-radius: 4px;
    background-color: #fff3cd;
    border: 1px solid #ffeeba;
}

.job-items-list-root {
    list-style: none;
    padding-left: 8px;
    margin: 0;
}

.job-items-list-child {
    list-style: none;
    margin-top: 4px;
    margin-left: 26px;               /* более заметный визуальный отступ для вложенных подпунктов */
    padding-left: 14px;
    border-left: 1px dashed #e0e0e0;  /* тонкая вертикальная линия, подчёркивающая иерархию */
}

.job-item {
    margin: 4px 0;
}

.job-item-content {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.job-item-label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
}

.job-item-label-parent {
    cursor: default; /* родительский пункт не кликается как чекбокс */
}

.job-item-checkbox {
    width: 18px;
    height: 18px;
    cursor: pointer;
    /* Делаем кастомный чекбокс с плавной анимацией "хлопушки" */
    -webkit-appearance: none;
    appearance: none;
    border-radius: 4px;
    border: 2px solid #b0b5bd;
    background-color: #ffffff;
    position: relative;
    transform-origin: center;
    transition:
        background-color 0.18s ease-out,
        border-color 0.18s ease-out,
        box-shadow 0.22s ease-out,
        transform 0.15s ease-out;
}

.job-item-checkbox:checked {
    background-color: #28a745;
    border-color: #28a745;
    box-shadow: 0 0 0 4px rgba(40, 167, 69, 0.25);
    transform: scale(1.05);
    animation: checkbox-pop 0.22s ease-out;
}

.job-item-checkbox::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 9px;
    height: 5px;
    border: 2px solid #ffffff;
    border-top: none;
    border-right: none;
    transform: translate(-50%, -55%) rotate(-45deg) scale(0.6);
    opacity: 0;
    transition:
        opacity 0.18s ease-out,
        transform 0.18s ease-out;
}

.job-item-checkbox:checked::after {
    opacity: 1;
    transform: translate(-50%, -55%) rotate(-45deg) scale(1);
}

.job-item-parent-checkbox {
    width: 16px;
    height: 16px;
    cursor: default;
    pointer-events: none;    /* полностью отключаем возможность кликнуть по чекбоксу родителя */
    opacity: 0.6;           /* визуально "серый" чекбокс */
    -webkit-appearance: none;
    appearance: none;
    border-radius: 4px;
    border: 2px solid #b0b5bd;
    background-color: #f1f3f5;
    position: relative;
}

.job-item-parent-checkbox::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 8px;
    height: 4px;
    border: 2px solid #6c757d;
    border-top: none;
    border-right: none;
    transform: translate(-50%, -55%) rotate(-45deg) scale(0.6);
    opacity: 0;
    transition:
        opacity 0.18s ease-out,
        transform 0.18s ease-out;
}

.job-item-parent-checkbox:checked::after {
    opacity: 1;
    transform: translate(-50%, -55%) rotate(-45deg) scale(1);
}

/* Анимация "хлопушки" при выборе чекбокса */
@keyframes checkbox-pop {
    0% {
        transform: scale(0.9);
        box-shadow: 0 0 0 0 rgba(40, 167, 69, 0.0);
    }
    60% {
        transform: scale(1.12);
        box-shadow: 0 0 0 6px rgba(40, 167, 69, 0.25);
    }
    100% {
        transform: scale(1.0);
        box-shadow: 0 0 0 4px rgba(40, 167, 69, 0.18);
    }
}

.job-item-title {
    font-weight: 500;
}

.job-item-title-parent {
    font-weight: 600;
}

.job-item-description {
    font-size: 13px;
    color: #666;
}

.job-item-done .job-item-title,
.job-item-done .job-item-description {
    text-decoration: line-through;
    opacity: 0.5;
    transition: opacity 0.2s ease, text-decoration-color 0.2s ease;
}

.job-item-parent-done .job-item-title-parent {
    color: #28a745;
}

/* --- Прогресс-бар --- */

.progress-bar {
    position: relative;
    width: 100%;
    height: 14px;
    border-radius: 7px;
    background-color: #e9ecef;
    overflow: hidden;
    margin-top: 6px;
}

.progress-bar-inner {
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    background: linear-gradient(90deg, #28a745, #8bc34a);
    border-radius: 7px;
    transition: width 0.25s ease-out;
}

