/* ============================================================
   PAL Admin — Soft Purple Design System (공유 토큰)
   ============================================================ */
@import url('https://cdn.jsdelivr.net/gh/orioncactus/pretendard@v1.3.9/dist/web/static/pretendard.css');

:root {
  --bg: #F6F4FF;
  --bg-deep: #EDE8FF;
  --surface: #FFFFFF;
  --primary: #7C5CFC;
  --primary-deep: #5B3FD9;
  --primary-light: #A98CFF;
  --accent: #C9BFFF;
  --danger: #F26E7E;
  --danger-bg: #FFEBEE;
  --text: #2A2440;
  --text-muted: #6E6690;
  --text-faint: #9C93BE;
  --border: #E7E1FF;
  --shadow-card: 0 4px 20px rgba(124, 92, 252, 0.08);
  --shadow-soft: 0 8px 30px rgba(124, 92, 252, 0.14);
  --radius-lg: 24px;
  --radius-md: 16px;
  --radius-sm: 10px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: 'Pretendard', -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}
button { font-family: inherit; cursor: pointer; border: none; background: none; }
input, textarea, select {
  font-family: inherit;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: 0.92rem;
  background: #fff;
  width: 100%;
  color: var(--text);
}
input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(124,92,252,0.15);
}
label { font-size: 0.82rem; font-weight: 700; color: var(--text-muted); display: block; margin-bottom: 6px; }
.field { margin-bottom: 14px; }

.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 9px 18px; border-radius: 999px;
  font-weight: 700; font-size: 0.86rem;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.btn-primary { background: linear-gradient(135deg, var(--primary), var(--primary-deep)); color: #fff; box-shadow: var(--shadow-card); }
.btn-primary:hover { transform: translateY(-1px); box-shadow: var(--shadow-soft); }
.btn-ghost { background: var(--bg-deep); color: var(--primary-deep); }
.btn-ghost:hover { background: var(--accent); }
.btn-danger { background: var(--danger-bg); color: var(--danger); }
.btn-danger:hover { background: var(--danger); color: #fff; }
.btn-sm { padding: 6px 12px; font-size: 0.78rem; }
.btn-icon { width: 34px; height: 34px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; padding: 0; }

/* ---------- Login gate ---------- */
.gate {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
}
.gate-card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-soft);
  padding: 48px 40px;
  text-align: center;
  max-width: 380px;
  width: 100%;
}
.gate-card .mark {
  width: 56px; height: 56px; border-radius: 16px; margin: 0 auto 18px;
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 800; font-size: 1.4rem;
}
.gate-card h1 { font-size: 1.3rem; margin-bottom: 8px; }
.gate-card p { color: var(--text-muted); font-size: 0.9rem; margin-bottom: 26px; }
.btn-google {
  background: #fff; border: 1px solid var(--border); color: var(--text);
  padding: 11px 22px; width: 100%; justify-content: center;
}
.btn-google img { width: 18px; height: 18px; margin-right: 4px; }
.gate-error { color: var(--danger); font-size: 0.85rem; margin-top: 16px; }

/* ---------- App shell ---------- */
.admin-app { display: none; min-height: 100vh; grid-template-columns: 380px 1fr; }
.admin-app.is-visible { display: grid; }

.admin-sidebar {
  background: var(--surface);
  border-right: 1px solid var(--border);
  overflow-y: auto;
  padding: 24px;
  display: flex; flex-direction: column; gap: 20px;
}
.admin-topbar {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 4px;
}
.admin-logo { display: flex; align-items: center; gap: 8px; font-weight: 800; }
.admin-logo .mark {
  width: 30px; height: 30px; border-radius: 9px;
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
  color: #fff; display: flex; align-items: center; justify-content: center; font-size: 0.85rem;
}
.admin-user { display: flex; align-items: center; gap: 8px; font-size: 0.8rem; color: var(--text-muted); }
.admin-user img { width: 26px; height: 26px; border-radius: 50%; }

.panel {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 18px;
}
.panel h2 {
  font-size: 0.82rem; text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--text-faint); margin-bottom: 14px; font-weight: 800;
}

