/* ============================================================
   M1more — 관리자 페이지 스타일
   ============================================================ */

:root {
  --bg: #070b14;
  --bg-soft: #0b1120;
  --surface: rgba(255, 255, 255, 0.045);
  --surface-2: rgba(255, 255, 255, 0.08);
  --border: rgba(255, 255, 255, 0.09);
  --text: #e9edf6;
  --muted: #9aa5ba;
  --accent: #6d8dff;
  --accent-2: #a78bfa;
  --accent-3: #22d3ee;
  --grad: linear-gradient(120deg, #6d8dff, #a78bfa 55%, #22d3ee);
  --radius: 18px;
  --font: "Pretendard Variable", Pretendard, -apple-system, BlinkMacSystemFont,
    "Segoe UI", "Malgun Gothic", "Apple SD Gothic Neo", system-ui, sans-serif;
  --mono: "Cascadia Code", Consolas, "D2Coding", monospace;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.7;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
img { max-width: 100%; display: block; }
button { font-family: inherit; cursor: pointer; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
code {
  font-family: var(--mono);
  font-size: 0.9em;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 2px 7px;
}

/* ---------- 브랜드 ---------- */
.brand { display: inline-flex; align-items: center; gap: 11px; }
.brand-mark-img {
  height: 30px; width: auto;
  object-fit: contain;
}
.brand-text { font-weight: 800; letter-spacing: 3px; font-size: 17px; }
.brand-sub {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 3px 11px;
  margin-left: 2px;
}

/* ---------- 버튼 / 칩 ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 24px;
  border-radius: 999px;
  border: 1px solid transparent;
  font-size: 14.5px;
  font-weight: 700;
  color: var(--text);
  background: var(--surface);
  transition: transform 0.18s ease, box-shadow 0.18s ease, background 0.18s;
}
.btn:hover { transform: translateY(-2px); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; transform: none; }
.btn-primary {
  background: var(--grad);
  color: #0a0e1c;
  box-shadow: 0 12px 30px rgba(109, 141, 255, 0.32);
}
.btn-ghost { background: var(--surface); border-color: var(--border); }
.btn-ghost:hover { background: var(--surface-2); }
.btn-sm { padding: 9px 17px; font-size: 13px; }

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--muted);
  font-size: 12.5px;
  font-weight: 600;
}
.chip b { color: var(--text); font-family: var(--mono); }
.chip-accent {
  border-color: rgba(109, 141, 255, 0.45);
  background: rgba(109, 141, 255, 0.12);
  color: #cdd8ff;
}

/* ============================================================
   화면: 로딩 / 오류
   ============================================================ */
.screen {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background:
    radial-gradient(ellipse 60% 55% at 70% 10%, rgba(109, 141, 255, 0.16), transparent 65%),
    radial-gradient(ellipse 55% 50% at 15% 90%, rgba(34, 211, 238, 0.12), transparent 65%),
    var(--bg);
  z-index: 40;
}

.loader-box, .error-box {
  width: min(520px, 94vw);
  text-align: center;
  padding: 48px 42px;
  border-radius: 24px;
  border: 1px solid var(--border);
  background: rgba(13, 19, 36, 0.75);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.5);
}

.loader-logo {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 11px;
  margin-bottom: 22px;
}
.loader-box h1, .error-box h1 {
  font-size: 1.7rem;
  font-weight: 800;
  letter-spacing: -0.5px;
  margin-bottom: 10px;
}
.status-text { color: var(--muted); margin-bottom: 26px; }

/* 4. 진행바 */
.progress {
  height: 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--border);
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  width: 0%;
  border-radius: 999px;
  background: var(--grad);
  transition: width 0.12s linear;
}
.progress-label {
  margin-top: 12px;
  font-family: var(--mono);
  font-size: 13px;
  color: var(--muted);
}
.hint { margin-top: 18px; font-size: 12.5px; color: rgba(154, 165, 186, 0.75); }

/* 5. 오류 화면 */
.error-icon {
  width: 72px; height: 72px;
  margin: 0 auto 22px;
  display: grid; place-items: center;
  border-radius: 22px;
  background: rgba(255, 120, 120, 0.12);
  color: #ff8b8b;
}
.error-icon svg { width: 38px; height: 38px; }
.error-desc { color: var(--muted); margin-bottom: 20px; }
.error-desc strong { color: #ffb4b4; }
.error-detail {
  text-align: left;
  margin: 0 auto 26px;
  max-width: 380px;
  color: var(--muted);
  font-size: 13.5px;
  list-style: none;
}
.error-detail li {
  padding: 7px 0 7px 22px;
  position: relative;
  border-bottom: 1px dashed var(--border);
}
.error-detail li:last-child { border-bottom: none; }
.error-detail li::before {
  content: '•';
  position: absolute;
  left: 6px;
  color: var(--accent-3);
}
.error-actions {
  display: flex;
  justify-content: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}
.error-hint { font-size: 12.5px; color: rgba(154, 165, 186, 0.8); }
.error-hint a { color: var(--accent-3); text-decoration: underline; }

/* ============================================================
   관리자 앱
   ============================================================ */
.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  border-bottom: 1px solid var(--border);
  background: rgba(7, 11, 20, 0.82);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}
.topbar-inner {
  width: min(1280px, 94vw);
  margin: 0 auto;
  height: 66px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}
.topbar-right { display: flex; align-items: center; gap: 12px; }

.admin-main {
  width: min(1280px, 94vw);
  margin: 32px auto 60px;
  display: grid;
  grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr);
  gap: 22px;
  align-items: start;
}
.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
}
.panel-editor { grid-row: span 2; }
.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}
.panel-head h2 { font-size: 1.18rem; font-weight: 800; }
.panel-head-actions { display: flex; align-items: center; gap: 10px; }
.panel-note {
  color: var(--muted);
  font-size: 12.8px;
  margin-bottom: 16px;
}

