/* =============================================================
   공용 컴포넌트 — 드로어 / 모달 / 폼 / 카드 / 칸반 / 토스트
   ============================================================= */

/* ---------- 드로어 ---------- */
.drawer {
  position: fixed; top: var(--navbar-h); right: 0; bottom: 0;
  width: min(560px, 94vw); background: var(--surface);
  border-left: 1px solid var(--card-border); box-shadow: -8px 0 28px rgba(16,18,32,.10);
  z-index: 50; overflow-y: auto; animation: slideIn .16s ease-out;
}
@keyframes slideIn { from { transform: translateX(18px); opacity: .4; } }
.drawer-scrim { position: fixed; inset: var(--navbar-h) 0 0 0; background: rgba(16,18,32,.16); z-index: 49; }
.drawer-head {
  position: sticky; top: 0; background: var(--surface); z-index: 2;
  border-bottom: 1px solid var(--card-border); padding: 16px 20px 12px;
  display: flex; align-items: flex-start; gap: 10px;
}
.drawer-head h2 { margin: 0; font-size: 17px; font-weight: 800; letter-spacing: -.02em; flex: 1; }
.drawer-close { border: 0; background: none; font-size: 20px; color: var(--muted); line-height: 1;
                padding: 0 4px; border-radius: 6px; }
.drawer-close:hover { background: var(--surface-2); color: var(--fg); }
.drawer-body { padding: 16px 20px 60px; }
.drawer-tabs { display: flex; gap: 2px; padding: 0 20px; border-bottom: 1px solid var(--card-border);
               overflow-x: auto; position: sticky; top: 61px; background: var(--surface); z-index: 2; }
.drawer-tabs button { border: 0; background: none; padding: 9px 12px; font-size: 12.5px;
                      font-weight: 600; color: var(--muted); border-bottom: 2px solid transparent;
                      white-space: nowrap; }
.drawer-tabs button[aria-selected="true"] { color: var(--accent); border-bottom-color: var(--accent); }

/* ---------- 모달 ---------- */
.modal-scrim { position: fixed; inset: 0; background: rgba(16,18,32,.32); z-index: 60; }
.modal {
  position: fixed; z-index: 61; left: 50%; top: 50%; transform: translate(-50%,-50%);
  width: min(600px, 94vw); max-height: 86vh; overflow: hidden;
  background: var(--surface); border-radius: var(--radius-lg); box-shadow: var(--shadow-3);
  display: flex; flex-direction: column;
}
.modal.wide { width: min(760px, 96vw); }
.modal-head { padding: 16px 20px 12px; border-bottom: 1px solid var(--card-border);
              display: flex; align-items: center; gap: 10px; }
.modal-head h2 { margin: 0; font-size: 16px; font-weight: 800; flex: 1; }
.modal-body { padding: 16px 20px; overflow-y: auto; flex: 1; }
.modal-foot { padding: 12px 20px; border-top: 1px solid var(--card-border);
              display: flex; gap: 8px; justify-content: flex-end; background: var(--surface); }

/* ---------- 버튼 ---------- */
.btn {
  border: 1px solid var(--card-border); background: var(--surface); color: var(--fg);
  border-radius: var(--radius-sm); padding: 7px 14px; font-weight: 600; font-size: 13px;
}
.btn:hover { background: var(--surface-2); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--accent); border-color: transparent; color: #fff; }
.btn-primary:hover { filter: brightness(1.06); background: var(--accent); }
.btn-danger { color: var(--danger); border-color: oklch(88% 0.06 25); }
.btn-danger:hover { background: oklch(97% 0.02 25); }
.btn-sm { padding: 4px 9px; font-size: 12px; }
.btn-ghost { border-color: transparent; background: none; color: var(--muted); }
.btn-ghost:hover { background: var(--surface-2); color: var(--fg); }

