/* components.css — 공통 UI 프리미티브.
 * 구 components/ui/*.tsx (shadcn + Radix) 를 대체한다. Radix 의존을 없애고
 * 실제로 쓰이던 variant 만 남겼다(button/input/textarea/popover/drawer).
 */

/* ── 버튼 ─────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 0 12px;
  height: 32px;
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  font-weight: 500;
  white-space: nowrap;
  transition: background-color 0.15s, color 0.15s, border-color 0.15s;
}

.btn-sm {
  height: 32px;
  padding: 0 12px;
  font-size: var(--text-sm);
}

.btn-primary {
  background: var(--primary);
  color: var(--primary-foreground);
}
.btn-primary:hover:not(:disabled) {
  background: color-mix(in oklab, var(--primary) 90%, var(--background));
}

.btn-outline {
  border: 1px solid var(--border);
  background: var(--background);
}
.btn-outline:hover:not(:disabled) {
  background: var(--accent);
}

.btn-ghost {
  color: var(--muted-foreground);
}
.btn-ghost:hover:not(:disabled) {
  background: var(--accent);
  color: var(--foreground);
}

/* 아이콘 전용 정사각 버튼 */
.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  flex-shrink: 0;
  border-radius: var(--radius-md);
  color: var(--muted-foreground);
  transition: background-color 0.15s, color 0.15s;
}
.icon-btn:hover:not(:disabled) {
  background: var(--accent);
  color: var(--foreground);
}

/* ── 입력 ─────────────────────────────────────────────────── */
.input,
.textarea {
  width: 100%;
  padding: 6px 10px;
  border: 1px solid var(--input);
  border-radius: var(--radius-md);
  background: var(--background);
  font-size: var(--text-sm);
  transition: border-color 0.15s, box-shadow 0.15s;
}

.input:focus-visible,
.textarea:focus-visible {
  outline: none;
  border-color: var(--ring);
  box-shadow: 0 0 0 3px color-mix(in oklab, var(--ring) 50%, transparent);
}

.input[aria-invalid="true"] {
  border-color: var(--destructive);
}

.textarea {
  resize: none;
  line-height: 1.5;
}

.form-error {
  font-size: var(--text-xs);
  color: var(--destructive);
}

/* ── 팝오버 ───────────────────────────────────────────────── */
/* 구 Radix Popover 대체. 위치는 사용처 CSS 가 지정하고, 여기서는 외형만. */
.popover {
  z-index: 60;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--popover);
  color: var(--popover-foreground);
  box-shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
}

