/* =============================================================================
   ExportHub V3 — main.css
   스택: Vanilla CSS (프레임워크 없음)
   기조: 텍스트 위주 고시인성 B2B 폐쇄몰 디자인
   참조: docs/02_PORTAL_OPERATOR.md (텍스트 위주 고시인성)
         docs/05_PORTAL_LOGISTICS.md (복잡성 최소화, 큰 버튼)
   ============================================================================= */

/* ── 1. CSS 변수 & 포탈 테마 ───────────────────────────────────────── */
:root {
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, .12);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, .15);
  --transition: 150ms ease;

  /* 공통 상태 컬러 */
  --color-danger: var(--c-red);
  --color-warning: var(--c-orange);
  --color-success: var(--c-green);
  --color-info: var(--c-blue);

  /* 기본(운영자) 테마 — 다크 네이비 */
  --topnav-bg: var(--c-navy-900);
  --topnav-text: var(--c-slate-100);
  --topnav-accent: var(--c-blue);
  --topnav-hover-bg: rgba(29, 78, 216, .15);
  --topnav-badge-bg: var(--c-red);
  --page-bg: var(--c-bg);
  --card-bg: var(--c-surface);
  --text-primary: var(--c-text);
  --text-secondary: var(--c-text-sub);
  --border-color: var(--c-border);
}

/* OPERATOR — 묵직한 네이비, 긴급 Red 포인트 */
.portal-operator {
  --topnav-bg: var(--c-navy-900);
  --topnav-text: var(--c-slate-100);
  --topnav-accent: var(--c-blue);
  --page-bg: var(--c-bg);
  --urgent-color: var(--c-red);
}

/* SUPPLIER — 차분한 슬레이트 블루 -> 네이비 800 */
.portal-supplier {
  --topnav-bg: var(--c-navy-800);
  --topnav-text: var(--c-slate-100);
  --topnav-accent: var(--c-blue);
  --page-bg: var(--c-bg);
}

/* BUYER — 딥 틸 */
.portal-buyer {
  --topnav-bg: var(--c-dark);
  --topnav-text: var(--c-surface);
  --topnav-accent: var(--c-green);
  --page-bg: var(--c-slate-100);
}

/* LOGISTICS — 밝은 회색 바탕, 굵은 검정 텍스트, 큰 버튼 */
.portal-logistics {
  --topnav-bg: var(--c-slate-100);
  --topnav-text: var(--c-text);
  --topnav-accent: var(--c-slate-600);
  --topnav-hover-bg: var(--c-slate-300);
  --page-bg: var(--c-surface);
  --text-primary: var(--c-text);
}

/* ── 2. 리셋 & 베이스 ──────────────────────────────────────────────── */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: var(--font-sans);
  background: var(--page-bg);
  color: var(--text-primary);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  line-height: 1.6;
}

a {
  color: var(--topnav-accent);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

img,
svg {
  display: block;
  max-width: 100%;
}

/* ── 3. 상단 내비게이션 바 ─────────────────────────────────────────── */
.topnav {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--topnav-bg);
  color: var(--topnav-text);
  box-shadow: var(--shadow-md);
  height: var(--gnb-h);
  flex-shrink: 0;
}

