/* ===========================================================================
   피터패트 AI — 공통 테마
   라이트 팔레트는 main_color.md 기준. 다크는 같은 톤에서 파생.
   =========================================================================== */

:root,
[data-theme="light"] {
  --color-primary: #0134FF;
  --color-primary-hover: #0022cc;
  --color-primary-soft: #F4F7FF;
  --color-accent: #FFE229;
  --color-accent-hover: #ffd400;
  --color-surface: #FFFFFF;
  --color-surface-2: #F7F9FC;
  --color-bg: #EEF2F7;
  --color-text: #0B1B2A;
  --color-text-muted: #5B6B7B;
  --color-border: #D1D1D1;
  --color-border-soft: #E4E8EF;
  --color-border-strong: #0134FF;
  --color-error: #d90429;
  --color-success: #2d7a3e;

  --sidebar-bg: #0B1B2A;
  --sidebar-text: #C7D2E0;
  --sidebar-text-dim: #8290A3;
  --sidebar-active-bg: rgba(255, 255, 255, 0.08);

  --shadow-sm: 0 1px 2px rgba(11, 27, 42, 0.06), 0 1px 3px rgba(11, 27, 42, 0.05);
  --shadow-md: 0 4px 16px rgba(11, 27, 42, 0.08);
  --shadow-lg: 0 12px 40px rgba(11, 27, 42, 0.12);
  --primary-glow: rgba(1, 52, 255, 0.18);
}

[data-theme="dark"] {
  --color-primary: #5B7BFF;
  --color-primary-hover: #7A93FF;
  --color-primary-soft: rgba(91, 123, 255, 0.12);
  --color-accent: #FFE229;
  --color-accent-hover: #ffd400;
  --color-surface: #141C2B;
  --color-surface-2: #1B2536;
  --color-bg: #0A111E;
  --color-text: #E6ECF5;
  --color-text-muted: #93A1B5;
  --color-border: #28344A;
  --color-border-soft: #20293A;
  --color-border-strong: #5B7BFF;
  --color-error: #ff5a6a;
  --color-success: #4ade80;

  --sidebar-bg: #0E1626;
  --sidebar-text: #C7D2E0;
  --sidebar-text-dim: #6E7C92;
  --sidebar-active-bg: rgba(91, 123, 255, 0.16);

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 6px 20px rgba(0, 0, 0, 0.35);
  --shadow-lg: 0 16px 48px rgba(0, 0, 0, 0.5);
  --primary-glow: rgba(91, 123, 255, 0.35);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
}

body {
  font-family: "Pretendard", "Inter", -apple-system, BlinkMacSystemFont,
    "Apple SD Gothic Neo", "Segoe UI", sans-serif;
  background: var(--color-bg);
  color: var(--color-text);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  transition: background 0.3s ease, color 0.3s ease;
}

a { color: inherit; text-decoration: none; }

/* ---------- 레이아웃 ---------- */
.layout {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: 256px;
  flex-shrink: 0;
  background: var(--sidebar-bg);
  color: var(--sidebar-text);
  display: flex;
  flex-direction: column;
  padding: 22px 16px;
  position: sticky;
  top: 0;
  height: 100vh;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 6px 8px 22px;
}
.brand-mark {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--color-primary), #6f8bff);
  color: #fff;
  font-weight: 700;
  font-size: 22px;
  display: grid;
  place-items: center;
  box-shadow: 0 6px 16px var(--primary-glow);
  overflow: hidden;
}
.brand-mark img { width: 100%; height: 100%; display: block; object-fit: cover; }
.brand-text { display: flex; flex-direction: column; line-height: 1.2; }
.brand-name { font-weight: 700; font-size: 16px; color: #fff; }
.brand-sub {
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--sidebar-text-dim);
}

.nav { display: flex; flex-direction: column; gap: 4px; flex: 1; }
.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 12px;
  border-radius: 10px;
  color: var(--sidebar-text);
  font-size: 14.5px;
  font-weight: 500;
  transition: background 0.18s ease, color 0.18s ease, transform 0.18s ease;
}
.nav-item:hover { background: var(--sidebar-active-bg); transform: translateX(2px); }
.nav-item.active {
  background: var(--sidebar-active-bg);
  color: #fff;
  position: relative;
}
.nav-item.active::before {
  content: "";
  position: absolute;
  left: -16px;
  top: 50%;
  transform: translateY(-50%);
  width: 4px;
  height: 22px;
  border-radius: 0 4px 4px 0;
  background: var(--color-accent);
}
.nav-item.subtle { color: var(--sidebar-text-dim); }
.nav-icon { width: 22px; display: inline-flex; align-items: center; justify-content: center; }

