/* ==================================================
   Inspection Templates
   Page CSS
================================================== */


/* ==================================================
   Page header
================================================== */

.page-intro {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 24px;
}

.page-intro h2 {
    margin: 0;
    font-size: 24px;
    line-height: 1.35;
    color: #1f2937;
}

.page-description {
    margin: 8px 0 0;
    color: #6b7280;
    font-size: 13px;
    line-height: 1.7;
}

.page-header-action {
    flex-shrink: 0;
}


.sidebar-section-title {
    margin: 18px 10px 6px;
    color: #7f8a9a;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.08em;
}


/* ==================================================
   Common buttons
================================================== */

.primary-button,
.secondary-button {
    display: inline-block;
    box-sizing: border-box;
    text-align: center;
    text-decoration: none;
    white-space: nowrap;
}

.primary-button {
    padding: 10px 17px;
    border: 0;
    border-radius: 8px;
    background: var(--primary);
    color: #fff;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
}

.primary-button:hover {
    opacity: 0.9;
}

.primary-button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.secondary-button {
    padding: 9px 14px;
    border: 1px solid #cfd6df;
    border-radius: 8px;
    background: #fff;
    color: #303945;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
}

.secondary-button:hover {
    background: #f7f8fa;
}

.secondary-button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.small-button {
    padding: 7px 11px;
    font-size: 12px;
}


.panel + .panel {
    margin-top: 18px;
}


/* ==================================================
   Section heading
================================================== */

.section-heading {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 20px;
    margin-bottom: 20px;
}

.section-heading h2 {
    margin: 5px 0 0;
    color: #1f2937;
    font-size: 20px;
    line-height: 1.4;
}

/* ==================================================
   Loading
================================================== */

.loading {
    margin: 20px 0;
    padding: 20px;
    text-align: center;
    color: #6b7280;
    font-size: 14px;
}


/* ==================================================
   Message
================================================== */

.message {
    margin: 0 0 20px;
    padding: 14px 16px;
    border-radius: 8px;
    font-size: 14px;
    line-height: 1.7;
    box-sizing: border-box;
}

.message.success {
    border: 1px solid #b7dfc5;
    background: #f0faf3;
    color: #1f6b3a;
}

.message.error {
    border: 1px solid #efb5b5;
    background: #fff4f4;
    color: #a12626;
}

.message.info {
    border: 1px solid #c7d7eb;
    background: #f4f8fc;
    color: #34506f;
}


/* ==================================================
   Table
================================================== */

.table-wrapper {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.data-table {
    width: 100%;
    min-width: 850px;
    border-collapse: collapse;
    font-size: 13px;
}

.data-table th {
    padding: 12px 14px;
    border-bottom: 1px solid #dfe4ea;
    background: #f7f8fa;
    color: #5f6875;
    font-size: 11px;
    font-weight: 700;
    text-align: left;
    white-space: nowrap;
}

.data-table td {
    padding: 14px;
    border-bottom: 1px solid #edf0f3;
    color: #303945;
    vertical-align: middle;
}

.data-table tbody tr:hover {
    background: #fafbfc;
}

.data-table tbody tr:last-child td {
    border-bottom: 0;
}


/* ==================================================
   Empty state
================================================== */

.empty-state {
    padding: 40px 20px !important;
    color: #8a939e !important;
    text-align: center;
}


/* ==================================================
   Status badge
================================================== */

.status-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 48px;
    padding: 4px 9px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 700;
    line-height: 1.4;
}

.status-badge.active {
    background: #e9f7ef;
    color: #176b3a;
}

.status-badge.inactive {
    background: #f0f1f3;
    color: #6b7280;
}


/* ==================================================
   Form panel
================================================== */

.form-panel {
    margin-top: 24px;
}

.form-section {
    margin-top: 28px;
    padding-top: 28px;
    border-top: 1px solid #e7eaee;
}

.form-section:first-of-type {
    margin-top: 0;
    padding-top: 0;
    border-top: 0;
}

.form-section-heading {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 20px;
    margin-bottom: 18px;
}

.form-section-heading h3 {
    margin: 0;
    color: #27313d;
    font-size: 16px;
    line-height: 1.5;
}

