/* Custom styles for PDF Invoice Processor */

/* Workflow icons styling */
.workflow-icon {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background-color: rgba(var(--bs-primary-rgb), 0.1);
    display: flex;
    justify-content: center;
    align-items: center;
    margin: 0 auto;
}

/* Dashed border for the upload area */
.dashed-border {
    border-style: dashed !important;
    border-width: 2px !important;
    transition: all 0.3s ease;
}

.dashed-border:hover {
    background-color: rgba(var(--bs-primary-rgb), 0.05);
    cursor: pointer;
}

/* Add some spacing for the file list items */
#filesList .list-group-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

/* File name text styling - ensure white color */
#upload-files-list td,
#processed-files-list td {
    color: #ffffff !important;
}

/* Specific styling for file names to ensure they are visible */
#upload-files-list td:first-child,
#processed-files-list td:first-child {
    color: #ffffff !important;
    font-weight: 500;
}

/* Styling for the file icons */
.file-icon {
    margin-right: 10px;
}

/* Add animation for the spinner */
.fa-spinner {
    animation: spin 2s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Status badges styling */
.badge.bg-uploading {
    background-color: var(--bs-primary);
}

.badge.bg-processing {
    background-color: var(--bs-warning);
}

.badge.bg-success {
    background-color: var(--bs-success);
}

.badge.bg-error {
    background-color: var(--bs-danger);
}

/* Make sure tables look good on mobile */
.table-responsive {
    max-height: 70vh; /* 화면 높이의 70%로 확대 */
    overflow-y: auto;
    border-radius: 0.375rem;
    border: 1px solid var(--bs-border-color);
}

/* 테이블 스타일 개선 */
.table-hover tbody tr:hover {
    background-color: rgba(var(--bs-primary-rgb), 0.05);
}

/* 파일 리스트 컨테이너 전체 높이 조정 */
#processed-files-container {
    min-height: 400px;
}

/* 파일 리스트 화면 전체 높이 조정 */
#files-screen .card {
    height: calc(100vh - 200px);
    max-height: 800px;
}

#files-screen .card-body {
    height: calc(100% - 60px);
    padding: 0;
}

/* 빈 상태 메시지 스타일 */
#no-processed-files {
    height: 400px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

/* 테이블 헤더 개선 */
.table-header {
    background-color: var(--bs-gray-100);
    border-bottom: 2px solid var(--bs-border-color);
}

.table-header th {
    font-weight: 600;
    border-bottom: 2px solid var(--bs-border-color);
    white-space: nowrap;
}

/* 테이블 셀 스타일 개선 */
.table td {
    vertical-align: top;
    word-break: break-word;
    padding: 1rem !important;
    min-height: 80px;
    line-height: 1.6;
}

/* 파일명 컬럼 스타일 */
.table td:first-child {
    font-weight: 500;
    color: var(--bs-dark);
}

/* 금액 컬럼 우측 정렬 */
.table td:nth-child(8) {
    text-align: right;
    font-weight: 500;
}

/* 작은 화면에서 테이블 스크롤 개선 */
@media (max-width: 768px) {
    .table-responsive {
        max-height: 60vh;
    }
    
    .table th, .table td {
        font-size: 0.85rem;
        padding: 0.5rem 0.3rem;
    }
    
    /* 모바일에서 일부 컬럼 숨기기 */
    .table th:nth-child(6),
    .table td:nth-child(6),
    .table th:nth-child(7),
    .table td:nth-child(7) {
        display: none;
    }
}

/* 대형 화면에서 더 넓은 공간 활용 */
@media (min-width: 1200px) {
    .table-responsive {
        max-height: 75vh;
    }
}

/* Progress animation */
@keyframes progress-bar-stripes {
    0% { background-position-x: 1rem; }
}

/* 반응형 디자인: 작은 화면에서는 세로 정렬 */
@media (max-width: 768px) {
    .card-header .d-flex {
        flex-direction: column;
        gap: 0.75rem !important;
        align-items: stretch !important;
    }
}

/* 모달 접근성 개선 */
.modal {
    pointer-events: none;
}

.modal.show {
    pointer-events: auto;
}