.admin-panel {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.admin-panel-head {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.admin-panel-title {
  font-size: var(--text-sm);
  font-weight: 500;
}
.admin-panel-desc {
  font-size: var(--text-xs);
  color: var(--muted-foreground);
}
.admin-panel-fields {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* ── 출처 드로어 ──────────────────────────────────────────── */
/* 구 Radix Sheet(side="right") 대체. */
.drawer-overlay {
  position: fixed;
  inset: 0;
  z-index: 70;
  background: rgb(0 0 0 / 0.4);
}

.drawer {
  position: fixed;
  inset: 0 0 0 auto;
  z-index: 80;
  display: flex;
  flex-direction: column;
  width: 75%;
  max-width: 768px;
  background: var(--background);
  border-left: 1px solid var(--border);
  box-shadow: -4px 0 12px rgb(0 0 0 / 0.08);
  animation: drawer-in 0.2s ease;
}

@keyframes drawer-in {
  from { transform: translateX(100%); }
  to { transform: translateX(0); }
}

.drawer-header {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  flex-shrink: 0;
  padding: 16px;
  border-bottom: 1px solid var(--border);
}

.drawer-heading {
  min-width: 0;
  flex: 1;
}

.drawer-title {
  font-size: var(--text-base);
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.drawer-desc {
  margin-top: 2px;
  font-size: var(--text-sm);
  color: var(--muted-foreground);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.drawer-body {
  min-height: 0;
  flex: 1;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.drawer-empty {
  padding: 32px 0;
  text-align: center;
  font-size: var(--text-sm);
  color: var(--muted-foreground);
}

/* 드로어가 열려 있는 동안 배경 스크롤 잠금 */
body.drawer-open {
  overflow: hidden;
}

/* ── 드로어 안 출처 목록(list 모드) ───────────────────────── */
.source-list {
  display: flex;
  flex-direction: column;
}

.source-list-item {
  border-bottom: 1px solid var(--border);
}

.source-list-summary {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  font-size: var(--text-sm);
  cursor: pointer;
  list-style: none;
  transition: background-color 0.15s;
}
.source-list-summary::-webkit-details-marker { display: none; }
.source-list-summary:hover {
  background: color-mix(in oklab, var(--muted) 50%, transparent);
}

.source-list-name {
  min-width: 0;
  flex: 1;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.source-list-chevron {
  color: var(--muted-foreground);
  transition: transform 0.15s;
}
.source-list-item[open] .source-list-chevron {
  transform: rotate(180deg);
}

.source-list-content {
  border-top: 1px solid color-mix(in oklab, var(--border) 60%, transparent);
  background: color-mix(in oklab, var(--muted) 20%, transparent);
}

.source-document {
  padding: 16px;
}

.source-loading {
  padding: 16px;
  font-size: var(--text-sm);
  color: var(--muted-foreground);
}

.source-error {
  padding: 16px;
  font-size: var(--text-sm);
  color: var(--destructive);
}

/* ── 의견 보내기 모달 (opinion-modal.js) ────────────────────── */
.sidebar-item-button {
  width: 100%;
  background: none;
  border: none;
  cursor: pointer;
  font: inherit;
  text-align: left;
}

.opinion-overlay {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgb(0 0 0 / 0.45);
  padding: 16px;
}

.opinion-card {
  width: 100%;
  max-width: 440px;
  background: var(--card);
  color: var(--card-foreground);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
  box-shadow: 0 12px 32px rgb(0 0 0 / 0.25);
}

.opinion-title {
  margin: 0 0 12px;
  font-size: var(--text-lg, 1.05rem);
  font-weight: 700;
}

.opinion-label {
  margin: 10px 0 6px;
  font-size: var(--text-sm);
  color: var(--muted-foreground);
}

.opinion-label-inline { margin: 0; }

.opinion-cats { display: flex; gap: 6px; flex-wrap: wrap; }

.opinion-cat {
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: none;
  color: var(--foreground);
  font-size: var(--text-sm);
  cursor: pointer;
}

.opinion-cat.is-active {
  background: var(--foreground);
  color: var(--background);
  border-color: var(--foreground);
}

.opinion-textarea {
  width: 100%;
  resize: vertical;
  min-height: 110px;
  padding: 10px 12px;
  border: 1px solid var(--input);
  border-radius: 8px;
  background: var(--background);
  color: var(--foreground);
  font: inherit;
  font-size: var(--text-sm);
}

.opinion-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
}

.opinion-stars { display: flex; gap: 2px; }

.opinion-star {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 1.15rem;
  line-height: 1;
  color: var(--border);
  padding: 2px;
}

.opinion-star.is-active { color: #f5a623; }

.opinion-counter {
  margin-left: auto;
  font-size: var(--text-xs, 0.72rem);
  color: var(--muted-foreground);
}

.opinion-error {
  margin: 10px 0 0;
  font-size: var(--text-sm);
  color: var(--destructive);
}

.opinion-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 14px;
}

.opinion-done { text-align: center; padding: 18px 0 6px; }
.opinion-done-title { margin: 0 0 6px; font-weight: 700; }
.opinion-done-desc {
  margin: 0 0 16px;
  font-size: var(--text-sm);
  color: var(--muted-foreground);
}


/* ── 로그인 화면 (login-gate.js) ─────────────────────────────────────────── */
.login-overlay {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 1.5rem;
  background: var(--background);
  overflow-y: auto;
  z-index: 100;
}

.login-card {
  width: 100%;
  max-width: 26rem;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  padding: 2rem;
  background: var(--card, var(--background));
  border: 1px solid var(--border);
  border-radius: 0.75rem;
}

.login-head { display: flex; flex-direction: column; gap: 0.375rem; }
.login-eyebrow {
  margin: 0;
  font-size: 0.75rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted-foreground);
}
.login-title { margin: 0; font-size: 1.375rem; font-weight: 700; line-height: 1.3; }
.login-desc { margin: 0; font-size: 0.875rem; color: var(--muted-foreground); line-height: 1.6; }

.login-form { display: flex; flex-direction: column; gap: 1rem; }
.login-field { display: flex; flex-direction: column; gap: 0.375rem; }
.login-label { font-size: 0.8125rem; font-weight: 600; }
.login-input { width: 100%; }
.login-submit { width: 100%; }

.login-error {
  margin: 0;
  font-size: 0.8125rem;
  line-height: 1.5;
  color: var(--destructive, #b3261e);
}

.login-foot {
  margin: 0;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
  font-size: 0.75rem;
  line-height: 1.6;
  color: var(--muted-foreground);
}

/* 사이드바 계정 표시 */
.account-org { font-weight: 600; }
