/* ============================================
   inventory.css — 재고 현황 전용 스타일
   원본: mia inventory.html에서 페이지 전용 추출
   ============================================ */

/* --- 상단 요약 카드 4개 (스펙 2.2) — 항상 일렬 --- */
.stat-cards-row {
  display: flex !important;
  flex-wrap: nowrap !important;
  gap: 0.75rem;
  margin-bottom: 1.5rem;
}

.stat-cards-row > .stat-card {
  flex: 1 1 0% !important;
  min-width: 0;
}

.stat-card {
  border-radius: 12px;
  padding: 1.25rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
  transition: all 0.3s ease;
}

.stat-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

.stat-icon {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  flex-shrink: 0;
}

.stat-card-blue .stat-icon { background: rgba(59, 130, 246, 0.1); color: #3B82F6; }
.stat-card-red .stat-icon { background: rgba(239, 68, 68, 0.1); color: #EF4444; }
.stat-card-green .stat-icon { background: rgba(34, 197, 94, 0.1); color: #22C55E; }
.stat-card-orange .stat-icon { background: rgba(245, 158, 11, 0.1); color: #F59E0B; }

.stat-label {
  font-size: 0.8125rem;
  color: var(--tertiary);
  margin-bottom: 2px;
}

.stat-value {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--brand);
  line-height: 1.2;
}

.stat-subtitle {
  font-size: 0.6875rem;
  color: var(--light);
  margin-top: 2px;
}

/* --- 2컬럼 레이아웃 (좌측 트리 + 우측 콘텐츠) --- */
.content-area {
  display: flex;
  gap: 24px;
}

/* --- 좌측 트리 패널 --- */
.left-panel {
  width: 280px;
  flex-shrink: 0;
  background: #FFFFFF;
  border-radius: 12px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
  overflow-y: auto;
  padding: 0;
}

/* --- 우측 콘텐츠 패널 --- */
.right-panel {
  flex: 1;
  min-width: 0;
  background: #FFFFFF;
  border-radius: 12px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
  padding: 24px;
}

/* --- 패널 헤더 (트리 패널 타이틀) --- */
.panel-header {
  display: flex;
  flex-direction: row;
  justify-content: flex-start;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid var(--tint);
  font-weight: 700;
  font-size: 0.9375rem;
  color: var(--brand);
  gap: 8px;
}

/* --- 트리 아이템 --- */
.tree-item {
  display: flex;
  align-items: center;
  padding: 6px 12px;
  cursor: pointer;
  border-radius: 6px;
  transition: all 0.2s ease;
  color: var(--secondary);
  font-size: 0.875rem;
}

.tree-item:hover {
  background: var(--bg-light);
}

.tree-item.active {
  background: rgba(59, 130, 246, 0.08);
  color: #3B82F6;
  font-weight: 700;
}

/* 트리 토글 화살표 */
.tree-toggle {
  width: 20px;
  cursor: pointer;
  text-align: center;
  transition: transform 0.2s ease;
  color: var(--light);
  flex-shrink: 0;
}

/* 트리 자식 컨테이너 (기본 숨김, .open 시 표시) */
.tree-children {
  display: none;
  padding-left: 8px;
}

.tree-children.open {
  display: block;
}

/* --- 탭 버튼 --- */
.tab-button {
  padding: 10px 20px;
  background: transparent;
  border: none;
  border-bottom: 3px solid transparent;
  cursor: pointer;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--tertiary);
  transition: all 0.2s ease;
  font-family: inherit;
}

.tab-button:hover {
  color: var(--brand);
}

.tab-button.active {
  border-bottom-color: #3B82F6;
  color: #3B82F6;
  font-weight: 700;
}

/* --- 탭 콘텐츠 --- */
.tab-content {
  display: none;
}

.tab-content.active {
  display: block;
}

/* --- 데이터 테이블 --- */
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

.data-table thead {
  background: var(--background);
  border-bottom: 1px solid var(--tint);
}

.data-table th {
  padding: 12px 16px;
  text-align: left;
  font-weight: 600;
  color: var(--tertiary);
  font-size: 0.8125rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.data-table td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--tint);
  color: var(--brand);
}

.data-table tbody tr:hover {
  background: var(--bg-light);
}

/* --- 재고 상태 뱃지 --- */
.status-badge.status-정상 {
  background: rgba(34, 197, 94, 0.1);
  color: #15803D;
}

.status-badge.status-부족 {
  background: rgba(239, 68, 68, 0.1);
  color: #DC2626;
}

.status-badge.status-과잉 {
  background: rgba(245, 158, 11, 0.1);
  color: #D97706;
}

/* --- 안전재고 경고 배너 --- */
.safety-warning-banner {
  background: rgba(239, 68, 68, 0.08);
  border: 1px solid rgba(239, 68, 68, 0.25);
  border-radius: 10px;
  padding: 12px 20px;
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  gap: 10px;
  color: #DC2626;
  font-size: 0.875rem;
  font-weight: 600;
}

.safety-warning-banner i {
  font-size: 1.125rem;
}

.safety-warning-banner .count-badge {
  background: #DC2626;
  color: #fff;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 0.75rem;
  font-weight: 700;
  margin-left: 4px;
}

/* 안전재고 미달 행 배경 */
.data-table tbody tr.row-danger {
  background: rgba(239, 68, 68, 0.06) !important;
}

.data-table tbody tr.row-danger:hover {
  background: rgba(239, 68, 68, 0.12) !important;
}

/* --- 이동 버튼 --- */
.btn-move {
  background: transparent;
  color: var(--tertiary);
  padding: 4px 10px;
  border-radius: 6px;
  border: 1px solid var(--tint);
  cursor: pointer;
  font-size: 0.75rem;
  font-weight: 600;
  transition: all 0.2s;
  white-space: nowrap;
  font-family: inherit;
}

.btn-move:hover {
  border-color: var(--brand);
  color: var(--brand);
  background: var(--bg-light);
}

/* --- 자재 이동 모달 --- */
.modal-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.4);
  z-index: 9000;
  align-items: center;
  justify-content: center;
}

