/* ===== Variables & reset ===== */
:root {
  --bg: #f1f3f5;
  --bg-card: #ffffff;
  --text: #1e293b;
  --text-muted: #64748b;
  --accent: #6366f1;
  --accent-hover: #4f46e5;
  --accent-subtle: rgba(99, 102, 241, 0.12);
  --border: #e2e8f0;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 3px rgba(0,0,0,0.06);
  --shadow-lg: 0 10px 40px -10px rgba(0,0,0,0.15);
  --font: "Segoe UI", "PingFang SC", "Microsoft JhengHei", sans-serif;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

a {
  text-decoration: none;
  color: inherit;
  transition: color 0.2s, background 0.2s;
}

ul { list-style: none; }

/* ===== Base ===== */
body {
  font-family: var(--font);
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
  min-height: 100vh;
}

@keyframes fade-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ===== Header ===== */
.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1.5rem;
  background: var(--bg-card);
  box-shadow: var(--shadow);
  position: sticky;
  top: 0;
  z-index: 100;
  transition: background 0.3s, box-shadow 0.3s;
}

.site-header.liquid-glass {
  background: rgba(255, 255, 255, 0.1);
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.03);
  backdrop-filter: blur(22px) saturate(200%);
  -webkit-backdrop-filter: blur(22px) saturate(200%);
  border-bottom: 1.5px solid rgba(255, 255, 255, 0.1);
  transition: background 0.5s, backdrop-filter 0.5s;
}

.logo {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.logo-icon {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  background: linear-gradient(135deg, var(--accent), #8b5cf6);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
}

.logo h1 {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--text);
}

.header-nav ul {
  display: flex;
  gap: 0.25rem;
}

.header-nav li a {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.9rem;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-weight: 500;
  font-size: 0.95rem;
}

.header-nav li a:hover,
.header-nav li a.active {
  color: var(--accent);
  background: var(--accent-subtle);
}

.menu-toggle {
  display: none;
  background: none;
  border: none;
  padding: 0.5rem;
  cursor: pointer;
  color: var(--text-muted);
  font-size: 1.25rem;
}

.fold-btn {
  position: absolute;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: none;
  background: var(--bg-card);
  box-shadow: var(--shadow);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  transition: background 0.2s, color 0.2s;
  z-index: 101;
}

.fold-btn:hover {
  background: var(--accent-subtle);
  color: var(--accent);
}

.fold-header-btn {
  top: 50%;
  right: 1rem;
  transform: translateY(-50%);
}

.fold-sidebar-btn {
  position: absolute;
  left: 0;
  top: 1.25rem;
  transform: translateX(-50%);
  z-index: 10;
}

/* ===== Main layout ===== */
.main-content {
  display: flex;
  min-height: calc(100vh - 60px);
}

/* ===== Sidebar (分类 unchanged) ===== */
.sidebar {
  width: 240px;
  background: var(--bg-card);
  box-shadow: var(--shadow);
  padding: 1.5rem 1rem;
  transition: width 0.3s, padding 0.3s;
}

.sidebar.liquid-glass {
  background: rgba(255, 255, 255, 0.12);
  box-shadow: 2px 0 10px rgba(0, 0, 0, 0.03);
  backdrop-filter: blur(22px) saturate(200%);
  -webkit-backdrop-filter: blur(22px) saturate(200%);
  border-right: 1.5px solid rgba(255, 255, 255, 0.1);
  transition: background 0.5s, backdrop-filter 0.5s;
}

.sidebar-header {
  margin-bottom: 1rem;
}

.sidebar-label {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}

.category-list li {
  margin-bottom: 0.25rem;
}

.category-list li a {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.65rem 0.9rem;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-weight: 500;
  transition: background 0.2s, color 0.2s;
}

.category-list li a:hover,
.category-list li a.active {
  background: var(--accent-subtle);
  color: var(--accent);
}

.category-list li a i {
  width: 18px;
  text-align: center;
  font-size: 0.9rem;
}

.sidebar.folded {
  width: 0 !important;
  min-width: 0 !important;
  padding: 0 !important;
  overflow: hidden;
}

.site-header.folded {
  height: 0 !important;
  min-height: 0 !important;
  padding: 0 !important;
  overflow: hidden;
}

.sidebar.folded .fold-sidebar-btn {
  left: 0;
  background: var(--bg-card);
  box-shadow: var(--shadow);
}

.site-header.folded .fold-header-btn {
  background: var(--bg-card);
  box-shadow: var(--shadow);
}

.sidebar.folded .fold-sidebar-btn i,
.site-header.folded .fold-header-btn i {
  transform: rotate(180deg);
}

/* ===== Main content & cards ===== */
main {
  flex: 1;
  padding: 1.5rem;
}

.container {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 1.25rem;
  animation: fade-in 0.4s ease-out;
}

.box {
  background: var(--bg-card);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  transition: transform 0.25s, box-shadow 0.25s;
  height: 100%;
  border: 1px solid var(--border);
}

.box:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-lg);
}