/* Heroicons 인라인 SVG 기본 크기 (currentColor 상속) */
.hi { width: 20px; height: 20px; display: inline-block; vertical-align: middle; flex-shrink: 0; }
.icon-btn .hi { width: 19px; height: 19px; }
.stat-icon .hi { width: 26px; height: 26px; }
.dropzone-icon .hi { width: 46px; height: 46px; }
.file-chip .hi { width: 17px; height: 17px; }
.sidebar-foot { border-top: 1px solid rgba(255, 255, 255, 0.07); padding-top: 12px; }

.main { flex: 1; display: flex; flex-direction: column; min-width: 0; }

.topbar {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px 28px;
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border-soft);
  position: sticky;
  top: 0;
  z-index: 20;
}
.page-title { font-size: 20px; font-weight: 700; margin: 0; flex: 1; }
.topbar-actions { display: flex; gap: 8px; align-items: center; }

.icon-btn {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  border: 1px solid var(--color-border-soft);
  background: var(--color-surface-2);
  color: var(--color-text);
  cursor: pointer;
  font-size: 16px;
  display: grid;
  place-items: center;
  transition: background 0.18s ease, transform 0.12s ease;
}
.icon-btn:hover { background: var(--color-primary-soft); transform: translateY(-1px); }
.icon-btn:active { transform: translateY(0); }

.menu-toggle { display: none; }
.theme-icon-dark { display: none; }
[data-theme="dark"] .theme-icon-light { display: none; }
[data-theme="dark"] .theme-icon-dark { display: inline; }

.content { padding: 28px; max-width: 1180px; width: 100%; margin: 0 auto; }

/* ---------- 카드 ---------- */
.card {
  background: var(--color-surface);
  border: 1px solid var(--color-border-soft);
  border-radius: 16px;
  padding: 22px;
  box-shadow: var(--shadow-sm);
}
.card h2 { margin: 0 0 4px; font-size: 17px; }
.card-sub { color: var(--color-text-muted); font-size: 13px; margin: 0 0 16px; }

.grid { display: grid; gap: 18px; }
.grid.cols-4 { grid-template-columns: repeat(4, 1fr); }
.grid.cols-2 { grid-template-columns: repeat(2, 1fr); }

/* ---------- 통계 카드 ---------- */
.stat-card {
  position: relative;
  overflow: hidden;
}
.stat-card .stat-icon {
  position: absolute;
  right: 16px;
  top: 16px;
  font-size: 26px;
  opacity: 0.85;
}
.stat-label { color: var(--color-text-muted); font-size: 13px; font-weight: 500; }
.stat-value {
  font-size: 34px;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-top: 6px;
  font-family: "Inter", sans-serif;
}
.stat-foot { font-size: 12px; color: var(--color-text-muted); margin-top: 6px; }
.stat-card.accent { border-color: transparent; background: linear-gradient(135deg, var(--color-primary), #5b7bff); color: #fff; }
.stat-card.accent .stat-label,
.stat-card.accent .stat-foot { color: rgba(255, 255, 255, 0.85); }

/* ---------- 폼/버튼 ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 11px 18px;
  border: none;
  border-radius: 10px;
  background: var(--color-primary);
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.18s ease, transform 0.12s ease, box-shadow 0.18s ease;
}
.btn:hover { background: var(--color-primary-hover); box-shadow: 0 6px 18px var(--primary-glow); }
.btn:active { transform: translateY(1px); }
.btn:disabled { background: var(--color-text-muted); cursor: not-allowed; box-shadow: none; opacity: 0.7; }
.btn.secondary {
  background: transparent;
  color: var(--color-primary);
  border: 1.5px solid var(--color-primary);
}
.btn.secondary:hover { background: var(--color-primary-soft); box-shadow: none; }
.btn.ghost { background: transparent; color: var(--color-text-muted); }
.btn.ghost:hover { background: var(--color-surface-2); box-shadow: none; }
.btn.dark { background: var(--color-text); color: var(--color-surface); }

.input, .textarea {
  width: 100%;
  padding: 11px 13px;
  border: 1.5px solid var(--color-border);
  border-radius: 10px;
  background: var(--color-surface);
  color: var(--color-text);
  font-size: 15px;
  font-family: inherit;
  transition: border-color 0.18s ease, box-shadow 0.18s ease;
}
.input:focus, .textarea:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px var(--color-primary-soft);
}
.field-label { display: block; font-size: 13px; color: var(--color-text-muted); margin: 14px 0 6px; font-weight: 500; }

.hidden { display: none !important; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }

/* ---------- 진행바 ---------- */
.progress-track {
  height: 8px;
  border-radius: 999px;
  background: var(--color-border-soft);
  overflow: hidden;
}
.progress-fill {
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--color-primary), #6f8bff);
  transition: width 0.3s ease;
}
.progress-detail {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: var(--color-text-muted);
  margin-top: 8px;
  font-family: "Inter", monospace;
}

/* ---------- 알림/상태 ---------- */
.status-line {
  font-size: 14px;
  padding: 12px 14px;
  border-radius: 10px;
  background: var(--color-surface-2);
  border: 1px solid var(--color-border-soft);
}
.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  background: var(--color-primary-soft);
  color: var(--color-primary);
}

