/* ==========================================
   Liao Wanning — Admin Styles
   ========================================== */
:root {
  --color-bg: #F5F5F3;
  --color-surface: #FFFFFF;
  --color-text: #1A1A1A;
  --color-text-light: #6B6B6B;
  --color-text-muted: #999999;
  --color-accent: #8B6F47;
  --color-accent-light: #C4A97D;
  --color-border: #E8E4DE;
  --color-border-light: #F0EDE8;
  --color-success: #4CAF50;
  --color-error: #E53935;
  --font-body: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --radius: 8px;
  --transition: 0.25s ease;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; }
body {
  font-family: var(--font-body);
  background: var(--color-bg);
  color: var(--color-text);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

/* ===== LOGIN PAGE ===== */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #F5F5F3 0%, #EDE8E0 100%);
}

.login-container {
  width: 100%;
  max-width: 400px;
  padding: 24px;
}

.login-card {
  background: var(--color-surface);
  border-radius: 12px;
  padding: 48px 40px 40px;
  box-shadow: 0 2px 20px rgba(0,0,0,0.06);
}

.login-header {
  text-align: center;
  margin-bottom: 36px;
}

.login-logo {
  font-family: Georgia, 'Times New Roman', serif;
  font-size: 1.4rem;
  font-weight: 600;
  color: var(--color-text);
  text-decoration: none;
  display: inline-block;
  margin-bottom: 20px;
}

.logo-dot { color: var(--color-accent); }

.login-title {
  font-size: 1.3rem;
  font-weight: 600;
  margin-bottom: 6px;
}

.login-subtitle {
  font-size: 0.85rem;
  color: var(--color-text-light);
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.form-group {
  position: relative;
}

.form-input {
  width: 100%;
  padding: 14px 0 6px;
  font-family: var(--font-body);
  font-size: 0.95rem;
  color: var(--color-text);
  background: transparent;
  border: none;
  border-bottom: 1.5px solid var(--color-border);
  outline: none;
  transition: var(--transition);
}

.form-input:focus {
  border-bottom-color: var(--color-accent);
}

.form-label {
  position: absolute;
  left: 0;
  top: 14px;
  font-size: 0.9rem;
  color: var(--color-text-muted);
  transition: var(--transition);
  pointer-events: none;
}

.form-input:focus ~ .form-label,
.form-input:not(:placeholder-shown) ~ .form-label {
  top: -4px;
  font-size: 0.7rem;
  color: var(--color-accent);
}

.form-error {
  display: none;
  font-size: 0.8rem;
  color: var(--color-error);
  margin-top: -12px;
}

.form-error.visible {
  display: block;
}

.btn-login {
  width: 100%;
  padding: 14px;
  font-family: var(--font-body);
  font-size: 0.9rem;
  font-weight: 500;
  background: var(--color-text);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  transition: var(--transition);
}

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

.login-hint {
  text-align: center;
  font-size: 0.78rem;
  color: var(--color-text-muted);
  margin-top: 20px;
}

.login-hint code {
  background: var(--color-border-light);
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 0.82rem;
}

/* ===== DASHBOARD ===== */
.dashboard-page {
  min-height: 100vh;
}

.dashboard-nav {
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  padding: 0 32px;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.dashboard-nav-left {
  display: flex;
  align-items: center;
  gap: 24px;
}

.dashboard-logo {
  font-family: Georgia, 'Times New Roman', serif;
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--color-text);
  text-decoration: none;
}

.dashboard-nav-links {
  display: flex;
  gap: 4px;
  list-style: none;
}

.dashboard-nav-links a {
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--color-text-light);
  padding: 8px 16px;
  border-radius: 6px;
  text-decoration: none;
  transition: var(--transition);
}

.dashboard-nav-links a:hover,
.dashboard-nav-links a.active {
  background: var(--color-border-light);
  color: var(--color-text);
}

.dashboard-nav-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.dashboard-user {
  font-size: 0.8rem;
  color: var(--color-text-muted);
}

