/* ============================================
   HUB-SPECIFIC STYLES
   ============================================ */

/* application.html.erb의 <main> overflow-auto가 flex 높이 체인을 끊으므로 override */
main:has(.hub-layout) {
  overflow: hidden !important;
  flex: 1;
  display: flex;
  flex-direction: column;
}

.hub-layout {
  flex: 1;
  display: flex;
  overflow: hidden;
}

/* 거래처 패널 */
.partner-panel {
  width: 280px;
  background: white;
  border-right: 1px solid var(--tint);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}

.partner-search-box {
  padding: 0.75rem;
  border-bottom: 1px solid var(--tint);
}

.partner-search-box input {
  width: 100%;
  background: var(--background);
  border: 1px solid var(--tint);
  border-radius: 8px;
  padding: 0.5rem 0.75rem;
  font-size: 0.8125rem;
  color: var(--brand);
  transition: border-color 0.3s;
}

.partner-search-box input::placeholder { color: var(--light); }
.partner-search-box input:focus { outline: none; border-color: #3B82F6; }

.partner-list {
  flex: 1;
  overflow-y: auto;
}

.partner-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 0.625rem 0.75rem;
  cursor: pointer;
  border-left: 3px solid transparent;
  transition: all 0.2s;
}

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

.partner-item.active {
  background: rgba(59, 130, 246, 0.06);
  border-left-color: #3B82F6;
}

.partner-summary {
  padding: 0.75rem;
  border-top: 1px solid var(--tint);
  background: var(--background);
}

/* 상태 뱃지 */
.hub-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 0.6875rem;
  font-weight: 600;
}

