@import url('design-tokens.css');
/* design-tokens.css에서 Pretendard 폰트 + 디자인 토큰 import */

/* ── Lucide 아이콘 공통 스타일 (이모지 대체) ── */
.ico, i[data-lucide], svg.lucide {
  display: inline-block;
  width: 1em;
  height: 1em;
  vertical-align: -0.15em;
  stroke-width: 2;
  flex-shrink: 0;
}

:root {
  /* ESDS는 design-tokens.css의 토큰을 기본으로 사용.
     아래는 ESDS 코드 호환을 위한 별칭(alias) 변수 매핑 */
  --bg:            #f7f6f1;          /* page bg */
  --surface-hover: #fafaf6;
  --border-strong: #d2cdc0;
  --text:          #1a1a1a;
  --text-muted:    #666666;
  --text-subtle:   #aaaaaa;

  --primary:       #1e2761;          /* 변경: 보라 → 네이비 */
  --primary-hover: #161d4a;
  --primary-soft:  #eef0f8;
  --primary-text:  #1e2761;

  --success:       #10b981;
  --success-soft:  #e7f7f1;
  --warn:          #b45309;
  --warn-soft:     #fdf3e0;
  --danger:        #e05050;
  --danger-soft:   #fde8e8;

  --accent:        #d4a72c;
  --accent-hover:  #b9901e;

  --radius-sm: 8px;
  --radius:    12px;
  --radius-lg: 16px;

  --shadow-xs: 0 1px 1px rgba(17,24,39,.03);
  --shadow-sm: 0 1px 3px rgba(0,0,0,.04), 0 1px 2px rgba(0,0,0,.06);
  --shadow-md: 0 4px 12px rgba(0,0,0,.08);
  --shadow-lg: 0 12px 32px -8px rgba(17,24,39,.12), 0 4px 12px rgba(17,24,39,.06);

  --ease: cubic-bezier(.22,.61,.36,1);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: 'Pretendard', -apple-system, BlinkMacSystemFont, system-ui, 'Apple SD Gothic Neo', sans-serif;
  font-feature-settings: "ss01", "tnum";
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  background: var(--bg);
  color: var(--text);
  font-size: 14.5px;
  line-height: 1.6;
  letter-spacing: -0.01em;
  word-break: keep-all;
  overflow-wrap: break-word;
}
h1, h2, h3, h4, h5, h6 { word-break: keep-all; overflow-wrap: break-word; line-height: 1.3; letter-spacing: -0.02em; }

a { color: var(--primary); text-decoration: none; transition: color .15s var(--ease); }
a:hover { color: var(--primary-hover); }
button, input, select, textarea { font-family: inherit; font-size: inherit; letter-spacing: inherit; }
code { font-family: 'SF Mono', ui-monospace, Menlo, monospace; font-size: 12.5px; background: #f3f3f5; padding: 2px 6px; border-radius: 6px; color: #444; }

/* ═════ Topbar ═════ */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 28px;
  background: rgba(255,255,255,.72);
  backdrop-filter: saturate(180%) blur(14px);
  -webkit-backdrop-filter: saturate(180%) blur(14px);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 20;
}
.topbar .brand {
  font-weight: 700; font-size: 16px; letter-spacing: -0.02em;
  color: var(--text);
  display: flex; align-items: center; gap: 8px;
}
.topbar .brand::before {
  content: ''; width: 20px; height: 20px; border-radius: 6px;
  background: linear-gradient(135deg, #1e2761 0%, #2c3a8a 100%);
  box-shadow: 0 2px 8px rgba(30,39,97,.3);
}
.topbar nav a {
  margin-left: 20px; color: var(--text-muted); font-size: 13.5px; font-weight: 500;
}
.topbar nav a:hover { color: var(--text); }
.topbar .right { display: flex; align-items: center; gap: 12px; }
.topbar .right .user { font-size: 13px; color: var(--text-muted); font-weight: 500; }

/* ═════ Layout ═════ */
.container { max-width: 1160px; margin: 32px auto 60px; padding: 0 28px; }
.narrow { max-width: 440px; margin: 80px auto 60px; padding: 0 24px; }

/* ═════ Card ═════ */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px 26px;
  margin-bottom: 16px;
  box-shadow: var(--shadow-xs);
  transition: box-shadow .2s var(--ease);
}
.card h2 {
  margin: 0 0 6px;
  font-size: 20px; font-weight: 700; letter-spacing: -0.02em;
}
.card h2 + p { margin-top: 0; }
.card h3 {
  margin: 18px 0 12px;
  font-size: 14px; font-weight: 600; color: var(--text);
  letter-spacing: -0.01em;
}