.form-section-heading p {
    margin: 5px 0 0;
    color: #7a838e;
    font-size: 13px;
    line-height: 1.6;
}


/* ==================================================
   Form grid
================================================== */

.form-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 18px;
}

.form-group {
    min-width: 0;
}

.form-group-wide {
    grid-column: 1 / -1;
}

.form-group label {
    display: block;
    margin-bottom: 7px;
    color: #374151;
    font-size: 13px;
    font-weight: 600;
}

.required {
    color: #c43d3d;
    margin-left: 3px;
}


/* ==================================================
   Form controls
================================================== */

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    box-sizing: border-box;
    border: 1px solid #cfd6df;
    border-radius: 8px;
    background: #fff;
    color: #27313d;
    font-family: inherit;
    font-size: 14px;
    line-height: 1.5;
    outline: none;
    transition:
        border-color 0.15s ease,
        box-shadow 0.15s ease;
}

.form-group input,
.form-group select {
    min-height: 42px;
    padding: 9px 11px;
}

.form-group textarea {
    min-height: 100px;
    padding: 10px 11px;
    resize: vertical;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    border-color: #7b8795;
    box-shadow: 0 0 0 3px rgba(107, 114, 128, 0.1);
}

.form-group input::placeholder,
.form-group textarea::placeholder {
    color: #a0a7b0;
}


/* ==================================================
   Items
================================================== */

.items-container {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.template-item-row {
    padding: 18px;
    border: 1px solid #dfe4ea;
    border-radius: 10px;
    background: #fafbfc;
}

.item-row-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 16px;
}

.item-row-header strong {
    color: #303945;
    font-size: 14px;
}


/* ==================================================
   Item form
================================================== */

.template-item-row .form-grid {
    grid-template-columns:
        minmax(0, 2fr)
        minmax(110px, 1fr)
        minmax(110px, 1fr);
}

.template-item-row .form-group:nth-child(4) {
    grid-column: 1 / 3;
}

.template-item-row .checkbox-group {
    grid-column: 3;
}


/* ==================================================
   Checkbox
================================================== */

.checkbox-group {
    display: flex;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
    min-height: 42px;
}

.checkbox-group label {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    margin: 0;
    color: #4b5563;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
}

.checkbox-group input[type="checkbox"] {
    width: 16px;
    height: 16px;
    margin: 0;
    accent-color: var(--primary);
}


/* ==================================================
   Disabled item editor
================================================== */

.template-item-row input:disabled,
.template-item-row select:disabled,
.template-item-row textarea:disabled {
    background: #f1f3f5;
    color: #6b7280;
    cursor: not-allowed;
}

.template-item-row button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}


/* ==================================================
   Form actions
================================================== */

.form-actions {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 10px;
    margin-top: 30px;
    padding-top: 22px;
    border-top: 1px solid #e7eaee;
}


/* ==================================================
   Hidden
================================================== */

[hidden] {
    display: none !important;
}


/* ==================================================
   Responsive
================================================== */

@media (max-width: 900px) {

    .page-intro {
        align-items: flex-start;
        flex-direction: column;
    }

    .page-header-action {
        width: 100%;
    }

    .page-header-action .primary-button {
        width: 100%;
    }

    .form-grid {
        grid-template-columns: 1fr;
    }

    .form-group-wide {
        grid-column: auto;
    }

    .template-item-row .form-grid {
        grid-template-columns: 1fr;
    }

    .template-item-row .form-group:nth-child(4) {
        grid-column: auto;
    }

    .template-item-row .checkbox-group {
        grid-column: auto;
    }

}


@media (max-width: 700px) {

    .content {
        padding: 24px 16px;
    }

    .panel {
        padding: 18px;
    }

    .page-intro h2 {
        font-size: 23px;
    }

    .section-heading {
        align-items: flex-start;
        flex-direction: column;
    }

    .form-section-heading {
        align-items: flex-start;
        flex-direction: column;
    }

    .form-section-heading .secondary-button {
        width: 100%;
    }

    .template-item-row {
        padding: 14px;
    }

    .item-row-header {
        align-items: flex-start;
    }

    .form-actions {
        flex-direction: column-reverse;
    }

    .form-actions .primary-button,
    .form-actions .secondary-button {
        width: 100%;
    }

}