/* 편집 도구 */
.editor-toolbar {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}
.editor-toolbar button {
  min-width: 38px;
  height: 34px;
  padding: 0 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  font-size: 13px;
  font-weight: 700;
}
.editor-toolbar button:hover { border-color: rgba(109, 141, 255, 0.55); }

/* 편집 그리드 */
.editor-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}
#md-editor {
  width: 100%;
  min-height: 560px;
  resize: vertical;
  padding: 18px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: #0a101f;
  color: var(--text);
  font-family: var(--mono);
  font-size: 13.5px;
  line-height: 1.85;
  outline: none;
}
#md-editor:focus { border-color: rgba(109, 141, 255, 0.6); }

.preview {
  min-height: 560px;
  max-height: 720px;
  overflow-y: auto;
  padding: 18px 20px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.02);
  font-size: 14px;
}

/* 미리보기 마크다운 */
.preview h1 { font-size: 1.5rem; margin: 10px 0 14px; padding-bottom: 12px; border-bottom: 1px solid var(--border); }
.preview h2 { font-size: 1.3rem; margin: 18px 0 10px; }
.preview h3 { font-size: 1.1rem; margin: 16px 0 8px; color: #cfd8ff; }
.preview p { margin: 10px 0; }
.preview ul, .preview ol { margin: 10px 0 10px 20px; }
.preview li { margin: 5px 0; }
.preview blockquote {
  margin: 14px 0;
  padding: 12px 18px;
  border-left: 3px solid var(--accent);
  border-radius: 0 12px 12px 0;
  background: rgba(109, 141, 255, 0.08);
}
.preview pre {
  margin: 14px 0;
  padding: 16px;
  border-radius: 12px;
  background: #0a101f;
  border: 1px solid var(--border);
  overflow-x: auto;
}
.preview pre code {
  background: none; border: none; padding: 0;
  white-space: pre;
  line-height: 1.8;
  color: #c6d2ea;
}
.preview a { color: var(--accent-3); text-decoration: underline; }
.preview hr { border: none; border-top: 1px solid var(--border); margin: 18px 0; }
.spoiler {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 6px;
  padding: 2px 6px;
  cursor: pointer;
  filter: blur(5px);
  transition: filter 0.25s ease;
}
.spoiler:hover, .spoiler.revealed { filter: blur(0); }

/* 배너 */
.banner-box {
  border: 1px solid var(--border);
  border-radius: 14px;
  overflow: hidden;
  background: var(--bg-soft);
  margin-bottom: 14px;
}
.banner-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}
#banner-file {
  color: var(--muted);
  font-size: 12.5px;
  max-width: 100%;
}
#banner-file::file-selector-button {
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--text);
  padding: 8px 15px;
  margin-right: 12px;
  font-weight: 600;
  cursor: pointer;
}