.modal-backdrop {
    pointer-events: auto;
    z-index: 1040;
}

/* 모달이 열릴 때 포커스 관리 */
.modal.show .modal-content {
    outline: none;
}

.modal-open {
    overflow: hidden !important;
}

/* body 상태 복원 강화 */
body:not(.modal-open) {
    overflow: auto !important;
    padding-right: 0 !important;
}

/* 모든 요소의 포인터 이벤트 복원 */
body:not(.modal-open) * {
    pointer-events: auto !important;
}

/* 버튼 안전성 */
.btn:focus,
.btn:active {
    outline: 2px solid #007bff;
    outline-offset: 2px;
}

/* 설정 모달 특별 처리 */
#settingsModal .modal-content {
    max-width: 500px;
    margin: 0 auto;
}

#settingsModal .form-select,
#settingsModal .form-range {
    transition: all 0.2s ease;
}

#settingsModal .form-select:focus,
#settingsModal .form-range:focus {
    box-shadow: 0 0 0 3px rgba(0, 123, 255, 0.25);
}

/* 긴급 UI 복원용 */
.ui-restored {
    pointer-events: auto !important;
    overflow: auto !important;
}

.ui-restored * {
    pointer-events: auto !important;
}

/* Clickable code badge styles */
.code-badge-clickable {
    transition: all 0.3s ease;
}

.code-badge-clickable:hover {
    transform: scale(1.1);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    filter: brightness(1.1);
}

/* Code detail modal content */
.code-detail-content h6 {
    border-bottom: 1px solid #dee2e6;
    padding-bottom: 8px;
    margin-bottom: 12px;
}

.code-detail-content .list-group-item {
    border: 1px solid rgba(0, 0, 0, 0.125);
    margin-bottom: 8px;
}

.code-detail-content .progress {
    background-color: #e9ecef;
}

/* Edit mode styles */
.editable-row {
    background-color: rgba(255, 193, 7, 0.05);
}

.modified-row {
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% {
        background-color: rgba(255, 193, 7, 0.1);
    }
    50% {
        background-color: rgba(255, 193, 7, 0.3);
    }
    100% {
        background-color: rgba(255, 193, 7, 0.1);
    }
}

.code-select {
    font-family: monospace;
    font-size: 1.1em;
    text-align: center;
    min-width: 150px;
}

.code-select-container {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.code-select option {
    font-family: monospace;
    padding: 5px;
}

.code-name {
    margin-top: 5px;
    font-size: 0.85em;
}

/* 편집 가능한 필드 스타일 - Bootstrap 클래스로 대체 */
/* .editable-field는 이제 bg-light border-warning border-2로 대체됨 */

/* Focus 스타일은 Bootstrap의 기본 form-control:focus 사용 */

/* 편집 모드 활성화 시 기본 정보 섹션 강조 */
.edit-mode #basic-info-section {
    background-color: rgba(255, 193, 7, 0.03);
    border: 2px solid rgba(255, 193, 7, 0.3);
    border-radius: 0.375rem;
    padding: 1rem;
    margin: -0.5rem;
    transition: all 0.3s ease;
}

/* 편집 모드 라벨 강조 */
.edit-mode label {
    font-weight: 600;
    color: #495057;
}

/* Hover 효과는 Bootstrap의 기본 스타일 사용 */

/* 편집 모드 테이블 - textarea 최소 높이만 설정 */
.editable-row textarea {
    resize: vertical;
    min-height: 120px;
}

.editable-row input[type="number"] {
    text-align: right;
}

.editable-row .form-control,
.editable-row .form-select {
    font-size: 1rem !important;
    padding: 0.5rem 0.75rem !important;
    min-height: calc(1.5em + 1rem + 4px) !important;
}

/* 테이블 셀 최소 높이 설정 */
.editable-row td {
    min-height: 150px !important;
    height: auto !important;
    padding: 1rem !important;
    vertical-align: top !important;
}

/* 편집 모드 입력 필드 시인성 개선 */
.editable-row .form-control,
.editable-row .form-select,
.editable-row textarea,
.editable-row input {
    background-color: #ffffff !important;
    color: #000000 !important;
    border: 3px solid #ffc107 !important;
    box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.075);
}