.box a {
  display: flex;
  flex-direction: column;
  height: 100%;
}

.box-image {
  height: 140px;
  overflow: hidden;
  background: var(--bg);
}

.box-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.4s ease;
}

.box:hover .box-image img {
  transform: scale(1.06);
}

.box-content {
  padding: 1.1rem 1.25rem;
  flex: 1;
  display: flex;
  flex-direction: column;
}

.box h2 {
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 0.35rem;
}

.box p {
  font-size: 0.875rem;
  color: var(--text-muted);
  margin-top: auto;
}

.box.warn {
  display: none;
}

/* ===== Modals overlay ===== */
.modal {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 1000;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  background: rgba(15, 23, 42, 0.4);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  animation: fade-in 0.2s ease-out;
}

.modal .modal-card {
  background: var(--bg-card);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 420px;
  max-height: 90vh;
  overflow: hidden;
  animation: fade-in 0.25s ease-out;
  position: relative;
}

/* Liquid glass: password gate & admin panel (frosted glass) */
.modal-card--gate,
.modal-card.admin-panel {
  background: rgba(255, 255, 255, 0.18);
  backdrop-filter: blur(22px) saturate(200%);
  -webkit-backdrop-filter: blur(22px) saturate(200%);
  border: 1px solid rgba(255, 255, 255, 0.35);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15), inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

.modal-card--gate .gate-title {
  color: var(--text);
}

.modal-card--gate .gate-desc {
  color: var(--text-muted);
}

.modal-card--gate .gate-input {
  background: rgba(255, 255, 255, 0.25);
  border: 1px solid rgba(255, 255, 255, 0.4);
  color: var(--text);
}

.modal-card--gate .gate-input::placeholder {
  color: var(--text-muted);
}

.modal-card--gate .gate-input:focus {
  background: rgba(255, 255, 255, 0.35);
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-subtle);
}

.modal-card.admin-panel .modal-card__head {
  border-bottom: 1px solid rgba(255, 255, 255, 0.2);
}

.modal-card.admin-panel .modal-card__title {
  color: var(--text);
}

.modal-card.admin-panel .admin-controls,
.modal-card.admin-panel .tabs {
  border-bottom-color: rgba(255, 255, 255, 0.2);
}

.modal-card.admin-panel .form-group input,
.modal-card.admin-panel .form-group select {
  background: rgba(255, 255, 255, 0.25);
  border: 1px solid rgba(255, 255, 255, 0.35);
  color: var(--text);
}

.modal-card.admin-panel .form-group input::placeholder {
  color: var(--text-muted);
}

.modal-card.admin-panel .form-group label {
  color: var(--text);
}

.modal-card.admin-panel .drag-area {
  background: rgba(255, 255, 255, 0.2);
  border: 2px dashed rgba(255, 255, 255, 0.5);
}

.modal-card.admin-panel .drag-area:hover,
.modal-card.admin-panel .drag-area.active {
  background: rgba(255, 255, 255, 0.3);
  border-color: var(--accent);
}

.modal-card--gate {
  max-width: 400px;
}

