/* ============================================================
   Abel — Suwon Admin Dashboard · v2
   Palette: champagne gold / ivory beige / dark espresso brown
   ============================================================ */

:root {
  /* Gold accent (primary) */
  --primary: #9B7B4A;
  --primary-deep: #1C1308;
  --primary-soft: rgba(155, 123, 74, 0.08);
  --primary-tint: rgba(155, 123, 74, 0.14);
  --primary-line: rgba(155, 123, 74, 0.32);

  /* Surfaces */
  --bg: #F3EDE3;
  --card: #FFFFFF;
  --ivory: #F7F1E5;
  --cream: #EDE5D4;

  /* Text */
  --text: #18120A;
  --text-soft: #5C4E3E;
  --text-mute: #9B8E82;
  --header-text: #F0E8D8;
  --header-text-mute: rgba(196, 175, 147, 0.6);

  /* Borders */
  --border: #DDD0BB;
  --border-soft: #E8DDC8;
  --hairline: #DDD0BB;

  /* States */
  --success: #2E7D32;
  --danger: #C0392B;
  --danger-soft: #FAE4E0;

  /* KakaoTalk preview */
  --kakao: #fee500;
  --kakao-deep: #181600;

  --shadow-card: 0 1px 2px rgba(28, 19, 8, 0.05),
                 0 10px 40px rgba(28, 19, 8, 0.08);
  --shadow-soft: 0 1px 2px rgba(28, 19, 8, 0.04),
                 0 4px 14px rgba(28, 19, 8, 0.06);

  --r-sm: 8px;
  --r-md: 12px;
  --r-lg: 18px;

  --max-w: 960px;
  --ease: cubic-bezier(0.22, 0.61, 0.36, 1);

  --font-sans: 'Pretendard', -apple-system, BlinkMacSystemFont,
               'Apple SD Gothic Neo', system-ui, 'Segoe UI', Roboto, sans-serif;
  --font-mono: ui-monospace, 'SF Mono', 'Cascadia Code', Menlo, Consolas, monospace;
}

*, *::before, *::after { box-sizing: border-box; }
html, body, h1, h2, h3, p, ul, ol, dl, form, pre { margin: 0; padding: 0; }
button { font: inherit; color: inherit; }
ul { list-style: none; }
pre { font-family: inherit; }

body {
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.55;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  letter-spacing: -0.005em;
  min-height: 100vh;
}

.admin {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 24px 18px 40px;
  padding-top: calc(24px + env(safe-area-inset-top));
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* ============================================================
   Header — espresso band with champagne accents
   ============================================================ */
.admin-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 22px;
  background: var(--primary-deep);
  color: var(--header-text);
  border-radius: var(--r-md);
  margin-bottom: 18px;
  box-shadow: var(--shadow-soft);
  position: relative;
  overflow: hidden;
}
.admin-header::before {
  content: '';
  position: absolute;
  inset: 0 0 auto 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(196,175,147,0.32), transparent);
}

.ah-left { display: flex; align-items: center; gap: 14px; }

.ah-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border-radius: 8px;
  background: rgba(196, 175, 147, 0.1);
  border: 1px solid rgba(196, 175, 147, 0.18);
  color: var(--header-text);
  font-weight: 700;
  font-size: 16px;
  letter-spacing: 0;
}

.ah-text { display: flex; flex-direction: column; line-height: 1.25; }

.ah-brand {
  font-size: 14.5px;
  font-weight: 600;
  letter-spacing: 0.34em;
  padding-left: 0.34em;
  color: var(--header-text);
}
.ah-loc {
  margin-top: 4px;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.2em;
  color: var(--header-text-mute);
}

.ah-tag {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.32em;
  padding-left: 0.32em;
  color: rgba(196, 175, 147, 0.5);
}

/* ============================================================
   Main
   ============================================================ */
