/* TZ Modal - A4 Document Style */

#modal-tz {
    z-index: 210; /* Вище за інші модалки */
}

#modal-tz .modal-box {
    background: #F9F7F2; /* Кремовий фон як у світлій темі */
    color: #333; /* Темний текст */
    width: 800px; /* Ширина, близька до А4 */
    max-width: 95vw;
    max-height: 95vh;
    padding: 30px;
    border-radius: 8px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.2);
    display: flex;
    flex-direction: column;
}

#modal-tz .modal-close {
    color: #666;
}

.tz-print-btn {
    position: absolute;
    top: 14px;
    right: 50px;
    background: none;
    border: none;
    color: #666;
    cursor: pointer;
    transition: color 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}
.tz-print-btn:hover {
    color: #000;
}

.tz-header {
    text-align: center;
    margin-bottom: 25px;
    border-bottom: 1px solid #000; /* Чорна лінія */
    padding-bottom: 15px;
}
.tz-header h2 {
    font-size: 1.5rem;
    font-weight: 700;
    color: #000 !important; /* Чорний текст */
    line-height: 1.3;
}
.tz-header span {
    display: block;
    font-size: 0.9rem;
    color: #000; /* Чорний текст */
    margin-top: 5px;
}

.tz-main-image {
    width: 100%;
    max-height: 300px;
    object-fit: contain;
    margin-bottom: 25px;
    border: 1px solid #000; /* Чорна рамка */
    border-radius: 4px;
}

.tz-section {
    margin-bottom: 12px;
    padding-bottom: 5px;
    border-bottom: none; /* Прибираємо зайву лінію */
}
.tz-section:last-of-type {
    border-bottom: none;
    margin-bottom: 0;
    padding-bottom: 0;
}
/* .tz-section-title стилізується інлайн в JS, але тут можна додати базові стилі */
/* .tz-section-title {
    color: #000;
} */
.tz-section-title span {
    font-size: 0.85rem;
    font-weight: normal;
    color: #777;
}

.tz-grid {
    display: grid;
    grid-template-columns: 1fr 1fr; /* Дві колонки для лейбла та значення */
    gap: 10px 20px;
}
.tz-label {
    font-weight: 400; /* Звичайний шрифт */
    color: #000; /* Чорний текст */
    font-size: 0.9rem;
}

/* Поля вводу в модалці ТЗ */
#modal-tz .form-input {
    width: 100%;
    padding: 6px 10px;
    border: 1px solid #000 !important; /* Чорна рамка */
    border-radius: 4px;
    font-family: inherit;
    font-size: 0.9rem;
    color: #000 !important; /* Чорний текст */
    background-color: #F9F7F2 !important; /* Бежевий/кремовий фон */
    outline: none;
    margin-top: 2px;
}

#modal-tz .form-input:focus {
    border-width: 2px !important; /* Трохи товстіша рамка при фокусі */
}
.tz-value input[type="checkbox"] {
    transform: scale(1.2);
    margin-left: 5px;
}
.tz-value input:focus,
.tz-value textarea:focus {
    border-color: #000; /* Чорна рамка при фокусі */
    box-shadow: none; /* Прибираємо тінь */
}

.tz-fasteners-text {
    font-size: 0.9rem;
    color: #444;
    line-height: 1.5;
}

/* Динамічні поля та кнопки */
.tz-add-row-btn {
    background: none;
    border: 1px dashed #000;
    color: #000;
    width: 100%;
    padding: 4px;
    margin-top: 8px;
    cursor: pointer;
    font-size: 1.1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}
.tz-add-row-btn:hover {
    background: rgba(0,0,0,0.05);
}
.tz-dynamic-row {
    display: flex;
    gap: 10px;
    margin-bottom: 5px;
    align-items: center;
}

.tz-actions {
    margin-top: 30px;
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

.tz-edit-icon {
    position: absolute;
    top: 20px;
    right: 60px;
    background: none;
    border: none;
    font-size: 1.4rem;
    color: #000; /* Чорний колір */
    cursor: pointer;
    transition: transform 0.2s;
    z-index: 5;
}
.tz-edit-icon:hover {
    transform: scale(1.2);
}

/* Перевизначення кольору тексту кнопок у модалці ТЗ */
#modal-tz .btn-primary,
#modal-tz .btn-ghost {
    color: #000 !important; /* Чорний текст для кнопок */
    border: 1px solid #000 !important; /* Чорна рамочка */
}

#modal-tz .btn-primary:hover {
    background: rgba(0,0,0,0.1) !important; /* Трохи темніший фон при наведенні */
}

@media (max-width: 600px) {
    #modal-tz .modal-box {
        padding: 20px;
    }
    .tz-grid {
        grid-template-columns: 1fr; /* На мобільних - одна колонка */
    }
    .tz-section-title {
        font-size: 1rem;
    }
    .tz-label, .tz-value {
        font-size: 0.85rem;
    }
}

/* Стилі для друку */
@media print {
    /* Ховаємо абсолютно все, крім модалки ТЗ */
    body > *:not(#modal-tz) {
        display: none !important;
    }
    
    #modal-tz {
        position: static !important;
        display: block !important;
        background: white !important;
    }

    #modal-tz .modal-overlay {
        display: none !important;
    }

    #modal-tz .modal-box {
        position: static !important;
        width: 100% !important;
        max-width: none !important;
        height: auto !important;
        max-height: none !important;
        margin: 0 !important;
        padding: 0 !important;
        border: none !important;
        box-shadow: none !important;
        background: white !important;
        overflow: visible !important;
    }
    
    /* Максимальна економія простору для друку */
    .tz-header-row {
        margin-bottom: 10px !important;
    }
    .tz-header-row img {
        width: 80px !important;
    }
    .tz-section {
        margin-bottom: 8px !important;
        padding-bottom: 2px !important;
    }
    .tz-section-title {
        font-size: 0.8rem !important;
    }
    .tz-label, .tz-value, #modal-tz .form-input, .tz-dynamic-row span {
        font-size: 0.75rem !important;
    }
    .tz-dynamic-row {
        margin-bottom: 2px !important;
    }
    #tz-form-container {
        gap: 5px !important;
    }

    /* Приховуємо сервісні кнопки: закрити, друк, зберегти/скасувати */
    .modal-close, .tz-print-btn, .tz-actions, .tz-edit-icon {
        display: none !important;
    }

    @page {
        margin: 1cm;
    }
}