/* TM Management Styles */

/* Main Container and Layout */
.tm-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 1rem 1rem 0.5rem 1rem;  /* 상하 패딩 축소: 2rem -> 1rem(top), 0.5rem(bottom) */
    height: 100vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;  /* 전체 페이지 스크롤 방지 */
}

.tm-header {
    background: linear-gradient(135deg, #fd7e14 0%, #ffc107 100%);
    color: white;
    padding: 2rem;
    border-radius: 0.5rem;
    margin-bottom: 2rem;
}

/* 2026-05-19: layout 을 grid 로 변경 — terminology / RAG 와 동일 패턴.
   - grid 350px 1fr + gap 2rem
   - sidebar/main 모두 전체 border + border-radius
   - max-height 제거 — tm 의 panel-header 가 *2 줄* (필터 dropdown row 추가) 라 80px 더 큼.
     terminology budget (300px outer) 안에 fit 안 됨 → workspace 의 max-height 강제 시 하단 spillover.
     content adaptive + page body scroll 로 변경. inner scroll 은 #tmListContainer 만. */
.tm-workspace {
    display: grid;
    grid-template-columns: 350px 1fr;
    gap: 2rem;
    min-height: 600px;
    margin-bottom: 2rem;
}

.sidebar-panel {
    background: #fff;
    border: 1px solid #dee2e6;
    border-radius: 0.5rem;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    flex-shrink: 0;
}

.main-panel {
    background: white;
    border: 1px solid #dee2e6;
    border-radius: 0.5rem;
    display: flex;
    flex-direction: column;
    min-width: 0;
    /* 2026-05-19: overflow:hidden 제거 — terminology 와 동일 패턴.
       inner scroll 은 #tmListContainer 만 받음 (다중 scrollbar 방지). */
}

.panel-header {
    flex-shrink: 0;  /* 헤더 높이 고정 */
    background: #f8f9fa;
    padding: 1rem;
    border-bottom: 1px solid #dee2e6;
    font-weight: 600;
}

.panel-body {
    flex: 1;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    min-height: 0;
    /* 2026-05-19: overflow:hidden 제거 — terminology 와 동일. inner scroll 은 #tmListContainer 만. */
}

/* Sidebar Section Styles */
.sidebar-section {
    border-bottom: 1px solid #e9ecef;
}

.sidebar-section-header {
    padding: 0.75rem 1rem;
    background: #f8f9fa;
    border-bottom: 1px solid #e9ecef;
    font-weight: 600;
    font-size: 0.9rem;
    color: #495057;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.sidebar-section-content {
    padding: 1rem;
    display: none;
    max-height: 400px;
    overflow-y: auto;
}

.sidebar-section.active .sidebar-section-content {
    display: block;
}

.sidebar-section.active .sidebar-section-header i:last-child {
    transform: rotate(90deg);
}

.sidebar-section-header i:last-child {
    transition: transform 0.2s;
}

/* TM Build Options */
.build-option {
    padding: 0.75rem;
    background: #f8f9fa;
    border-radius: 0.375rem;
    border: 1px solid #e9ecef;
}

.build-option h6 {
    font-size: 0.875rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.file-upload-wrapper {
    position: relative;
}

.file-upload-wrapper input[type="file"] {
    font-size: 0.875rem;
}

.build-option button:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* TM Item Styles */
.tm-item {
    background: #f8f9fa;
    padding: 0.5rem 0.75rem;  /* 패딩 줄임: 1rem -> 0.5rem 0.75rem */
    border-radius: 0.375rem;
    margin-bottom: 0.5rem;  /* 아이템 간 간격 줄임: 0.75rem -> 0.5rem */
    border: 1px solid #dee2e6;
    transition: all 0.2s;
}

.tm-item:hover {
    background: #e9ecef;
    border-color: #adb5bd;
}

.tm-source {
    font-weight: 500;
    margin-bottom: 0.25rem;  /* 여백 줄임: 0.5rem -> 0.25rem */
    color: #212529;
    line-height: 1.3;  /* 줄 간격 조정 */
}

.tm-target {
    color: #495057;
    margin-bottom: 0.25rem;  /* 여백 줄임: 0.5rem -> 0.25rem */
    line-height: 1.3;  /* 줄 간격 조정 */
}

.tm-meta {
    font-size: 0.875rem;
    color: #6c757d;
    margin-bottom: 0;  /* 하단 여백 제거 */
    line-height: 1.2;  /* 줄 간격 조정 */
}

/* Button Styles */
.btn-icon {
    padding: 0.25rem 0.5rem;
    font-size: 0.875rem;
    border: none;
    background: transparent;
    color: #6c757d;
    transition: all 0.2s;
}

.btn-icon:hover {
    color: #212529;
    background: #e9ecef;
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 3rem 1rem;
    color: #6c757d;
}

.empty-state i {
    font-size: 3rem;
    margin-bottom: 1rem;
    opacity: 0.5;
}

/* Search Box */
.search-box {
    position: relative;
}

.search-box input {
    padding-right: 2.5rem;
}

.search-box button {
    position: absolute;
    right: 0.5rem;
    top: 50%;
    transform: translateY(-50%);
    border: none;
    background: none;
    color: #6c757d;
}

/* Match Tester */
.match-tester {
    background: #f8f9fa;
    padding: 1rem;
    border-radius: 0.375rem;
    margin-bottom: 1rem;
}

.threshold-slider {
    margin: 1rem 0;
}

/* Loading State */
.loading-state {
    text-align: center;
    padding: 3rem;
    color: #6c757d;
}

/* TM Form Styles */
.tm-form-field {
    margin-bottom: 1rem;
}

.tm-form-label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: #212529;
}

.tm-form-input,
.tm-form-textarea,
.tm-form-select {
    width: 100%;
    padding: 0.5rem 0.75rem;
    font-size: 1rem;
    line-height: 1.5;
    color: #495057;
    background-color: #fff;
    background-clip: padding-box;
    border: 1px solid #ced4da;
    border-radius: 0.375rem;
    transition: border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
}

.tm-form-input:focus,
.tm-form-textarea:focus,
.tm-form-select:focus {
    color: #495057;
    background-color: #fff;
    border-color: #86b7fe;
    outline: 0;
    box-shadow: 0 0 0 0.25rem rgb(13 110 253 / 25%);
}

.tm-form-textarea {
    resize: vertical;
    /* 2026-05-20: 기본 height 120px 명시 — 200px+ stretch override + 충분한 visible space.
       min-height = floor (72px), height = default (120px). resize:vertical 그대로 → 사용자 drag 로 확장. */
    min-height: 72px;
    height: 120px;
}

.tm-form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

/* Excel Upload Styles */
.excel-upload-section {
    background: #f8f9fa;
    border: 2px dashed #dee2e6;
    border-radius: 0.5rem;
    padding: 2rem;
    text-align: center;
    transition: all 0.3s ease;
}

.excel-upload-section:hover {
    border-color: #fd7e14;
    background: #fff5ec;
}

.excel-upload-icon {
    font-size: 3rem;
    color: #fd7e14;
    margin-bottom: 1rem;
}

.file-upload-input {
    display: none;
}

.file-upload-label {
    display: inline-block;
    padding: 0.75rem 1.5rem;
    background: #fd7e14;
    color: white;
    border-radius: 0.375rem;
    cursor: pointer;
    transition: all 0.2s;
}

.file-upload-label:hover {
    background: #e56f0c;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(253, 126, 20, 0.3);
}

/* Upload Progress */
.upload-progress-container {
    margin-top: 1.5rem;
    padding: 1.5rem;
    background: white;
    border-radius: 0.375rem;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.progress-steps {
    display: flex;
    justify-content: space-between;
    margin-bottom: 1rem;
}

.progress-step {
    flex: 1;
    text-align: center;
    position: relative;
}

.progress-step::after {
    content: '';
    position: absolute;
    top: 20px;
    right: -50%;
    width: 100%;
    height: 2px;
    background: #dee2e6;
}

.progress-step:last-child::after {
    display: none;
}

.progress-step.active::after {
    background: #fd7e14;
}

.progress-step-icon {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: #dee2e6;
    color: white;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 0.5rem;
    position: relative;
    z-index: 1;
}

.progress-step.active .progress-step-icon {
    background: #fd7e14;
}

.progress-step.completed .progress-step-icon {
    background: #28a745;
}

/* Sheet Preview Modal Custom Styles */
.sheet-preview-modal {
    max-width: 90vw;
}

.column-role-selector {
    background: #f8f9fa;
    padding: 1rem;
    border-radius: 0.375rem;
    margin-bottom: 1rem;
}

.column-role-item {
    display: flex;
    align-items: center;
    margin-bottom: 0.5rem;
}

.column-role-label {
    min-width: 120px;
    font-weight: 500;
}

/* Animations */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.fade-in-up {
    animation: fadeInUp 0.3s ease-out;
}

/* 2026-05-19: Tab Styles — RAG 패턴 적용 (.tm-tabs wrapper + nav-link padding 1rem 1.5rem + border 3px).
   color 는 TM theme (orange #fd7e14) 유지. */
.tm-tabs {
    border-bottom: 1px solid #dee2e6;
}

.tm-tabs .nav-tabs {
    border-bottom: none;
    padding: 0 1rem;
}

/* 2026-05-20: button base 룰 (main.css line 227 `button { background: #007bff }`) override.
   nav-link 가 button element 라 광범위 룰의 영향을 받아 hover 시 blue fill + 흰 글자.
   base + hover + focus + active 모두 background: transparent 명시. */
.tm-tabs .nav-link,
.tm-tabs .nav-link:hover,
.tm-tabs .nav-link:focus,
.tm-tabs .nav-link.active:hover,
.tm-tabs .nav-link.active:focus {
    background-color: transparent;
}

.tm-tabs .nav-link {
    border: none;
    border-radius: 0;
    padding: 1rem 1.5rem;
    color: #6c757d;
    border-bottom: 3px solid transparent;
}

.tm-tabs .nav-link.active {
    background: none;
    color: #fd7e14;
    border-bottom-color: #fd7e14;
}

.tm-tabs .nav-link:hover {
    border-color: transparent;
    color: #fd7e14;
}

/* 탭 컨텐츠 기본 스타일 */
#tmTabContent {
    height: calc(100% - 48px);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

/* TM 목록 탭 전용 스타일 */
#tm-list-panel {
    height: 100%;
    /* 2026-05-19: overflow:hidden 제거 — outer clip → inner scroll cascade 의 다중 scrollbar 방지. */
}

#tm-list-panel.show.active {
    display: flex !important;
    flex-direction: column;
    align-items: stretch;  /* 전체 너비 사용 */
    justify-content: flex-start;  /* 상단 정렬 */
}