.admin-main {
  flex: 1;
  background: var(--card);
  border: 1px solid var(--border-soft);
  border-radius: var(--r-lg);
  padding: 36px 30px;
  box-shadow: var(--shadow-card);
}

.view { display: block; animation: viewIn 0.4s var(--ease); }
.view[hidden] { display: none; }

@keyframes viewIn {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ============================================================
   Menu landing
   ============================================================ */
.menu-head { text-align: center; margin-bottom: 36px; }

.menu-eyebrow {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.22em;
  padding-left: 0.22em;
  color: var(--primary);
  margin-bottom: 14px;
}

.menu-title {
  font-size: 32px;
  font-weight: 700;
  letter-spacing: -0.04em;
  color: var(--primary-deep);
  margin-bottom: 10px;
}

.menu-desc {
  font-size: 14.5px;
  color: var(--text-soft);
}

.menu-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px;
}

.menu-card {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
  text-align: left;
  padding: 24px 22px 22px;
  background: var(--ivory);
  border: 1px solid var(--border-soft);
  border-radius: var(--r-md);
  cursor: pointer;
  transition: transform 0.2s var(--ease),
              background 0.2s var(--ease),
              border-color 0.2s var(--ease),
              box-shadow 0.2s var(--ease);
  -webkit-tap-highlight-color: transparent;
}
.menu-card:hover {
  background: #fff;
  border-color: var(--primary-line);
  transform: translateY(-2px);
  box-shadow: 0 10px 26px rgba(155, 123, 74, 0.14);
}
.menu-card:active { transform: translateY(0); }
.menu-card:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px rgba(155, 123, 74, 0.22);
}

.mc-num {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.14em;
  color: var(--primary);
  margin-bottom: 14px;
}
.mc-name {
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.025em;
  color: var(--primary-deep);
}
.mc-sub {
  margin-top: 4px;
  font-size: 12.5px;
  color: var(--text-soft);
  letter-spacing: -0.005em;
}

/* ============================================================
   Detail view — back button, form head
   ============================================================ */
.back-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px 8px 10px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--text-soft);
  cursor: pointer;
  margin-bottom: 22px;
  transition: color 0.2s var(--ease), border-color 0.2s var(--ease), background 0.2s var(--ease);
}
.back-btn:hover {
  color: var(--primary);
  border-color: var(--primary-line);
  background: var(--ivory);
}

.form-head { margin-bottom: 26px; }

.form-eyebrow {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.14em;
  color: var(--primary);
  margin-bottom: 12px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.form-eyebrow .ey-sep { color: var(--text-mute); opacity: 0.6; margin: 0 2px; }

.form-title {
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.035em;
  color: var(--primary-deep);
  margin-bottom: 8px;
}

.form-desc {
  font-size: 14px;
  color: var(--text-soft);
}

/* ============================================================
   Form shell — side-by-side on desktop
   ============================================================ */
.form-shell {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 22px;
  margin-bottom: 22px;
}

@media (max-width: 720px) {
  .form-shell { grid-template-columns: 1fr; }
}

.admin-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.field { display: flex; flex-direction: column; gap: 8px; }

.field-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.field label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  letter-spacing: -0.01em;
}

.req, .opt {
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.02em;
  padding: 2px 7px;
  border-radius: 999px;
}
.req { color: var(--primary); background: var(--primary-soft); }
.opt { color: var(--text-mute); background: var(--border-soft); }

.field input[type="text"],
.field input[type="tel"],
.field input[type="url"],
.field input[type="date"],
.field input[type="time"] {
  font-family: inherit;
  font-size: 14.5px;
  line-height: 1.5;
  color: var(--text);
  width: 100%;
  padding: 11px 13px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
  -webkit-appearance: none;
  appearance: none;
}

.field input::placeholder { color: var(--text-mute); }

.field input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(155, 123, 74, 0.14);
}

.err {
  font-size: 12px;
  color: var(--danger);
  display: none;
}
.hint { font-size: 11.5px; color: var(--text-mute); }