/* ---------- 폼 ---------- */
.field { margin-bottom: 14px; }
.field > label { display: block; font-size: 12px; font-weight: 700; color: var(--muted); margin-bottom: 5px; }
.field .hint { font-size: 11.5px; color: var(--faint); margin-top: 4px; }
.input, .select, .textarea {
  width: 100%; border: 1px solid var(--card-border); border-radius: var(--radius-sm);
  padding: 8px 10px; background: var(--surface); outline: none;
}
.input:focus, .select:focus, .textarea:focus { border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-weak); }
.textarea { min-height: 78px; resize: vertical; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.row > .grow { flex: 1; min-width: 120px; }
.checkline { display: flex; align-items: center; gap: 6px; font-size: 12.5px; }
.checkline input { margin: 0; }

/* 공개등급 셀렉터 */
.vis-picker { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.vis-picker button {
  border: 1px solid var(--card-border); background: var(--surface); border-radius: var(--radius-sm);
  padding: 8px 4px; font-size: 12px; font-weight: 600; color: var(--muted);
}
.vis-picker button[aria-pressed="true"] {
  border-color: var(--accent); background: var(--accent-weak); color: var(--accent);
}
.vis-desc { font-size: 11.5px; color: var(--muted); margin-top: 6px;
            background: var(--surface-2); border-radius: 6px; padding: 7px 9px; }

/* 알림 행 */
.rem-row { display: flex; gap: 6px; align-items: center; margin-bottom: 6px; flex-wrap: wrap; }
.rem-row .select { width: auto; min-width: 118px; }
.rem-targets { display: flex; gap: 10px; align-items: center; font-size: 12px; }
.rem-targets label { display: flex; align-items: center; gap: 4px; }
.rem-targets input:disabled + span { color: var(--faint); }

/* ---------- 구독 검색 ---------- */
.sub-search { position: relative; }
.sub-search input {
  width: 100%; border: 1px solid var(--card-border); border-radius: 10px;
  padding: 11px 12px 11px 36px; font-size: 14px; outline: none;
}
.sub-search input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-weak); }
.sub-search::before {
  content: '🔍'; position: absolute; left: 11px; top: 50%; transform: translateY(-50%);
  font-size: 14px; opacity: .55; pointer-events: none;
}
.sub-group-title {
  font-size: 11px; font-weight: 800; color: var(--faint); letter-spacing: .04em;
  padding: 14px 4px 6px;
}
.sub-item {
  display: flex; align-items: center; gap: 10px; padding: 8px 10px;
  border-radius: 9px; cursor: default;
}
.sub-item:hover, .sub-item.active { background: var(--surface-2); }
.avatar {
  width: 30px; height: 30px; min-width: 30px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700; color: #fff; background: var(--primary);
}
.avatar.dept  { background: var(--c3); border-radius: 8px; }
.avatar.cal   { background: var(--c5); border-radius: 8px; }
.avatar.campaign { background: var(--c8); border-radius: 8px; }
.sub-text { flex: 1; min-width: 0; }
.sub-label { font-weight: 600; font-size: 13px; }
.sub-sublabel { font-size: 11.5px; color: var(--muted); overflow: hidden;
                text-overflow: ellipsis; white-space: nowrap; }
.sub-empty { text-align: center; color: var(--faint); padding: 36px 10px; font-size: 13px; }

/* ---------- 카드 / 대시보드 ---------- */
.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 14px; }
.card {
  background: var(--surface); border: 1px solid var(--card-border);
  border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow-1);
}
.card > h3 { margin: 0 0 10px; font-size: 13.5px; font-weight: 800; letter-spacing: -.01em;
             display: flex; align-items: center; gap: 6px; }
.card .count-pill {
  background: var(--accent-weak); color: var(--accent); border-radius: 999px;
  padding: 1px 8px; font-size: 11px; font-weight: 700;
}
.card .count-pill.danger { background: oklch(96% 0.03 25); color: var(--danger); }
.list-row {
  display: flex; align-items: center; gap: 9px; padding: 7px 4px;
  border-bottom: 1px solid var(--line); cursor: pointer; border-radius: 6px;
}
.list-row:last-child { border-bottom: 0; }
.list-row:hover { background: var(--surface-2); }
.list-main { flex: 1; min-width: 0; }
.list-title { font-size: 13px; font-weight: 600; overflow: hidden;
              text-overflow: ellipsis; white-space: nowrap; }
.list-sub { font-size: 11px; color: var(--faint); }
.list-right { font-size: 11.5px; color: var(--muted); white-space: nowrap; }
.list-right.late { color: var(--danger); font-weight: 700; }

.progress { height: 6px; border-radius: 999px; background: var(--surface-2); overflow: hidden; }
.progress > i { display: block; height: 100%; background: var(--ok); border-radius: 999px; }
.progress.warn > i { background: var(--warn); }
.bar-row { display: flex; align-items: center; gap: 8px; padding: 3px 0; font-size: 12px; }
.bar-row .nm { width: 84px; min-width: 84px; overflow: hidden; text-overflow: ellipsis;
               white-space: nowrap; color: var(--muted); }
.bar-row .bar-outer { flex: 1; height: 8px; background: var(--surface-2); border-radius: 999px; }
.bar-row .bar-inner { height: 100%; background: var(--accent); border-radius: 999px; }