.editable-row .form-control:focus,
.editable-row .form-select:focus,
.editable-row textarea:focus,
.editable-row input:focus {
    background-color: #fffdf0 !important;
    border-color: #ff9800 !important;
    box-shadow: 0 0 0 0.2rem rgba(255, 152, 0, 0.25), inset 0 1px 2px rgba(0, 0, 0, 0.075) !important;
    outline: none;
}

/* 코드 입력 필드 특별 스타일 */
.code-input-autocomplete {
    background-color: #ffffff !important;
    color: #212529 !important;
    border: 2px solid #ffc107 !important;
    font-family: monospace;
    font-weight: 600;
    letter-spacing: 0.5px;
    font-size: 1.1rem !important;
    padding: 0.5rem 0.75rem !important;
    min-height: calc(1.5em + 1rem + 4px) !important;
    width: 200px !important;
    min-width: 200px !important;
    opacity: 1 !important;
    -webkit-text-fill-color: #212529 !important;
}

.code-input-autocomplete:focus {
    background-color: #fffdf0 !important;
    border-color: #ff9800 !important;
    box-shadow: 0 0 0 0.2rem rgba(255, 152, 0, 0.25) !important;
}

/* 어두운 테마에서도 읽기 쉽도록 placeholder 색상 조정 */
.editable-row .form-control::placeholder,
.editable-row textarea::placeholder,
.editable-row input::placeholder {
    color: #6c757d !important;
    opacity: 0.8;
}

/* 편집 중인 행 강조 */
.editable-row {
    background-color: rgba(255, 193, 7, 0.08) !important;
    border-left: 4px solid #ffc107;
    transition: all 0.3s ease;
}

/* 수정된 필드 강조 */
.editable-row .form-control.modified,
.editable-row .form-select.modified,
.editable-row textarea.modified,
.editable-row input.modified {
    background-color: #fff8e1 !important;
    border-color: #ff6f00 !important;
}

/* 자동완성 스타일 */
.autocomplete-suggestions {
    top: 100%;
    left: 0;
    margin-top: 2px;
    background-color: #ffffff !important;
    border: 2px solid #ffc107 !important;
    border-radius: 0.375rem;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1), 0 1px 3px rgba(0, 0, 0, 0.08);
}

.autocomplete-item {
    cursor: pointer;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid #f0f0f0;
    color: #212529 !important;
    background-color: #ffffff !important;
    -webkit-text-fill-color: #212529 !important;
    transition: all 0.2s ease;
}

.autocomplete-item:last-child {
    border-bottom: none;
    border-radius: 0 0 0.375rem 0.375rem;
}

.autocomplete-item:hover {
    background-color: #fff8e1 !important;
    color: #212529 !important;
    border-left: 3px solid #ffc107;
    padding-left: calc(1rem - 3px);
}

.autocomplete-item.bg-primary {
    background-color: #ffc107 !important;
    color: #212529 !important;
    font-weight: 600;
}

/* 자동완성 코드 이름 표시 */
.code-autocomplete-container .code-name,
.editable-row .code-autocomplete-container .code-name,
div.code-name,
body.dark .code-name,
[data-bs-theme="dark"] .code-name,
.small.code-name,
div.small.code-name {
    color: #212529 !important;
    background-color: #ffffff !important;
    padding: 0.25rem 0.5rem !important;
    border-radius: 0.25rem !important;
    margin-top: 0.25rem !important;
    font-size: 0.875rem !important;
    border: 1px solid #dee2e6 !important;
    -webkit-text-fill-color: #212529 !important;
    opacity: 1 !important;
    display: block !important;
    box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.05) !important;
}

/* Bootstrap small 클래스 오버라이드 */
.code-name.small {
    font-size: 0.875rem !important;
    color: #212529 !important;
}

.cursor-pointer {
    cursor: pointer;
}

/* Edit mode button states */
#edit-mode-toggle.btn-warning {
    animation: blink 1s infinite;
}

@keyframes blink {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.7;
    }
}