.modal-card--narrow {
  max-width: 360px;
}

.modal-card--wide {
  max-width: 640px;
}

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

.modal-card__title {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.modal-card__title i {
  color: var(--accent);
}

.modal-card__body {
  padding: 1.5rem;
  overflow-y: auto;
  max-height: calc(90vh - 60px);
}

.close-btn,
.modal-card__close {
  position: absolute;
  top: 1rem;
  right: 1rem;
  width: 32px;
  height: 32px;
  border: none;
  background: none;
  color: var(--text-muted);
  font-size: 1.5rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  transition: background 0.2s, color 0.2s;
}

.close-btn:hover,
.modal-card__close:hover {
  background: var(--bg);
  color: var(--text);
}

.modal-card--gate .gate-close:hover,
.modal-card.admin-panel .modal-card__close:hover {
  background: rgba(255, 255, 255, 0.25);
  color: var(--text);
}

/* ===== Password gate (visitor entry) ===== */
.modal-card--gate .modal-card {
  padding: 0;
}

.gate-card {
  padding: 2.5rem 2rem;
  text-align: center;
  position: relative;
}

.gate-icon {
  width: 56px;
  height: 56px;
  margin: 0 auto 1.25rem;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), #8b5cf6);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
}

.gate-title {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 0.5rem;
}

.gate-desc {
  font-size: 0.95rem;
  color: var(--text-muted);
  margin-bottom: 1.5rem;
}

.gate-form {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.gate-input {
  width: 100%;
  padding: 0.85rem 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 1rem;
  font-family: inherit;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.gate-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-subtle);
}

.gate-btn {
  padding: 0.85rem 1.25rem;
  font-size: 1rem;
  font-weight: 600;
}

.gate-close {
  top: 0.75rem;
  right: 0.75rem;
}

/* ===== Settings page ===== */
.settings-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.9rem 0;
  border-bottom: 1px solid var(--border);
  gap: 1rem;
}

.settings-item:last-child {
  border-bottom: none;
}

.settings-label {
  font-size: 0.95rem;
  color: var(--text);
}

.settings-item--toggle {
  cursor: pointer;
  border: none;
}

.toggle-input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-slider {
  position: relative;
  width: 44px;
  height: 24px;
  background: var(--border);
  border-radius: 24px;
  transition: background 0.25s;
}

.toggle-slider::after {
  content: "";
  position: absolute;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #fff;
  top: 2px;
  left: 2px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
  transition: transform 0.25s;
}

.toggle-input:checked + .toggle-slider {
  background: var(--accent);
}

.toggle-input:checked + .toggle-slider::after {
  transform: translateX(20px);
}

/* ===== Buttons ===== */
.btn {
  padding: 0.6rem 1.2rem;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 0.95rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: inherit;
}

.btn--block {
  width: 100%;
}

.btn--sm {
  padding: 0.4rem 0.85rem;
  font-size: 0.875rem;
}

.btn--primary,
.primary-btn {
  background: var(--accent);
  color: #fff;
}

.btn--primary:hover,
.primary-btn:hover {
  background: var(--accent-hover);
}

.btn--secondary,
.secondary-btn {
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
}

.btn--secondary:hover,
.secondary-btn:hover {
  background: var(--border);
}

.btn--ghost {
  background: transparent;
  color: var(--text-muted);
}

.btn--ghost:hover {
  background: var(--accent-subtle);
  color: var(--accent);
}

.danger-btn {
  background: #dc2626;
  color: #fff;
}

.danger-btn:hover {
  background: #b91c1c;
}

/* ===== Admin panel ===== */
.admin-panel {
  max-width: 90%;
}

.admin-panel__head {
  flex-wrap: wrap;
  gap: 0.5rem;
}

.admin-panel__actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.admin-panel__body {
  padding-top: 1rem;
}

.admin-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  align-items: center;
  margin-bottom: 1.25rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border);
}

.admin-controls__item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.admin-controls__label {
  font-size: 0.9rem;
  color: var(--text);
}