.hub-badge-a { background: rgba(59,130,246,0.1); color: #2563EB; }
.hub-badge-b { background: rgba(100,116,139,0.15); color: #64748B; }
.hub-badge-c { background: rgba(245,158,11,0.15); color: #D97706; }

/* 채널 버튼 */
.ch-btn {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 0.375rem 0.625rem;
  font-size: 0.75rem;
  background: white;
  border: 1px solid var(--tint);
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s;
  color: var(--secondary);
}

.ch-btn:hover {
  border-color: #3B82F6;
  color: #3B82F6;
}

/* 탭 */
.hub-tab {
  padding: 0.375rem 0.75rem;
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--light);
  border-bottom: 2px solid transparent;
  cursor: pointer;
  transition: all 0.2s;
  background: none;
  border-top: none;
  border-left: none;
  border-right: none;
}

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

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

/* OCR 드롭존 */
.dropzone-area {
  margin: 0.75rem;
  padding: 1.5rem;
  border: 2px dashed var(--tint);
  border-radius: 12px;
  text-align: center;
  transition: all 0.3s;
}

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

/* Tabulator 오버라이드 (라이트 테마) */
.tabulator {
  background: white !important;
  border: 1px solid var(--tint) !important;
  border-radius: 8px !important;
  font-size: 13px !important;
}

.tabulator .tabulator-header {
  background: var(--background) !important;
  border-bottom: 1px solid var(--tint) !important;
}

.tabulator .tabulator-header .tabulator-col {
  background: var(--background) !important;
  border-right: 1px solid var(--tint) !important;
}

.tabulator .tabulator-header .tabulator-col .tabulator-col-content .tabulator-col-title {
  color: var(--tertiary) !important;
  font-weight: 600 !important;
  font-size: 11px !important;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.tabulator-row {
  border-bottom: 1px solid var(--tint) !important;
}

.tabulator-row.tabulator-row-even {
  background: white !important;
}

.tabulator-row.tabulator-row-odd {
  background: var(--background) !important;
}

.tabulator-row:hover {
  background: var(--bg-light) !important;
}

.tabulator-cell {
  border-right: 1px solid var(--tint) !important;
  color: var(--brand) !important;
}

.tabulator-cell.tabulator-editing input {
  background: white !important;
  color: var(--brand) !important;
  border: 1px solid #3B82F6 !important;
}

.tabulator-footer {
  background: var(--background) !important;
  border-top: 1px solid var(--tint) !important;
  color: var(--tertiary) !important;
}

/* 일괄모드 그룹 헤더 */
.tabulator-row.tabulator-group {
  background: var(--background) !important;
  border-bottom: 1px solid var(--tint) !important;
  min-height: 36px !important;
}
.tabulator-row.tabulator-group .tabulator-group-header {
  display: flex !important;
  align-items: center !important;
  padding: 6px 12px !important;
  font-size: 13px !important;
}

/* 개별/일괄 토글 */
.view-toggle-btn {
  padding: 3px 12px;
  font-size: 11px;
  font-weight: 600;
  border: none;
  background: transparent;
  color: var(--light);
  cursor: pointer;
  font-family: inherit;
  transition: all 0.15s;
}
.view-toggle-btn.active {
  background: #3B82F6;
  color: white;
}

/* 상세 패널 */
#detail-panel.open {
  width: 380px !important;
  border-left-width: 1px !important;
}
.hub-detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.hub-detail-grid .full {
  grid-column: 1 / -1;
}
.hub-detail-field {
  min-width: 0;
}
.hub-detail-field-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--light);
  margin-bottom: 3px;
}
.hub-detail-field-value {
  font-size: 13px;
  color: var(--brand);
  padding: 6px 10px;
  background: white;
  border: 1px solid var(--tint);
  border-radius: 6px;
  min-height: 32px;
  display: flex;
  align-items: center;
}
.hub-detail-field-value.mono {
  font-family: 'JetBrains Mono', monospace;
}
.hub-detail-field-input {
  font-size: 13px;
  color: var(--brand);
  padding: 6px 10px;
  background: white;
  border: 1px solid var(--tint);
  border-radius: 6px;
  min-height: 32px;
  width: 100%;
  outline: none;
  font-family: inherit;
}
.hub-detail-field-input:focus {
  border-color: #3B82F6;
}
.hub-detail-field-select {
  font-size: 13px;
  color: var(--brand);
  padding: 6px 10px;
  background: white;
  border: 1px solid var(--tint);
  border-radius: 6px;
  min-height: 32px;
  width: 100%;
  outline: none;
  font-family: inherit;
  cursor: pointer;
}
.hub-detail-field-select:focus {
  border-color: #3B82F6;
}
.hub-detail-section-title {
  font-size: 11px;
  font-weight: 700;
  color: var(--tertiary);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin: 14px 0 8px;
  padding-bottom: 4px;
  border-bottom: 1px solid var(--tint);
  grid-column: 1 / -1;
}
.hub-detail-section-title:first-child {
  margin-top: 0;
}
.detail-check-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 0;
}
.detail-check-row input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: #3B82F6;
  cursor: default;
  pointer-events: none;
}
.detail-check-row span {
  font-size: 13px;
  color: var(--brand);
}
.tabulator-row.detail-active {
  background: rgba(59,130,246,0.08) !important;
}

/* 숫자 오른쪽 정렬 */
.tabulator-cell[tabulator-field="unit_price"],
.tabulator-cell[tabulator-field="subtotal"],
.tabulator-cell[tabulator-field="width"],
.tabulator-cell[tabulator-field="height"],
.tabulator-cell[tabulator-field="glass_w"],
.tabulator-cell[tabulator-field="glass_h"],
.tabulator-cell[tabulator-field="qty"] {
  text-align: right !important;
  font-family: 'JetBrains Mono', monospace !important;
  font-size: 12px !important;
}

/* 변경된 셀 */
.cell-changed { background: rgba(245, 158, 11, 0.08) !important; }
.cell-uncertain { background: rgba(239, 68, 68, 0.08) !important; }

/* 단축키 뱃지 */
kbd {
  display: inline-block;
  padding: 1px 5px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  color: var(--light);
  background: var(--bg-light);
  border: 1px solid var(--tint);
  border-radius: 3px;
}

/* 하단 액션 바 */
.hub-action-bar {
  height: 56px;
  background: white;
  border-top: 1px solid var(--tint);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1rem;
  flex-shrink: 0;
}

.hub-action-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0.375rem 0.75rem;
  font-size: 0.75rem;
  background: white;
  border: 1px solid var(--tint);
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s;
  color: var(--secondary);
}

