/* ============================================================
   cmdoctors — 디자인 시스템 (Phase 1, final_plan/05-design-system 구현)

   - Pretendard 폰트 (CDN)
   - 의료/인사 톤 (차분한 청색 + 청록 액센트)
   - 빌드 도구 X, composer X
   ============================================================ */

@import url('https://cdn.jsdelivr.net/gh/orioncactus/pretendard@v1.3.9/dist/web/variable/pretendardvariable.min.css');

:root {
  /* 폰트 */
  --font-sans: 'Pretendard Variable', Pretendard, -apple-system, BlinkMacSystemFont, system-ui,
               Roboto, 'Helvetica Neue', 'Segoe UI', 'Apple SD Gothic Neo', 'Noto Sans KR', 'Malgun Gothic', sans-serif;
  --font-mono: 'JetBrains Mono', 'Cascadia Code', 'Consolas', monospace;

  /* 타이포 */
  --text-xs:   0.75rem;
  --text-sm:   0.875rem;
  --text-base: 1rem;
  --text-lg:   1.125rem;
  --text-xl:   1.25rem;
  --text-2xl:  1.5rem;
  --text-3xl:  1.875rem;

  /* 표면 */
  --bg-base:        #ffffff;
  --bg-subtle:      #f8fafc;
  --bg-muted:       #f1f5f9;
  --bg-hover:       #f1f5f9;

  /* 테두리 */
  --border-default: #e2e8f0;
  --border-strong:  #cbd5e1;
  --border-focus:   #2563eb;

  /* 텍스트 */
  --text-strong:    #0f172a;
  --text-default:   #1e293b;
  --text-muted:     #64748b;
  --text-disabled:  #94a3b8;

  /* 브랜드 */
  --brand-50:  #eff6ff;
  --brand-100: #dbeafe;
  --brand-500: #3b82f6;
  --brand-600: #2563eb;
  --brand-700: #1d4ed8;
  --brand-900: #1e3a8a;

  /* 액센트 (청록) */
  --accent-500: #14b8a6;
  --accent-600: #0d9488;

  /* 시맨틱 */
  --success-500: #16a34a;
  --warn-500:    #d97706;
  --danger-500:  #dc2626;
  --danger-600:  #b91c1c;

  /* 잠금 */
  --locked-bg:     #f1f5f9;
  --locked-text:   #64748b;
  --locked-border: #cbd5e1;

  /* 간격 */
  --space-1:  0.25rem;
  --space-2:  0.5rem;
  --space-3:  0.75rem;
  --space-4:  1rem;
  --space-6:  1.5rem;
  --space-8:  2rem;
  --space-12: 3rem;

  /* 모서리 / 그림자 */
  --radius-sm: 4px;
  --radius-md: 6px;
  --radius-lg: 10px;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow-md: 0 4px 12px rgba(15, 23, 42, 0.08);
  --shadow-lg: 0 12px 32px rgba(15, 23, 42, 0.12);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: var(--text-base);
  color: var(--text-default);
  background: var(--bg-subtle);
  line-height: 1.6;
}

a { color: var(--brand-600); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3, h4 { color: var(--text-strong); line-height: 1.2; margin: 0 0 var(--space-3); }
h1 { font-size: var(--text-2xl); font-weight: 700; }
h2 { font-size: var(--text-xl); font-weight: 600; }
h3 { font-size: var(--text-lg); font-weight: 600; }

/* ============================================================
   상단바 (카테고리 탭 + 사용자 + 로그아웃)
   ============================================================ */
.topbar {
  background: var(--bg-base);
  border-bottom: 1px solid var(--border-default);
  padding: var(--space-3) var(--space-6);
  display: flex;
  align-items: center;
  gap: var(--space-6);
  position: sticky;
  top: 0;
  z-index: 50;
}
.topbar .logo {
  font-size: var(--text-lg);
  font-weight: 700;
  color: var(--brand-700);
  letter-spacing: -0.02em;
}
.topbar .spacer { flex: 1; }
.topbar .user {
  font-size: var(--text-sm);
  color: var(--text-muted);
}

/* 카테고리 탭 (의사 / 물리치료사 placeholder) */
.category-tabs {
  display: flex;
  gap: var(--space-1);
}
.category-tabs a,
.category-tabs .tab-disabled {
  padding: var(--space-2) var(--space-4);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--text-muted);
  text-decoration: none;
}
.category-tabs a:hover { background: var(--bg-hover); color: var(--text-default); }
.category-tabs a.active {
  background: var(--brand-600);
  color: white;
  font-weight: 600;
}
.category-tabs .tab-disabled {
  color: var(--text-disabled);
  background: var(--bg-muted);
  cursor: not-allowed;
}