.btn-logout {
  font-family: var(--font-body);
  font-size: 0.8rem;
  font-weight: 500;
  background: transparent;
  border: 1px solid var(--color-border);
  color: var(--color-text-light);
  padding: 6px 16px;
  border-radius: 6px;
  cursor: pointer;
  transition: var(--transition);
}

.btn-logout:hover {
  border-color: var(--color-error);
  color: var(--color-error);
}

.dashboard-main {
  max-width: 1100px;
  margin: 0 auto;
  padding: 40px 32px;
}

.dashboard-header {
  margin-bottom: 32px;
}

.dashboard-header h1 {
  font-size: 1.5rem;
  font-weight: 600;
  margin-bottom: 4px;
}

.dashboard-header p {
  font-size: 0.85rem;
  color: var(--color-text-light);
}

/* Dashboard cards */
.dashboard-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
  margin-bottom: 40px;
}

.stat-card {
  background: var(--color-surface);
  border-radius: var(--radius);
  padding: 24px;
  border: 1px solid var(--color-border-light);
}

.stat-card-label {
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 8px;
}

.stat-card-value {
  font-family: Georgia, 'Times New Roman', serif;
  font-size: 2rem;
  font-weight: 600;
  color: var(--color-text);
}

.stat-card-sub {
  font-size: 0.8rem;
  color: var(--color-text-light);
  margin-top: 2px;
}

/* Section cards */
.dashboard-section {
  background: var(--color-surface);
  border-radius: var(--radius);
  border: 1px solid var(--color-border-light);
  margin-bottom: 20px;
  overflow: hidden;
}

.dashboard-section-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--color-border-light);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

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

.btn-edit {
  font-family: var(--font-body);
  font-size: 0.78rem;
  font-weight: 500;
  background: transparent;
  border: 1px solid var(--color-border);
  color: var(--color-text-light);
  padding: 6px 14px;
  border-radius: 6px;
  cursor: pointer;
  transition: var(--transition);
}

.btn-edit:hover {
  border-color: var(--color-accent);
  color: var(--color-accent);
}

.dashboard-section-body {
  padding: 20px 24px;
}

/* Content items */
.content-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 0;
  border-bottom: 1px solid var(--color-border-light);
}

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

.content-item-title {
  font-size: 0.9rem;
  font-weight: 500;
}

.content-item-preview {
  font-size: 0.8rem;
  color: var(--color-text-muted);
  margin-top: 2px;
}

.content-item-actions {
  display: flex;
  gap: 8px;
}

.btn-sm {
  font-family: var(--font-body);
  font-size: 0.75rem;
  background: transparent;
  border: none;
  color: var(--color-text-muted);
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 4px;
  transition: var(--transition);
}

.btn-sm:hover {
  background: var(--color-border-light);
  color: var(--color-text);
}

/* ===== PAGE EDITOR ===== */
.editor-page .dashboard-main {
  max-width: 800px;
}

.editor-form {
  background: var(--color-surface);
  border-radius: var(--radius);
  border: 1px solid var(--color-border-light);
  padding: 32px;
}

.editor-field {
  margin-bottom: 24px;
}

.editor-field label {
  display: block;
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--color-text-light);
  margin-bottom: 8px;
}

.editor-field input,
.editor-field textarea {
  width: 100%;
  padding: 10px 14px;
  font-family: var(--font-body);
  font-size: 0.9rem;
  color: var(--color-text);
  border: 1px solid var(--color-border);
  border-radius: 6px;
  outline: none;
  transition: var(--transition);
  background: var(--color-bg);
}

.editor-field input:focus,
.editor-field textarea:focus {
  border-color: var(--color-accent);
}

/* Rich text editor */
.rich-toolbar {
  display: flex;
  gap: 4px;
  margin-bottom: 8px;
  padding: 6px 8px;
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: 6px 6px 0 0;
  border-bottom: none;
}

.rich-btn {
  font-family: var(--font-body);
  font-size: 0.85rem;
  padding: 4px 10px;
  background: transparent;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  color: var(--color-text-light);
  transition: var(--transition);
  line-height: 1.4;
}

.rich-btn:hover {
  background: var(--color-border-light);
  color: var(--color-text);
}