/* 버전 기록 */
.history-list { list-style: none; max-height: 420px; overflow-y: auto; }
.history-item {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 11px 12px;
  border-radius: 12px;
  border: 1px solid transparent;
  cursor: pointer;
  transition: background 0.18s, border-color 0.18s;
}
.history-item:hover {
  background: var(--surface-2);
  border-color: rgba(109, 141, 255, 0.35);
}
.history-version {
  font-family: var(--mono);
  font-size: 12.5px;
  color: var(--accent-3);
  font-weight: 700;
}
.history-label { color: var(--muted); font-size: 12px; }
.history-date { color: var(--muted); font-size: 11.5px; white-space: nowrap; }

/* 푸터 */
.admin-footer {
  border-top: 1px solid var(--border);
  padding: 22px;
  text-align: center;
  color: var(--muted);
  font-size: 12.5px;
}

/* 모달 */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(4, 7, 15, 0.72);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  z-index: 60;
}
.modal-box {
  width: min(760px, 94vw);
  max-height: 84vh;
  display: flex;
  flex-direction: column;
  border-radius: 20px;
  border: 1px solid var(--border);
  background: #0c1324;
  box-shadow: 0 30px 90px rgba(0, 0, 0, 0.55);
}
.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 22px;
  border-bottom: 1px solid var(--border);
}
.modal-head h3 { font-size: 1.05rem; font-weight: 800; }
.modal-close {
  width: 34px; height: 34px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 18px;
  line-height: 1;
}
.modal-body { padding: 20px 22px; overflow-y: auto; font-size: 14px; }
.modal-body pre {
  padding: 14px;
  border-radius: 12px;
  background: #0a101f;
  border: 1px solid var(--border);
  overflow-x: auto;
  white-space: pre;
}
.modal-body blockquote {
  margin: 12px 0;
  padding: 10px 16px;
  border-left: 3px solid var(--accent);
  background: rgba(109, 141, 255, 0.08);
  border-radius: 0 10px 10px 0;
}
.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 16px 22px;
  border-top: 1px solid var(--border);
}

/* 토스트 */
.toast {
  position: fixed;
  left: 50%;
  bottom: 30px;
  transform: translate(-50%, 20px);
  background: rgba(20, 28, 52, 0.96);
  border: 1px solid rgba(109, 141, 255, 0.5);
  color: var(--text);
  padding: 12px 22px;
  border-radius: 999px;
  font-size: 13.5px;
  font-weight: 600;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease, transform 0.25s ease;
  z-index: 100;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* 반응형 */
@media (max-width: 1020px) {
  .admin-main { grid-template-columns: 1fr; }
  .panel-editor { grid-row: auto; }
  .editor-grid { grid-template-columns: 1fr; }
  #md-editor, .preview { min-height: 380px; }
}

@media (max-width: 720px) {
  .topbar-inner { height: 62px; gap: 10px; }
  .brand-mark-img { height: 28px; }
  .brand-text { font-size: 16px; }
  .brand-sub { display: none; }
  .topbar-right .chip { display: none; }
  .admin-main { margin: 16px auto 40px; gap: 14px; width: 94vw; }
  .panel { padding: 16px; border-radius: 16px; }
  .panel-head h2 { font-size: 1.05rem; }
  .panel-head-actions { width: 100%; justify-content: space-between; }
  #md-editor { min-height: 300px; font-size: 12.5px; }
  .preview { min-height: 260px; }
  .editor-toolbar button { min-width: 42px; height: 42px; }
  .btn { min-height: 44px; padding: 11px 18px; }
  .btn-sm { min-height: 40px; padding: 9px 15px; }
  .history-item { grid-template-columns: 1fr auto; }
  .history-label { grid-column: 1 / -1; order: 3; }
  .modal-box { max-height: 88vh; }
  .loader-box, .error-box { padding: 36px 24px; }
  .error-actions .btn { width: 100%; }
}