.admin-controls__toggle {
  cursor: pointer;
}

.tabs {
  display: flex;
  gap: 0.25rem;
  margin-bottom: 1.25rem;
  border-bottom: 1px solid var(--border);
  padding-bottom: 0.75rem;
}

.tab-btn {
  padding: 0.5rem 1rem;
  border: none;
  background: none;
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: background 0.2s, color 0.2s;
}

.tab-btn:hover {
  color: var(--text);
  background: var(--bg);
}

.tab-btn.active {
  color: var(--accent);
  background: var(--accent-subtle);
}

.tab-content {
  animation: fade-in 0.2s ease-out;
}

.form-group {
  margin-bottom: 1.1rem;
}

.form-group label {
  display: block;
  margin-bottom: 0.4rem;
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text);
}

.form-group input[type="text"],
.form-group input[type="password"],
.form-group select {
  width: 100%;
  padding: 0.65rem 0.9rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.95rem;
  font-family: inherit;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.form-group input:focus,
.form-group select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-subtle);
}

.form-group input[type="checkbox"] {
  width: auto;
  margin-right: 0.5rem;
}

.category-selection {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.category-selection select {
  flex: 1;
}

.image-upload-container {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.drag-area {
  border: 2px dashed var(--border);
  border-radius: var(--radius-sm);
  padding: 1.25rem;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
  background: var(--bg);
}

.drag-area:hover,
.drag-area.active {
  border-color: var(--accent);
  background: var(--accent-subtle);
}

.drag-area .icon {
  font-size: 1.5rem;
  color: var(--accent);
  margin-bottom: 0.35rem;
}

.drag-area p {
  font-size: 0.875rem;
  color: var(--text-muted);
  margin: 0;
}

.drag-area p span {
  color: var(--accent);
  font-weight: 500;
}

.image-preview {
  display: none;
  max-height: 120px;
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.image-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.site-preview {
  margin: 1rem 0;
  padding: 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
}

/* Custom prompt (add category) */
.custom-prompt-overlay {
  position: fixed;
  inset: 0;
  z-index: 1001;
  background: rgba(15, 23, 42, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  animation: fade-in 0.2s ease-out;
}

.custom-prompt {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 1.5rem;
  max-width: 420px;
  width: 100%;
  box-shadow: var(--shadow-lg);
  animation: fade-in 0.25s ease-out;
}

.custom-prompt h3 {
  margin-bottom: 1rem;
  font-size: 1.1rem;
  color: var(--text);
}

.icon-suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1rem;
  max-height: 140px;
  overflow-y: auto;
  padding: 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

.icon-option {
  display: flex;
  align-items: center;
  padding: 0.4rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s;
}

.icon-option:hover {
  background: var(--bg);
}

.icon-option.selected {
  background: var(--accent-subtle);
  border-color: var(--accent);
}

.icon-option i {
  margin-right: 0.4rem;
}

.prompt-buttons {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  margin-top: 1rem;
}

/* Background video */
#bgVideo {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  object-fit: cover;
  z-index: -1;
  pointer-events: none;
}

/* ===== Responsive ===== */
@media (max-width: 992px) {
  .main-content {
    flex-direction: column;
  }

  .sidebar {
    width: 100%;
    padding: 1rem;
  }

  .container {
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  }
}

@media (max-width: 768px) {
  .site-header {
    padding: 0.6rem 1rem;
  }

  .header-nav ul {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--bg-card);
    box-shadow: var(--shadow-lg);
    flex-direction: column;
    padding: 0.5rem;
  }

  .header-nav ul.active {
    display: flex;
  }

  .header-nav li a {
    padding: 0.75rem 1rem;
  }

  .menu-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
  }

  main {
    padding: 1rem;
  }

  .container {
    grid-template-columns: 1fr;
  }

  .modal-card--wide {
    max-width: 100%;
  }

  .admin-panel__body {
    padding: 1rem;
  }

  .gate-card {
    padding: 1.75rem 1.5rem;
  }

  .gate-title {
    font-size: 1.35rem;
  }
}
