/* ── 공통 디자인 시스템 ── */
:root {
  --bg:         #1e1e2e;
  --bg2:        #27273a;
  --bg3:        #313145;
  --surface:    #2a2a3e;
  --border:     #3a3a52;
  --accent:     #7c6af7;
  --accent2:    #a78bfa;
  --text:       #e2e2f0;
  --text2:      #9090b0;
  --text3:      #5a5a7a;
  --danger:     #f87171;
  --success:    #4ade80;
  --warning:    #fbbf24;
  --sidebar-w:  56px;
  --titlebar-h: 38px;
  --radius:     10px;
  --radius-sm:  6px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'Malgun Gothic', 'Noto Sans KR', sans-serif;
  background: var(--bg);
  color: var(--text);
  height: 100vh;
  overflow: hidden;
  user-select: none;
}

/* ── 타이틀바 ── */
.titlebar {
  height: var(--titlebar-h);
  background: var(--bg);
  display: flex;
  align-items: center;
  padding: 0 12px;
  -webkit-app-region: drag;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.titlebar-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--text2);
  flex: 1;
}

.titlebar-controls {
  display: flex;
  gap: 6px;
  -webkit-app-region: no-drag;
}

.titlebar-btn {
  width: 28px;
  height: 22px;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 12px;
  background: transparent;
  color: var(--text2);
  transition: background 0.15s, color 0.15s;
  display: flex;
  align-items: center;
  justify-content: center;
}

.titlebar-btn:hover          { background: var(--bg3); color: var(--text); }
.titlebar-btn.close:hover    { background: var(--danger); color: #fff; }

/* ── 레이아웃 ── */
.app-layout {
  display: flex;
  height: calc(100vh - var(--titlebar-h));
}

/* ── 사이드바 ── */
.sidebar {
  width: var(--sidebar-w);
  background: var(--bg2);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 8px 0;
  flex-shrink: 0;
  overflow-y: auto;
  align-items: center;
}

.sidebar-group-label { display: none; }

.nav-item {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 11px 0;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  color: var(--text3);
  border-left: 3px solid transparent;
  position: relative;
}

.nav-item:hover {
  background: var(--bg3);
  color: var(--text2);
}

.nav-item.active {
  color: var(--accent2);
  border-left-color: var(--accent);
  background: var(--surface);
}

.nav-icon {
  width: 22px;
  height: 22px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.nav-icon svg {
  width: 22px;
  height: 22px;
  stroke: currentColor;
  fill: none;
}

.sidebar-divider {
  height: 1px;
  background: var(--border);
  margin: 6px 10px;
  width: calc(100% - 20px);
}

/* ── 메인 콘텐츠 ── */
.content {
  flex: 1;
  overflow: hidden;
  position: relative;
}

.tool-panel {
  display: none;
  width: 100%;
  height: 100%;
  overflow-y: auto;
  padding: 28px 32px;
  animation: fadeIn 0.15s ease;
}

.tool-panel.active { display: block; }

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── 공통 컴포넌트 ── */
.panel-title {
  font-size: 20px;
  font-weight: 800;
  color: var(--text);
  margin-bottom: 6px;
}

.panel-subtitle {
  font-size: 13px;
  color: var(--text2);
  margin-bottom: 24px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 16px;
}

.btn {
  padding: 8px 18px;
  border-radius: var(--radius-sm);
  border: none;
  cursor: pointer;
  font-size: 13px;
  font-weight: 700;
  transition: opacity 0.15s, transform 0.1s;
}

.btn:active { transform: scale(0.97); }

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

.btn-primary:hover { opacity: 0.85; }

.btn-ghost {
  background: var(--bg3);
  color: var(--text);
}

.btn-ghost:hover { background: var(--border); }

input[type="text"],
input[type="number"],
input[type="date"],
select {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 14px;
  padding: 8px 12px;
  outline: none;
  transition: border-color 0.2s;
  font-family: inherit;
}

input:focus, select:focus {
  border-color: var(--accent);
}

select option { background: var(--bg3); }

/* ── 웰컴 화면 ── */
.welcome {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: var(--text2);
  text-align: center;
  gap: 12px;
}

.welcome-icon { font-size: 56px; }
.welcome h2 { font-size: 20px; color: var(--text); }
.welcome p  { font-size: 13px; line-height: 1.7; }

/* ── 준비중 플레이스홀더 ── */
.coming-soon {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 60%;
  gap: 12px;
  color: var(--text3);
}

.coming-soon .icon { font-size: 48px; opacity: 0.5; }
.coming-soon p { font-size: 14px; }

/* 스크롤바 */
::-webkit-scrollbar { width: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text3); }

/* ── 라이트 모드 CSS 변수 ── */
html[data-theme="light"] {
  --bg:         #f5f7fa;
  --bg2:        #ffffff;
  --bg3:        #eaedf5;
  --surface:    #f0f2f8;
  --border:     #dde1ee;
  --text:       #1a1a2e;
  --text2:      #4a4a6a;
  --text3:      #8080a0;
}

/* ── 테마 토글 버튼 ── */
.sidebar-spacer { flex: 1; }
.theme-toggle-item {
  width: 100%; display: flex; align-items: center; justify-content: center;
  padding: 11px 0; cursor: pointer;
  transition: background 0.15s, color 0.15s;
  color: var(--text3); border-left: 3px solid transparent;
  border-top: 1px solid var(--border);
}
.theme-toggle-item:hover { background: var(--bg3); color: var(--text2); }