.topnav__inner {
  max-width: 1440px;
  margin: 0 auto;
  height: 100%;
  padding: 0 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

/* 브랜드 / 포탈명 */
.topnav__brand {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.topnav__logo {
  font-size: 13px;
  font-weight: 800;
  letter-spacing: .05em;
  background: var(--topnav-accent);
  color: #fff;
  border-radius: 4px;
  padding: 3px 7px;
  line-height: 1;
}

.topnav__portal-name {
  font-size: 15px;
  font-weight: 700;
  color: var(--topnav-text);
  letter-spacing: -.01em;
  white-space: nowrap;
}

/* 우측 액션 그룹 */
.topnav__actions {
  display: flex;
  align-items: center;
  gap: 4px;
}

/* 아이콘 버튼 (알림) */
.topnav__icon-btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: var(--radius);
  color: var(--topnav-text);
  transition: background var(--transition);
  text-decoration: none;
}

.topnav__icon-btn:hover {
  background: var(--topnav-hover-bg);
  text-decoration: none;
}

.topnav__icon {
  width: 22px;
  height: 22px;
  flex-shrink: 0;
}

/* 미읽음 배지 */
.topnav__badge {
  display: none;
  position: absolute;
  top: 5px;
  right: 5px;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  background: var(--topnav-badge-bg, #ef4444);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  border-radius: 8px;
  align-items: center;
  justify-content: center;
  line-height: 1;
  pointer-events: none;
}

/* 사용자명 */
.topnav__username {
  font-size: 13px;
  font-weight: 600;
  color: var(--topnav-text);
  padding: 0 8px;
  opacity: .85;
  white-space: nowrap;
  max-width: 140px;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* 로그아웃 버튼 */
.topnav__logout-btn {
  display: inline-flex;
  align-items: center;
  height: 34px;
  padding: 0 14px;
  border: 1px solid rgba(255, 255, 255, .2);
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 600;
  color: var(--topnav-text);
  transition: background var(--transition), border-color var(--transition);
  white-space: nowrap;
  text-decoration: none;
}

.topnav__logout-btn:hover {
  background: var(--topnav-hover-bg);
  border-color: rgba(255, 255, 255, .35);
  text-decoration: none;
}

.portal-logistics .topnav__logout-btn {
  border-color: #d1d5db;
  color: #374151;
}

/* ── 4. 플래시 메시지 ──────────────────────────────────────────────── */
.flash-container {
  position: fixed;
  top: 64px;
  right: 20px;
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: 400px;
}

.flash {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 16px;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 500;
  box-shadow: var(--shadow-md);
  animation: slideIn .2s ease;
}

@keyframes slideIn {
  from {
    opacity: 0;
    transform: translateX(20px);
  }

  to {
    opacity: 1;
    transform: translateX(0);
  }
}

.flash--error {
  background: #fef2f2;
  border-left: 4px solid var(--color-danger);
  color: #991b1b;
}

.flash--warning {
  background: #fff7ed;
  border-left: 4px solid var(--color-warning);
  color: #9a3412;
}

.flash--success {
  background: #f0fdf4;
  border-left: 4px solid var(--color-success);
  color: #166534;
}

.flash--info {
  background: #eff6ff;
  border-left: 4px solid var(--color-info);
  color: #1e40af;
}

.flash__close {
  margin-left: auto;
  flex-shrink: 0;
  background: none;
  border: none;
  cursor: pointer;
  font-size: 14px;
  opacity: .6;
  padding: 0 2px;
  line-height: 1;
}

.flash__close:hover {
  opacity: 1;
}

/* ── 5. 메인 콘텐츠 영역 ───────────────────────────────────────────── */
.main-content {
  flex: 1;
  width: 100%;
  max-width: 1440px;
  margin: 0 auto;
  padding: 28px 24px 48px;
}

/* ── 6. 카드 컴포넌트 ──────────────────────────────────────────────── */
.card {
  background: var(--card-bg);
  border-radius: 8px;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border-color);
}

.card__header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.card__title {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-primary);
}

.card__body {
  padding: 20px;
}

/* ── 7. KPI 카드 그리드 ────────────────────────────────────────────── */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
}

.kpi-card {
  background: var(--card-bg);
  border-radius: 8px;
  padding: 20px;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  gap: 8px;
  cursor: pointer;
  transition: box-shadow var(--transition), transform var(--transition);
  text-decoration: none;
  color: inherit;
}

.kpi-card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
  text-decoration: none;
}

.kpi-card__label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: .04em;
}

.kpi-card__value {
  font-size: 36px;
  font-weight: 800;
  color: var(--text-primary);
  line-height: 1;
}

.kpi-card--urgent .kpi-card__value {
  color: var(--color-danger);
}

.kpi-card--warning .kpi-card__value {
  color: var(--color-warning);
}

/* ── 8. 버튼 ───────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 38px;
  padding: 0 18px;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid transparent;
  transition: background var(--transition), opacity var(--transition);
  white-space: nowrap;
  text-decoration: none;
}

.btn:disabled {
  opacity: .45;
  cursor: not-allowed;
}

.btn--primary {
  background: var(--c-navy-800);
  color: #fff;
}

.btn--primary:hover {
  filter: brightness(1.1);
  text-decoration: none;
}

.btn--danger {
  background: var(--c-red);
  color: #fff;
}

.btn--danger:hover {
  filter: brightness(1.08);
  text-decoration: none;
}

.btn--secondary, .btn--ghost, .btn--outline {
  background: var(--c-surface);
  border-color: var(--c-navy-800);
  color: var(--c-navy-800);
}

.btn--secondary:hover, .btn--ghost:hover, .btn--outline:hover {
  background: var(--c-slate-100);
  text-decoration: none;
}

.btn--sm { height: 28px; padding: 0 10px; font-size: var(--fs-12); } /* 호환 별칭 (2026-10-24) */

/* 물류 포탈 — 큰 버튼 (05 §디자인 방침) */
.portal-logistics .btn {
  height: 52px;
  font-size: 16px;
  border-radius: 8px;
  min-width: 160px;
}