/* 프로젝트 파일 탭 전용 스타일 */
#project-files-panel {
    height: 100%;
    /* 2026-05-19: overflow:hidden 제거 — 동일 패턴. */
}

#project-files-panel.show.active {
    display: flex !important;
    flex-direction: column;
    align-items: stretch;  /* 전체 너비 사용 */
    justify-content: flex-start;  /* 상단 정렬 */
}

/* TM 목록 탭 스타일 */
#tm-list-panel .panel-header {
    flex-shrink: 0;  /* 헤더 높이 고정 */
    background: #f8f9fa;
    padding: 1rem;
    border-bottom: 1px solid #dee2e6;
}

#tm-list-panel .panel-body {
    display: flex;
    flex-direction: column;
    flex: 1;  /* 남은 공간 차지 */
    overflow: hidden;
    padding: 1rem;
    min-height: 0;  /* flexbox overflow 작동 */
}

/* 2026-05-19: list 의 유일 scroll source — *single source of truth*.
   height budget:
     workspace max-height = 100vh - 250px
     내부 fit: tm-tabs(50) + panel-header(80) + pagination(60) + padding/border(30) ≈ 220px
     + 안전 여유 80px = 300px budget
   → tmListContainer max-height = (100vh - 250px) - 300px = 100vh - 550px.
   terminology 의 .table-container max-height 와 동일 값. */