/* 읽기 전용 필드 스타일 */
.form-control[readonly] {
    background-color: #e9ecef !important;
    border: 1px solid #ced4da !important;
    color: #495057 !important;
    cursor: not-allowed;
}

/* 카테고리 코드 입력 필드 특별 처리 */
.editable-row input[readonly].form-control-sm {
    background-color: #f8f9fa !important;
    border: 1px solid #dee2e6 !important;
    font-family: monospace;
    text-align: center;
}

/* 편집 모드 진입/종료 트랜지션 */
* {
    transition: background-color 0.3s ease, border-color 0.3s ease;
}

/* 다크 테마 지원 */
body.dark .editable-row .form-control,
body.dark .editable-row .form-select,
body.dark .editable-row textarea,
body.dark .editable-row input,
[data-bs-theme="dark"] .editable-row .form-control,
[data-bs-theme="dark"] .editable-row .form-select,
[data-bs-theme="dark"] .editable-row textarea,
[data-bs-theme="dark"] .editable-row input,
.editable-row .form-control,
.editable-row .form-select,
.editable-row textarea,
.editable-row input {
    background-color: #ffffff !important;
    color: #212529 !important; /* Bootstrap의 기본 검은색 */
    border: 3px solid #ffc107 !important;
    opacity: 1 !important;
    -webkit-text-fill-color: #212529 !important; /* Safari/Chrome 대응 */
}

/* 편집 필드 placeholder 색상 */
.editable-row .form-control::placeholder,
.editable-row textarea::placeholder,
.editable-row input::placeholder {
    color: #6c757d !important;
    opacity: 1 !important;
}

/* 읽기 전용 모드 테이블 색상 유지 */
body.dark .table td:not(.editable-row td),
[data-bs-theme="dark"] .table td:not(.editable-row td) {
    color: #ffffff;
}

/* 편집 모드 특정 입력 필드 너비 조정 */
.editable-row textarea[name="description"] {
    width: 100% !important;
    min-width: 300px !important;
}

.editable-row input[type="text"] {
    width: 100% !important;
    min-width: 120px !important;
}

.editable-row input[type="number"] {
    width: 100% !important;
    min-width: 100px !important;
}

.editable-row select {
    width: 100% !important;
    min-width: 100px !important;
}

/* 테이블 레이아웃 개선 */
.table-responsive {
    overflow-x: auto;
}

.table.editable-mode {
    min-width: 1500px;
}

/* 편집 모드 컬럼 너비 지정 */
.editable-row td:nth-child(2) { /* 설명 */
    min-width: 450px !important;
    width: 40% !important;
}

.editable-row td:nth-child(3) { /* 카테고리 */
    min-width: 120px !important;
}

.editable-row td:nth-child(4) { /* 수량 */
    min-width: 100px !important;
}

.editable-row td:nth-child(5) { /* 코드 */
    min-width: 220px !important;
}

.editable-row td:nth-child(6) { /* 금액 */
    min-width: 120px !important;
}

.editable-row td:nth-child(7) { /* 통화 */
    min-width: 100px !important;
}

.editable-row td:nth-child(8) { /* 관세 */
    min-width: 120px !important;
}

/* 파일 네비게이션 */
.file-navigation {
    transition: all 0.3s ease;
}

.file-navigation:hover {
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.file-position {
    font-weight: 500;
    color: #495057;
}

.file-position strong {
    color: #007bff;
    font-size: 1.2em;
}

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

.file-info {
    max-width: 300px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* 반응형 디자인 */
@media (max-width: 768px) {
    .file-navigation {
        flex-direction: column;
        gap: 1rem;
    }
    
    .nav-controls {
        order: 2;
    }
    
    .file-info {
        order: 1;
        max-width: 100%;
        text-align: center;
    }
}

/* AI 확인 결과 스타일 */
#ai-check-results {
    max-height: 400px;
    overflow-y: auto;
}

#ai-check-results .alert {
    font-size: 0.9rem;
}

#ai-check-results .btn-sm {
    font-size: 0.85rem;
}

.bg-success-subtle {
    background-color: rgba(25, 135, 84, 0.1) !important;
    transition: background-color 0.3s ease;
}