.rich-btn-img {
  margin-left: auto;
  font-size: 0.8rem;
}

.rich-editor {
  min-height: 180px;
  padding: 12px 14px;
  font-family: var(--font-body);
  font-size: 0.9rem;
  color: var(--color-text);
  border: 1px solid var(--color-border);
  border-radius: 0 0 6px 6px;
  outline: none;
  background: var(--color-bg);
  line-height: 1.7;
  overflow-y: auto;
}

.rich-editor:focus {
  border-color: var(--color-accent);
}

.rich-editor img {
  max-width: 100%;
  height: auto;
  border-radius: 4px;
  margin: 8px 0;
  display: block;
  box-shadow: 0 1px 6px rgba(0,0,0,0.08);
}

.rich-editor:empty::before {
  content: attr(data-placeholder);
  color: var(--color-text-muted);
  pointer-events: none;
}

.editor-field textarea {
  min-height: 120px;
  resize: vertical;
}

.editor-actions {
  display: flex;
  gap: 12px;
  margin-top: 32px;
}

.btn-save {
  font-family: var(--font-body);
  font-size: 0.9rem;
  font-weight: 500;
  padding: 10px 28px;
  background: var(--color-text);
  color: #fff;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  transition: var(--transition);
}

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

.btn-cancel {
  font-family: var(--font-body);
  font-size: 0.9rem;
  font-weight: 500;
  padding: 10px 28px;
  background: transparent;
  color: var(--color-text-light);
  border: 1px solid var(--color-border);
  border-radius: 6px;
  cursor: pointer;
  transition: var(--transition);
}

.btn-cancel:hover {
  color: var(--color-text);
  border-color: var(--color-text-muted);
}

.btn-sm-del {
  color: var(--color-error) !important;
}
.btn-sm-del:hover {
  background: #FDE8E8 !important;
}

/* ===== ADMIN TABLE ===== */
.admin-table {
  background: var(--color-surface);
  border-radius: var(--radius);
  border: 1px solid var(--color-border-light);
  overflow-x: auto;
}

.admin-table table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}

.admin-table th {
  text-align: left;
  padding: 14px 16px;
  font-weight: 500;
  color: var(--color-text-muted);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 1px;
  background: var(--color-bg);
  border-bottom: 1px solid var(--color-border);
}

.admin-table td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--color-border-light);
  vertical-align: middle;
}

.admin-table tr:last-child td {
  border-bottom: none;
}

.admin-table tr:hover td {
  background: var(--color-bg);
}

/* ===== LOADING ===== */
.loading {
  text-align: center;
  padding: 60px;
  color: var(--color-text-muted);
}

/* ===== DASHBOARD NAV SCROLL ===== */
.dashboard-nav-links {
  overflow-x: auto;
  white-space: nowrap;
  -webkit-overflow-scrolling: touch;
}

/* ===== MULTI-IMAGE UPLOAD ===== */
.multi-image-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 12px;
}

.multi-image-item {
  position: relative;
  display: inline-block;
}

.multi-image-item img {
  width: 120px;
  height: 120px;
  object-fit: cover;
  border-radius: 6px;
  border: 1px solid var(--color-border);
}

.btn-remove-img {
  position: absolute;
  top: -6px;
  right: -6px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: none;
  background: var(--color-error);
  color: #fff;
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2;
}

.img-title-input {
  display: block;
  width: 120px;
  margin-top: 4px;
  padding: 4px 6px;
  font-size: 0.75rem;
  font-family: var(--font-body);
  border: 1px solid var(--color-border);
  border-radius: 4px;
  outline: none;
  background: var(--color-bg);
  color: var(--color-text);
}

.img-title-input:focus {
  border-color: var(--color-accent);
}

.multi-image-upload {
  display: block;
  margin-top: 8px;
}

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
  .dashboard-stats {
    grid-template-columns: 1fr;
  }
  .dashboard-nav {
    padding: 0 16px;
  }
  .dashboard-main {
    padding: 24px 16px;
  }
  .editor-form {
    padding: 20px;
  }
}