.field.is-error .err { display: block; }
.field.is-error input {
  border-color: var(--danger);
  background: var(--danger-soft);
}

/* ============================================================
   수강생명 자동완성 (주소록)
   ============================================================ */
.field.has-autocomplete { position: relative; }

.autocomplete-list {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  margin: 0;
  padding: 4px;
  list-style: none;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  box-shadow: var(--shadow-card);
  max-height: 248px;
  overflow-y: auto;
  z-index: 20;
}

.autocomplete-list[hidden] { display: none; }

.ac-item {
  display: flex;
  flex-direction: column;
  border-radius: 6px;
  transition: background 0.12s ease;
}

.ac-row {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 4px 4px 0;
}

.ac-main {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 6px 11px;
  border-radius: 6px;
  cursor: pointer;
  min-width: 0;
}

.ac-main:hover { background: var(--primary-soft); }

.ac-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  letter-spacing: -0.01em;
}

.ac-meta {
  font-size: 12px;
  color: var(--text-mute);
  letter-spacing: -0.01em;
  white-space: nowrap;
}

.ac-expand {
  flex-shrink: 0;
  background: transparent;
  border: 1px solid var(--border-soft);
  color: var(--text-mute);
  width: 26px;
  height: 26px;
  border-radius: 6px;
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.18s ease, background 0.12s ease, color 0.12s ease;
}

.ac-expand:hover {
  background: var(--primary-tint);
  color: var(--text);
}

.ac-expand.is-open {
  transform: rotate(90deg);
  background: var(--primary-soft);
  color: var(--primary);
}

.ac-history {
  padding: 4px 12px 10px 12px;
  border-top: 1px dashed var(--border-soft);
  margin: 2px 4px 0 4px;
}

.ac-history[hidden] { display: none; }

.ac-history ul {
  list-style: none;
  padding: 4px 0 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.ah-item {
  display: flex;
  flex-direction: column;
  border-left: 2px solid var(--primary-tint);
}

.ah-line {
  position: relative;
  padding: 6px 24px 6px 12px;
  font-size: 12.5px;
  color: var(--text-soft);
  line-height: 1.45;
  letter-spacing: -0.01em;
  cursor: pointer;
  border-radius: 4px;
  transition: background 0.12s ease;
}

.ah-line:hover { background: var(--primary-soft); }

.ah-line::after {
  content: '▾';
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 9px;
  color: var(--text-mute);
  transition: transform 0.18s ease;
}

.ah-item.is-open .ah-line::after {
  transform: translateY(-50%) rotate(180deg);
  color: var(--primary);
}

.ah-body {
  margin: 4px 0 8px 12px;
  padding: 10px 12px;
  background: var(--ivory);
  border: 1px solid var(--border-soft);
  border-radius: 8px;
  font-family: inherit;
  font-size: 12px;
  line-height: 1.55;
  color: var(--text);
  white-space: pre-wrap;
  word-break: break-word;
  overflow-wrap: break-word;
}

.ah-body[hidden] { display: none; }

/* ============================================================
   연락처 발송 이력 패널 (우측 슬라이드 인)
   ============================================================ */
.contact-detail {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(440px, 100vw);
  background: var(--bg);
  border-left: 1px solid var(--border);
  box-shadow: -10px 0 32px rgba(28, 19, 8, 0.14);
  z-index: 100;
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform 0.24s ease;
}

.contact-detail.is-shown { transform: translateX(0); }

.contact-detail[hidden] { display: none; }

.cd-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 18px 20px;
  background: var(--primary-deep);
  color: var(--header-text);
}

.cd-name {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -0.01em;
  margin: 0;
}

.cd-sub {
  font-size: 12px;
  color: var(--header-text-mute);
  margin: 3px 0 0;
  letter-spacing: -0.01em;
}

