/* =========================================================
 * 5단계: 관리자 화면
 * ========================================================= */
body.no-scroll { overflow: hidden; }

.admin {
  position: fixed; inset: 0; z-index: 95; display: flex; flex-direction: column;
  background: #faf7fb; animation: adIn .25s ease;
}
@keyframes adIn { from { opacity: 0; transform: translateY(12px); } }
.admin__top {
  flex: none; display: flex; align-items: center; justify-content: space-between; gap: 12px;
  height: 64px; padding: 0 20px; background: var(--text); color: #fff;
}
.admin__top strong { font-size: 16px; }
.admin__top-btns { display: flex; gap: 8px; }
.admin__top .pill-btn { min-height: 36px; background: rgba(255, 255, 255, .1); border-color: rgba(255, 255, 255, .2); color: #fff; }
.admin__top .pill-btn:hover { background: rgba(255, 255, 255, .2); }
.admin__top .pill-btn--solid { background: #fff; color: var(--text); }
.admin__top .pill-btn--solid:hover { background: var(--pink-100); }

.admin__body { flex: 1; min-height: 0; display: grid; grid-template-columns: 220px 1fr; }
.admin__tabs { display: flex; flex-direction: column; gap: 4px; padding: 16px 12px; border-right: 1px solid var(--line); background: #fff; overflow-y: auto; }
.admin__tabs button {
  display: flex; align-items: center; gap: 10px; min-height: 44px; padding: 0 14px; border: 0; border-radius: 12px;
  background: none; font: inherit; font-size: 15px; font-weight: 600; color: var(--muted); cursor: pointer; text-align: left; white-space: nowrap;
}
.admin__tabs button:hover { background: var(--pink-50); color: var(--text); }
.admin__tabs button[aria-selected="true"] { background: linear-gradient(135deg, var(--pink-100), var(--lilac-100)); color: var(--text); font-weight: 800; }
.admin__main { overflow-y: auto; padding: 28px 32px 120px; }
.admin__main > * { max-width: 980px; }

.admin__save {
  position: fixed; left: 50%; bottom: 20px; z-index: 96; transform: translateX(-50%);
  display: flex; align-items: center; gap: 10px; width: max-content; max-width: calc(100% - 24px);
  padding: 10px 10px 10px 20px; border-radius: 999px; background: var(--text); color: #fff;
  box-shadow: 0 16px 40px rgba(58, 46, 63, .35); font-size: 14px; font-weight: 600;
}
.admin__save[hidden] { display: none; }
.admin__save .pill-btn { min-height: 40px; background: transparent; color: #fff; border-color: rgba(255,255,255,.3); }
.admin__save .btn { min-height: 40px; }

.ad-head { margin-bottom: 20px; }
.ad-head h2 { font-size: 24px; font-weight: 800; }
.ad-head p { margin-top: 4px; color: var(--muted); font-size: 14px; }
.ad-note { margin-bottom: 18px; padding: 12px 16px; border-radius: 14px; background: #fff7e6; border: 1px solid #ffe2a8; font-size: 14px; }
.ad-card { margin-bottom: 16px; padding: 20px 22px; border-radius: 20px; background: #fff; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 10px; align-items: flex-start; }
.ad-card h3 { font-size: 16px; font-weight: 800; }
.ad-card textarea, .ad-inline input, .admin-input {
  width: 100%; padding: 10px 14px; border-radius: 12px; border: 1.5px solid var(--line); font: inherit; font-size: 15px; background: #fff;
}
.ad-card textarea:focus, .ad-inline input:focus, .admin-input:focus, .ed input:focus, .ed textarea:focus { outline: none; border-color: var(--lilac-400); box-shadow: 0 0 0 4px var(--lilac-100); }
.ad-inline { display: flex; gap: 8px; width: 100%; }
.ad-inline input { flex: 1; min-width: 0; min-height: 42px; }
.ad-row { display: flex; flex-wrap: wrap; gap: 8px; }
.ad-card .drop { width: 100%; }
.ad-empty { padding: 30px; text-align: center; border-radius: 16px; border: 2px dashed var(--line); color: var(--muted); }
code { padding: 1px 6px; border-radius: 6px; background: var(--lilac-100); font-size: .92em; }

.ad-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 18px; }
.ad-chip { min-height: 38px; padding: 0 14px; border-radius: 999px; border: 1px solid var(--line); background: #fff; font: inherit; font-size: 14px; font-weight: 600; cursor: pointer; }
.ad-chip[aria-pressed="true"] { background: var(--text); color: #fff; border-color: var(--text); }

/* 범용 편집기 */
.ed { display: flex; flex-direction: column; gap: 14px; margin-bottom: 16px; }
.ed fieldset, .admin__main > fieldset { margin: 0; padding: 16px 18px 18px; border: 1px solid var(--line); border-radius: 18px; background: #fff; min-width: 0; }
.admin__main > fieldset { display: flex; flex-direction: column; gap: 10px; align-items: flex-start; }
.ed legend, .admin__main > fieldset > legend { padding: 0 6px; font-size: 15px; font-weight: 800; }
.ed legend small { font-weight: 600; color: var(--muted); margin-left: 4px; }
.ed-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 14px; width: 100%; }
.ed-fields > fieldset, .ed-field--wide, .ed-fields > .ed-add { grid-column: 1 / -1; }
.ed-field { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.ed-field label { font-size: 13px; font-weight: 700; color: var(--muted); }
.ed-field input, .ed-field textarea, .ed-prim input {
  width: 100%; min-height: 40px; padding: 8px 12px; border-radius: 10px; border: 1.5px solid var(--line); font: inherit; font-size: 14px; background: #fff;
}
.ed-field textarea { resize: vertical; }
.ed-hint { font-size: 12px; color: var(--muted); }
.ed-hint.is-ok { color: #23874f; font-weight: 700; }
.ed-hint.is-bad { color: #d23a3a; font-weight: 700; }
.ed-bool { display: flex; align-items: center; gap: 8px; font-size: 14px; font-weight: 600; }
.ed-bool input { width: 18px; height: 18px; accent-color: var(--pink-500); }
.ed-arr { display: flex; flex-direction: column; gap: 8px; }
.ed-item { border: 1px solid var(--line); border-radius: 14px; background: #fcfafd; }
.ed-item > summary { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 8px 10px 8px 14px; cursor: pointer; font-size: 14px; font-weight: 700; }
.ed-item > summary span:first-child { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ed-item > .ed-fields { padding: 4px 14px 14px; }
.ed-prim { display: flex; align-items: flex-end; gap: 8px; }
.ed-prim .ed-field { flex: 1; }
.ed-prim .ed-field label { display: none; }
.ed-tools { display: flex; gap: 4px; flex: none; }
.ed-tools button {
  width: 32px; height: 32px; border-radius: 8px; border: 1px solid var(--line); background: #fff; cursor: pointer; font-size: 13px; color: var(--muted);
}
.ed-tools button:hover:not(:disabled) { background: var(--pink-50); color: var(--text); }
.ed-tools button[data-act="del"]:hover { background: #fff1f1; color: #d23a3a; }
.ed-tools button:disabled { opacity: .35; cursor: default; }
.ed-add { align-self: flex-start; min-height: 36px; padding: 0 14px; border-radius: 10px; border: 1.5px dashed var(--lilac-200); background: none; font: inherit; font-size: 13px; font-weight: 700; color: var(--lilac-600); cursor: pointer; }
.ed-add:hover { background: var(--lilac-100); }
.ed-add--del { border-color: #ffc7d0; color: #d23a3a; }

/* 표 */
.ad-table-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 24px 0 10px; }
.ad-table-head h3 { font-size: 16px; font-weight: 800; }
.ad-table-wrap { overflow-x: auto; border-radius: 16px; background: #fff; box-shadow: var(--shadow); }
.ad-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.ad-table th, .ad-table td { padding: 10px 12px; border-bottom: 1px solid var(--line); text-align: left; white-space: nowrap; }
.ad-table th { position: sticky; top: 0; background: #fbf8fc; font-size: 13px; color: var(--muted); }
.ad-table tbody tr:last-child td { border-bottom: 0; }
.ad-table .td-long { white-space: normal; min-width: 220px; }
.tr-miss td { color: var(--muted); }
.ad-x { padding: 4px 10px; border-radius: 8px; border: 1px solid var(--line); background: #fff; font: inherit; font-size: 12px; cursor: pointer; color: var(--muted); }
.ad-x:hover { background: #fff1f1; border-color: #ffc7d0; color: #d23a3a; }
.ad-table--att th, .ad-table--att td { padding: 6px; text-align: center; }
.ad-table--att td:nth-child(-n+2), .ad-table--att th:nth-child(-n+2) { text-align: left; padding: 6px 10px; }
.at-cell { width: 30px; height: 30px; border-radius: 8px; border: 0; font: inherit; font-weight: 800; cursor: pointer; }
.at-ok { background: #eafaf1; color: #23874f; }
.at-miss { background: #fff1f1; color: #d23a3a; }
.at-todo { background: #f6f2f8; color: #b3a7b9; }
.ad-task { margin-bottom: 10px; border-radius: 16px; background: #fff; box-shadow: var(--shadow); }
.ad-task > summary { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; padding: 14px 18px; cursor: pointer; }
.ad-task > summary strong { flex: 1; min-width: 200px; }
.ad-task .ad-table-wrap { box-shadow: none; border-top: 1px solid var(--line); border-radius: 0 0 16px 16px; }
.ad-notice { display: flex; gap: 12px; align-items: flex-start; justify-content: space-between; margin-bottom: 8px; padding: 14px 18px; border-radius: 16px; background: #fff; box-shadow: var(--shadow); }
.ad-notice small { margin-left: 8px; color: var(--muted); }
.ad-notice p { margin-top: 4px; font-size: 14px; color: var(--muted); white-space: pre-line; }
.ad-bar { display: grid; grid-template-columns: 180px 1fr 100px; align-items: center; gap: 12px; width: 100%; font-size: 14px; }
.ad-bar__track { height: 14px; border-radius: 4px; background: #f6f2f8; overflow: hidden; }
.ad-bar__track i { display: block; height: 100%; border-radius: 0 4px 4px 0; background: linear-gradient(90deg, var(--pink-400), var(--lilac-400)); }
.ad-bar b { text-align: right; font-size: 13px; }

.ed-field[hidden] { display: none; }

/* 수업 일정 탭 */
.cal-form { align-items: stretch; }
.cal-form.is-editing { outline: 2px solid var(--pink-400); }
.cal-form h3 small { margin-left: 6px; font-weight: 600; }
.cal-form select, .ed-field select {
  width: 100%; min-height: 40px; padding: 8px 12px; border-radius: 10px; border: 1.5px solid var(--line); font: inherit; font-size: 14px; background: #fff;
}
.cf-del { color: #d23a3a; border-color: #ffc7d0; }
.cf-del:hover { background: #fff1f1; }
.cal-table .tr-month td { background: #fbf8fc; font-size: 13px; font-weight: 800; color: var(--lilac-600); padding: 8px 12px; }
.cal-table .tr-editing td { background: #fff4f8; }
.cal-table .td-date { font-weight: 700; }
.cal-table td small { display: block; margin-top: 2px; color: var(--muted); font-size: 12px; }
.cal-table .td-act { text-align: right; }
.cal-k { display: inline-block; padding: 3px 9px; border-radius: 999px; font-size: 12px; font-weight: 800; white-space: nowrap; }
.cal-k--class { background: var(--lilac-100); color: var(--lilac-600); }
.cal-k--exam { background: #fff1e0; color: #c8641c; }
.cal-k--off { background: #fff1f1; color: #d23a3a; }
.cal-k--event { background: #e6f4ff; color: #1f6fb2; }
.cal-k--due { background: var(--pink-100); color: var(--pink-500); }

/* 사이트 화면의 '편집' 버튼 — 관리자 모드일 때만 보임 */
.admin-edit {
  display: none; margin: 12px auto 0; min-height: 36px; padding: 0 16px; border-radius: 999px; cursor: pointer;
  border: 1.5px dashed var(--lilac-400); background: #fff; color: var(--lilac-600); font: inherit; font-size: 13px; font-weight: 800;
}
.admin-edit:hover { background: var(--lilac-100); }
body.is-admin .admin-edit { display: inline-flex; align-items: center; }
#schedule .admin-edit { margin: 0 0 0 10px; vertical-align: middle; }
.section__head .admin-edit { display: none; }
body.is-admin .section__head .admin-edit { display: inline-flex; }

/* 관리자 로그인 팝업 */
.admin-login .admin-input { margin-top: 16px; min-height: 48px; text-align: center; }
.admin-login .field__err { margin: 8px 0 0; }
.admin-login .modal__cta { margin-top: 14px; }
.shake { animation: shake .35s; }
@keyframes shake { 25% { transform: translateX(-8px); } 50% { transform: translateX(8px); } 75% { transform: translateX(-4px); } }

@media (max-width: 820px) {
  .admin__body { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
  .admin__tabs { flex-direction: row; padding: 8px 10px; overflow-x: auto; border-right: 0; border-bottom: 1px solid var(--line); scrollbar-width: none; }
  .admin__tabs::-webkit-scrollbar { display: none; }
  .admin__tabs button { min-height: 38px; padding: 0 12px; font-size: 14px; flex: none; }
  .admin__main { padding: 20px 16px 120px; }
  .ed-fields { grid-template-columns: 1fr; }
  .ad-bar { grid-template-columns: 1fr 70px; }
  .ad-bar .ad-bar__track { grid-column: 1 / -1; grid-row: 2; }
}
@media (max-width: 560px) {
  .admin__top { height: 56px; padding: 0 12px; }
  .admin__top strong { font-size: 14px; }
  .admin__top .pill-btn { padding: 0 12px; font-size: 13px; }
  .admin__save { flex-wrap: wrap; justify-content: center; border-radius: 20px; padding: 12px; text-align: center; }
  .admin__save span { width: 100%; }
}