.hub-action-btn:hover {
  border-color: #3B82F6;
  color: #3B82F6;
}

.hub-action-btn.primary {
  background: #3B82F6;
  color: white;
  border-color: #3B82F6;
}

.hub-action-btn.primary:hover {
  background: #2563EB;
}

.hub-action-btn.danger:hover {
  border-color: #EF4444;
  color: #EF4444;
}

.hub-action-btn.warn:hover {
  border-color: #F59E0B;
  color: #D97706;
}

/* KPI 상단 바 */
.kpi-bar {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  padding: 0 1.5rem;
  height: 40px;
  background: white;
  border-bottom: 1px solid var(--tint);
  flex-shrink: 0;
  font-size: 0.75rem;
}

.kpi-bar .kpi-item {
  display: flex;
  align-items: center;
  gap: 0.375rem;
}

.kpi-bar .kpi-label { color: var(--light); }
.kpi-bar .kpi-value { font-family: 'JetBrains Mono', monospace; font-weight: 600; color: var(--brand); }
.kpi-bar .kpi-value.accent { color: #3B82F6; }
.kpi-bar .kpi-value.warn { color: #D97706; }

.kpi-bar .kpi-divider {
  width: 1px;
  height: 16px;
  background: var(--tint);
}

/* Ctrl+K 커맨드 팔레트 */
.cmd-overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: 20vh;
  background: rgba(0,0,0,0.4);
  backdrop-filter: blur(4px);
}

.cmd-overlay.hidden {
  display: none !important;
}

.cmd-box {
  width: 560px;
  background: white;
  border: 1px solid var(--tint);
  border-radius: 12px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.15);
  overflow: hidden;
}

.cmd-box input {
  width: 100%;
  padding: 0.75rem 1rem;
  border: none;
  border-bottom: 1px solid var(--tint);
  font-size: 0.875rem;
  color: var(--brand);
  background: transparent;
}

.cmd-box input::placeholder { color: var(--light); }
.cmd-box input:focus { outline: none; }

.cmd-results {
  max-height: 300px;
  overflow-y: auto;
  padding: 0.5rem;
}
.hub-toast {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  background: var(--brand);
  color: white;
  padding: 1rem 1.5rem;
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  z-index: 60;
  animation: slideIn 0.3s ease;
}

@keyframes slideIn {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

/* OCR 스캔 애니메이션 */
@keyframes scan-line {
  0% { top: 0%; }
  100% { top: 100%; }
}

.ocr-scanning { position: relative; }
.ocr-scanning::after {
  content: '';
  position: absolute;
  left: 0; right: 0;
  height: 2px;
  background: linear-gradient(90deg, transparent, #3B82F6, transparent);
  animation: scan-line 1.5s ease-in-out infinite;
}

::-webkit-scrollbar { width: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--tint); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--light); }

/* ============================================
   전화 메모 모달
   ============================================ */
.memo-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0,0,0,0.45);
  backdrop-filter: blur(4px);
}

.memo-overlay.hidden {
  display: none !important;
}

/* LEARNINGS: display:flex가 Tailwind hidden(display:none)을 덮어쓰므로 !important 필수 */
.memo-footer-actions.hidden {
  display: none !important;
}

.memo-modal {
  width: 860px;
  max-width: 95vw;
  max-height: 82vh;
  background: white;
  border-radius: 16px;
  box-shadow: 0 24px 80px rgba(0,0,0,0.18);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.memo-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--tint);
  background: var(--background);
}

.memo-header-title {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 1rem;
  font-weight: 700;
  color: var(--brand);
}

.memo-header-title i { color: #3B82F6; }

.memo-close {
  background: none;
  border: none;
  color: var(--light);
  font-size: 1.25rem;
  cursor: pointer;
  padding: 0.25rem;
  transition: color 0.2s;
}
.memo-close:hover { color: var(--brand); }

.memo-body {
  display: flex;
  flex: 1;
  overflow: hidden;
  min-height: 480px;
}

/* 좌측: 메모 입력 */
.memo-left {
  width: 300px;
  min-width: 260px;
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--tint);
  flex-shrink: 0;
}