/* ═════ Category grid (대시보드) ═════ */
.grid-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 14px;
}
.cat-card {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px 22px;
  display: block;
  color: inherit;
  overflow: hidden;
  transition: all .2s var(--ease);
  box-shadow: var(--shadow-xs);
}
.cat-card::after {
  content: ''; position: absolute; top: 0; left: 0; right: 0; height: 2px;
  background: linear-gradient(90deg, var(--primary), var(--accent));
  opacity: 0; transition: opacity .2s var(--ease);
}
.cat-card:hover {
  border-color: var(--border-strong);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  text-decoration: none;
}
.cat-card:hover::after { opacity: 1; }
.cat-card .name { font-weight: 600; font-size: 15px; margin-bottom: 6px; letter-spacing: -0.01em; }
.cat-card .desc { font-size: 13px; color: var(--text-muted); min-height: 38px; line-height: 1.5; }
.cat-card .count {
  margin-top: 12px; font-size: 12px; color: var(--primary-text);
  font-weight: 500; display: inline-flex; align-items: center; gap: 4px;
}
.cat-card .count::before {
  content: '';
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--primary);
}

/* ═════ Form ═════ */
label { display: block; margin-bottom: 7px; font-size: 13px; font-weight: 500; color: var(--text); }
input[type=text], input[type=email], input[type=password], input[type=number],
input[type=url], input[type=tel], input[type=date], select, textarea {
  width: 100%;
  padding: 10px 13px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  font-size: 14px;
  background: var(--surface);
  color: var(--text);
  transition: border-color .15s var(--ease), box-shadow .15s var(--ease);
}
textarea { min-height: 88px; resize: vertical; line-height: 1.55; }
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(91,91,214,.15);
}
input::placeholder, textarea::placeholder { color: var(--text-subtle); }
.field { margin-bottom: 14px; }
.field .req { color: var(--danger); margin-left: 3px; font-weight: 600; }

/* 비밀번호 보기/숨기기 토글 */
.input-wrap { position: relative; }
.input-wrap > input[type="password"],
.input-wrap > input[type="text"] { width: 100%; padding-right: 64px; box-sizing: border-box; }
.input-eye {
  position: absolute; right: 8px; top: 50%; transform: translateY(-50%);
  min-width: 48px;
  background: transparent; border: 0; padding: 4px 8px; cursor: pointer;
  font-size: 12.5px; color: var(--text-subtle); border-radius: 4px;
}
.input-eye:hover { color: var(--text); background: rgba(0,0,0,0.04); }

