/* regulations.css - 내규 관리 공통 및 페이지별 스타일 통합 */

/* 분류 관리 모달(z-index 10040)보다 SweetAlert2를 위에 표시 */
body .swal2-container {
    z-index: 10060 !important;
}

.regulations-container,
.form-container,
.view-container {
    margin-top: 120px !important;
    margin-bottom: 60px !important;
    padding: 0 !important;
    box-sizing: border-box;
}

.intranet-page-inner {
    width: 100%;
    max-width: min(76rem, calc(100% - 2rem));
    margin-left: auto;
    margin-right: auto;
    padding: 0 clamp(16px, 3vw, 40px);
    box-sizing: border-box;
}

/* [공통] 헤더 영역 */
.regulations-header,
.form-header,
.view-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 25px;
    padding-bottom: 15px;
    border-bottom: none !important;
}

.regulations-header h1,
.form-header h1 {
    font-size: 1.5rem;
    color: #333;
    margin: 0;
}

/* [공통] 카테고리 탭 및 배지 */
.regulations-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 20px;
}

.regulations-toolbar .category-tabs {
    flex: 1 1 auto;
    min-width: 0;
}

.regulations-toolbar #btn-manage-categories {
    flex-shrink: 0;
}

.category-tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 0;
    flex-wrap: wrap;
}

.category-tab {
    background: white;
    border: 1px solid #ddd;
    padding: 8px 18px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9rem;
    color: #666;
    transition: all 0.2s;
}

.category-tab.active {
    background: #ff6a00;
    border-color: #ff6a00;
    color: white;
}

