/* ============================================================
   dashboard.css – ZabiTech Dashboard
   ============================================================ */

[hidden] { display: none !important; }

/* ============================================================
   AUTH GATE
   ============================================================ */
.auth-gate {
  min-height: 60vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 40px 20px;
  color: var(--muted);
  font-size: 15px;
  transition: opacity .22s ease;
}
.auth-gate.is-leaving { opacity: 0; pointer-events: none; }
.auth-gate p { margin: 0; }
.auth-gate a {
  color: var(--primary);
  font-weight: 600;
  text-decoration: none;
}
.auth-gate a:hover { text-decoration: underline; }

.spinner-lg {
  width: 36px;
  height: 36px;
  border: 3px solid #dbeafe;
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ============================================================
   SHELL / MAIN
   ============================================================ */
.dash-shell { display: block; }

.dashboard-main {
  max-width: 860px;
  margin: 0 auto;
  padding: 30px 20px 60px;
}

/* ============================================================
   INTRO
   ============================================================ */
.dash-intro {
  text-align: center;
  margin-bottom: 24px;
}

.dash-title {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-size: clamp(1.4rem, 3vw, 1.85rem);
  font-weight: 700;
  margin: 0 0 10px;
  letter-spacing: -.02em;
  color: var(--text);
  line-height: 1.2;
}
.dash-title-wave { font-size: .95em; }

.dash-sub {
  max-width: 640px;
  margin: 0 auto;
  font-size: 1rem;
  color: var(--muted);
  line-height: 1.65;
}
.dash-sub strong { color: var(--text-2); }

/* ============================================================
   TABS
   ============================================================ */
.dash-nav {
  display: flex;
  gap: 6px;
  margin-bottom: 20px;
  padding: 4px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow-x: auto;
}

.dash-tab {
  flex: 1;
  min-width: 120px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 14px;
  font: inherit;
  font-size: 14.5px;
  font-weight: 600;
  color: var(--text-2);
  background: transparent;
  border: 0;
  border-radius: 8px;
  cursor: pointer;
  white-space: nowrap;
  transition: background .15s ease, color .15s ease;
}
.dash-tab:hover { background: #f1f5f9; }
.dash-tab.is-active {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 2px 6px rgba(0, 120, 212, .25);
}
.dash-tab.is-active .badge {
  background: rgba(255, 255, 255, .25);
  color: #fff;
}
.dash-tab:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

/* ============================================================
   TAB PANELS
   ============================================================ */
.tab-panel { display: none; }
.tab-panel.is-active { display: block; animation: fadeIn .25s ease; }

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ============================================================
   CARDS
   ============================================================ */
.dash-card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 18px;
  box-shadow: 0 8px 24px rgba(16, 24, 40, .06);
  padding: 24px;
}

.dash-card-title {
  margin: 0 0 6px;
  font-size: 1.2rem;
  font-weight: 700;
  letter-spacing: -.01em;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 10px;
}

.dash-card-sub {
  margin: 0 0 22px;
  color: var(--muted);
  font-size: .94rem;
  line-height: 1.55;
}

.badge {
  background: var(--border);
  color: var(--text-2);
  font-size: 11.5px;
  font-weight: 700;
  padding: 2px 9px;
  border-radius: 999px;
  display: inline-block;
}

/* ============================================================
   FIELDS
   ============================================================ */
.article-form .field { margin-bottom: 18px; }
.article-form .field:last-of-type { margin-bottom: 4px; }

.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
  margin-bottom: 18px;
}
.field-row .field { margin-bottom: 0; }

.field label,
.field-label {
  display: block;
  font-size: .9rem;
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--text-2);
}

.field .counter {
  margin: 5px 0 0;
  font-size: 12.5px;
  color: var(--muted);
  text-align: right;
}

.field .hint {
  margin: 5px 0 0;
  font-size: 12.5px;
  color: var(--muted);
  line-height: 1.5;
}

.field .error {
  display: none;
  margin: 5px 0 0;
  font-size: 12.5px;
  font-weight: 500;
  color: #dc2626;
  line-height: 1.45;
}
.field .error.is-visible { display: block; }

.muted { color: var(--muted); font-weight: 400; }

.article-form select {
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg width='20' height='20' viewBox='0 0 20 20' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M5 7.5L10 12.5L15 7.5' stroke='%23667085' stroke-width='1.5' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 40px;
  cursor: pointer;
}

/* ============================================================
   QUILL
   ============================================================ */
.editor-host { background: #fff; border-radius: 10px; }

#editor .ql-editor {
  min-height: 300px;
  max-height: 480px;
  overflow-y: auto;
  font-size: 15px;
  line-height: 1.65;
  padding: 16px 18px;
}

