/* ================================================================
   VvvebJS 網頁管理器 — 儀表板樣式
   深色主題 + 玻璃態 (Glassmorphism)
   ================================================================ */

/* ── CSS 變數 ──────────────────────────────────────────────────── */
:root {
  --bg-base:        #0d0f14;
  --bg-surface:     #13161e;
  --bg-card:        rgba(255, 255, 255, 0.04);
  --bg-card-hover:  rgba(255, 255, 255, 0.07);
  --border:         rgba(255, 255, 255, 0.08);
  --border-focus:   rgba(99, 102, 241, 0.6);

  --text-primary:   #f0f2f8;
  --text-secondary: #8b90a8;
  --text-muted:     #555a72;

  --accent:         #6366f1;
  --accent-hover:   #4f52d8;
  --accent-glow:    rgba(99, 102, 241, 0.25);
  --purple:         #8b5cf6;
  --danger:         #ef4444;
  --danger-hover:   #dc2626;
  --success:        #22c55e;

  --radius-sm:      6px;
  --radius-md:      12px;
  --radius-lg:      18px;

  --shadow-card:    0 4px 24px rgba(0, 0, 0, 0.4);
  --shadow-modal:   0 20px 60px rgba(0, 0, 0, 0.6);

  --transition:     0.2s ease;
  --font:           'Inter', system-ui, -apple-system, sans-serif;
}

/* ── Reset ─────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; scroll-behavior: smooth; }
body {
  font-family: var(--font);
  background: var(--bg-base);
  color: var(--text-primary);
  min-height: 100vh;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
ul { list-style: none; }
input, textarea, select { font-family: inherit; }
button { cursor: pointer; font-family: inherit; }

/* ── 頂部導覽列 ─────────────────────────────────────────────────── */
.topbar {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 2rem;
  height: 62px;
  background: rgba(13, 15, 20, 0.85);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border);
}

.topbar-brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.brand-icon {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  flex-shrink: 0;
}

.brand-name {
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  background: linear-gradient(135deg, #e0e2ff 0%, #a5b4fc 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.brand-name em {
  font-style: normal;
  font-weight: 300;
  opacity: 0.8;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.site-count {
  font-size: 0.85rem;
  color: var(--text-secondary);
  font-weight: 500;
}

/* ── 按鈕 ─────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.5rem 1.1rem;
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  font-weight: 500;
  border: 1px solid transparent;
  transition: background var(--transition), transform var(--transition), box-shadow var(--transition);
  white-space: nowrap;
}

.btn:active { transform: scale(0.97); }

.btn-primary {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
  box-shadow: 0 0 0 0 var(--accent-glow);
}
.btn-primary:hover {
  background: var(--accent-hover);
  box-shadow: 0 0 20px var(--accent-glow);
}

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border-color: var(--border);
}
.btn-ghost:hover {
  background: rgba(255,255,255,0.06);
  color: var(--text-primary);
}

.btn-danger {
  background: var(--danger);
  color: #fff;
  border-color: var(--danger);
}
.btn-danger:hover { background: var(--danger-hover); }

.btn-sm { padding: 0.35rem 0.8rem; font-size: 0.8rem; }

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  border: none;
  background: transparent;
  color: var(--text-muted);
  transition: background var(--transition), color var(--transition);
}
.icon-btn:hover {
  background: rgba(255,255,255,0.1);
  color: var(--text-primary);
}

/* ── 主內容 ───────────────────────────────────────────────────── */
.main-content {
  max-width: 1280px;
  margin: 0 auto;
  padding: 2rem 2rem 4rem;
}
.project-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1.5rem;
  margin-bottom: 1.75rem;
  padding: 1.4rem 1.6rem;
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: var(--radius-lg);
  background: rgba(255,255,255,0.04);
  backdrop-filter: blur(12px);
}

.project-header-info {
  max-width: min(720px, 100%);
}

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.25rem 0.75rem;
  border-radius: 999px;
  background: rgba(99,102,241,0.12);
  color: #dbeafe;
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  margin-bottom: 0.85rem;
}

.project-header h1 {
  font-size: 1.75rem;
  line-height: 1.1;
  margin-bottom: 0.5rem;
}

.project-subtitle {
  color: var(--text-secondary);
  max-width: 740px;
}

.project-header-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.btn-secondary {
  background: transparent;
  color: var(--text-primary);
  border: 1px solid rgba(255,255,255,0.14);
}

.btn-secondary:hover {
  background: rgba(255,255,255,0.08);
}

.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-bottom: 1.5rem;
}

.tab {
  padding: 0.85rem 1.15rem;
  border-radius: 999px;
  background: rgba(255,255,255,0.04);
  color: var(--text-secondary);
  font-weight: 600;
  cursor: pointer;
  transition: background var(--transition), color var(--transition), transform var(--transition);
}

.tab:hover {
  background: rgba(255,255,255,0.08);
}

.tab.active {
  background: var(--accent);
  color: #fff;
}

.panel {
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  margin-bottom: 1.5rem;
}

.panel-header,
.panel-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.25rem;
}

.panel-header h2,
.panel-card-header h3 {
  font-size: 1.1rem;
  margin: 0;
}