.cd-close {
  background: transparent;
  border: 1px solid rgba(240, 232, 216, 0.22);
  color: var(--header-text);
  width: 30px;
  height: 30px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.12s ease;
  flex-shrink: 0;
}

.cd-close:hover { background: rgba(240, 232, 216, 0.12); }

.cd-body {
  flex: 1;
  overflow-y: auto;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.cd-empty {
  font-size: 13px;
  color: var(--text-mute);
  text-align: center;
  padding: 32px 12px;
  margin: 0;
}

.cd-card {
  background: var(--card);
  border: 1px solid var(--border-soft);
  border-radius: 12px;
  padding: 12px 14px;
  box-shadow: var(--shadow-soft);
}

.cd-card-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}

.cd-tag {
  font-size: 11px;
  font-weight: 700;
  color: var(--primary);
  background: var(--primary-soft);
  padding: 3px 9px;
  border-radius: 999px;
  letter-spacing: 0.02em;
}

.cd-when {
  font-size: 11.5px;
  color: var(--text-mute);
  letter-spacing: -0.01em;
}

.cd-card-body {
  font-family: inherit;
  font-size: 12px;
  line-height: 1.55;
  color: var(--text);
  white-space: pre-wrap;
  word-break: break-word;
  overflow-wrap: break-word;
  margin: 0;
}

.ac-history-empty {
  font-size: 12px;
  color: var(--text-mute);
  padding: 6px 0 2px;
  margin: 0;
}

/* ============================================================
   Preview (KakaoTalk-style)
   ============================================================ */
.preview {
  background: var(--ivory);
  border: 1px solid var(--border-soft);
  border-radius: var(--r-md);
  padding: 14px;
  display: flex;
  flex-direction: column;
}

.preview-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
  padding: 0 4px;
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.06em;
  color: var(--text-mute);
}
.ph-bubble {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  background: var(--kakao);
  color: var(--kakao-deep);
  border-radius: 6px;
}

.preview-card {
  background: var(--kakao);
  border-radius: var(--r-sm);
  padding: 10px 10px 12px;
  flex: 1;
}
.preview-from {
  font-size: 11.5px;
  font-weight: 700;
  color: var(--kakao-deep);
  margin: 4px 6px 8px;
  letter-spacing: -0.005em;
}

.preview-body {
  background: #fff;
  border-radius: 6px;
  padding: 14px 14px 16px;
  font-size: 13px;
  line-height: 1.7;
  color: var(--text);
  white-space: pre-wrap;
  word-break: break-word;
  font-family: var(--font-sans);
  min-height: 220px;
  letter-spacing: -0.005em;
}
.preview-body.is-empty { color: var(--text-mute); font-style: italic; }

/* ============================================================
   Submit button — espresso with gold hover
   ============================================================ */
.btn-send {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  width: 100%;
  min-height: 54px;
  padding: 16px 24px;
  background: var(--primary-deep);
  color: var(--header-text);
  border: 1px solid var(--primary-deep);
  border-radius: var(--r-sm);
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.04em;
  cursor: pointer;
  position: relative;
  overflow: hidden;
  transition: background 0.2s var(--ease),
              transform 0.15s var(--ease),
              box-shadow 0.2s var(--ease);
  box-shadow: 0 4px 16px rgba(28, 19, 8, 0.18);
  -webkit-tap-highlight-color: transparent;
}
.btn-send::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(196,175,147,0.4), transparent);
}
.btn-send:hover {
  background: #2C1F0E;
  transform: translateY(-1px);
  box-shadow: 0 10px 26px rgba(28, 19, 8, 0.26);
}
.btn-send:active { transform: translateY(0); }
.btn-send svg {
  opacity: 0.75;
  transition: transform 0.2s var(--ease), opacity 0.2s var(--ease);
}
.btn-send:hover svg { transform: translateX(4px); opacity: 1; }