#tmListContainer {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    max-height: calc(100vh - 550px);
    overflow-y: auto;
}

/* 2026-05-19: overflow + height 제거 — scroll source 는 부모 #tmListContainer 만 (single source of truth).
   #tmList 는 *content wrapper* 로 natural visible + height auto.
   기존 `overflow-y:auto + height:calc(...)` 가 *부모 #tmListContainer 의 scroll bar 와 cascading 2 개 scrollbar 생성* 원인.
   padding-bottom 제거 — 상단/하단 대칭. .panel-body 의 padding:1rem 이 outer breathing buffer 역할. */
#tmList {
    overflow-x: hidden;
}

/* 중복 제거 - 위에서 이미 정의됨 */

#paginationContainer {
    flex-shrink: 0;
    margin-top: -2px;
    position: relative;
    z-index: 10;
}

/* 2026-05-20: pagination 영역의 background + padding — terminology 와 동일 톤. */
.pagination-container {
    padding: 0.75rem 1rem;
    border-top: 1px solid #dee2e6;
    background: #f8f9fa;
}

/* 프로젝트 파일 탭 스타일 */
#project-files-panel .panel-header {
    flex-shrink: 0;  /* 헤더 높이 고정 */
    background: #f8f9fa;
    padding: 1rem;
    border-bottom: 1px solid #dee2e6;
}

#project-files-panel .panel-body {
    display: flex;
    flex-direction: column;
    flex: 1;  /* 남은 공간 차지 */
    overflow: hidden;
    padding: 1rem;
    min-height: 0;  /* flexbox overflow 작동 */
}

/* File Table Styles */
#filesTableContainer {
    flex: 1;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

#filesTableContainer .table-responsive {
    flex: 1;
    overflow-y: auto;
    margin-bottom: 10px;
    /* 2026-05-20: TM 목록 #tmListContainer (line 519) 와 동일 budget 적용.
       height budget = workspace top offset (250px) + 내부 chrome (300px) = 550px.
       내부 chrome = panel-header(80) + tm-tabs(50) + padding/border(30) + 안전(140).
       페이지네이션이 없으므로 TM 목록 대비 60px 여유 있지만, 사이드 패널 spillover
       방지 위해 같은 budget 으로 통일 — sidebar 의 자연 height 와 잘 fit. */
    max-height: calc(100vh - 550px);
}