/* ── 9. 배지(상태 태그) ────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 9px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .03em;
  white-space: nowrap;
}

.badge--pending { background: var(--c-slate-100); color: var(--c-amber); }
.badge--approved { background: var(--c-slate-100); color: var(--c-green); }
.badge--rejected { background: var(--c-slate-100); color: var(--c-red); }
.badge--draft { background: var(--c-slate-100); color: var(--c-gray); }
.badge--inactive { background: var(--c-slate-100); color: var(--c-slate-600); }
.badge--discontinued { background: var(--c-slate-100); color: var(--c-dark); }
.badge--scrapped { background: var(--c-slate-100); color: var(--c-gray); border: 1px solid var(--c-border); }
.badge--review { background: var(--c-slate-100); color: var(--c-orange); }
/* 호환 별칭 (2026-10-24) — 정의 없이 쓰이던 옛 배지명을 §7 색에 연결. 신규 사용 금지(status_map.js 사용) */
.badge--success { background: var(--c-slate-100); color: var(--c-green); }
.badge--warning { background: var(--c-slate-100); color: var(--c-amber); }
.badge--danger { background: var(--c-slate-100); color: var(--c-red); }
.badge--info { background: var(--c-slate-100); color: var(--c-blue); }
.badge--primary { background: var(--c-slate-100); color: var(--c-navy-800); }
.badge--neutral,
.badge--secondary { background: var(--c-slate-100); color: var(--c-gray); }
.badge--outline { background: transparent; color: var(--c-text-sub); border: 1px solid var(--c-border); }

/* ── 10. 테이블 (SCM 와이드 테이블) ─────────────────────────────────── */
.table-wrap {
  overflow-x: auto;
  border-radius: var(--radius);
  border: 1px solid var(--c-border);
  background: var(--c-surface);
}

.tbl {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--fs-13);
}

.tbl th,
.tbl td {
  padding: 4px 8px; /* 가이드라인: 셀 패딩 4px 8px */
  text-align: left;
  border-bottom: 1px solid var(--c-border);
  height: var(--row-h); /* 행 높이 36px */
  vertical-align: middle;
}

.tbl th {
  font-size: var(--fs-12);
  font-weight: 700;
  color: var(--c-text-invert);
  background: var(--c-navy-800);
  white-space: nowrap;
  position: sticky;
  top: 0;
  z-index: 10;
}

.tbl tr:last-child td {
  border-bottom: none;
}

.tbl tbody tr:nth-child(even) {
  background: var(--c-slate-100); /* 짝수행 줄무늬 */
}

.tbl tbody tr:hover {
  background: rgba(29, 78, 216, 0.05); /* 호버 하이라이트 */
}

/* 호환 별칭 (2026-10-24) — 정의 없이 쓰이던 옛 표 클래스. 간격·너비는 .tbl과 같고, 머리줄은 화면별 인라인 색과
   충돌하지 않도록 밝은 배경+진한 글씨. 신규 화면은 .tbl 사용 (UX_UI_GUIDELINE §6.1) */
.table-responsive { overflow-x: auto; }
.table,
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--fs-13);
}
.table th, .table td,
.data-table th, .data-table td {
  padding: 4px 8px;
  text-align: left;
  border-bottom: 1px solid var(--c-border);
  height: var(--row-h);
  vertical-align: middle;
}
.table th,
.data-table th {
  font-size: var(--fs-12);
  font-weight: 700;
  color: var(--c-text);
  background: var(--c-slate-100);
  white-space: nowrap;
}
.table tbody tr:hover,
.data-table tbody tr:hover { background: rgba(29, 78, 216, 0.05); }
.table-bordered th, .table-bordered td { border: 1px solid var(--c-border); }

.font-mono {
  font-family: var(--font-mono) !important;
  font-size: var(--fs-13);
  letter-spacing: -0.02em;
}

.text-right { text-align: right !important; }
.text-center { text-align: center !important; }

/* ── 11. 폼 요소 ────────────────────────────────────────────────────── */
.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
}

.form-label--required::after {
  content: ' *';
  color: var(--color-danger);
}

.form-input,
.form-select,
.form-textarea,
.form-control {
  width: 100%;
  height: 40px;
  padding: 0 12px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  font-size: 14px;
  font-family: var(--font-sans);
  color: var(--text-primary);
  background: #fff;
  transition: border-color var(--transition), box-shadow var(--transition);
}

.form-textarea {
  height: auto;
  padding: 10px 12px;
  resize: vertical;
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus,
.form-control:focus {
  outline: none;
  border-color: var(--topnav-accent);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, .12);
}

.form-input[readonly],
.form-input:disabled {
  background: #f1f5f9;
  color: var(--text-secondary);
  cursor: not-allowed;
}

/* ── 12. 페이지 헤더 ───────────────────────────────────────────────── */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}

.page-header__title {
  font-size: 22px;
  font-weight: 800;
  color: var(--text-primary);
  letter-spacing: -.02em;
}

.page-header__subtitle {
  font-size: 13px;
  color: var(--text-secondary);
  margin-top: 2px;
}