.btn-send.is-loading { color: transparent; pointer-events: none; }
.btn-send.is-loading svg { display: none; }
.btn-send.is-loading::after {
  content: '';
  position: absolute;
  width: 18px; height: 18px;
  border: 2px solid rgba(240, 232, 216, 0.35);
  border-top-color: var(--header-text);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ============================================================
   History
   ============================================================ */
.history { margin-top: 36px; }

.history header {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  margin-bottom: 16px;
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.18em;
  padding-left: 0.18em;
  color: var(--text-mute);
}
.h-line {
  flex: 1;
  height: 1px;
  background: var(--hairline);
  max-width: 80px;
}

.history-list { display: flex; flex-direction: column; gap: 8px; }

.history-list li {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: var(--ivory);
  border: 1px solid var(--border-soft);
  border-radius: var(--r-sm);
  font-size: 13px;
}
.history-list .hl-title { font-weight: 600; color: var(--primary-deep); }
.history-list .hl-sub { font-size: 11.5px; color: var(--text-soft); margin-top: 2px; }
.history-list .hl-time {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-mute);
  letter-spacing: 0.02em;
}

.history.has-items .history-empty { display: none; }
.history-empty {
  text-align: center;
  font-size: 13px;
  color: var(--text-mute);
  padding: 14px 0;
  letter-spacing: -0.005em;
}

/* ============================================================
   Footer
   ============================================================ */
.admin-foot {
  padding-top: 22px;
  text-align: center;
  font-size: 11.5px;
  letter-spacing: 0.04em;
  color: var(--text-mute);
}

/* ============================================================
   Toast
   ============================================================ */
.toast {
  position: fixed;
  left: 50%;
  bottom: 26px;
  transform: translate(-50%, 120%);
  padding: 13px 20px;
  background: var(--primary-deep);
  color: var(--header-text);
  font-size: 13.5px;
  font-weight: 500;
  border-radius: 999px;
  box-shadow: 0 8px 22px rgba(28, 19, 8, 0.28);
  opacity: 0;
  transition: transform 0.4s var(--ease), opacity 0.3s var(--ease);
  z-index: 100;
  max-width: calc(100% - 32px);
  text-align: center;
}
.toast.is-shown { transform: translate(-50%, 0); opacity: 1; }
.toast.is-success { background: var(--success); box-shadow: 0 8px 22px rgba(46,125,50,0.28); }
.toast.is-error { background: var(--danger); box-shadow: 0 8px 22px rgba(192,57,43,0.28); }

/* ============================================================
   Send result strip — below the send button
   ============================================================ */
.send-result {
  margin-top: 12px;
  padding: 11px 15px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 500;
  line-height: 1.45;
  border: 1px solid transparent;
  transition: opacity 0.25s ease;
}
.send-result[data-state="pending"] {
  background: #eef2ff;
  border-color: #c7d2fe;
  color: #4338ca;
}
.send-result[data-state="success"] {
  background: #f0fdf4;
  border-color: #bbf7d0;
  color: #15803d;
}
.send-result[data-state="error"] {
  background: #fff1f2;
  border-color: #fecdd3;
  color: #be123c;
}
.send-result[data-state="timeout"] {
  background: #fffbeb;
  border-color: #fde68a;
  color: #92400e;
}

/* ============================================================
   Responsive
   ============================================================ */
@media (max-width: 520px) {
  .admin-main { padding: 28px 20px; }
  .admin-header { padding: 14px 18px; }
  .ah-mark { width: 32px; height: 32px; font-size: 14px; }
  .ah-brand { font-size: 13px; letter-spacing: 0.28em; padding-left: 0.28em; }
  .ah-loc { font-size: 10.5px; }
  .ah-tag { font-size: 10px; letter-spacing: 0.26em; padding-left: 0.26em; }
  .menu-title { font-size: 24px; }
  .menu-grid { grid-template-columns: 1fr; }
  .form-title { font-size: 21px; }
  .field-grid { grid-template-columns: 1fr; }
  .preview-body { min-height: 180px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}
