/* ==========================================================================
   YPPD Admin Dashboard
   ========================================================================== */

.admin-body { background: var(--bg); min-height: 100vh; }

/* ---------------------------------- Topbar ---------------------------------- */
.admin-topbar { background: var(--white); border-bottom: 1px solid var(--border); }
.admin-topbar-inner {
  max-width: 1100px; margin: 0 auto; padding: 16px 24px;
  display: flex; align-items: center; justify-content: space-between;
}
.admin-topbar .brand img.logo-img { height: 48px; filter: none; }
.admin-topbar-actions { display: flex; align-items: center; gap: 12px; }

/* Buttons throughout the admin dashboard are more compact than the public site's */
.admin-body .btn { padding: 9px 18px; font-size: 0.85rem; }

/* ---------------------------------- Main ---------------------------------- */
.admin-main { max-width: 1100px; margin: 0 auto; padding: 40px 24px 80px; }
.admin-main-narrow { max-width: 760px; }
.admin-main h1 { color: var(--navy); margin-bottom: 4px; }
.admin-sub { color: var(--muted); font-size: 0.92rem; }
.admin-main-head { display: flex; align-items: center; justify-content: space-between; gap: 20px; margin-bottom: 28px; flex-wrap: wrap; }

.admin-empty {
  background: var(--white); border: 1px dashed var(--border); border-radius: var(--radius);
  padding: 48px; text-align: center; color: var(--muted);
}

