/* =============================================================================
   Admin dashboard styles (login + dashboard + editor)
   ============================================================================= */

/* Respect the HTML `hidden` attribute everywhere. This prevents `display:flex`
   rules from accidentally revealing a hidden modal / panel / editor. */
[hidden] { display: none !important; }

.admin-body { background: var(--color-bg-alt, #faf3f4); }

.admin-header {
  background: var(--color-white, #fff);
  border-bottom: 1px solid var(--color-border, #f0d9dd);
}
.admin-header-inner {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 4px;
}
.admin-header-actions { display: flex; align-items: center; gap: 14px; }
.admin-user {
  display: inline-flex; align-items: center; gap: 8px;
  font-weight: 600; color: var(--color-dark, #1a0608);
}
.admin-user i { color: var(--color-primary, #c8102e); }

.btn-sm { padding: 8px 16px; font-size: 0.85rem; }
.btn-danger {
  background: #d93b3b; color: #fff;
  border: 2px solid transparent;
}
.btn-danger:hover { background: #b32a2a; color: #fff; transform: translateY(-1px); }

/* ----- Login page (full-screen, centered card) ----- */
.admin-login-body {
  min-height: 100vh;
  background:
    radial-gradient(circle at 20% 0%, rgba(200, 16, 46, 0.10), transparent 55%),
    radial-gradient(circle at 80% 100%, rgba(244, 166, 35, 0.12), transparent 55%),
    var(--color-bg-alt, #faf3f4);
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
}
.admin-login-body .admin-login {
  width: 100%;
  display: flex; align-items: center; justify-content: center;
}
.admin-login-card {
  width: 100%; max-width: 440px;
  background: var(--color-white, #fff);
  padding: 40px 36px 28px;
  border-radius: 24px;
  border: 1px solid var(--color-border, #f0d9dd);
  box-shadow: 0 24px 60px rgba(26, 6, 8, 0.18);
  text-align: center;
  position: relative;
}
.admin-login-logo {
  display: inline-block;
  margin-bottom: 8px;
}
.admin-login-logo img {
  height: 72px; width: auto; display: block;
}
.admin-login-icon {
  width: 72px; height: 72px; margin: 6px auto 18px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, var(--color-primary, #c8102e), var(--color-primary-light, #e63950));
  color: #fff; font-size: 1.7rem;
  box-shadow: 0 10px 24px rgba(200, 16, 46, 0.30);
}
.admin-login-card h1 {
  font-family: "Poppins", "Segoe UI", sans-serif;
  font-size: 1.7rem;
  margin: 0 0 6px;
  color: var(--color-dark, #1a0608);
  font-weight: 700;
}
.admin-login-card > p { color: var(--color-muted, #6b6b6b); margin-bottom: 22px; }
.admin-login-card form { text-align: left; display: grid; gap: 14px; }
.admin-login-pw { position: relative; }
.admin-login-pw input { padding-right: 44px; }
.admin-login-pw-toggle {
  position: absolute; right: 8px; top: 50%; transform: translateY(-50%);
  width: 32px; height: 32px;
  display: inline-flex; align-items: center; justify-content: center;
  background: none; border: none; cursor: pointer;
  color: var(--color-muted, #6b6b6b);
  border-radius: 6px;
}
.admin-login-pw-toggle:hover { background: var(--color-bg-alt, #faf3f4); color: var(--color-primary, #c8102e); }
.admin-login-back {
  display: inline-flex; align-items: center; gap: 6px;
  margin-top: 18px;
  font-size: 0.85rem;
  color: var(--color-muted, #6b6b6b);
}
.admin-login-back:hover { color: var(--color-primary, #c8102e); }
.admin-login-sub { color: var(--color-muted, #6b6b6b); margin-bottom: 22px; }
.admin-login-hint {
  margin-top: 22px; padding: 12px 14px;
  background: var(--color-bg-alt, #faf3f4);
  border-left: 3px solid var(--color-accent, #f4a623);
  border-radius: 6px;
  font-size: 0.85rem; color: var(--color-muted, #6b6b6b);
  text-align: left;
}
.admin-login-hint i { color: var(--color-accent, #f4a623); margin-right: 6px; }

/* ----- Self-contained form + button styles (so admin.html doesn't need style.css) ----- */
.form-field { display: block; }
.form-field label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--color-dark, #1a0608);
}
.form-field input,
.form-field select,
.form-field textarea {
  width: 100%;
  padding: 12px 14px;
  border: 1.5px solid var(--color-border, #f0d9dd);
  border-radius: 10px;
  font: inherit;
  font-size: 0.95rem;
  background: var(--color-bg, #fff);
  color: var(--color-text, #2b2b2b);
  transition: border-color 0.2s, box-shadow 0.2s;
  outline: none;
}
.form-field input::placeholder { color: #b9a4a8; }
.form-field input:focus,
.form-field select:focus,
.form-field textarea:focus {
  border-color: var(--color-primary, #c8102e);
  box-shadow: 0 0 0 4px rgba(200, 16, 46, 0.10);
}

.btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: 8px;
  padding: 14px 24px;
  border-radius: 999px;
  font-weight: 600;
  font-size: 0.95rem;
  letter-spacing: 0.02em;
  cursor: pointer;
  border: 2px solid transparent;
  white-space: nowrap;
  line-height: 1;
  transition: all 0.2s;
  text-decoration: none;
}
.btn:disabled { opacity: 0.65; cursor: not-allowed; }
.btn-lg { padding: 14px 26px; font-size: 1rem; }
.btn-primary {
  background: var(--color-primary, #c8102e);
  color: #fff;
  box-shadow: 0 6px 16px rgba(200, 16, 46, 0.30);
}
.btn-primary:hover:not(:disabled) {
  background: var(--color-primary-dark, #8a0a20);
  color: #fff;
  transform: translateY(-2px);
  box-shadow: 0 10px 22px rgba(200, 16, 46, 0.40);
}
.btn-ghost {
  background: rgba(255, 255, 255, 0.6);
  color: var(--color-dark, #1a0608);
  border-color: var(--color-border, #f0d9dd);
}
.btn-ghost:hover:not(:disabled) {
  background: var(--color-bg-alt, #faf3f4);
  border-color: var(--color-primary, #c8102e);
  color: var(--color-primary, #c8102e);
}

.form-feedback {
  display: none;
  padding: 10px 14px;
  background: rgba(200, 16, 46, 0.08);
  color: var(--color-primary-dark, #8a0a20);
  border-left: 4px solid var(--color-primary, #c8102e);
  border-radius: 6px;
  font-size: 0.92rem;
  margin-top: 4px;
}
.form-feedback.is-visible { display: block; }
.form-feedback.is-error { background: rgba(217, 59, 59, 0.10); color: #b32a2a; border-left-color: #d93b3b; }

/* ----- Dashboard ----- */
.admin-dashboard { padding: 30px 0 60px; }
.admin-tabs {
  display: flex; gap: 6px; margin-bottom: 24px;
  border-bottom: 2px solid var(--color-border, #f0d9dd);
  overflow-x: auto;
}
.admin-tab {
  padding: 12px 18px;
  background: none; border: none;
  font: inherit; font-weight: 600;
  color: var(--color-muted, #6b6b6b);
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  cursor: pointer;
  display: inline-flex; align-items: center; gap: 8px;
  white-space: nowrap;
  transition: color 0.2s, border-color 0.2s;
}
.admin-tab:hover { color: var(--color-primary, #c8102e); }
.admin-tab.is-active { color: var(--color-primary, #c8102e); border-bottom-color: var(--color-primary, #c8102e); }

.admin-toolbar {
  display: flex; gap: 10px; margin-bottom: 18px; flex-wrap: wrap;
}

/* ----- Posts table ----- */
.admin-table-wrap {
  background: var(--color-white, #fff);
  border-radius: var(--radius-md, 12px);
  border: 1px solid var(--color-border, #f0d9dd);
  overflow: hidden;
}
.admin-table {
  width: 100%; border-collapse: collapse;
}
.admin-table th, .admin-table td {
  text-align: left;
  padding: 14px 16px;
  border-bottom: 1px solid var(--color-border, #f0d9dd);
  font-size: 0.95rem;
  vertical-align: middle;
}
.admin-table thead th {
  background: var(--color-bg-alt, #faf3f4);
  color: var(--color-muted, #6b6b6b);
  font-weight: 600; font-size: 0.85rem; letter-spacing: 0.04em; text-transform: uppercase;
}
.admin-table tbody tr:last-child td { border-bottom: 0; }
.admin-table tbody tr:hover { background: rgba(200, 16, 46, 0.03); }

.post-thumb { width: 80px; }
.post-thumb img { width: 64px; height: 48px; object-fit: cover; border-radius: 6px; display: block; }
.post-thumb--placeholder {
  width: 64px; height: 48px;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--color-bg-alt, #faf3f4);
  border-radius: 6px;
  color: var(--color-muted, #6b6b6b);
}
.post-title-cell { font-weight: 600; color: var(--color-dark, #1a0608); }
.post-excerpt-cell { font-size: 0.85rem; color: var(--color-muted, #6b6b6b); margin-top: 2px; }
.post-tags-cell { margin-top: 6px; display: flex; flex-wrap: wrap; gap: 4px; }
.post-tag {
  display: inline-block;
  font-size: 0.72rem;
  padding: 3px 8px;
  background: rgba(200, 16, 46, 0.08);
  color: var(--color-primary, #c8102e);
  border-radius: 999px;
  font-weight: 600;
}
.post-actions { white-space: nowrap; }
.post-actions .btn { margin-right: 6px; }
.post-actions .btn:last-child { margin-right: 0; }

.admin-empty {
  text-align: center;
  padding: 60px 20px;
  color: var(--color-muted, #6b6b6b);
}
.admin-empty i { font-size: 2rem; color: var(--color-primary, #c8102e); display: inline-block; margin-bottom: 8px; }

/* ----- Editor (full-screen panel) ----- */
.admin-editor {
  background: var(--color-white, #fff);
  border: 1px solid var(--color-border, #f0d9dd);
  border-radius: var(--radius-md, 12px);
  padding: 24px;
  margin-top: 24px;
}
.admin-editor-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 18px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--color-border, #f0d9dd);
}
.admin-editor-head h2 { margin: 0; font-size: 1.3rem; }
.admin-editor-form { display: grid; gap: 16px; }
.admin-editor-form .form-field textarea {
  min-height: 320px;
  font-family: var(--font-body, "Inter", sans-serif);
  line-height: 1.6;
}
.form-hint {
  display: block;
  margin-top: 6px;
  font-size: 0.82rem;
  color: var(--color-muted, #6b6b6b);
}
.post-image-preview {
  display: flex; align-items: center; gap: 14px;
  padding: 12px;
  background: var(--color-bg-alt, #faf3f4);
  border-radius: var(--radius-sm, 6px);
  border: 1px solid var(--color-border, #f0d9dd);
}
.post-image-preview img {
  width: 140px; height: 100px; object-fit: cover;
  border-radius: 6px; display: block;
}
.post-image-source {
  display: flex; flex-wrap: wrap; gap: 14px;
  margin-bottom: 10px;
}
.post-image-source-option {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 8px 14px;
  background: var(--color-bg-alt, #faf3f4);
  border: 1px solid var(--color-border, #f0d9dd);
  border-radius: 999px;
  cursor: pointer;
  font-size: 0.88rem;
  font-weight: 500;
  transition: background 0.2s, border-color 0.2s;
}
.post-image-source-option:hover { background: rgba(200, 16, 46, 0.05); }
.post-image-source-option input { accent-color: var(--color-primary, #c8102e); }
.post-image-source-option:has(input:checked) {
  background: rgba(200, 16, 46, 0.10);
  border-color: var(--color-primary, #c8102e);
  color: var(--color-primary-dark, #8a0a20);
}
.post-image-remove {
  background: none; border: none; cursor: pointer;
  color: var(--color-danger, #d93b3b);
  font-weight: 600; font-size: 0.9rem;
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 10px; border-radius: 6px;
}
.post-image-remove:hover { background: rgba(217, 59, 59, 0.10); }
.admin-editor-actions {
  display: flex; justify-content: flex-end; gap: 10px;
  border-top: 1px solid var(--color-border, #f0d9dd);
  padding-top: 16px;
}

/* ----- Rich text editor (toolbar + content area) ----- */
.rte-toolbar {
  display: flex; flex-wrap: wrap; gap: 4px;
  padding: 6px;
  background: var(--color-bg-alt, #faf3f4);
  border: 1.5px solid var(--color-border, #f0d9dd);
  border-bottom: none;
  border-radius: 10px 10px 0 0;
  align-items: center;
}
.rte-btn {
  width: 32px; height: 32px;
  display: inline-flex; align-items: center; justify-content: center;
  background: transparent; border: 1px solid transparent;
  border-radius: 6px; cursor: pointer;
  color: var(--color-dark, #1a0608);
  font-size: 0.85rem;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.rte-btn:hover { background: rgba(200, 16, 46, 0.10); color: var(--color-primary, #c8102e); }
.rte-btn.is-active { background: rgba(200, 16, 46, 0.15); color: var(--color-primary-dark, #8a0a20); border-color: rgba(200, 16, 46, 0.30); }
.rte-select {
  height: 32px; padding: 0 8px;
  background: #fff; border: 1px solid var(--color-border, #f0d9dd);
  border-radius: 6px; font-size: 0.85rem; color: var(--color-dark, #1a0608);
  cursor: pointer;
}
.rte-sep {
  width: 1px; height: 20px; margin: 0 4px;
  background: var(--color-border, #f0d9dd);
}
.rte-editor {
  min-height: 360px;
  padding: 16px 18px;
  background: #fff;
  border: 1.5px solid var(--color-border, #f0d9dd);
  border-top: none;
  border-radius: 0 0 10px 10px;
  font-family: var(--font-body, "Inter", sans-serif);
  font-size: 1rem;
  line-height: 1.7;
  color: var(--color-text, #2b2b2b);
  outline: none;
  overflow-y: auto;
  max-height: 600px;
}
.rte-editor:focus { border-color: var(--color-primary, #c8102e); box-shadow: 0 0 0 4px rgba(200, 16, 46, 0.10); }
.rte-editor:empty::before {
  content: attr(data-placeholder);
  color: #b9a4a8;
  pointer-events: none;
}
/* Content rendered inside the editor */
.rte-editor h2 { font-family: "Poppins", sans-serif; font-size: 1.6rem; margin: 0.8em 0 0.4em; color: var(--color-dark, #1a0608); }
.rte-editor h3 { font-family: "Poppins", sans-serif; font-size: 1.3rem; margin: 0.7em 0 0.4em; color: var(--color-dark, #1a0608); }
.rte-editor h4 { font-family: "Poppins", sans-serif; font-size: 1.1rem; margin: 0.6em 0 0.4em; color: var(--color-dark, #1a0608); }
.rte-editor p  { margin: 0 0 0.8em; }
.rte-editor ul, .rte-editor ol { margin: 0 0 1em 1.4em; }
.rte-editor li { margin-bottom: 0.3em; }
.rte-editor blockquote {
  border-left: 4px solid var(--color-primary, #c8102e);
  padding: 10px 14px;
  margin: 0 0 1em;
  background: var(--color-bg-alt, #faf3f4);
  color: var(--color-muted, #6b6b6b);
  font-style: italic;
}
.rte-editor pre {
  background: #1a0608; color: #f5f5f5;
  padding: 14px 16px; border-radius: 8px;
  font-family: "Fira Code", Consolas, monospace;
  font-size: 0.9rem; line-height: 1.6;
  overflow-x: auto;
  margin: 0 0 1em;
}
.rte-editor a { color: var(--color-primary, #c8102e); text-decoration: underline; }

/* ----- Settings cards ----- */
.admin-card {
  background: var(--color-white, #fff);
  border: 1px solid var(--color-border, #f0d9dd);
  border-radius: var(--radius-md, 12px);
  padding: 24px;
  margin-bottom: 18px;
  max-width: 760px;
}
.admin-card h3 { margin: 0 0 16px; font-size: 1.1rem; display: inline-flex; align-items: center; gap: 8px; }
.admin-card h3 i { color: var(--color-primary, #c8102e); }
.admin-card-danger h3 i { color: var(--color-danger, #d93b3b); }
.admin-card-danger p { color: var(--color-muted, #6b6b6b); margin-bottom: 14px; }

/* ----- Confirm modal ----- */
.admin-modal {
  position: fixed; inset: 0; z-index: 200;
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
}
.admin-modal[hidden] { display: none !important; }
.admin-editor[hidden] { display: none !important; }
.admin-panel[hidden]   { display: none !important; }
.admin-modal-backdrop {
  position: absolute; inset: 0;
  background: rgba(26, 6, 8, 0.55);
  backdrop-filter: blur(2px);
}
.admin-modal-card {
  position: relative;
  max-width: 460px; width: 100%;
  background: var(--color-white, #fff);
  border-radius: var(--radius-lg, 20px);
  padding: 28px;
  box-shadow: var(--shadow-lg, 0 18px 48px rgba(26, 6, 8, 0.18));
}
.admin-modal-card h3 { margin: 0 0 8px; }
.admin-modal-card p { color: var(--color-muted, #6b6b6b); margin-bottom: 18px; }
.admin-modal-actions {
  display: flex; justify-content: flex-end; gap: 10px;
}

@media (max-width: 720px) {
  .admin-table thead { display: none; }
  .admin-table, .admin-table tbody, .admin-table tr, .admin-table td { display: block; width: 100%; }
  .admin-table tr {
    border-bottom: 1px solid var(--color-border, #f0d9dd);
    padding: 14px 16px;
  }
  .admin-table td { border-bottom: 0; padding: 6px 0; }
  .admin-table .post-thumb { width: 100%; }
  .admin-table .post-thumb img { width: 100%; height: 160px; }
  .post-actions { text-align: right; }
}