.modal-overlay.open {
  display: flex;
}

.modal-box {
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.15);
  width: 440px;
  max-width: 90vw;
  overflow: hidden;
}

.modal-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--tint);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-header h3 {
  font-size: 1rem;
  font-weight: 700;
  color: var(--brand);
  margin: 0;
}

.modal-close {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--light);
  font-size: 1.125rem;
  transition: color 0.2s;
}

.modal-close:hover {
  color: var(--brand);
}

.modal-body {
  padding: 24px;
}

.modal-field {
  margin-bottom: 16px;
}

.modal-field label {
  display: block;
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--tertiary);
  margin-bottom: 6px;
}

.modal-field input,
.modal-field select {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--tint);
  border-radius: 8px;
  font-size: 0.875rem;
  font-family: inherit;
  color: var(--brand);
  background: #fff;
  transition: border-color 0.2s;
}

.modal-field input:focus,
.modal-field select:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(44, 51, 68, 0.08);
}

.modal-field input[readonly] {
  background: var(--bg-light);
  color: var(--tertiary);
  cursor: not-allowed;
}

.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--tint);
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.modal-btn {
  padding: 10px 20px;
  border-radius: 8px;
  border: none;
  cursor: pointer;
  font-size: 0.875rem;
  font-weight: 600;
  transition: all 0.2s;
  font-family: inherit;
}

.modal-btn-cancel {
  background: var(--bg-light);
  color: var(--tertiary);
  border: 1px solid var(--tint);
}

.modal-btn-cancel:hover {
  background: var(--tint);
}

.modal-btn-confirm {
  background: var(--brand);
  color: #fff;
}

.modal-btn-confirm:hover {
  background: var(--secondary);
}

/* --- 탭 내 검색 입��� --- */
.inv-tab-search {
  width: 160px;
  border: 1px solid var(--tint);
  border-radius: 6px;
  padding: 5px 10px;
  font-size: 0.75rem;
  color: var(--brand);
  outline: none;
  font-family: inherit;
}

.inv-tab-search:focus {
  border-color: #3B82F6;
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.1);
}

/* --- 입출고 유형 뱃지 --- */
.type-badge {
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 0.625rem;
  font-weight: 600;
}

.type-badge-자재 {
  background: rgba(99, 102, 241, 0.1);
  color: #4F46E5;
}

.type-badge-완제품 {
  background: rgba(34, 197, 94, 0.1);
  color: #15803D;
}

.type-badge-반제품 {
  background: rgba(245, 158, 11, 0.1);
  color: #D97706;
}

/* --- 탭 바 레이아웃 --- */
.tab-bar {
  display: flex;
  align-items: center;
  border-bottom: 2px solid var(--tint);
  margin-bottom: 24px;
}

.tab-buttons {
  display: flex;
  align-items: center;
}

.tab-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 8px;
  padding-bottom: 6px;
}

/* --- CSV 내보내기 버튼 (스펙 10) --- */
.btn-csv {
  background: var(--bg-light);
  color: var(--tertiary);
  border: 1px solid var(--tint);
  border-radius: 6px;
  padding: 5px 12px;
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  font-family: inherit;
}

.btn-csv:hover {
  background: var(--tint);
  color: var(--brand);
}