/* ── 13. 로딩 스피너 ────────────────────────────────────────────────── */
.spinner {
  width: 24px;
  height: 24px;
  border: 3px solid var(--border-color);
  border-top-color: var(--topnav-accent);
  border-radius: 50%;
  animation: spin .7s linear infinite;
  flex-shrink: 0;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* ── 14. 빈 상태 (Empty State) ─────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--text-secondary);
}

.empty-state__icon {
  font-size: 40px;
  margin-bottom: 12px;
}

.empty-state__text {
  font-size: 15px;
  font-weight: 500;
}

/* ── 15. 반응형 ─────────────────────────────────────────────────────── */
@media (max-width: 768px) {
  .topnav__inner {
    padding: 0 16px;
  }

  .topnav__username {
    display: none;
  }

  .main-content {
    padding: 16px 16px 40px;
  }

  .kpi-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .page-header {
    flex-direction: column;
    align-items: flex-start;
  }
}

@media (max-width: 480px) {
  .kpi-grid {
    grid-template-columns: 1fr;
  }
}
/* ── 16. 물류 포탈 세로 태블릿 (UX 기준서 §5 F1, 2026-12-02) — 768px부터 가로 스크롤 없이, 1024px 미만은 LNB 접기 ── */
.portal-logistics .lnb-toggle,
.portal-logistics .lnb-backdrop { display: none; }
.portal-logistics .portal-main { min-width: 0; }
.portal-logistics input:not([type="checkbox"]):not([type="radio"]):not([type="hidden"]):not([type="file"]),
.portal-logistics select,
.portal-logistics .form-control,
.portal-logistics .form-input,
.portal-logistics .form-select { min-height: 48px; }
.portal-logistics .btn { min-height: 48px; }
.portal-logistics .btn--sm { height: auto; min-height: 48px; padding: 0 14px; font-size: 14px; }
.portal-logistics .table-wrap,
.portal-logistics .table-responsive { max-width: 100%; overflow-x: auto; }

@media (max-width: 1023px) {
  .portal-logistics .lnb-toggle {
    display: inline-flex; align-items: center; justify-content: center;
    position: fixed; top: 2px; left: 8px; z-index: 110;
    height: 48px; min-width: 88px; padding: 0 14px;
    border: 1px solid var(--c-border); border-radius: 8px;
    background: var(--c-surface); color: var(--c-text);
    font-size: 16px; font-weight: 700; cursor: pointer;
  }
  .portal-logistics .topnav__brand { padding-left: 100px; }
  .portal-logistics .portal-sidebar {
    position: fixed; top: var(--gnb-h); left: 0; bottom: 0; z-index: 120;
    overflow-y: auto; transform: translateX(-100%); transition: transform .2s ease;
  }
  .portal-logistics.lnb-open .portal-sidebar { transform: translateX(0); }
  .portal-logistics .lnb-backdrop { position: fixed; inset: var(--gnb-h) 0 0 0; z-index: 115; background: rgba(0, 0, 0, .4); }
  .portal-logistics.lnb-open .lnb-backdrop { display: block; }
  .portal-logistics .portal-nav__item { min-height: 48px; }
  .portal-logistics .portal-main { padding: 16px !important; width: 100%; }
}

/* ── 17. 목록 한 줄 36px·말줄임(.tbl--compact)과 페이지 나누기 줄(.eh-pager) (UX 기준서 Priority 2·§5·§6.1, 2026-12-02) ── */
.tbl--compact td { max-width: 260px; height: var(--row-h); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tbl--compact td.num, .tbl--compact td.text-right, .tbl--compact td.tbl-noclip { max-width: none; }
.tbl--compact td.tbl-noclip { overflow: visible; white-space: normal; }
.tbl--compact td > .badge, .tbl--compact td > .btn { vertical-align: middle; }
.eh-pager { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding: 8px 4px; font-size: var(--fs-13); color: var(--c-text-sub); }
.eh-pager__nav { display: inline-flex; align-items: center; gap: 8px; }
.eh-pager__btn { height: 32px; padding: 0 12px; border: 1px solid var(--c-border); border-radius: var(--radius); background: var(--c-surface); color: var(--c-text); font-size: var(--fs-13); cursor: pointer; }
.eh-pager__btn:disabled { opacity: .45; cursor: not-allowed; }
.portal-logistics .eh-pager__btn { height: 48px; min-width: 88px; }

/* 금액·수량 칸: 오른쪽 정렬 + 고정폭 숫자 (UX 리뷰 §6-14) */
.col-num { text-align: right; font-family: var(--font-mono); font-variant-numeric: tabular-nums; }

/* 표가 넓어도 페이지 전체가 가로로 넘치지 않게 — flex 자식은 min-width:0이어야 안쪽 .table-wrap이 스크롤된다 (UX 기준서 §5) */
.portal-main, .main-content { min-width: 0; }