#filesTable {
    margin-bottom: 0;
}

#filesTable th {
    font-weight: 600;
    color: #495057;
    border-bottom: 2px solid #dee2e6;
    position: sticky;
    top: 0;
    background-color: white;
    z-index: 10;
}

#filesTable td {
    vertical-align: middle;
    word-break: break-word;
    max-width: 300px;
}

/* 2026-05-20: `.text-nowrap` 적용 td 에서 word-break / overflow-wrap reset.
   `#filesTable td` 의 `word-break: break-word` 가 specificity 로 .text-nowrap 의 nowrap 을 이기지는 못하지만
   *letter 단위 break* 를 별도로 트리거. 작은 viewport 에서 "440.08 KB" 가 세로 letter 분리되는 원인.
   .text-nowrap td 에 한해서는 word-break / overflow-wrap 도 nowrap 동지 (keep-all + normal). */
#filesTable td.text-nowrap {
    word-break: keep-all;
    overflow-wrap: normal;
}

/* 2026-05-20: 프로젝트 파일 탭 — 파일명/크기/날짜/버튼 폰트 크기 10% 축소.
   Bootstrap default 1rem → 0.9rem, btn-sm 0.875rem → 0.7875rem.
   TM 관리 + 용어집 관리 양쪽에 동일 적용 (두 페이지가 이 CSS 공유). */
#filesTable th,
#filesTable td {
    font-size: 0.9rem;
}
#filesTable .btn-sm {
    font-size: 0.7875rem;
}

/* 2026-05-20: outline-secondary 의 visible outline 회복.
   원인 = sheets.css line 185 의 `.view-sheets-btn { border: none; background: primary }` 가
   TM 관리에서 import 되어 `.view-sheets-btn.btn-outline-secondary` 의 border 를 제거.
   용어집 관리는 sheets.css 안 import → Bootstrap default outline 그대로 보임.
   여기서는 `.view-sheets-btn + .btn-outline-secondary` 조합 매치 + `!important` 로 sheets.css 의
   border:none 을 무력화 → 용어집과 동일한 visual (1px 진한 회색 outline, btn-primary 와 동일 height). */
#filesTable .view-sheets-btn.btn-outline-secondary,
#filesTable .btn-outline-secondary {
    background-color: #fff !important;
    border: 1px solid #6c757d !important;
    color: #6c757d !important;
    /* 2026-05-20: vertical padding +2px (위아래 합 +4px) — 시트 선택 버튼 높이 강조. */
    padding: calc(0.25rem + 2px) 0.5rem !important;
}
#filesTable .view-sheets-btn.btn-outline-secondary:hover,
#filesTable .btn-outline-secondary:hover {
    background-color: #6c757d !important;
    border-color: #6c757d !important;
    color: #fff !important;
}

#filesTable .form-check-input {
    margin-top: 0;
}

.file-status-badge {
    font-size: 0.75rem;
    padding: 0.25rem 0.5rem;
}

/* 파일명이 긴 경우 처리 */
#filesTable td:nth-child(2) {
    max-width: 350px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

#filesTable td:nth-child(2):hover {
    overflow: visible;
    white-space: normal;
    word-break: break-all;
}

/* 프로젝트 파일 탭 페이지네이션 - 공통 스타일 적용 */
#filesPaginationContainer {
    /* pagination-container 클래스의 스타일 상속 */
    flex-shrink: 0;
}

/* Responsive Design */
@media (max-width: 768px) {
    .tm-workspace {
        grid-template-columns: 1fr;
        height: auto;
    }
    
    .sidebar-panel {
        order: 2;
        max-height: 400px;
    }
    
    .main-panel {
        order: 1;
    }
    
    .tm-form-row {
        grid-template-columns: 1fr;
    }
}

/* 2026-05-19: 사이드 패널의 *총 TM 갯수* stats card — terminology.html 의 .stats-grid 패턴 차용. */
.tm-stats-section { padding: 0.5rem 1rem; }
.tm-stats-grid { display: grid; grid-template-columns: 1fr; gap: 0.5rem; }
.tm-stat-card {
    background: #ffffff;
    border: 1px solid #dee2e6;
    border-radius: 8px;
    padding: 0.875rem 0.5rem;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.25rem;
}
.tm-stat-number {
    font-size: 1.6rem;
    font-weight: 700;
    color: #6f42c1;
    line-height: 1.1;
}
.tm-stat-label {
    font-size: 0.8rem;
    color: #6c757d;
}