/* 메뉴 탭 */
.nav-tabs {
  background: var(--bg-base);
  border-bottom: 1px solid var(--border-default);
  display: flex;
  gap: var(--space-1);
  padding: 0 var(--space-6);
}
.nav-tab {
  padding: var(--space-3) var(--space-4);
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--text-muted);
  border-bottom: 2px solid transparent;
  text-decoration: none;
}
.nav-tab.active { color: var(--brand-600); border-bottom-color: var(--brand-600); font-weight: 600; }
.nav-tab:hover { color: var(--text-default); text-decoration: none; }

/* ============================================================
   본문 페이지
   ============================================================ */
.page {
  max-width: 1280px;
  margin: 0 auto;
  padding: var(--space-6);
}
.page-wide { max-width: 100%; padding: var(--space-6); }

/* ============================================================
   버튼
   ============================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-4);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  font-weight: 500;
  font-family: var(--font-sans);
  cursor: pointer;
  transition: background 120ms;
  border: 1px solid transparent;
  text-decoration: none;
}
.btn-primary   { background: var(--brand-600); color: white; }
.btn-primary:hover { background: var(--brand-700); text-decoration: none; }
.btn-secondary { background: white; color: var(--text-default); border-color: var(--border-strong); }
.btn-secondary:hover { background: var(--bg-hover); text-decoration: none; }
.btn-danger    { background: white; color: var(--danger-600); border-color: var(--danger-500); }
.btn-danger:hover { background: var(--danger-500); color: white; text-decoration: none; }
.btn-ghost     { background: transparent; color: var(--brand-600); }
.btn-ghost:hover { background: var(--brand-50); text-decoration: none; }
.btn[disabled] { opacity: 0.5; cursor: not-allowed; }

/* ============================================================
   입력 폼
   ============================================================ */
.input, .select, textarea.input {
  width: 100%;
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-sm);
  font-size: var(--text-sm);
  font-family: var(--font-sans);
  background: white;
  color: var(--text-default);
}
.input:focus, .select:focus, textarea.input:focus {
  outline: none;
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}
.input[disabled], .select[disabled] {
  background: var(--bg-muted);
  color: var(--text-disabled);
  cursor: not-allowed;
}

label { display: block; font-size: var(--text-sm); font-weight: 500; margin-bottom: var(--space-1); color: var(--text-default); }

/* ============================================================
   카드
   ============================================================ */
.card {
  background: var(--bg-base);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  padding: var(--space-4);
  box-shadow: var(--shadow-sm);
}
.card-header {
  font-size: var(--text-lg);
  font-weight: 600;
  margin-bottom: var(--space-3);
  color: var(--text-strong);
}

/* ============================================================
   표 (스프레드시트형)
   ============================================================ */
.sheet {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--text-sm);
  background: white;
}
.sheet th, .sheet td {
  border: 1px solid var(--border-default);
  padding: var(--space-1) var(--space-2);
  text-align: right;
}
.sheet thead th {
  position: sticky; top: 0;
  background: var(--bg-subtle);
  font-weight: 600;
  text-align: center;
  z-index: 1;
}
.sheet tr:hover td { background: var(--bg-hover); }
.sheet tr.locked td { background: var(--locked-bg); color: var(--locked-text); }
.sheet td.preview { background: var(--brand-50); font-weight: 500; }
.sheet td.disabled-cell { background: var(--bg-muted); }
.sheet input[type="number"], .sheet input[type="text"] {
  border: none; background: transparent;
  width: 100%; text-align: right; padding: 0;
  font-family: var(--font-sans); font-size: inherit; color: inherit;
}
.sheet input[type="number"]:focus, .sheet input[type="text"]:focus {
  outline: 2px solid var(--brand-500);
  outline-offset: -2px;
}