.panel-note {
  color: var(--text-secondary);
  font-size: 0.92rem;
  margin-top: 0.35rem;
}

.panel-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.panel-card {
  background: rgba(255,255,255,0.03);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: var(--radius-md);
  padding: 1.2rem;
}

.panel-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1rem;
}

.summary-card {
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  min-height: 140px;
}

.summary-card-title {
  color: var(--text-secondary);
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.summary-card-value {
  font-size: 1.45rem;
  font-weight: 700;
  color: var(--text-primary);
}

.summary-card-note {
  color: var(--text-muted);
  font-size: 0.88rem;
}

.card-form {
  display: grid;
  gap: 1rem;
}

.pages-list {
  display: grid;
  gap: 0.75rem;
}

.page-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem;
  border-radius: var(--radius-sm);
  background: rgba(255,255,255,0.03);
  border: 1px solid rgba(255,255,255,0.08);
}

.page-item-info {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.page-item-info strong {
  color: var(--text-primary);
}

.page-file {
  color: var(--text-secondary);
  font-size: 0.85rem;
}

.page-item-actions {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  flex-wrap: wrap;
}

.page-empty {
  padding: 1.2rem;
  border-radius: var(--radius-sm);
  border: 1px dashed rgba(255,255,255,0.16);
  color: var(--text-secondary);
  background: rgba(255,255,255,0.02);
}

.tree-root {
  padding: 0.75rem;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(255,255,255,0.08);
  background: rgba(255,255,255,0.03);
  min-height: 170px;
}

.tree-item {
  list-style: none;
  padding: 0.65rem 0.8rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  transition: background var(--transition), border-color var(--transition);
}

.tree-item:hover {
  background: rgba(255,255,255,0.05);
  border-color: rgba(255,255,255,0.1);
}

.tree-title {
  color: var(--text-primary);
  font-size: 0.95rem;
}

.tree-children {
  list-style: none;
  padding-left: 1rem;
  margin-top: 0.35rem;
}

.tree-drop-hover {
  background: rgba(99,102,241,0.1);
}

.tree-item-actions .btn {
  padding: 0.35rem 0.7rem;
}

.media-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.85rem;
  margin-bottom: 1rem;
}

.media-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1rem;
}

.media-card {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  padding: 1rem;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(255,255,255,0.08);
  background: rgba(255,255,255,0.03);
}

.media-card img {
  width: 100%;
  height: auto;
  border-radius: var(--radius-sm);
  object-fit: cover;
}

.media-info {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.media-meta {
  color: var(--text-secondary);
  font-size: 0.82rem;
}

.media-actions {
  display: flex;
  gap: 0.6rem;
  flex-wrap: wrap;
}
/* ── 搜尋列 ─────────────────────────────────────────────────────── */
.search-bar-wrap {
  margin-bottom: 2rem;
}

.search-bar {
  position: relative;
  max-width: 380px;
}

.search-icon {
  position: absolute;
  left: 0.9rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  pointer-events: none;
}

.search-bar input {
  width: 100%;
  padding: 0.6rem 0.9rem 0.6rem 2.6rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-size: 0.9rem;
  transition: border-color var(--transition), background var(--transition);
  outline: none;
}
.search-bar input::placeholder { color: var(--text-muted); }
.search-bar input:focus {
  border-color: var(--border-focus);
  background: rgba(99, 102, 241, 0.05);
}

/* ── 專案卡片網格 ─────────────────────────────────────────────── */
.projects-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 1.25rem;
}

/* ── 專案卡片 ────────────────────────────────────────────────── */
.project-card {
  position: relative;
  display: flex;
  flex-direction: column;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.4rem;
  transition: background var(--transition), border-color var(--transition), transform var(--transition), box-shadow var(--transition);
  overflow: hidden;
}

.project-card:hover {
  background: var(--bg-card-hover);
  border-color: rgba(99, 102, 241, 0.3);
  transform: translateY(-3px);
  box-shadow: var(--shadow-card), 0 0 40px rgba(99, 102, 241, 0.08);
}

.card-glow {
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at 20% 10%, rgba(99,102,241,0.08) 0%, transparent 60%);
  pointer-events: none;
  opacity: 0;
  transition: opacity var(--transition);
}
.project-card:hover .card-glow { opacity: 1; }

.card-header-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 1rem;
}

.card-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  background: linear-gradient(135deg, rgba(99,102,241,0.2), rgba(139,92,246,0.15));
  border: 1px solid rgba(99,102,241,0.25);
  border-radius: var(--radius-md);
  color: #a5b4fc;
}

.card-body {
  flex: 1;
  margin-bottom: 1rem;
}