.badge {
  display: inline-block; font-size: 10.5px; font-weight: 700; padding: 2px 7px;
  border-radius: 999px; background: var(--surface-2); color: var(--muted);
}
.badge.ok    { background: oklch(95% 0.04 155); color: var(--ok); }
.badge.warn  { background: oklch(96% 0.05 70);  color: oklch(48% 0.13 70); }
.badge.danger{ background: oklch(96% 0.03 25);  color: var(--danger); }
.badge.info  { background: var(--accent-weak);  color: var(--accent); }

.empty-state { text-align: center; color: var(--faint); padding: 44px 12px; font-size: 13px; }

/* ---------- 칸반 ---------- */
.kanban { display: flex; gap: 12px; overflow-x: auto; padding-bottom: 12px; align-items: flex-start; }
.kb-col {
  min-width: 244px; width: 244px; background: var(--surface-2);
  border-radius: var(--radius); padding: 10px; max-height: 100%;
}
.kb-col.drop { outline: 2px dashed var(--accent); outline-offset: -2px; }
.kb-col h4 { margin: 0 0 8px; font-size: 12px; font-weight: 800; color: var(--muted);
             display: flex; justify-content: space-between; }
.kb-card {
  background: var(--surface); border: 1px solid var(--card-border); border-radius: 9px;
  padding: 9px 10px; margin-bottom: 7px; cursor: grab; box-shadow: var(--shadow-1);
}
.kb-card:active { cursor: grabbing; }
.kb-card .t { font-size: 12.5px; font-weight: 600; margin-bottom: 4px; }
.kb-card .m { font-size: 11px; color: var(--faint); display: flex; gap: 6px; flex-wrap: wrap; }

/* ---------- 테이블 ---------- */
.tbl-wrap { overflow-x: auto; border: 1px solid var(--card-border); border-radius: var(--radius);
            background: var(--surface); }
.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
.tbl th {
  text-align: left; padding: 9px 12px; font-size: 11.5px; font-weight: 700;
  color: var(--muted); border-bottom: 1px solid var(--card-border); white-space: nowrap;
  background: var(--surface-2); position: sticky; top: 0;
}
.tbl td { padding: 9px 12px; border-bottom: 1px solid var(--line); }
.tbl tr:last-child td { border-bottom: 0; }
.tbl tbody tr { cursor: pointer; }
.tbl tbody tr:hover { background: var(--surface-2); }

/* ---------- 컨텍스트 메뉴 / 팝오버 ---------- */
.popover {
  position: fixed; z-index: 70; background: var(--surface);
  border: 1px solid var(--card-border); border-radius: 10px;
  box-shadow: var(--shadow-3); padding: 5px; min-width: 190px;
}
.popover button, .popover a {
  display: flex; width: 100%; align-items: center; gap: 8px; border: 0; background: none;
  padding: 7px 10px; border-radius: 7px; font-size: 12.5px; text-align: left;
  color: var(--fg); text-decoration: none;
}
.popover button:hover, .popover a:hover { background: var(--surface-2); }
.popover hr { border: 0; border-top: 1px solid var(--line); margin: 4px 0; }
.swatches { display: grid; grid-template-columns: repeat(5, 1fr); gap: 5px; padding: 6px 8px; }
.swatches button { width: 20px; height: 20px; border-radius: 50%; border: 0; padding: 0; }

/* ---------- 토스트 ---------- */
.toast-wrap { position: fixed; left: 50%; bottom: 26px; transform: translateX(-50%);
              z-index: 100; display: flex; flex-direction: column; gap: 8px; align-items: center; }
.toast {
  background: var(--navbar-bg); color: #fff; padding: 9px 16px; border-radius: 999px;
  font-size: 12.5px; font-weight: 600; box-shadow: var(--shadow-3);
  animation: toastIn .16s ease-out;
}
.toast.err { background: var(--danger); }
@keyframes toastIn { from { transform: translateY(8px); opacity: 0; } }

/* ---------- 스켈레톤 ---------- */
.sk { background: linear-gradient(90deg, var(--surface-2) 25%, oklch(94% 0.005 260) 37%, var(--surface-2) 63%);
      background-size: 400% 100%; animation: skl 1.2s ease infinite; border-radius: 6px; }
@keyframes skl { from { background-position: 100% 0; } to { background-position: 0 0; } }

@media (max-width: 768px) {
  .drawer { width: 100vw; }
  .vis-picker { grid-template-columns: repeat(2, 1fr); }
}