/* ---------------------------------- Table ---------------------------------- */
.admin-table-wrap { background: var(--white); border-radius: var(--radius); box-shadow: var(--shadow-soft); overflow: hidden; overflow-x: auto; }
.admin-table { width: 100%; border-collapse: collapse; min-width: 640px; }
.admin-table th {
  text-align: left; font-family: var(--ff-heading); font-size: 0.78rem; letter-spacing: 0.04em;
  text-transform: uppercase; color: var(--muted); padding: 16px 20px; border-bottom: 1px solid var(--border);
}
.admin-table td { padding: 14px 20px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.admin-table tr:last-child td { border-bottom: none; }
.admin-nowrap { white-space: nowrap; }

.admin-post-cell { display: flex; align-items: center; gap: 14px; }
.admin-thumb { width: 52px; height: 52px; border-radius: 10px; object-fit: cover; flex-shrink: 0; background: var(--bg-alt); }
.admin-thumb-empty { background: var(--bg-alt); }
.admin-post-title { font-weight: 600; color: var(--ink); }
.admin-post-excerpt { font-size: 0.85rem; color: var(--muted); max-width: 320px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.admin-badge {
  display: inline-block; padding: 4px 12px; border-radius: 100px; font-size: 0.78rem; font-weight: 600;
}
.admin-badge-live { background: rgba(1,114,180,0.12); color: var(--blue-dark); }
.admin-badge-draft { background: var(--bg-alt); color: var(--muted); }

.admin-actions-cell { display: flex; gap: 8px; align-items: center; }
.admin-inline-form { display: inline-flex; margin: 0; }
.admin-icon-btn {
  display: inline-flex; align-items: center; justify-content: center; width: 34px; height: 34px;
  border-radius: 8px; border: 1px solid var(--border); background: var(--white); color: var(--navy);
  cursor: pointer; transition: all .15s ease;
}
.admin-icon-btn svg { width: 16px; height: 16px; }
.admin-icon-btn:hover { border-color: var(--blue); color: var(--blue); }
.admin-icon-btn-danger:hover { border-color: #b91c1c; color: #b91c1c; }

/* ---------------------------------- Edit-post header ---------------------------------- */
.admin-edit-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 24px; }
.admin-edit-head h1 { margin-bottom: 2px; }

/* ---------------------------------- Form ---------------------------------- */
.admin-form { background: var(--white); border-radius: var(--radius); box-shadow: var(--shadow-soft); padding: 8px 32px; }
.admin-form-section { padding: 24px 0; border-bottom: 1px solid var(--border); }
.admin-form-section:last-of-type { border-bottom: none; }
.admin-form label { display: block; font-size: 0.85rem; font-weight: 600; color: var(--navy); margin: 20px 0 8px; }
.admin-form label:first-child { margin-top: 0; }
.admin-form input[type="text"],
.admin-form input[type="date"],
.admin-form textarea {
  width: 100%; border: 1.5px solid var(--border); border-radius: 10px; padding: 12px 14px;
  font-family: var(--ff-body); font-size: 0.94rem; background: var(--bg); box-sizing: border-box;
  transition: border-color .2s ease, background .2s ease;
}
.admin-form input:focus, .admin-form textarea:focus { outline: none; border-color: var(--blue); background: var(--white); }
.admin-hint { font-weight: 400; color: var(--muted); font-size: 0.8rem; }

/* Slug-regeneration note */
.admin-slug-note {
  display: flex; align-items: flex-start; gap: 10px; background: var(--bg-alt); border-radius: 10px;
  padding: 12px 14px; font-size: 0.85rem; color: var(--muted); cursor: pointer;
}
.admin-slug-note input { width: auto; margin-top: 3px; accent-color: var(--blue); }
.admin-slug-note code { background: var(--white); padding: 2px 6px; border-radius: 4px; color: var(--navy); border: 1px solid var(--border); }

/* Cover-image dropzone */
.admin-dropzone {
  position: relative; border-radius: 12px; overflow: hidden;
  border: 1.5px dashed var(--border); background: var(--bg); cursor: pointer;
  transition: border-color .2s ease, background .2s ease;
}
.admin-dropzone:hover { border-color: var(--blue); background: var(--bg-alt); }
.admin-dropzone-input { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; z-index: 1; }
.admin-dropzone-empty {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
  padding: 40px 20px; text-align: center; color: var(--muted); pointer-events: none;
}
.admin-dropzone-empty svg { width: 30px; height: 30px; color: var(--blue); margin-bottom: 4px; }
.admin-dropzone-empty strong { color: var(--navy); }
.admin-dropzone-preview { position: relative; border-style: solid; }
.admin-dropzone-preview img { width: 100%; height: 220px; object-fit: cover; display: block; }
.admin-dropzone-overlay {
  position: absolute; inset: 0; background: rgba(11,47,69,0.55);
  display: flex; align-items: center; justify-content: center;
  opacity: 0; transition: opacity .2s ease; pointer-events: none;
}
.admin-dropzone:hover .admin-dropzone-overlay { opacity: 1; }
.admin-dropzone-change {
  color: var(--white); font-family: var(--ff-heading); font-weight: 600; font-size: 0.88rem;
  border: 1.5px solid rgba(255,255,255,0.75); border-radius: 100px; padding: 9px 20px;
}
.admin-dropzone-remove {
  position: absolute; top: 10px; right: 10px; z-index: 3; width: 30px; height: 30px; border-radius: 50%;
  border: none; background: rgba(11,47,69,0.78); color: var(--white); font-size: 1.15rem; line-height: 1;
  cursor: pointer; display: flex; align-items: center; justify-content: center; transition: background .15s ease;
}
.admin-dropzone-remove:hover { background: #b91c1c; }
.admin-upload-status { font-size: 0.85rem; color: var(--blue); margin: 10px 0 0; }

/* Rich-text editor */
#editor { background: var(--white); border-radius: 0 0 10px 10px; min-height: 260px; }
.ql-toolbar.ql-snow { border-radius: 10px 10px 0 0; background: var(--bg-alt); border-color: var(--border) !important; }
.ql-container.ql-snow { border-color: var(--border) !important; font-family: var(--ff-body); font-size: 0.96rem; }

/* Publish row + toggle switch */
.admin-form-row { display: grid; grid-template-columns: 1fr auto; gap: 20px; align-items: center; }
label.admin-toggle { display: flex; align-items: center; gap: 12px; cursor: pointer; margin: 0; position: relative; }
.admin-toggle input { position: absolute; opacity: 0; width: 0; height: 0; }
.admin-toggle-track {
  display: inline-block;
  position: relative; width: 44px; height: 24px; border-radius: 100px; background: var(--border);
  transition: background .2s ease; flex-shrink: 0;
}
.admin-toggle-track::after {
  content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%;
  background: var(--white); box-shadow: 0 1px 3px rgba(0,0,0,0.3); transition: transform .2s ease;
}
.admin-toggle input:checked + .admin-toggle-track { background: var(--blue); }
.admin-toggle input:checked + .admin-toggle-track::after { transform: translateX(20px); }
.admin-toggle-label { font-size: 0.9rem; font-weight: 600; color: var(--navy); }
.admin-toggle-label span { display: block; font-size: 0.78rem; font-weight: 400; color: var(--muted); margin-top: 1px; }

.admin-form-actions { display: flex; justify-content: flex-end; gap: 12px; padding: 24px 0; }
@media (max-width: 640px) { .admin-form { padding: 8px 22px; } .admin-form-row { grid-template-columns: 1fr; justify-items: start; gap: 16px; } }

/* ---------------------------------- Login ---------------------------------- */
.admin-login-wrap {
  min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 24px;
}
.admin-login-card {
  width: 100%; max-width: 380px; background: var(--white); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 40px 36px; text-align: center;
}
.admin-login-logo { height: 52px; margin-bottom: 28px; }
.admin-login-card h1 { font-size: 1.4rem; color: var(--navy); margin-bottom: 4px; }
.admin-login-sub { color: var(--muted); font-size: 0.9rem; margin-bottom: 22px; }
.admin-login-card label { display: block; text-align: left; font-size: 0.85rem; font-weight: 600; color: var(--navy); margin: 14px 0 8px; }
.admin-login-card input {
  width: 100%; border: 1px solid var(--border); border-radius: 10px; padding: 12px 14px;
  font-family: var(--ff-body); font-size: 0.94rem; background: var(--bg); box-sizing: border-box;
}
.admin-login-card input:focus { outline: none; border-color: var(--blue); background: var(--white); }
.admin-login-card .btn { margin-top: 20px; }
.admin-error {
  background: rgba(185,28,28,0.08); color: #b91c1c; border-radius: 8px; padding: 10px 14px;
  font-size: 0.88rem; margin-bottom: 4px;
}

@media (max-width: 640px) {
  .admin-form-row { grid-template-columns: 1fr; }
  .admin-table { min-width: 560px; }
}
