/* ============================================================
   라엔텍 포털 공용 디자인 시스템 (portal-theme.css)
   ------------------------------------------------------------
   포털에 하드코딩되는 문서, 포털에서 링크되는 페이지가
   동일한 색·타이포·상단바·컴포넌트를 쓰도록 하는 단일 기준 파일.

   사용법 요약 (자세한 내용은 /DESIGN.md):
   1) <head>에  <link rel="stylesheet" href="/assets/portal-theme.css">
   2) 상단바는 DESIGN.md의 표준 마크업을 복사
   3) 다크모드 초기화 스크립트(DESIGN.md 참조)를 <body> 끝에 추가
   ------------------------------------------------------------
   ⚠ 이 파일이 유일한 원본(single source of truth)입니다.
     색/여백/컴포넌트를 바꿀 때는 각 문서가 아니라 이 파일만 수정하세요.
   ============================================================ */

/* === 디자인 토큰 (라이트) === */
:root {
  --bg: #ffffff;
  --surface: #ffffff;
  --surface-2: #f0f2f5;
  --border: #e2e5ea;
  --text: #1d2433;
  --text-muted: #6b7280;
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --danger: #ef4444;
  --warning: #f59e0b;
  --success: #10b981;
  --shadow-sm: 0 1px 2px rgba(0,0,0,.05);
  --shadow-md: 0 4px 12px rgba(0,0,0,.08);
  --shadow-lg: 0 10px 28px rgba(0,0,0,.16);
  --radius: 8px;
  --topbar-h: 56px;
  --maxw: 960px;              /* 본문 최대 폭 */
}

/* === 다크모드 — body.dark 로 토글 === */
body.dark {
  --bg: #1a1d24;
  --surface: #1a1d24;
  --surface-2: #232730;
  --border: #2d3340;
  --text: #e6e9ef;
  --text-muted: #8b94a3;
  --primary: #60a5fa;
  --primary-hover: #3b82f6;
  --danger: #f87171;
  --warning: #fbbf24;
  --success: #34d399;
  --shadow-sm: 0 1px 2px rgba(0,0,0,.4);
  --shadow-md: 0 4px 12px rgba(0,0,0,.5);
  --shadow-lg: 0 10px 28px rgba(0,0,0,.6);
  color-scheme: dark;
}

/* === 기본 === */
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; min-height: 100%; }
body {
  font-family: 'Pretendard', -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Malgun Gothic', sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
}
.hidden { display: none !important; }
a { color: var(--primary); }

/* === 버튼 === */
button, .btn {
  font-family: inherit; font-size: 13px;
  border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--surface); color: var(--text);
  padding: 7px 14px; cursor: pointer;
}
button:hover, .btn:hover { background: var(--surface-2); }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-danger-ghost { color: var(--danger); }
button:disabled, .btn:disabled { opacity: .5; cursor: default; }

/* === 입력 === */
input, select, textarea {
  font-family: inherit; font-size: 14px;
  background: var(--surface); color: var(--text);
  border: 1px solid var(--border); border-radius: var(--radius);
  padding: 9px 12px; outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--primary); }

/* === 상단바 (표준 마크업은 DESIGN.md 참조) === */
.topbar {
  height: var(--topbar-h);
  display: flex; align-items: center; gap: 12px;
  padding: 0 20px;
  border-bottom: 1px solid var(--border);
  background: color-mix(in srgb, var(--surface) 84%, transparent);
  backdrop-filter: blur(10px);
  position: sticky; top: 0; z-index: 10;
}
.topbar-brand {
  display: flex; align-items: center; gap: 12px;
  text-decoration: none; color: inherit;
  border-radius: var(--radius); padding: 4px 6px; margin-left: -6px;
  flex-shrink: 0;
}
.topbar-brand:hover { background: var(--surface-2); }
.topbar-logo { height: 28px; }
.topbar-title { font-size: 15.5px; font-weight: 700; white-space: nowrap; }
.topbar-date { color: var(--text-muted); font-size: 12.5px; white-space: nowrap; }
.topbar-spacer { flex: 1; }
.topbar button { white-space: nowrap; flex-shrink: 0; }
/* 사용자 칩 — 표시 전용 span, 또는 설정 여는 button(포털 메인) 공용 */
.topbar .user-chip {
  color: var(--text-muted); font-size: 13px;
  border: none; background: none; padding: 6px 10px;
  display: inline-flex; align-items: center; gap: 6px;
  white-space: nowrap;
}
.topbar .user-chip b { color: var(--text); font-weight: 700; }
.topbar button.user-chip { cursor: pointer; border-radius: var(--radius); }
.topbar button.user-chip:hover { background: var(--surface-2); }