.category-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 3px;
    font-size: 0.7rem;
    font-weight: 500;
    margin-right: 8px;
}
.category-badge.cat-tone-0 { background: #e3f2fd; color: #1976D2; }
.category-badge.cat-tone-1 { background: #f3e5f5; color: #7B1FA2; }
.category-badge.cat-tone-2 { background: #e8f5e9; color: #388E3C; }

/* [목록] 테이블 */
.regulations-list {
    width: 100%;
    border-top: 2px solid #333;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    box-sizing: border-box;
}

.regulations-table {
    width: 100% !important;
    min-width: 520px;
    table-layout: fixed;
    border-collapse: collapse;
}

.regulations-table th.col-no,
.regulations-table td:nth-child(1) {
    width: 44px;
    min-width: 44px;
    max-width: 52px;
    padding-left: 6px;
    padding-right: 6px;
    box-sizing: border-box;
}

.regulations-table th.col-category,
.regulations-table td:nth-child(2) {
    width: 112px;
    min-width: 112px;
}

.regulations-table th.col-date,
.regulations-table td:nth-child(4) {
    width: 104px;
    min-width: 104px;
    white-space: nowrap;
}

.regulations-table th {
    background: #f8f9fa;
    padding: 12px;
    border-bottom: 1px solid #ddd;
    font-size: 0.9rem;
    color: #333;
    text-align: center;
}

.regulations-table th.col-title {
    width: auto;
    text-align: left;
    padding-left: 15px;
}

.regulations-table td {
    padding: 15px;
    font-size: 0.95rem;
    border-bottom: 1px solid #eee;
    text-align: center;
}

.regulations-table tbody tr {
    cursor: pointer;
    transition: background-color 0.2s;
}

.regulations-table td.col-title {
    text-align: left;
    padding-left: 15px;
    color: #333;
    text-decoration: none !important;
    transition: none;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.regulations-table tbody tr:hover td.col-title {
    color: #333 !important;
    text-decoration: none !important;
}

.regulations-table td .category-badge {
    margin-right: 0;
}

.regulations-table tbody tr:hover {
    background: #fafafa;
}

.view-actions {
    display: flex;
    justify-content: center;
    gap: 12px;
    margin-top: 50px;
    padding-top: 30px;
    border-top: 1px solid #eee;
}

.view-actions .btn-list,
.view-actions .btn-edit,
.view-actions .btn-delete {
    font-size: 0.95rem !important;
    font-weight: 500 !important;
    line-height: 1.2;
    height: 42px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
}

/* 목록 버튼 */
.btn-list {
    background: #6c757d !important;
    color: white !important;
    border: none;
    padding: 10px 25px;
    border-radius: 6px;
    font-weight: 500;
    transition: background 0.2s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-decoration: none !important;
}

.btn-list:hover {
    background: #5a6268 !important;
    text-decoration: none !important;
}

/* 수정 버튼 */
.btn-edit {
    background: #ff6a00 !important;
    color: white !important;
    border: none;
    padding: 10px 25px;
    border-radius: 6px;
    font-weight: 500;
    transition: background 0.2s;
}
.btn-edit:hover { background: #e55d00 !important; }

/* 삭제 버튼 */
.btn-delete {
    background: #e74c3c !important;
    color: white !important;
    border: none;
    padding: 10px 25px;
    border-radius: 6px;
    font-weight: 500;
    transition: background 0.2s;
}
.btn-delete:hover { background: #c0392b !important; }

.file-text-badge {
    font-size: 11px;
    background: #f0f0f0;
    color: #666;
    padding: 2px 5px;
    border-radius: 3px;
    margin-left: 5px;
    vertical-align: middle;
}

.pagination-container {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin-top: 30px;
}

.page-btn {
    border: 1px solid #ddd;
    background: white;
    padding: 6px 12px;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s;
}

.page-btn.active {
    background: #ff6a00;
    color: white;
    border-color: #ff6a00;
    font-weight: bold;
}

.page-btn:hover:not(.active) {
    background: #f5f5f5;
}

/* [폼] 등록 및 수정 */
.form-content {
    background: white;
    padding: 40px 0;
    border-radius: 0;
}
.form-group { margin-bottom: 25px; }
.form-group label { display: block; font-weight: 600; margin-bottom: 8px; color: #333; font-size: 0.95rem; }
.form-group .form-group-label-like {
    display: block;
    font-weight: 600;
    margin-bottom: 8px;
    color: #333;
    font-size: 0.95rem;
}
.form-hint.trip-report-image-hint {
    font-size: 0.88rem;
    color: #555;
    line-height: 1.55;
    margin: 0 0 10px 0;
    font-weight: 400;
}
label.trip-report-files-label {
    cursor: pointer;
}
label.trip-report-files-label .trip-report-files-label-title {
    display: block;
    margin-bottom: 6px;
}
label.trip-report-files-label .trip-report-image-hint {
    display: block;
    margin-bottom: 10px;
}
.form-hint.trip-report-link-hint {
    font-size: 0.88rem;
    color: #555;
    line-height: 1.55;
    margin: 0 0 8px 0;
    font-weight: 400;
}
.form-hint.trip-report-link-hint code {
    font-size: 0.85em;
    background: #f0f0f0;
    padding: 1px 5px;
    border-radius: 3px;
}
.form-group label.trip-report-sublabel {
    display: block;
    margin-top: 12px;
    margin-bottom: 6px;
    font-weight: 600;
    color: #333;
    font-size: 0.92rem;
}
a.trip-report-external-link {
    color: #0d6efd;
    word-break: break-all;
    text-decoration: underline;
}
a.trip-report-external-link:hover {
    color: #0a58ca;
}
.form-group.trip-report-links-form-group {
    margin-bottom: 1.25rem;
}
details.trip-report-links-details {
    border: 1px solid #dee2e6;
    border-radius: 8px;
    background: #fff;
    overflow: hidden;
}
summary.trip-report-links-summary {
    list-style: none;
    cursor: pointer;
    padding: 12px 14px;
    font-weight: 600;
    color: #333;
    font-size: 0.95rem;
    background: #f4f6f8;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    user-select: none;
}
summary.trip-report-links-summary::-webkit-details-marker {
    display: none;
}
summary.trip-report-links-summary::marker {
    content: '';
}
.trip-report-links-summary-title .optional-label {
    font-weight: 400;
    color: #777;
    font-size: 0.88rem;
}
.trip-report-links-summary-chevron {
    flex-shrink: 0;
    font-size: 0.7rem;
    line-height: 1;
    color: #555;
}
.trip-report-links-summary-chevron::before {
    content: '\25BC';
}
details.trip-report-links-details[open] .trip-report-links-summary-chevron::before {
    content: '\25B2';
}
.trip-report-links-details-inner {
    padding: 12px 14px 14px;
    border-top: 1px solid #e9ecef;
    background: #fff;
}
.trip-report-link-blocks {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}
.trip-report-link-block {
    padding: 0.75rem 0.85rem;
    border: 1px solid #dee2e6;
    border-radius: 6px;
    background: #fafafa;
}
.trip-report-link-block-label {
    font-size: 0.88rem;
    font-weight: 600;
    color: #444;
    margin-bottom: 0.45rem;
}
ul.trip-report-link-list {
    list-style: none;
    margin: 0;
    padding: 0;
}
ul.trip-report-link-list li {
    margin: 0.4rem 0;
}
ul.trip-report-link-list li a {
    word-break: break-all;
}

/* 출장보고서 상세: 외부 링크 OG 미리보기 카드 */
ul.trip-report-link-list.trip-report-link-list--previews li {
    margin: 0 0 14px 0;
}
ul.trip-report-link-list.trip-report-link-list--previews li:last-child {
    margin-bottom: 0;
}
.trip-report-link-preview-item {
    list-style: none;
}
.trip-report-link-preview {
    max-width: 420px;
}
.trip-report-link-preview--loading .trip-report-link-preview-skeleton {
    height: 96px;
    border-radius: 10px;
    background: linear-gradient(90deg, #ececec 25%, #f5f5f5 50%, #ececec 75%);
    background-size: 200% 100%;
    animation: trip-report-link-skel 1.1s ease-in-out infinite;
}
@keyframes trip-report-link-skel {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}
a.trip-report-link-preview-card {
    display: block;
    text-decoration: none;
    color: inherit;
    border: 1px solid #dee2e6;
    border-radius: 10px;
    overflow: hidden;
    background: #fff;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
    transition: box-shadow 0.15s ease, border-color 0.15s ease;
}
a.trip-report-link-preview-card:hover {
    border-color: #c5ccd4;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.08);
}
.trip-report-link-preview-img-wrap {
    width: 100%;
    aspect-ratio: 1.85 / 1;
    background: #e9ecef;
    overflow: hidden;
}
.trip-report-link-preview-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    vertical-align: middle;
}
.trip-report-link-preview-body {
    padding: 12px 14px 14px;
}
.trip-report-link-preview-title {
    font-weight: 700;
    font-size: 0.98rem;
    line-height: 1.35;
    color: #1a1a1a;
    margin: 0 0 6px 0;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.trip-report-link-preview-desc {
    font-size: 0.86rem;
    line-height: 1.45;
    color: #5c5c5c;
    margin: 0 0 8px 0;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.trip-report-link-preview-site {
    font-size: 0.82rem;
    color: #0d6efd;
    text-decoration: underline;
    word-break: break-all;
}
.trip-report-link-preview--fallback {
    max-width: none;
}

.form-group label .optional-label {
    font-weight: 400;
    color: #777;
    font-size: 0.88rem;
}
.trip-report-body-text {
    white-space: pre-wrap;
    margin-bottom: 1.25rem;
    line-height: 1.65;
    color: #333;
}
.form-group label .required { color: #e74c3c; }
.form-group input[type="text"],
.form-group input[type="url"],
.form-group textarea,
.form-group select {
    width: 100%;
    padding: 12px 15px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 0.95rem;
    box-sizing: border-box;
}
.form-group textarea { min-height: 300px; resize: vertical; }
.current-file { display: flex; align-items: center; gap: 10px; margin-top: 10px; padding: 10px 15px; background: #f5f5f5; border-radius: 6px; font-size: 0.9rem; }

/* [상세] 보기 페이지 스타일 */
.view-content { background: white; border-top: 2px solid #333; }
.view-info-table { width: 100%; border-collapse: collapse; }
.view-info-table td { padding: 12px 15px; border-bottom: 1px solid #eee; font-size: 0.9rem; }
.view-info-table .label { background: #f8f9fa; width: 100px; font-weight: 600; color: #333; text-align: center; }
.view-body { padding: 30px 20px; min-height: 300px; white-space: pre-wrap; line-height: 1.8; font-size: 0.95rem; color: #333; }

/* [공통] 버튼 */
.btn-primary, .btn-submit {
    background: #ff6a00; color: white; border: none; padding: 10px 25px; border-radius: 6px; font-weight: 600; cursor: pointer;
}
.btn-secondary, .btn-cancel {
    background: #6c757d; color: white; border: none; padding: 10px 25px; border-radius: 6px; cursor: pointer;
}
.form-actions, .view-actions {
    display: flex; justify-content: center; gap: 15px; margin-top: 40px; padding-top: 30px; border-top: 1px solid #eee;
}

.btn-outline {
    background: white;
    color: #c0392b;
    border: 1px solid #c0392b;
    padding: 8px 14px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.85rem;
}
.btn-outline:hover {
    background: #fdecea;
}

/* 분류 관리 모달 */
.category-modal-overlay[hidden] {
    display: none !important;
}

.category-modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 10040;
    background: rgba(0, 0, 0, 0.45);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    box-sizing: border-box;
}

.category-modal {
    background: #fff;
    border-radius: 10px;
    max-width: 640px;
    width: 100%;
    max-height: min(90vh, 720px);
    display: flex;
    flex-direction: column;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.18);
}

.category-modal-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid #eee;
}

.category-modal-head h2 {
    margin: 0;
    font-size: 1.15rem;
    color: #333;
}

.category-modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    line-height: 1;
    cursor: pointer;
    color: #666;
    padding: 4px 8px;
}

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

.category-add-form {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
    margin-bottom: 16px;
}

.category-add-form input[type="text"] {
    flex: 1 1 160px;
    min-width: 0;
    padding: 10px 12px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 0.9rem;
    box-sizing: border-box;
}

.category-add-form input[type="number"] {
    width: 88px;
    padding: 10px 12px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 0.9rem;
    box-sizing: border-box;
}

.category-manage-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.category-manage-row {
    display: grid;
    grid-template-columns: 1fr 72px auto auto;
    gap: 8px;
    align-items: center;
    padding: 10px 12px;
    background: #f8f9fa;
    border-radius: 8px;
    font-size: 0.88rem;
}

.category-manage-row .cat-name-input {
    min-width: 0;
    padding: 8px 10px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 0.88rem;
    box-sizing: border-box;
}

.category-manage-row .cat-order-input {
    width: 100%;
    padding: 8px 6px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 0.88rem;
    box-sizing: border-box;
}

.category-manage-row .cat-active-label {
    display: flex;
    align-items: center;
    gap: 4px;
    white-space: nowrap;
    font-size: 0.82rem;
    color: #555;
}

.category-manage-row .btn-cat-del {
    padding: 8px 12px;
    font-size: 0.82rem;
    border-radius: 6px;
}

.category-modal-actions {
    display: flex;
    justify-content: flex-end;
    margin-top: 14px;
}

.category-manage-loading,
.category-manage-empty,
.category-manage-error {
    margin: 0;
    font-size: 0.9rem;
    color: #666;
}

/* 출장보고서 목록 (분류 없음: 번호–제목–등록일) */
.trip-reports-header-single {
    margin-bottom: 18px;
}

.regulations-table.trip-reports-table-no-category {
    min-width: 360px;
}

.regulations-table.trip-reports-table-no-category th:nth-child(2),
.regulations-table.trip-reports-table-no-category td:nth-child(2) {
    width: auto !important;
    min-width: 0 !important;
    max-width: none !important;
}

.regulations-table.trip-reports-table-no-category td:nth-child(2) {
    text-align: center !important;
    padding-left: 12px;
    padding-right: 12px;
}

.regulations-table.trip-reports-table-no-category th.col-title {
    text-align: center !important;
    padding-left: 12px;
    padding-right: 12px;
}

.regulations-table.trip-reports-table-no-category td.col-title {
    text-align: center !important;
    padding-left: 12px;
    padding-right: 12px;
}

.regulations-table.trip-reports-table-no-category th.col-date,
.regulations-table.trip-reports-table-no-category td:nth-child(3) {
    width: 104px;
    min-width: 104px;
    white-space: nowrap;
}

/* 출장보고서 상세: 본문 아래에 이미지로 표시 */
.trip-report-document-images {
    margin-top: 28px;
    margin-left: 0;
    margin-right: 0;
}

.trip-report-document-image {
    width: 96%;
    max-width: 1300px;
    height: auto;
    margin: 0 auto 20px;
    display: block;
    border-radius: 8px;
}

.trip-report-legacy-file-note {
    font-size: 0.9rem;
    color: #666;
    margin-top: 20px;
    line-height: 1.5;
}

@media (max-width: 768px) {
    .trip-report-document-images {
        margin-top: 20px;
    }

    .trip-report-document-image {
        width: 100%;
        border-radius: 4px;
    }
}

/* [반응형] 모바일 */
@media (max-width: 768px) {
    .regulations-container, .form-container, .view-container {
        padding: 0 !important;
        margin-top: 100px !important;
    }
    .intranet-page-inner {
        padding-left: 15px !important;
        padding-right: 15px !important;
    }
    .regulations-header { flex-direction: column; align-items: flex-start; gap: 10px; }
    .regulations-table th.col-no { width: 40px; }
    .regulations-table th.col-category { width: 60px; }
    .regulations-table th.col-date { width: 80px; }
    .regulations-table.trip-reports-table-no-category th.col-date,
    .regulations-table.trip-reports-table-no-category td:nth-child(3) { width: 80px; min-width: 80px; }
    .form-actions, .view-actions { flex-direction: column; }
    .btn-submit, .btn-cancel, .btn-edit, .btn-delete { width: 100%; }
    .category-manage-row {
        grid-template-columns: 1fr;
    }
    .category-manage-row .cat-active-label {
        justify-content: flex-start;
    }
}