.card-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 0.35rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.card-desc {
  font-size: 0.82rem;
  color: var(--text-muted);
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.card-meta {
  display: flex;
  gap: 1rem;
  margin-bottom: 1.1rem;
}

.meta-item {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.78rem;
  color: var(--text-muted);
}

.card-actions { margin-top: auto; }
.card-actions .btn { width: 100%; justify-content: center; }

/* ── 空狀態 ─────────────────────────────────────────────────── */
.empty-state {
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 5rem 2rem;
  color: var(--text-muted);
  display: flex;
  gap: 1rem;
}

.empty-state svg { opacity: 0.3; }
.empty-state h2 { font-size: 1.3rem; color: var(--text-secondary); }
.empty-state p { font-size: 0.9rem; max-width: 320px; }
.empty-state .btn { margin-top: 0.5rem; }

/* ── 輸入框 ─────────────────────────────────────────────────── */
input[type=text],
input[type=email],
textarea {
  width: 100%;
  padding: 0.6rem 0.85rem;
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 0.875rem;
  outline: none;
  transition: border-color var(--transition);
  resize: vertical;
}

input[type=text]:focus,
input[type=email]:focus,
textarea:focus {
  border-color: var(--border-focus);
  background: rgba(99,102,241,0.06);
}

input[type=text]::placeholder,
textarea::placeholder { color: var(--text-muted); }

.input-disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* ── Form group ─────────────────────────────────────────────── */
.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  margin-bottom: 1.1rem;
}

.form-group label {
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--text-secondary);
}

.required { color: var(--danger); }

.slug-preview {
  font-size: 0.78rem;
  color: var(--accent);
  font-family: monospace;
  min-height: 1.1em;
}

.hint-text {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 0.25rem;
}
.hint-text.danger { color: rgba(239,68,68,0.7); }

/* ── Modal ──────────────────────────────────────────────────── */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.65);
  backdrop-filter: blur(6px);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition);
}

.modal-backdrop.active {
  opacity: 1;
  pointer-events: all;
}

.modal-box {
  background: #1a1d27;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-modal);
  width: 90%;
  max-width: 480px;
  transform: translateY(20px) scale(0.97);
  transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.modal-backdrop.active .modal-box {
  transform: translateY(0) scale(1);
}

.modal-sm { max-width: 380px; }

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border);
}

.modal-header h2 {
  font-size: 1rem;
  font-weight: 600;
}

.modal-close {
  background: none;
  border: none;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 4px;
  border-radius: 6px;
  transition: background var(--transition), color var(--transition);
}
.modal-close:hover { background: rgba(255,255,255,0.08); color: var(--text-primary); }

.modal-body {
  padding: 1.5rem;
}

.modal-body p { font-size: 0.9rem; color: var(--text-secondary); line-height: 1.6; }
.modal-body strong { color: var(--text-primary); }

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--border);
}

/* ── Offcanvas ──────────────────────────────────────────────── */
.offcanvas-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  backdrop-filter: blur(4px);
  z-index: 200;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition);
}
.offcanvas-backdrop.active {
  opacity: 1;
  pointer-events: all;
}

.offcanvas {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: 380px;
  max-width: 100%;
  background: #1a1d27;
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: -8px 0 40px rgba(0,0,0,0.4);
}
.offcanvas-backdrop.active .offcanvas {
  transform: translateX(0);
}

.offcanvas-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border);
}
.offcanvas-header h2 { font-size: 1rem; font-weight: 600; }

.offcanvas-body {
  flex: 1;
  overflow-y: auto;
  padding: 1.5rem;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

.offcanvas-footer {
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
}

/* ── 分隔線 / 區段標籤 ──────────────────────────────────────── */
.divider {
  height: 1px;
  background: var(--border);
  margin: 1.25rem 0;
}

.section-label {
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin-bottom: 0.75rem;
}
.section-label.danger { color: rgba(239,68,68,0.6); }

/* ── 頁面清單 ─────────────────────────────────────────────── */
.pages-list {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.page-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.75rem;
  background: rgba(255,255,255,0.03);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.pages-loading, .no-pages {
  font-size: 0.85rem;
  color: var(--text-muted);
  padding: 0.5rem 0;
}

/* ── 危險區域 ────────────────────────────────────────────── */
.danger-zone {
  padding: 1rem;
  border: 1px solid rgba(239,68,68,0.2);
  border-radius: var(--radius-md);
  background: rgba(239,68,68,0.04);
}
.danger-zone .btn-danger { width: 100%; justify-content: center; }

/* ── Toast ──────────────────────────────────────────────── */
.toast-container {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 999;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  pointer-events: none;
}

.toast {
  padding: 0.75rem 1.25rem;
  border-radius: var(--radius-md);
  font-size: 0.875rem;
  font-weight: 500;
  color: #fff;
  box-shadow: 0 4px 20px rgba(0,0,0,0.4);
  transform: translateX(120%);
  opacity: 0;
  transition: transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.35s ease;
  pointer-events: all;
  max-width: 320px;
}

.toast.show { transform: translateX(0); opacity: 1; }
.toast-success { background: #166534; border: 1px solid #22c55e40; }
.toast-error   { background: #7f1d1d; border: 1px solid #ef444440; }

/* ── 捲軸美化 ─────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.15); }

/* ── 響應式 ─────────────────────────────────────────────── */
@media (max-width: 640px) {
  .topbar { padding: 0 1rem; }
  .main-content { padding: 1.25rem 1rem 3rem; }
  .site-count { display: none; }
  .offcanvas { width: 100%; }
}