/* ═════ Buttons ═════ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 10px 18px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 600;
  letter-spacing: -0.01em;
  background: var(--primary);
  color: #fff;
  cursor: pointer;
  transition: all .15s var(--ease);
  box-shadow: var(--shadow-xs);
}
.btn:hover { background: var(--primary-hover); box-shadow: var(--shadow-sm); }
.btn:active { transform: translateY(0); box-shadow: var(--shadow-xs); }

.btn.secondary {
  background: var(--surface);
  color: var(--text);
  border-color: var(--border-strong);
}
.btn.secondary:hover { background: var(--surface-hover); border-color: #c4c4cc; color: var(--text); }

.btn.primary {
  background: var(--primary);
  color: #fff;
}
.btn.primary:hover { background: var(--primary-hover); }

.btn.danger { background: var(--danger); color: #fff; }
.btn.danger:hover { background: #b91c1c; }

.btn.sm { padding: 6px 11px; font-size: 12.5px; }

/* ═════ Table ═════ */
table {
  width: 100%; border-collapse: separate; border-spacing: 0;
  font-size: 13.5px;
}
th, td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: middle;
}
th {
  background: transparent;
  font-weight: 500;
  color: var(--text-muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  border-bottom: 1px solid var(--border-strong);
}
tbody tr { transition: background .12s var(--ease); }
tbody tr:hover td { background: var(--surface-hover); }
tbody tr:last-child td { border-bottom: 0; }
td code { font-size: 12px; }

/* ═════ Badge ═════ */
.badge {
  display: inline-flex; align-items: center;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 500;
  letter-spacing: 0;
  line-height: 1.4;
  border: 1px solid transparent;
}
.badge.gray   { background: #f3f3f5;       color: #52525b; border-color: #e6e6eb; }
.badge.green  { background: var(--success-soft); color: var(--success); border-color: #c4eccf; }
.badge.red    { background: var(--danger-soft);  color: var(--danger);  border-color: #f5c8c8; }
.badge.yellow { background: var(--warn-soft);    color: var(--warn);    border-color: #f0d990; }

/* ═════ Msg ═════ */
.msg {
  padding: 11px 14px;
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  margin: 12px 0;
  display: flex; align-items: flex-start; gap: 8px;
  line-height: 1.5;
}
.msg.err  { background: var(--danger-soft);  color: var(--danger);  border: 1px solid #f5c8c8; }
.msg.ok   { background: var(--success-soft); color: var(--success); border: 1px solid #c4eccf; }

/* ═════ Auth ═════ */
.auth-top-brand {
  display: flex; align-items: center; justify-content: center; gap: 9px;
  font-size: 18px; font-weight: 700; letter-spacing: -0.02em;
  color: var(--text);
  margin-bottom: 24px;
  transition: opacity .15s var(--ease);
}
.auth-top-brand::before {
  content: ''; width: 22px; height: 22px; border-radius: 7px;
  background: linear-gradient(135deg, #1e2761 0%, #2c3a8a 100%);
  box-shadow: 0 2px 8px rgba(30,39,97,.3);
}
.auth-top-brand:hover { color: var(--text); text-decoration: none; opacity: .75; }

body.admin-auth .auth-top-brand { color: #fff; }
body.admin-auth .auth-top-brand:hover { color: #fff; }

.auth-box {
  background: var(--surface);
  padding: 36px 32px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-lg);
}
.auth-box h1 {
  margin: 0 0 24px;
  font-size: 22px; font-weight: 700; letter-spacing: -0.025em;
  text-align: center;
}
.auth-box .footnote {
  text-align: center; margin-top: 18px;
  font-size: 13px; color: var(--text-muted);
}

/* ═════ Utility ═════ */
.row { display: flex; gap: 12px; flex-wrap: wrap; }
.row > * { flex: 1; min-width: 140px; }
.muted { color: var(--text-muted); font-size: 13px; line-height: 1.6; }
.right-align { text-align: right; }

/* ═════ Hero (랜딩) ═════ */
.hero {
  padding: 72px 0 40px;
  text-align: center;
}
.hero .eyebrow {
  display: inline-block;
  padding: 4px 12px;
  background: var(--primary-soft);
  color: var(--primary-text);
  border-radius: 999px;
  font-size: 12px; font-weight: 500;
  margin-bottom: 18px;
}
.hero h1 {
  font-size: 44px; font-weight: 800;
  letter-spacing: -0.035em; line-height: 1.1;
  margin: 0 0 16px;
  color: var(--text);
}
.hero p {
  font-size: 16px; color: var(--text-muted);
  max-width: 580px; margin: 0 auto 28px; line-height: 1.6;
}
.hero .cta { display: flex; justify-content: center; gap: 10px; flex-wrap: wrap; }

.feature-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 14px; margin-top: 28px;
}
.feature {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
}
.feature .ic {
  width: 36px; height: 36px; border-radius: 10px;
  background: var(--primary-soft); color: var(--primary-text);
  display: flex; align-items: center; justify-content: center;
  font-size: 18px; font-weight: 600; margin-bottom: 14px;
}
.feature h4 { margin: 0 0 6px; font-size: 15px; font-weight: 600; letter-spacing: -0.01em; }
.feature p  { margin: 0; font-size: 13px; color: var(--text-muted); line-height: 1.55; }

/* ═════ Dialog ═════ */
dialog {
  border: 0;
  border-radius: var(--radius-lg);
  padding: 0;
  width: 480px; max-width: 92vw;
  box-shadow: var(--shadow-lg);
  background: var(--surface);
}
dialog::backdrop { background: rgba(10,10,10,.35); backdrop-filter: blur(2px); }
dialog .dlg-head {
  padding: 16px 22px;
  border-bottom: 1px solid var(--border);
  font-weight: 600; font-size: 15px; letter-spacing: -0.01em;
}
dialog .dlg-body { padding: 22px; }
dialog .dlg-foot {
  padding: 14px 22px;
  border-top: 1px solid var(--border);
  text-align: right;
  display: flex; justify-content: flex-end; gap: 8px;
  background: #fafafb;
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}

/* ═════ Scrollbar ═════ */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #d4d4db; border: 2px solid var(--bg); border-radius: 6px; }
::-webkit-scrollbar-thumb:hover { background: #b4b4bc; }

/* ═════ Responsive — 태블릿 ═════ */
@media (max-width: 900px) {
  .container { padding: 0 18px; margin: 24px auto 40px; }
  .hero { padding: 56px 0 32px; }
  .hero h1 { font-size: 36px; }
}

/* ═════ Responsive — 모바일 ═════ */
@media (max-width: 640px) {
  body { font-size: 14px; }

  /* 상단바 */
  .topbar {
    padding: 12px 16px;
    flex-wrap: wrap;
    gap: 8px;
  }
  .topbar .brand { font-size: 15px; }
  .topbar nav { display: flex; flex-wrap: wrap; }
  .topbar nav a { margin-left: 12px; font-size: 13px; }
  .topbar nav a:first-child { margin-left: 0; }
  .topbar .right .user {
    max-width: 100px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  /* 컨테이너 */
  .container { margin: 18px auto 40px; padding: 0 14px; }
  .narrow { margin: 32px auto 40px; padding: 0 14px; }

  /* 카드 */
  .card { padding: 18px 16px; border-radius: 12px; margin-bottom: 12px; }
  .card h2 { font-size: 17px; }

  /* Hero */
  .hero { padding: 32px 0 20px; }
  .hero h1 { font-size: 26px; letter-spacing: -0.03em; }
  .hero p { font-size: 14px; margin-bottom: 22px; }
  .hero .cta { flex-direction: column; width: 100%; }
  .hero .cta .btn { width: 100%; }

  /* Feature / Cat grid */
  .grid-cards, .feature-grid { grid-template-columns: 1fr; gap: 10px; }
  .cat-card { padding: 16px 18px; }

  /* 폼 row: 한 줄 세로 스택 */
  .row { flex-direction: column; gap: 0; }
  .row > * { flex: 1 1 auto; min-width: 0; }

  /* Auth box */
  .auth-box { padding: 26px 22px; }
  .auth-box h1 { font-size: 19px; }

  /* 테이블: 카드 내부에서 가로 스크롤 */
  .card { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .card > table, .card table { min-width: 520px; }
  th, td { padding: 10px 12px; font-size: 13px; }
  th { font-size: 11px; }

  /* 버튼 */
  .btn { padding: 9px 14px; font-size: 13.5px; }
  .btn.sm { padding: 5px 9px; font-size: 12px; }

  /* Dialog */
  dialog { width: 94vw; border-radius: 14px; }
  dialog .dlg-body { padding: 18px; }

  /* 상단 로그아웃 버튼이 옆으로 안 밀리게 */
  .topbar .right { gap: 8px; }
}

/* 매우 작은 화면 */
@media (max-width: 380px) {
  .hero h1 { font-size: 22px; }
  .topbar nav a { margin-left: 10px; font-size: 12px; }
  .card { padding: 16px 14px; }
}

/* ════════════════════════════════════════════
   📱 모바일 안전망 (Mobile Safety Net)
   • 4개 사이트 공통 — 안 짤리고 다 보이게
═══════════════════════════════════════════ */

/* 전역 안전 */
*, *::before, *::after { box-sizing: border-box; }
html, body { max-width: 100vw; }
body { overflow-x: hidden; }
img, video, iframe, embed, object { max-width: 100%; height: auto; }
table { max-width: 100%; }
pre, code { overflow-x: auto; max-width: 100%; word-break: break-all; }

/* 가로 스크롤 헬퍼 (래퍼에 추가하면 안에 큰 테이블이 들어가도 OK) */
.table-wrap, .responsive-table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  max-width: 100%;
}

/* 긴 문자열 강제 줄바꿈 (URL, 영문 단어 등이 화면 밖으로 튀어나가는 것 방지) */
.break-word { word-break: break-word; overflow-wrap: anywhere; }

/* iOS Safari 입력 줌 방지 (16px 미만이면 입력 시 자동 확대됨) */
@media (max-width: 768px) {
  input:not([type="checkbox"]):not([type="radio"]):not([type="range"]),
  select, textarea {
    font-size: 16px !important;
    max-width: 100%;
  }
  button { max-width: 100%; }
}

/* ── 태블릿·작은 데스크탑 (≤768px) ────────── */
@media (max-width: 768px) {
  body { font-size: 14px; }

  /* 큰 헤딩 축소 */
  h1, .h1 { font-size: clamp(18px, 5vw, 24px) !important; line-height: 1.3; }
  h2, .h2 { font-size: clamp(16px, 4vw, 20px) !important; line-height: 1.35; }
  h3, .h3 { font-size: clamp(14px, 3.5vw, 17px) !important; }

  /* 흔한 컨테이너 패턴 — 좌우 패딩 축소 (max-width는 강제하지 않음) */
  .container, .wrap, [class$="-wrap"]:not([class*="dropzone"]):not([class*="chat"]) {
    padding-left: clamp(10px, 4vw, 16px);
    padding-right: clamp(10px, 4vw, 16px);
  }
  /* 모달·다이얼로그 풀폭 */
  dialog, .modal, [class*="-modal"] {
    width: calc(100vw - 24px) !important;
    max-width: calc(100vw - 24px) !important;
    margin: 12px auto !important;
  }

  /* 절대 위치 요소 보호 (뷰포트 밖으로 못 나가게) */
  [style*="position:absolute"], [style*="position: absolute"] {
    max-width: 100vw;
  }
}

/* ── 모바일 (≤480px) ────────────────────── */
@media (max-width: 480px) {
  body { font-size: 13px; }

  /* 컨테이너 패딩 더 축소 */
  .container, .wrap, [class$="-wrap"] {
    padding-left: 10px !important;
    padding-right: 10px !important;
  }

  /* 카드 패딩 축소 */
  .card, [class$="-card"]:not([class*="lucide"]):not(.tp-card) {
    padding: 12px !important;
  }

  /* 그리드 → 1열 강제 (data-mobile-stack 속성 또는 .grid 같은 클래스가 있을 때만) */
  [data-mobile-stack="1"],
  [data-mobile-stack] {
    grid-template-columns: 1fr !important;
    flex-direction: column !important;
  }

  /* 헤딩 더 축소 */
  h1, .h1 { font-size: 20px !important; }
  h2, .h2 { font-size: 17px !important; }

  /* 버튼 풀폭 옵션 */
  .btn-block, .full-mobile { width: 100% !important; }
}

/* ── 매우 좁은 폰 (≤360px) ──────────────── */
@media (max-width: 360px) {
  body { font-size: 12.5px; }
  .container, .wrap { padding-left: 8px !important; padding-right: 8px !important; }
}