/* 일반 표 */
.table {
  width: 100%; border-collapse: collapse; font-size: var(--text-sm); background: white;
}
.table th, .table td {
  border-bottom: 1px solid var(--border-default);
  padding: var(--space-3); text-align: left;
}
.table thead th { background: var(--bg-subtle); font-weight: 600; color: var(--text-strong); }
.table tr:hover td { background: var(--bg-hover); }

/* ============================================================
   배지/칩
   ============================================================ */
.badge {
  display: inline-flex; align-items: center;
  padding: 2px 8px;
  border-radius: 9999px;
  font-size: var(--text-xs);
  font-weight: 500;
  border: 1px solid transparent;
}
.badge-locked  { background: var(--locked-bg); color: var(--locked-text); border-color: var(--locked-border); }
.badge-warn    { background: #fef3c7; color: var(--warn-500); }
.badge-success { background: #dcfce7; color: var(--success-500); }
.badge-danger  { background: #fee2e2; color: var(--danger-600); }

/* ============================================================
   모달 / 토스트
   ============================================================ */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(15, 23, 42, 0.4);
  display: flex; align-items: center; justify-content: center;
  z-index: 1000;
}
.modal {
  background: white;
  border-radius: var(--radius-lg);
  padding: var(--space-6);
  max-width: 480px; width: 90%;
  box-shadow: var(--shadow-lg);
}
.modal-title { font-size: var(--text-xl); font-weight: 600; margin-bottom: var(--space-3); }
.modal-actions { display: flex; gap: var(--space-2); justify-content: flex-end; margin-top: var(--space-4); }

.toast-container { position: fixed; top: var(--space-4); right: var(--space-4); z-index: 2000; }
.toast {
  background: var(--text-strong);
  color: white;
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-md);
  margin-bottom: var(--space-2);
  box-shadow: var(--shadow-md);
  animation: toast-in 200ms ease-out;
  min-width: 240px;
}
.toast-success { background: var(--success-500); }
.toast-warn    { background: var(--warn-500); }
.toast-error   { background: var(--danger-500); }
@keyframes toast-in {
  from { opacity: 0; transform: translateY(-8px); }
  to   { opacity: 1; transform: none; }
}

/* ============================================================
   유틸
   ============================================================ */
.flex   { display: flex; align-items: center; gap: var(--space-3); }
.flex-c { display: flex; align-items: center; justify-content: center; }
.flex-b { display: flex; align-items: center; justify-content: space-between; }
.muted  { color: var(--text-muted); }
.right  { text-align: right; }
.mt-2 { margin-top: var(--space-2); } .mt-4 { margin-top: var(--space-4); } .mt-6 { margin-top: var(--space-6); }
.mb-2 { margin-bottom: var(--space-2); } .mb-4 { margin-bottom: var(--space-4); } .mb-6 { margin-bottom: var(--space-6); }
.gap-2 { gap: var(--space-2); } .gap-4 { gap: var(--space-4); }
.text-sm { font-size: var(--text-sm); }
.text-xs { font-size: var(--text-xs); }
.font-bold { font-weight: 700; }
.font-medium { font-weight: 500; }
.text-muted { color: var(--text-muted); }
.text-danger { color: var(--danger-600); }
.text-success { color: var(--success-500); }

/* ============================================================
   로그인 화면 전용
   ============================================================ */
.login-shell {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg-subtle);
}
.login-card {
  background: white;
  border-radius: var(--radius-lg);
  padding: var(--space-8);
  box-shadow: var(--shadow-lg);
  width: 100%; max-width: 420px;
}
.login-card h1 {
  text-align: center;
  margin-bottom: var(--space-6);
  color: var(--brand-700);
}
.login-card .subtitle {
  text-align: center; color: var(--text-muted);
  font-size: var(--text-sm);
  margin-bottom: var(--space-6);
}
.login-card .field { margin-bottom: var(--space-3); }
.login-card .error {
  background: #fee2e2; color: var(--danger-600);
  padding: var(--space-3); border-radius: var(--radius-sm);
  margin-bottom: var(--space-3); font-size: var(--text-sm);
}
.login-card .footer-note {
  margin-top: var(--space-6);
  text-align: center; font-size: var(--text-xs); color: var(--text-disabled);
}
