/* ====================================================================
   NPD Stories Pro — Author Dashboard Styles  v2.4.0
   ==================================================================== */

/* ── Full-width breakout ── */
.npd-dashboard-wrap {
  width: 100%;
  position: relative;
  box-sizing: border-box;
  padding: 0 24px 40px;
  background: #f9f5f6;
  min-height: 60vh;
  overflow-x: hidden;
}

.npd-dashboard {
  max-width: 1200px;
  margin: 0 auto;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

/* ── Header ── */
.npd-dashboard-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 20px 24px; background: #fff; border-radius: 14px;
  box-shadow: 0 2px 12px rgba(94,29,45,.08); margin-bottom: 24px;
  flex-wrap: wrap; gap: 12px;
}
.npd-dashboard-welcome { display: flex; align-items: center; gap: 14px; }
.npd-dashboard-avatar  { width: 52px; height: 52px; border-radius: 50%; object-fit: cover; border: 3px solid #f0e6e9; }
.npd-dashboard-name    { font-size: 1.05rem; font-weight: 700; color: var(--npd-primary); margin: 0 0 2px; }
.npd-dashboard-role    { font-size: .78rem; color: #999; }

/* ── Toast — fixed, always on top ── */
#npd-toast {
  display: none;
  position: fixed;
  top: 24px; right: 24px;
  z-index: 999999;
  align-items: flex-start; gap: 10px;
  min-width: 300px; max-width: 440px;
  padding: 14px 16px 14px 18px;
  border-radius: 12px;
  font-size: .9rem; font-weight: 600; line-height: 1.5;
  box-shadow: 0 10px 32px rgba(0,0,0,.18), 0 2px 8px rgba(0,0,0,.10);
  animation: npdToastIn .25s ease forwards;
}
#npd-toast.npd-toast-show { display: flex; }
@keyframes npdToastIn {
  from { opacity: 0; transform: translateY(-14px) scale(.97); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}
#npd-toast.npd-t-success { background: #ecfdf5; color: #065f46; border-left: 5px solid #10b981; }
#npd-toast.npd-t-error   { background: #fef2f2; color: #991b1b; border-left: 5px solid #ef4444; }
#npd-toast.npd-t-info    { background: #eff6ff; color: #1e40af; border-left: 5px solid #3b82f6; }
#npd-toast.npd-t-warning { background: #fffbeb; color: #92400e; border-left: 5px solid #f59e0b; }
.npd-toast-icon  { font-size: 1.1rem; flex-shrink: 0; margin-top: 2px; }
.npd-toast-msg   { flex: 1; }
.npd-toast-close {
  flex-shrink: 0; background: none; border: none; cursor: pointer;
  font-size: 1.3rem; line-height: 1; padding: 0 0 0 4px; color: inherit;
  opacity: .5; transition: opacity .15s;
}
.npd-toast-close:hover { opacity: 1; }
@media (max-width: 520px) {
  #npd-toast { left: 12px; right: 12px; top: auto; bottom: 16px; min-width: 0; max-width: none; }
}

/* ── Posts toolbar ── */
.npd-posts-toolbar {
  display: flex; justify-content: space-between; align-items: flex-start;
  margin-bottom: 16px; flex-wrap: wrap; gap: 10px;
}
.npd-posts-count { font-size: .85rem; color: #777; font-weight: 600; padding-top: 10px; }

/* Desktop: all filters in one horizontal row */
.npd-posts-filters {
  display: flex; flex-direction: row; flex-wrap: wrap;
  gap: 8px; align-items: center;
}
.npd-posts-filters select {
  padding: 8px 14px; border: 2px solid #e8d8db; border-radius: 8px;
  font-size: .83rem; color: var(--npd-primary); background: #fff; cursor: pointer;
  min-width: 130px;
}
.npd-apply-filters-btn,
.npd-reset-filters-btn {
  padding: 8px 16px; font-size: .83rem; white-space: nowrap;
}

/* Tablet & mobile: stack filters vertically, full width */
@media (max-width: 768px) {
  .npd-posts-toolbar {
    flex-direction: column; align-items: stretch;
  }
  .npd-posts-count { padding-top: 0; }
  .npd-posts-filters {
    flex-direction: column; align-items: stretch; width: 100%;
  }
  .npd-posts-filters select {
    width: 100%; min-width: 0;
  }
  .npd-apply-filters-btn,
  .npd-reset-filters-btn {
    width: 100%; justify-content: center;
  }
}

/* ── Posts list ── */
.npd-posts-list  { display: flex; flex-direction: column; gap: 10px; }
.npd-post-row {
  display: flex; align-items: center; gap: 14px;
  background: #fff; border-radius: 12px; padding: 14px 18px;
  box-shadow: 0 2px 8px rgba(0,0,0,.06); transition: box-shadow .2s;
  flex-wrap: nowrap;
}
.npd-post-row:hover { box-shadow: 0 6px 18px rgba(0,0,0,.11); }
.npd-post-thumb    { width: 64px; height: 48px; object-fit: cover; border-radius: 8px; flex-shrink: 0; }
.npd-post-row-body { flex: 1; min-width: 0; }
.npd-post-row-title{ font-weight: 700; color: var(--npd-primary); font-size: .93rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.npd-post-cat      { font-size: .75rem; color: #999; font-weight: 600; margin: 2px 0 5px; display: block; }
.npd-post-row-meta { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-top: 4px; }
.npd-post-row-status {
  padding: 2px 10px; border-radius: 20px; font-size: .72rem; font-weight: 700; text-transform: uppercase;
}
.npd-status-publish{ background:#e8f5e9; color:#2e7d32; }
.npd-status-draft  { background:#fff8e1; color:#f57f17; }
.npd-status-pending{ background:#e3f2fd; color:#1565c0; }
.npd-post-row-views{ font-size: .78rem; color: #aaa; }
.npd-post-row-actions { display: flex; gap: 6px; flex-shrink: 0; }
.npd-post-row-actions button, .npd-btn-view-post {
  border: none; background: none; cursor: pointer; font-size: .8rem;
  padding: 6px 10px; border-radius: 7px; transition: background .2s; line-height: 1;
}
.npd-btn-edit-post  { color: var(--npd-primary); }
.npd-btn-edit-post:hover  { background: #f0e6e9; }
.npd-btn-delete-post{ color: #dc2626; }
.npd-btn-delete-post:hover{ background: #fef2f2; }
.npd-btn-view-post {
  display: inline-flex; align-items: center; justify-content: center;
  color: #0284c7; text-decoration: none !important;
}
.npd-btn-view-post:hover { background: #e0f2fe; }
.npd-loading  { text-align: center; padding: 48px; color: #bbb; font-size: .9rem; }
.npd-no-posts { text-align: center; padding: 48px; color: #ccc; font-size: .9rem; }

/* ── Pagination ── */
.npd-pagination { display: flex; gap: 6px; justify-content: center; margin-top: 20px; flex-wrap: wrap; }
.npd-page-btn {
  border: 2px solid #e8d0d5; border-radius: 8px;
  background: #fff; color: var(--npd-primary); font-weight: 700; font-size: .82rem;
  cursor: pointer; transition: all .2s;
}
.npd-page-btn:hover, .npd-page-btn.active { background: var(--npd-primary); color: #fff; border-color: var(--npd-primary); }

/* ── Edit-request badge ── */
.npd-er-badge {
  display: inline-flex; align-items: center; gap: 4px;
  background: #fff8e1; color: #b45309; border: 1px solid #fcd34d;
  border-radius: 4px; padding: 1px 7px; font-size: .7rem; font-weight: 700;
  margin-left: 8px; vertical-align: middle;
}

/* ════════════════════════════════════════════════════════
   EDITOR MODAL
════════════════════════════════════════════════════════ */
.npd-modal-dashboard-backdrop {
  display: none;
  position: fixed; inset: 0;
  background: rgba(30, 10, 18, .55);
  /* backdrop-filter removed — it creates a stacking context that traps
     the modal behind the overlay even at higher z-index */
  z-index: 9000;
}
.npd-modal-dashboard-backdrop.npd-modal-open { display: block; }

.npd-editor-modal {
  display: none;
  position: fixed;
  top: 0; right: 0; bottom: 0;
  width: 100%; max-width: 720px;
  background: #fff;
  z-index: 9001;
  flex-direction: column;
  box-shadow: -8px 0 40px rgba(0,0,0,.2);
  overflow: hidden;
  animation: npd-slide-in .28s ease forwards;
}
.npd-editor-modal.npd-modal-open { display: flex; }
@keyframes npd-slide-in {
  from { transform: translateX(100%); opacity: .5; }
  to   { transform: translateX(0);    opacity: 1; }
}

.npd-modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 24px; border-bottom: 2px solid #f0e6e9;
  background: #fff; flex-shrink: 0;
}
.npd-modal-header h4 { margin: 0; font-size: 1.05rem; font-weight: 700; color: var(--npd-primary); }
.npd-modal-header-actions { display: flex; align-items: center; gap: 10px; }
.npd-modal-close-btn {
  background: none; border: none; font-size: 1.5rem; line-height: 1;
  color: #aaa; cursor: pointer; padding: 0 4px; transition: color .15s;
}
.npd-modal-close-btn:hover { color: var(--npd-primary); }

.npd-modal-body {
  flex: 1; overflow-y: auto; padding: 24px;
  scrollbar-width: thin; scrollbar-color: #e8d0d5 transparent;
}

.npd-modal-footer {
  padding: 16px 24px; border-top: 2px solid #f0e6e9;
  background: #fdf8f9; display: flex; justify-content: space-between;
  align-items: center; flex-wrap: wrap; gap: 10px; flex-shrink: 0;
}
.npd-modal-footer-right { display: flex; gap: 8px; flex-wrap: wrap; }

/* ── Form fields ── */
.npd-form-group { margin-bottom: 20px; }
.npd-label { display: block; font-size: .88rem; font-weight: 700; color: #333; margin-bottom: 7px; }
.npd-required { color: #dc2626; margin-left: 2px; }
.npd-input, .npd-textarea, .npd-select {
  width: 100%; padding: 10px 14px; border: 2px solid #e8d0d5; border-radius: 9px;
  font-size: .93rem; color: #222; background: #fff; transition: border-color .2s;
  box-sizing: border-box; font-family: inherit;
}
.npd-input:focus, .npd-textarea:focus, .npd-select:focus {
  outline: none; border-color: var(--npd-primary); box-shadow: 0 0 0 3px rgba(94,29,45,.1);
}
.npd-textarea  { min-height: 72px; resize: vertical; }
.npd-select {
  cursor: pointer; appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24'%3E%3Cpath fill='%235E1D2D' d='M7 10l5 5 5-5z'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center;
  background-size: 18px; padding-right: 38px;
}

/* ── Post-type toggle ── */
.npd-type-buttons { display: flex; gap: 8px; }
.npd-type-btn {
  padding: 8px 18px; border: 2px solid #e8d0d5; border-radius: 8px;
  background: #fff; color: #888; font-size: .85rem; font-weight: 600;
  cursor: pointer; transition: all .2s; display: inline-flex; align-items: center; gap: 7px;
}
.npd-type-btn.active {
  background: var(--npd-primary); color: #fff;
  border-color: var(--npd-primary); box-shadow: 0 3px 10px rgba(94,29,45,.3);
}
.npd-type-btn:hover:not(.active) { border-color: var(--npd-primary); color: var(--npd-primary); }
.npd-type-btn.npd-type-btn-locked {
    opacity: 0.55;
    cursor: not-allowed;
    pointer-events: none;
}
.npd-type-btn.npd-type-btn-locked.active {
    opacity: 1;
    cursor: default;
}

/* ── Tag pills ── */
.npd-tag-checkboxes { display: flex; flex-wrap: wrap; gap: 8px; padding: 4px 0; }
.npd-checkbox-label {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 5px 13px; border: 2px solid #e8d0d5; border-radius: 20px;
  cursor: pointer; font-size: .82rem; font-weight: 600; color: #666;
  transition: background .15s, border-color .15s, color .15s; user-select: none;
}
.npd-checkbox-label input { display: none; }
.npd-checkbox-label:has(input:checked) {
  background: var(--npd-primary); border-color: var(--npd-primary); color: #fff;
}

/* ── Image upload area ── */
.npd-image-upload-area {
  border: 2px dashed #e8d0d5; border-radius: 10px;
  background: #fdf8f9; transition: border-color .2s; overflow: hidden;
}
.npd-image-upload-area:hover { border-color: var(--npd-primary); }
.npd-image-upload-label {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 8px; padding: 28px 16px; cursor: pointer; color: #bbb; transition: color .2s;
}
.npd-image-upload-label:hover { color: var(--npd-primary); }
.npd-image-upload-label span { font-size: .88rem; font-weight: 600; }
#npd-image-preview-wrap {
  display: none; position: relative; padding: 12px; text-align: center;
}
.npd-image-preview-img {
  max-width: 200px; max-height: 140px; border-radius: 8px;
  object-fit: cover; border: 2px solid #e8d0d5; display: block; margin: 0 auto;
}
.npd-image-remove-btn {
  position: absolute; top: 8px; right: 8px;
  background: #dc2626; color: #fff; border: none; border-radius: 50%;
  width: 24px; height: 24px; cursor: pointer; font-size: .8rem;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 2px 6px rgba(0,0,0,.2); transition: background .15s;
}
.npd-image-remove-btn:hover { background: #b91c1c; }
.npd-upload-progress { height: 4px; background: #f0e0e4; margin: 0 12px 12px; border-radius: 2px; overflow: hidden; }
.npd-upload-bar      { height: 100%; background: var(--npd-primary); transition: width .2s; }

/* ── CKEditor ── */
.npd-editor-textarea { display: none; }
.ck-editor__editable  { min-height: 220px; font-size: 1rem; line-height: 1.8; }
.npd-word-limit-badge {
  float: right; font-size: .72rem; font-weight: normal; color: #999;
  background: #f0e6e9; padding: 2px 8px; border-radius: 10px; margin-left: 8px;
}
.npd-word-counter     { font-size: .78rem; color: #aaa; text-align: right; margin-top: 6px; }
#npd-word-count       { font-weight: 700; color: var(--npd-primary); }
#npd-word-count.over-limit { color: #dc2626; }

/* ── Autosave status ── */
.npd-autosave-status { font-size: .78rem; color: #aaa; font-style: italic; }

/* ── Edit-request notice ── */
.npd-alert            { padding: 12px 16px; border-radius: 9px; font-size: .88rem; margin-bottom: 16px; }
.npd-alert-warning    { background: #fffbeb; color: #92400e; border-left: 4px solid #f59e0b; }

/* ── Buttons ── */
.npd-btn {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 9px 20px; border-radius: 9px; font-size: .88rem; font-weight: 700;
  border: 2px solid transparent; cursor: pointer; transition: all .2s; line-height: 1.2;
  text-decoration: none !important; white-space: nowrap;
}
.npd-btn:disabled { opacity: .55; cursor: not-allowed; }
.npd-btn-primary  { background: var(--npd-primary); color: #fff !important; border-color: var(--npd-primary); }
.npd-btn-primary:hover:not(:disabled)  { background: var(--npd-secondary); border-color: var(--npd-secondary); }
.npd-btn-secondary{ background: #f0e6e9; color: var(--npd-primary); border-color: #e8d0d5; }
.npd-btn-secondary:hover:not(:disabled){ background: #e8d0d5; }
.npd-btn-outline  { background: transparent; color: var(--npd-primary); border-color: #e8d0d5; }
.npd-btn-outline:hover:not(:disabled)  { background: #f9f0f2; border-color: var(--npd-primary); }
.npd-btn-warning  { background: #f59e0b; color: #fff; border-color: #f59e0b; }
.npd-btn-warning:hover:not(:disabled)  { background: #d97706; border-color: #d97706; }
.npd-btn-danger   { background: #ef4444; color: #fff; border-color: #ef4444; }

/* ── Login prompt ── */
.npd-login-prompt { text-align: center; padding: 60px 20px; }
.npd-login-prompt h5 { margin: 0 0 16px; color: var(--npd-primary); font-size: 1.1rem; }

/* ── Responsive ── */
@media (max-width: 640px) {
  .npd-dashboard-wrap { padding: 0 12px 32px; }
  .npd-dashboard-header { flex-direction: column; text-align: center; }
  .npd-post-row { flex-wrap: wrap; }
  .npd-editor-modal { max-width: 100%; border-radius: 0; }
  .npd-modal-footer-right { width: 100%; }
  .npd-modal-footer-right .npd-btn { flex: 1; justify-content: center; }
}

/* ── Story Tag Picker (in dashboard modal) ───────────────────────────── */
.npd-story-tag-picker {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 8px;
}
.npd-tag-pick-item {
    cursor: pointer;
    user-select: none;
    display: inline-flex;
}
.npd-tag-pick-item input[type="checkbox"] {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}
.npd-tag-pick-item .npd-story-tag-badge {
    opacity: 0.45;
    transition: opacity 0.2s, transform 0.15s;
    cursor: pointer;
}
.npd-tag-pick-item:hover .npd-story-tag-badge {
    opacity: 0.7;
}
.npd-tag-pick-item input:checked + .npd-story-tag-badge {
    opacity: 1;
    transform: scale(1.06);
    box-shadow: 0 2px 8px rgba(0,0,0,0.25);
}
.npd-label-hint {
    font-size: 11px;
    font-weight: 400;
    color: #888;
    margin-left: 6px;
}