/* ---------- 회의록 단계 ---------- */
.steps { display: flex; flex-direction: column; gap: 18px; }
.sample {
  padding: 8px 12px;
  margin: 6px 0;
  border-left: 3px solid var(--color-primary);
  background: var(--color-surface-2);
  border-radius: 6px;
  font-size: 14px;
}
.markdown-editor {
  width: 100%;
  min-height: 460px;
  resize: vertical;
  border: 1.5px solid var(--color-border);
  border-radius: 12px;
  padding: 16px;
  background: var(--color-surface-2);
  color: var(--color-text);
  font-family: ui-monospace, "SF Mono", "Cascadia Code", monospace;
  font-size: 13px;
  line-height: 1.65;
}

/* ---------- 업로드 카드 접기 ---------- */
.upload-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  cursor: pointer;
  user-select: none;
}
.upload-head .chevron {
  color: var(--color-text-muted);
  margin-top: 2px;
  transition: transform 0.3s ease;
  flex-shrink: 0;
}
#upload-panel.collapsed .upload-head .chevron { transform: rotate(180deg); }
#upload-body { overflow: hidden; padding-top: 16px; }

/* ---------- 드롭존 ---------- */
.dropzone {
  position: relative;
  border: 2.5px dashed var(--color-border);
  border-radius: 18px;
  padding: 48px 28px;
  text-align: center;
  cursor: pointer;
  background: var(--color-surface-2);
  transition: border-color 0.2s ease, background 0.2s ease;
  overflow: hidden;
}
.dropzone:hover { border-color: var(--color-primary); }
.dropzone.dragover {
  border-color: var(--color-primary);
  background: var(--color-primary-soft);
}
.dropzone-icon {
  font-size: 46px;
  display: inline-block;
  will-change: transform;
}
.dropzone-title { font-size: 17px; font-weight: 600; margin-top: 10px; }
.dropzone-hint { color: var(--color-text-muted); font-size: 13px; margin-top: 4px; }
.dropzone .ripple {
  position: absolute;
  border-radius: 50%;
  background: var(--primary-glow);
  transform: scale(0);
  pointer-events: none;
}
.file-chip {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  margin-top: 16px;
  padding: 10px 16px;
  border-radius: 999px;
  background: var(--color-primary-soft);
  color: var(--color-primary);
  font-weight: 600;
  font-size: 14px;
}
.file-chip .remove { cursor: pointer; opacity: 0.7; }
.file-chip .remove:hover { opacity: 1; }

/* ---------- 차트 ---------- */
.chart-wrap { position: relative; height: 280px; }

.download-link {
  display: inline-flex;
  align-items: center;
  padding: 11px 18px;
  border-radius: 10px;
  background: var(--color-text);
  color: var(--color-surface);
  font-size: 14px;
  font-weight: 600;
}

/* ---------- 반응형 ---------- */
/* 모바일 사이드바 off-canvas 배경 */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  z-index: 35;
  opacity: 0;
  transition: opacity 0.25s ease;
}
.sidebar-overlay.show { display: block; opacity: 1; }

/* 태블릿 이하 — 사이드바를 off-canvas 로 */
@media (max-width: 960px) {
  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    z-index: 40;
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    box-shadow: var(--shadow-lg);
  }
  .sidebar.open { transform: translateX(0); }
  .menu-toggle { display: grid; }
  .content { padding: 20px; }
  .grid.cols-4 { grid-template-columns: repeat(2, 1fr); }
  .grid.cols-2 { grid-template-columns: 1fr; }
  .chart-wrap { height: 240px; }
}

/* 모바일(폰) */
@media (max-width: 600px) {
  .topbar { padding: 12px 16px; gap: 10px; }
  .page-title { font-size: 17px; }
  .content { padding: 14px; }
  .card { padding: 16px; border-radius: 14px; }
  .grid { gap: 14px; }
  .stat-value { font-size: 26px; }
  .stat-card .stat-icon { top: 14px; right: 14px; }
  .stat-card .stat-icon .hi { width: 22px; height: 22px; }
  .dropzone { padding: 30px 16px; }
  .dropzone-icon .hi { width: 40px; height: 40px; }
  .markdown-editor { min-height: 320px; }
  .btn { padding: 10px 14px; }
  .download-link { padding: 10px 14px; font-size: 13px; }
  h1 { font-size: 22px; }
  .card h2 { font-size: 16px; }
  /* 결과/문서 변환 액션이 좁은 화면에서 가로로 넘치지 않게 */
  .actions { flex-direction: column; align-items: stretch; }
  .actions .spacer { display: none; }
  .actions .btn, .actions .download-link { width: 100%; }
}

/* 아주 좁은 화면 — 통계 카드 1열 */
@media (max-width: 380px) {
  .grid.cols-4 { grid-template-columns: 1fr; }
}