/* Section list (reorderable) */
.section-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 12px; }
.section-row {
  display: flex; align-items: center; gap: 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  cursor: grab;
  transition: box-shadow 0.15s ease, border-color 0.15s ease;
}
.section-row:hover { box-shadow: var(--shadow-card); }
.section-row.is-active { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(124,92,252,0.15); }
.section-row.is-hidden { opacity: 0.5; }
.section-row .drag-handle { color: var(--text-faint); font-size: 0.9rem; }
.section-row .row-main { flex: 1; min-width: 0; }
.section-row .row-type {
  font-size: 0.68rem; font-weight: 800; color: var(--primary-deep);
  background: var(--bg-deep); padding: 2px 8px; border-radius: 999px;
  display: inline-block; margin-bottom: 3px;
}
.section-row .row-title { font-size: 0.86rem; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.section-row .row-actions { display: flex; gap: 4px; flex-shrink: 0; }
.section-row .row-actions button {
  width: 26px; height: 26px; border-radius: 8px; font-size: 0.75rem;
  display: flex; align-items: center; justify-content: center; color: var(--text-muted);
}
.section-row .row-actions button:hover { background: var(--bg-deep); }

.add-section-select { display: flex; gap: 8px; }

/* Settings items */
.setting-row { margin-bottom: 16px; }
.toggle-row { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.switch { position: relative; width: 42px; height: 24px; flex-shrink: 0; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch .track {
  position: absolute; inset: 0; background: var(--border); border-radius: 999px; transition: background 0.2s ease;
}
.switch .track::before {
  content: ''; position: absolute; width: 18px; height: 18px; left: 3px; top: 3px;
  background: #fff; border-radius: 50%; transition: transform 0.2s ease; box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}
.switch input:checked + .track { background: var(--primary); }
.switch input:checked + .track::before { transform: translateX(18px); }

.save-hint { font-size: 0.75rem; color: var(--text-faint); }
.logout-link { font-size: 0.78rem; color: var(--text-faint); text-decoration: underline; align-self: flex-start; }

/* ---------- Preview pane ---------- */
.admin-preview {
  overflow-y: auto;
  background: var(--bg-deep);
  position: relative;
}
.preview-toolbar {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 24px;
  background: rgba(237,232,255,0.85);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
.preview-toolbar .hint { font-size: 0.82rem; color: var(--text-muted); }
.preview-frame-wrap {
  padding: 24px;
}
.preview-surface {
  background: var(--bg);
  border-radius: 24px;
  overflow: hidden;
  box-shadow: var(--shadow-soft);
  min-height: 70vh;
}

/* Clickable overlay on preview sections */
#preview-sections .section,
#preview-sections .hero {
  position: relative;
  cursor: pointer;
  transition: outline 0.15s ease;
  outline: 2px dashed transparent;
  outline-offset: -2px;
}
#preview-sections .section:hover,
#preview-sections .hero:hover {
  outline-color: var(--primary-light);
}
.preview-edit-tag {
  position: absolute; top: 10px; right: 24px;
  background: var(--primary); color: #fff;
  font-size: 0.7rem; font-weight: 700;
  padding: 4px 10px; border-radius: 999px;
  opacity: 0; transition: opacity 0.15s ease;
  pointer-events: none;
}
#preview-sections .section:hover .preview-edit-tag,
#preview-sections .hero:hover .preview-edit-tag { opacity: 1; }

/* ---------- Modal editor ---------- */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(42,36,64,0.45);
  backdrop-filter: blur(4px);
  display: none; align-items: center; justify-content: center;
  z-index: 200; padding: 20px;
}
.modal-overlay.is-open { display: flex; }
.modal-card {
  background: #fff; border-radius: var(--radius-lg);
  max-width: 560px; width: 100%; max-height: 88vh;
  display: flex; flex-direction: column;
  box-shadow: var(--shadow-soft);
}
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 20px 24px; border-bottom: 1px solid var(--border);
}
.modal-header h2 { font-size: 1.05rem; font-weight: 800; }
.modal-header button { width: 30px; height: 30px; border-radius: 50%; background: var(--bg-deep); }
.modal-body { padding: 20px 24px; overflow-y: auto; }
.modal-footer {
  padding: 16px 24px; border-top: 1px solid var(--border);
  display: flex; justify-content: space-between; align-items: center;
}
.repeat-item {
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 12px; margin-bottom: 10px; position: relative;
}
.repeat-item .remove-item {
  position: absolute; top: 8px; right: 8px;
  width: 24px; height: 24px; border-radius: 50%;
  background: var(--danger-bg); color: var(--danger); font-size: 0.7rem;
}

.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%) translateY(20px);
  background: var(--text); color: #fff; padding: 12px 22px; border-radius: 999px;
  font-size: 0.86rem; font-weight: 600; box-shadow: var(--shadow-soft);
  opacity: 0; pointer-events: none; transition: all 0.25s ease; z-index: 300;
}
.toast.is-visible { opacity: 1; transform: translateX(-50%) translateY(0); }

@media (max-width: 900px) {
  .admin-app.is-visible { grid-template-columns: 1fr; }
  .admin-sidebar { border-right: none; border-bottom: 1px solid var(--border); }
}