.memo-left-header {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--tint);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.memo-left-label {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--tertiary);
}

.memo-textarea {
  flex: 1;
  padding: 1rem;
  border: none;
  resize: none;
  font-size: 0.9375rem;
  line-height: 1.8;
  color: var(--brand);
  background: white;
  font-family: 'Noto Sans KR', sans-serif;
}

.memo-textarea::placeholder { color: var(--tint); }
.memo-textarea:focus { outline: none; }

.memo-hint {
  padding: 0.625rem 1rem;
  background: var(--background);
  border-top: 1px solid var(--tint);
  font-size: 0.6875rem;
  color: var(--light);
  line-height: 1.6;
}

/* 우측: 파싱 결과 */
.memo-right {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: var(--background);
}

.memo-right-header {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--tint);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.memo-right-label {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--tertiary);
  display: flex;
  align-items: center;
  gap: 0.375rem;
}

.memo-right-label .ai-dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: #10B981;
  display: inline-block;
}

.memo-parsed-area {
  height: 450px;
  max-height: 450px;
  overflow-y: auto;
  padding: 1rem;
  flex-shrink: 0;
}

/* 우측: 폼 아이템 카드 */
.form-item {
  background: white;
  border: 1px solid var(--tint);
  border-radius: 10px;
  margin-bottom: 0.75rem;
  overflow: hidden;
  transition: border-color 0.2s;
}

.form-item:hover { border-color: #93b4f5; }

.form-item-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.5rem 0.75rem;
  background: var(--background);
  border-bottom: 1px solid var(--tint);
}

.form-item-num {
  font-size: 0.625rem;
  font-weight: 700;
  color: white;
  background: #3B82F6;
  width: 18px; height: 18px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.form-item-partner {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--brand);
  margin-left: 0.5rem;
}

.form-item-subtotal {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.75rem;
  font-weight: 600;
  color: #3B82F6;
}

.form-row {
  display: grid;
  gap: 1px;
  background: var(--tint);
}

.form-row + .form-row { border-top: 1px solid var(--tint); }
.form-row.r1 { grid-template-columns: 2fr repeat(5, 1fr); }
.form-row.r2 { grid-template-columns: repeat(7, 1fr); }
.form-row.r3 { display: flex; gap: 1px; background: var(--tint); }
.form-row.r4 { grid-template-columns: 2fr 1fr 1fr 2fr; }

.form-cell {
  background: white;
  padding: 0.375rem 0.5rem;
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-height: 44px;
}

.form-cell-label {
  font-size: 0.5625rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--light);
  font-weight: 600;
  white-space: nowrap;
}

.form-cell input,
.form-cell select {
  border: none;
  background: transparent;
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--brand);
  padding: 0;
  width: 100%;
  font-family: 'JetBrains Mono', monospace;
}

.form-cell input:focus,
.form-cell select:focus {
  outline: none;
  color: #3B82F6;
}

.form-cell input[type="checkbox"] {
  width: 14px;
  height: 14px;
  accent-color: #3B82F6;
  margin-top: 2px;
}

.form-cell.auto {
  background: var(--background);
}

.form-cell.auto input {
  color: var(--tertiary);
}

/* 빈 상태 */
.parsed-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  gap: 0.75rem;
  color: var(--light);
}

.parsed-empty i {
  font-size: 2.5rem;
  opacity: 0.3;
}

.parsed-empty-text {
  font-size: 0.875rem;
  text-align: center;
  line-height: 1.6;
}

/* 파싱 중 애니메이션 */
@keyframes pulse-dot {
  0%, 100% { opacity: 0.3; }
  50% { opacity: 1; }
}

.parsing-indicator {
  display: flex;
  align-items: center;
  gap: 0.375rem;
  font-size: 0.75rem;
  color: #3B82F6;
}

.parsing-indicator .dot {
  width: 4px; height: 4px;
  border-radius: 50%;
  background: #3B82F6;
  animation: pulse-dot 1s ease-in-out infinite;
}

.parsing-indicator .dot:nth-child(2) { animation-delay: 0.2s; }
.parsing-indicator .dot:nth-child(3) { animation-delay: 0.4s; }