/* === 본문 컨테이너 === */
.main {
  max-width: var(--maxw); margin: 0 auto;
  padding: 28px 20px 60px;
}

/* === 섹션 제목 (왼쪽 프라이머리 악센트 바) === */
.section-title {
  font-size: 16px; font-weight: 700;
  margin: 32px 0 12px;
  display: flex; align-items: center; gap: 10px;
}
.section-title:first-child { margin-top: 0; }
.section-title::before {
  content: '';
  width: 4px; height: 16px; border-radius: 2px;
  background: linear-gradient(180deg, var(--primary), color-mix(in srgb, var(--primary) 55%, transparent));
}
.section-title .count { color: var(--text-muted); font-weight: 400; font-size: 13px; }

/* === 카드 그리드 === */
.card-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 14px;
}
.card {
  background: var(--surface);
  border: 1px solid var(--border); border-radius: 14px;
  padding: 20px 18px;
  box-shadow: var(--shadow-sm);
}
/* 클릭 가능한 링크 카드 */
a.card, .card-link {
  display: block; text-decoration: none; color: inherit;
  transition: box-shadow .18s, transform .18s, border-color .18s;
}
a.card:hover, .card-link:hover {
  transform: translateY(-2px);
  border-color: color-mix(in srgb, var(--primary) 35%, var(--border));
  box-shadow: 0 14px 30px -14px color-mix(in srgb, var(--primary) 32%, rgba(0,0,0,.3));
}
.card-title { font-weight: 700; font-size: 15px; margin-bottom: 3px; }
.card-desc { color: var(--text-muted); font-size: 12.5px; }

/* === 상태 칩 === */
.chip {
  display: inline-block; padding: 2px 9px; border-radius: 20px;
  font-size: 11.5px; font-weight: 600;
}
.chip.ok      { background: color-mix(in srgb, var(--success) 15%, transparent); color: var(--success); }
.chip.pending { background: color-mix(in srgb, var(--warning) 18%, transparent); color: var(--warning); }
.chip.danger  { background: color-mix(in srgb, var(--danger) 15%, transparent); color: var(--danger); }
.chip.info    { background: color-mix(in srgb, var(--primary) 14%, transparent); color: var(--primary); }
.chip.muted   { background: var(--surface-2); color: var(--text-muted); }

/* === 테이블 === */
.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border); border-radius: 12px;
  box-shadow: var(--shadow-sm);
}
table { border-collapse: collapse; width: 100%; font-size: 13px; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border); white-space: nowrap; }
th {
  background: var(--surface-2); font-weight: 600; color: var(--text-muted);
  font-size: 11.5px; letter-spacing: .03em;
}
tbody tr { transition: background .12s; }
tbody tr:hover { background: color-mix(in srgb, var(--primary) 4%, transparent); }
tr:last-child td { border-bottom: none; }

/* === 빈 상태 === */
.empty-state {
  border: 1.5px dashed color-mix(in srgb, var(--text-muted) 35%, transparent);
  border-radius: 14px;
  padding: 64px 20px; text-align: center;
  color: var(--text-muted); font-size: 13.5px;
  background: color-mix(in srgb, var(--surface-2) 40%, transparent);
}

/* === 모달 === */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(0,0,0,.4);
  display: flex; align-items: center; justify-content: center;
  padding: 16px;
}
.modal {
  width: 100%; max-width: 340px;
  background: var(--surface);
  border: 1px solid var(--border); border-radius: 12px;
  box-shadow: var(--shadow-lg);
  padding: 24px;
}
.modal h3 { margin: 0 0 16px; font-size: 16px; }
.modal-btns { display: flex; gap: 8px; justify-content: flex-end; margin-top: 6px; }

/* === 모바일 (좁은 폭) === */
@media (max-width: 640px) {
  .topbar { gap: 6px; padding: 0 10px; }
  .topbar-brand { gap: 8px; padding: 4px; margin-left: -4px; }
  .topbar-logo { height: 24px; }
  .topbar-title { font-size: 14px; }
  .topbar-date { display: none; }
  .topbar button { padding: 6px 9px; font-size: 12px; }
  .topbar .user-chip { padding: 6px 6px; gap: 4px; }
  .topbar .user-chip #user-position { display: none; }  /* 좁은 폭: 이름만 */
  .main { padding: 18px 12px 48px; }
  .card-grid { grid-template-columns: 1fr; }
  /* iOS 입력창 포커스 자동 확대 방지 — 16px 미만이면 확대됨 */
  input, select, textarea { font-size: 16px; }
}