.editor-host .ql-toolbar.ql-snow {
  border: 1px solid var(--border-2, #cbd5e1) !important;
  border-top-left-radius: 10px;
  border-top-right-radius: 10px;
  border-bottom: 0 !important;
  background: #fcfcfd;
  font-family: inherit;
}

.editor-host .ql-container.ql-snow {
  border: 1px solid var(--border-2, #cbd5e1) !important;
  border-bottom-left-radius: 10px;
  border-bottom-right-radius: 10px;
  font-family: inherit;
  font-size: 15px;
}

/* ============================================================
   BUTTONS
   ============================================================ */
.form-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 22px;
  flex-wrap: wrap;
}

.btn-primary.btn-block {
  width: 100%;
  padding: 13px 22px;
  font-size: 15.5px;
  min-width: 0;
}

.btn-ghost {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 12px 18px;
  background: #fff;
  color: var(--text-2);
  border: 1px solid var(--border-2, #cbd5e1);
  border-radius: 10px;
  font: inherit;
  font-size: .95rem;
  font-weight: 500;
  cursor: pointer;
  transition: background .16s ease, border-color .16s ease;
}
.btn-ghost:hover { background: #f8fafc; }
.btn-ghost:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px rgba(0, 120, 212, .18);
}

.btn-sm { padding: 7px 12px; font-size: 13px; }

.btn-link-danger {
  background: none;
  border: 0;
  padding: 4px 8px;
  color: #dc2626;
  font: inherit;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  border-radius: 6px;
  transition: background .15s ease;
}
.btn-link-danger:hover { background: #fef2f2; }

.auth-status {
  margin: 14px 0 0;
  font-size: 13.5px;
  color: var(--primary);
  min-height: 18px;
  line-height: 1.5;
}

/* ============================================================
   MY POSTS
   ============================================================ */
.my-posts {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.article-card {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px 18px;
  background: #fff;
  transition: border-color .18s ease, box-shadow .18s ease;
}
.article-card:hover {
  border-color: var(--border-2, #cbd5e1);
  box-shadow: 0 8px 20px -10px rgba(16, 24, 40, .12);
}

.article-card-head {
  display: flex;
  gap: 8px;
  margin-bottom: 8px;
  flex-wrap: wrap;
}

.pill {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 700;
  background: var(--border);
  color: var(--text-2);
  letter-spacing: .01em;
  text-transform: capitalize;
}
.pill-approved { background: #d1fae5; color: #065f46; }
.pill-pending  { background: #dbeafe; color: #1e40af; }
.pill-rejected { background: #fee2e2; color: #991b1b; }
.pill-draft    { background: #fef3c7; color: #92400e; }

.article-card h3 {
  margin: 0 0 6px;
  font-size: 17px;
  font-weight: 700;
  color: var(--text);
  line-height: 1.35;
}

.article-card p {
  margin: 0 0 10px;
  font-size: 14px;
  line-height: 1.55;
  color: var(--muted);
}

.article-card-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-size: 12.5px;
  flex-wrap: wrap;
  border-top: 1px solid var(--border);
  padding-top: 10px;
  margin-top: 8px;
}

.empty {
  padding: 40px 20px;
  text-align: center;
  color: var(--muted);
  font-size: .95rem;
  line-height: 1.55;
  margin: 0;
  border: 1px dashed var(--border-2, #cbd5e1);
  border-radius: 12px;
  background: #fcfcfd;
}

/* ============================================================
   APPROVALS
   ============================================================ */
.approvals-list {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.approval-card {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 18px 20px;
  background: #fff;
  transition: border-color .18s ease, box-shadow .18s ease;
}
.approval-card:hover {
  border-color: var(--primary);
  box-shadow: 0 8px 20px -10px rgba(0, 120, 212, .18);
}

.approval-head {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-bottom: 10px;
  flex-wrap: wrap;
}

.approval-title {
  margin: 0 0 6px;
  font-size: 17px;
  font-weight: 700;
  color: var(--text);
  line-height: 1.35;
}

.approval-author {
  margin: 0 0 12px;
  font-size: 13px;
  color: var(--muted);
}
.approval-author strong { color: var(--text-2); }

.approval-excerpt {
  margin: 0 0 16px;
  padding: 12px 14px;
  font-size: 13.5px;
  line-height: 1.6;
  color: var(--text-2);
  background: #f8fafc;
  border-left: 3px solid var(--primary);
  border-radius: 0 8px 8px 0;
}

.approval-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  border-top: 1px solid var(--border);
  padding-top: 14px;
  align-items: center;
}

.btn-approve,
.btn-reject {
  padding: 8px 16px;
  font: inherit;
  font-size: 13.5px;
  font-weight: 600;
  border: 0;
  border-radius: 8px;
  cursor: pointer;
  transition: filter .15s ease, opacity .15s ease;
}
.btn-approve {
  background: #10b981;
  color: #fff;
}
.btn-reject {
  background: #dc2626;
  color: #fff;
}
.btn-approve:hover:not(:disabled),
.btn-reject:hover:not(:disabled) { filter: brightness(1.08); }
.btn-approve:disabled,
.btn-reject:disabled { opacity: .5; cursor: not-allowed; }

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 640px) {
  .dashboard-main { padding: 20px 14px 40px; }

  .dash-nav {
    padding: 3px;
    gap: 3px;
  }
  .dash-tab {
    min-width: 90px;
    padding: 9px 10px;
    font-size: 13.5px;
  }
  .dash-tab .badge {
    font-size: 10.5px;
    padding: 1px 7px;
  }

  .dash-card {
    padding: 18px 16px;
    border-radius: 14px;
  }
  .dash-card-title { font-size: 1.1rem; }
  .dash-card-sub   { font-size: .9rem; margin-bottom: 16px; }

  .field-row { grid-template-columns: 1fr; gap: 16px; }

  .form-actions {
    flex-direction: column;
    align-items: stretch;
  }
  .btn-primary.btn-block,
  .btn-ghost { width: 100%; }

  .dash-title { font-size: 1.3rem; }
  .dash-sub   { font-size: .94rem; }

  .article-card,
  .approval-card { padding: 14px; }
  .article-card h3,
  .approval-title { font-size: 15.5px; }

  .approval-actions {
    flex-direction: column;
    align-items: stretch;
  }
  .approval-actions .btn-ghost,
  .btn-approve,
  .btn-reject {
    width: 100%;
    text-align: center;
    justify-content: center;
  }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
    scroll-behavior: auto !important;
  }
}