/* 모달 푸터 */
.memo-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.875rem 1.5rem;
  border-top: 1px solid var(--tint);
  background: white;
}

.memo-footer-info {
  font-size: 0.75rem;
  color: var(--light);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.memo-footer-count {
  font-family: 'JetBrains Mono', monospace;
  font-weight: 600;
  color: var(--brand);
}

.memo-footer-actions {
  display: flex;
  gap: 0.5rem;
}

.memo-btn {
  padding: 0.5rem 1rem;
  font-size: 0.8125rem;
  font-weight: 600;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s;
  border: 1px solid var(--tint);
  background: white;
  color: var(--secondary);
}

.memo-btn:hover { border-color: var(--light); }

.memo-btn.primary {
  background: #3B82F6;
  color: white;
  border-color: #3B82F6;
}

.memo-btn.primary:hover { background: #2563EB; }

.memo-btn.primary:disabled,
.memo-btn.estimate:disabled {
  background: var(--tint);
  border-color: var(--tint);
  color: var(--light);
  cursor: not-allowed;
}

.memo-btn.estimate {
  border-color: #F59E0B;
  color: #D97706;
  background: white;
}

.memo-btn.estimate:hover {
  background: #FFFBEB;
  border-color: #D97706;
}

.memo-btn.as-claim {
  background: #EF4444;
  color: white;
  border-color: #EF4444;
}
.memo-btn.as-claim:hover { background: #DC2626; }
.memo-btn.as-claim:disabled {
  background: var(--tint);
  border-color: var(--tint);
  color: var(--light);
  cursor: not-allowed;
}

/* AS/클레임 모드 우측 패널 */
.as-mode-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 6px;
  background: #FEF2F2;
  color: #DC2626;
  font-size: 0.6875rem;
  font-weight: 700;
  letter-spacing: 0.3px;
}

.as-claim-card {
  background: white;
  border: 1px solid #FECACA;
  border-radius: 10px;
  margin-bottom: 0.75rem;
  overflow: hidden;
  transition: border-color 0.2s;
}
.as-claim-card:hover { border-color: #F87171; }

.as-claim-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.625rem 0.75rem;
  background: #FEF2F2;
  border-bottom: 1px solid #FECACA;
}

.as-claim-card-head .as-icon {
  width: 24px; height: 24px;
  border-radius: 6px;
  background: #EF4444;
  color: white;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.6875rem;
}

.as-claim-field {
  padding: 0.5rem 0.75rem;
  border-bottom: 1px solid #FEE2E2;
}
.as-claim-field:last-child { border-bottom: none; }

.as-claim-field label {
  display: block;
  font-size: 0.5625rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--light);
  font-weight: 600;
  margin-bottom: 2px;
}

.as-claim-field input,
.as-claim-field select,
.as-claim-field textarea {
  border: none;
  background: transparent;
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--brand);
  padding: 0;
  width: 100%;
  font-family: 'Noto Sans KR', sans-serif;
}
.as-claim-field input:focus,
.as-claim-field select:focus,
.as-claim-field textarea:focus { outline: none; color: #EF4444; }

.as-claim-field textarea {
  resize: none;
  min-height: 60px;
  line-height: 1.6;
}

.as-claim-field .as-field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1px;
  background: #FEE2E2;
  border-radius: 6px;
  overflow: hidden;
}

.as-claim-field .as-field-cell {
  background: white;
  padding: 0.375rem 0.5rem;
  display: flex;
  flex-direction: column;
  gap: 1px;
}

/* ===== Phase 11-4: 라인 단위 잠금 ===== */
.lock-icon-cell {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
}
.lock-icon-cell.locked {
  background: rgba(239,68,68,0.08);
  border-radius: 4px;
}
.tabulator .tabulator-row.row-locked {
  background: rgba(239,68,68,0.04) !important;
}
.tabulator .tabulator-row.row-locked:hover {
  background: rgba(239,68,68,0.08) !important;
}
.tabulator .tabulator-row.row-locked .tabulator-cell {
  color: var(--light);
}