/* --- 행 클릭 커서 --- */
.clickable-row {
  cursor: pointer;
}

/* --- 상세 슬라이드 패널 (스펙 2.2) --- */
.inv-detail-panel {
  width: 0;
  overflow: hidden;
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
  transition: width 0.3s ease, padding 0.3s ease;
  flex-shrink: 0;
}

.inv-detail-panel.open {
  width: 360px;
  padding: 0;
  overflow-y: auto;
}

.detail-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--tint);
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  background: #fff;
  z-index: 1;
}

.detail-header h3 {
  font-size: 1rem;
  font-weight: 700;
  color: var(--brand);
  margin: 0;
}

.detail-section {
  padding: 16px 20px;
  border-bottom: 1px solid var(--tint);
}

.detail-section h4 {
  font-size: 0.875rem;
  font-weight: 700;
  color: var(--brand);
  margin: 0 0 12px 0;
}

/* 품목 정보 그리드 */
.inv-detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.inv-detail-grid-item {
  padding: 8px;
  background: var(--background);
  border-radius: 6px;
}

.inv-detail-grid-label {
  font-size: 0.6875rem;
  color: var(--light);
  margin-bottom: 2px;
}

.inv-detail-grid-value {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--brand);
}

/* LOT 이력 리스트 */
.detail-lot-list {
  max-height: 200px;
  overflow-y: auto;
}

.lot-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 0;
  border-bottom: 1px solid var(--bg-light);
  font-size: 0.8125rem;
}

.lot-item:last-child {
  border-bottom: none;
}

.lot-direction {
  width: 40px;
  text-align: center;
  flex-shrink: 0;
}

.lot-direction.in { color: #22C55E; }
.lot-direction.out { color: #EF4444; }

.lot-info {
  flex: 1;
}

.lot-date {
  font-size: 0.6875rem;
  color: var(--light);
}

/* 재고 조정 폼 (스펙 10: 재고 실사) */
.adjust-form {
  padding: 4px 0;
}

.adjust-diff {
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 0.8125rem;
  font-weight: 600;
  margin-top: 8px;
}

.adjust-diff.positive {
  background: rgba(34, 197, 94, 0.1);
  color: #15803D;
}

.adjust-diff.negative {
  background: rgba(239, 68, 68, 0.1);
  color: #DC2626;
}

.adjust-diff.zero {
  background: var(--bg-light);
  color: var(--tertiary);
}

/* --- 안전재고 경고 토스트 (스펙 10) --- */
.inv-toast {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  background: var(--brand);
  color: white;
  padding: 1rem 1.5rem;
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
  z-index: 9999;
  display: flex;
  align-items: center;
  gap: 12px;
  animation: toast-slide-in 0.4s ease;
  max-width: 400px;
}

.inv-toast-warning {
  background: linear-gradient(135deg, #DC2626 0%, #B91C1C 100%);
}

.inv-toast-icon {
  font-size: 1.25rem;
  flex-shrink: 0;
}

.inv-toast-body {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.inv-toast-body strong {
  font-size: 0.875rem;
}

.inv-toast-body span {
  font-size: 0.75rem;
  opacity: 0.85;
}

.inv-toast-close {
  background: none;
  border: none;
  color: rgba(255, 255, 255, 0.6);
  cursor: pointer;
  font-size: 0.875rem;
  padding: 4px;
  transition: color 0.2s;
  flex-shrink: 0;
}

.inv-toast-close:hover {
  color: #fff;
}

@keyframes toast-slide-in {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

@keyframes toast-slide-out {
  from { transform: translateX(0); opacity: 1; }
  to { transform: translateX(100%); opacity: 0; }
}

/* --- 바코드 스캔 영역 --- */
.scan-area {
  padding: 2rem;
  border: 2px dashed var(--tint);
  border-radius: 12px;
  background: var(--bg-light);
}

/* --- 엑셀 드롭존 --- */
.excel-dropzone {
  padding: 2rem;
  border: 2px dashed var(--tint);
  border-radius: 12px;
  background: var(--bg-light);
  text-align: center;
  cursor: pointer;
  transition: all 0.2s;
}

.excel-dropzone:hover {
  border-color: #3B82F6;
  background: rgba(59, 130, 246, 0.03);
}

/* --- 모달 input (스캔/엑셀용) --- */
.modal-input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--tint);
  border-radius: 8px;
  font-size: 0.875rem;
  font-family: inherit;
  color: var(--brand);
  background: #fff;
}

.modal-input:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(44, 51, 68, 0.08);
}

/* --- 안전재고 긴급 뱃지 애니메이션 --- */
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.6; }
}
