/* ============================================================
   admin.css — Shared stylesheet for AIS EduTrack admin pages
   (Data Logs, Backlog, Upload)
   Depends on: ../css/style.css (custom properties, base styles)
   ============================================================ */

/* ── Page layout ─────────────────────────────────────────── */

.admin-page {
  max-width: 1200px;
  margin: 0 auto;
  padding: 2rem 1.5rem 4rem;
}

.admin-page-header {
  display: flex;
  flex-direction: row;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
  gap: 1rem;
}

.admin-page-header h2 {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--grey-900);
  margin: 0;
}

.admin-header-actions {
  display: flex;
  flex-direction: row;
  gap: 0.5rem;
  align-items: center;
  flex-wrap: wrap;
}

/* ── Filters ─────────────────────────────────────────────── */

.admin-filter-select {
  border: 1px solid var(--grey-200);
  border-radius: var(--radius);
  padding: 0.35rem 0.6rem;
  font-size: 0.82rem;
  background: var(--white);
  color: var(--grey-700);
  cursor: pointer;
}

/* ── Table ───────────────────────────────────────────────── */

.admin-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.admin-table thead tr {
  background: var(--teal-900);
  color: var(--white);
}

.admin-table th {
  padding: 0.65rem 1rem;
  font-size: 0.78rem;
  font-weight: 600;
  text-align: left;
  letter-spacing: 0.04em;
  white-space: nowrap;
}

.admin-table td {
  padding: 0.6rem 1rem;
  font-size: 0.82rem;
  color: var(--grey-700);
  border-bottom: 1px solid var(--grey-100);
  vertical-align: middle;
}

.admin-table tbody tr {
  cursor: pointer;
  transition: background 0.1s;
}

.admin-table tbody tr:hover {
  background: var(--teal-50);
}

.admin-table tbody tr.row-active {
  background: var(--teal-50);
  border-left: 3px solid var(--teal-600);
}

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

.admin-table-empty {
  text-align: center;
  color: var(--grey-400);
  padding: 2rem;
  font-style: italic;
}

/* ── Status / log badges ─────────────────────────────────── */

.log-status-ok {
  display: inline-block;
  padding: 0.2rem 0.5rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 600;
  background: var(--green-bg);
  color: var(--green);
}

.log-status-err {
  display: inline-block;
  padding: 0.2rem 0.5rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 600;
  background: var(--red-bg);
  color: var(--red);
}

.log-row-error td {
  background: #fff8f8;
}

/* ── Backlog badges ──────────────────────────────────────── */

.badge {
  display: inline-block;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 600;
  margin-right: 0.25rem;
}

.badge-note {
  background: var(--grey-100);
  color: var(--grey-700);
}

.badge-feature {
  background: var(--teal-100);
  color: var(--teal-700);
}

.badge-draft {
  background: var(--grey-100);
  color: var(--grey-500);
}

.badge-backlog {
  background: var(--gold-100);
  color: #7a5a00;
}

.badge-done {
  background: var(--green-bg);
  color: var(--green);
}

/* ── Access denied ───────────────────────────────────────── */

.admin-access-denied {
  padding: 2rem;
  background: var(--grey-50);
  border: 1px solid var(--grey-200);
  border-radius: var(--radius);
  max-width: 480px;
  margin: 2rem auto;
  text-align: center;
}

.admin-access-denied p {
  color: var(--grey-700);
  font-weight: 600;
  margin-bottom: 0.5rem;
}

.admin-access-sub {
  color: var(--grey-400);
  font-size: 0.85rem;
  font-weight: 400;
}

/* ── Backlog layout (table + drawer side by side) ────────── */

.backlog-layout {
  display: flex;
  gap: 0;
  position: relative;
  min-height: 400px;
}

.backlog-table-wrap {
  flex: 1;
  overflow-x: auto;
  transition: width 0.25s;
}

.backlog-drawer {
  width: 0;
  overflow: hidden;
  transition: width 0.25s;
  border-left: 1px solid var(--grey-200);
  background: var(--white);
  display: flex;
  flex-direction: column;
}

.backlog-drawer.drawer-open {
  width: 480px;
  min-width: 320px;
}

/* ── Drawer internals ────────────────────────────────────── */

.drawer-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--grey-100);
}

.drawer-badges {
  display: flex;
  gap: 0.25rem;
  flex-wrap: wrap;
}

.drawer-close {
  background: none;
  border: none;
  font-size: 1rem;
  cursor: pointer;
  color: var(--grey-400);
  padding: 0.25rem 0.5rem;
  border-radius: var(--radius);
  transition: color 0.15s;
}

.drawer-close:hover {
  color: var(--grey-700);
}

.drawer-body {
  padding: 1.25rem;
  overflow-y: auto;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.drawer-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--grey-900);
  margin: 0;
  cursor: text;
  border-radius: 4px;
  padding: 2px 4px;
}

.drawer-title:hover {
  background: var(--grey-100);
}

.drawer-title-input {
  font-size: 1.1rem;
  font-weight: 700;
  width: 100%;
  border: 1px solid var(--teal-400);
  border-radius: 4px;
  padding: 2px 4px;
  outline: none;
}

.drawer-meta {
  font-size: 0.78rem;
  color: var(--grey-400);
  margin: 0;
}

.drawer-text {
  font-size: 0.85rem;
  color: var(--grey-700);
  line-height: 1.6;
  cursor: text;
  min-height: 40px;
  border-radius: 4px;
  padding: 4px;
}

.drawer-text:hover {
  background: var(--grey-100);
}

.drawer-text-placeholder {
  color: var(--grey-300);
  font-style: italic;
}

.drawer-text-input {
  width: 100%;
  min-height: 80px;
  border: 1px solid var(--teal-400);
  border-radius: 4px;
  padding: 0.5rem;
  font-size: 0.85rem;
  line-height: 1.5;
  resize: vertical;
  outline: none;
  font-family: inherit;
}

.drawer-actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.drawer-action-btn {
  background: var(--teal-600);
  color: var(--white);
  border: none;
  padding: 0.35rem 0.85rem;
  border-radius: var(--radius);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
}

.drawer-action-btn:hover {
  background: var(--teal-700);
}

.drawer-action-secondary {
  background: var(--grey-200);
  color: var(--grey-700);
}

.drawer-action-secondary:hover {
  background: var(--grey-300);
}

.drawer-action-danger {
  background: var(--red-bg);
  color: var(--red);
}

.drawer-action-danger:hover {
  background: var(--red);
  color: var(--white);
}

/* ── Comments ────────────────────────────────────────────── */

.drawer-comments {
  border-top: 1px solid var(--grey-100);
  padding-top: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.drawer-comments h4 {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--grey-500);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin: 0;
}

.comment {
  background: var(--grey-50);
  border-radius: var(--radius);
  padding: 0.65rem 0.75rem;
  position: relative;
}

.comment-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.35rem;
}

.comment-author {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--teal-700);
}

.comment-time {
  font-size: 0.72rem;
  color: var(--grey-400);
  flex: 1;
}

.comment-delete {
  background: none;
  border: none;
  color: var(--grey-300);
  cursor: pointer;
  font-size: 0.75rem;
  padding: 0.1rem 0.3rem;
  border-radius: 3px;
  transition: color 0.15s;
}

.comment-delete:hover {
  color: var(--red);
}

.comment-body {
  font-size: 0.82rem;
  color: var(--grey-700);
  line-height: 1.5;
  white-space: pre-wrap;
}

.comment-compose {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-top: 0.5rem;
}

.comment-compose textarea {
  border: 1px solid var(--grey-200);
  border-radius: var(--radius);
  padding: 0.5rem;
  font-size: 0.82rem;
  font-family: inherit;
  resize: vertical;
  outline: none;
  transition: border-color 0.15s;
}

.comment-compose textarea:focus {
  border-color: var(--teal-400);
}

/* ── Modal ───────────────────────────────────────────────── */

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-card {
  background: var(--white);
  border-radius: var(--radius);
  padding: 1.75rem;
  width: 480px;
  max-width: 90vw;
  box-shadow: var(--shadow-md);
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.modal-card h3 {
  font-size: 1.1rem;
  font-weight: 700;
  margin: 0;
}

.modal-field {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.modal-field label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--grey-700);
}

.modal-input,
.modal-textarea {
  border: 1px solid var(--grey-200);
  border-radius: var(--radius);
  padding: 0.5rem 0.75rem;
  font-size: 0.85rem;
  font-family: inherit;
  outline: none;
  transition: border-color 0.15s;
  width: 100%;
  box-sizing: border-box;
}

.modal-input:focus,
.modal-textarea:focus {
  border-color: var(--teal-400);
}

.modal-textarea {
  resize: vertical;
}

.modal-actions {
  display: flex;
  gap: 0.75rem;
  justify-content: flex-end;
  margin-top: 0.5rem;
}

.modal-cancel {
  background: none;
  border: 1px solid var(--grey-200);
  border-radius: var(--radius);
  padding: 0.4rem 1rem;
  font-size: 0.85rem;
  cursor: pointer;
  color: var(--grey-700);
  transition: all 0.15s;
}

.modal-cancel:hover {
  background: var(--grey-100);
}

/* ── Responsive ──────────────────────────────────────────── */

@media (max-width: 768px) {
  .admin-page {
    padding: 1rem 1rem 3rem;
  }

  .backlog-drawer.drawer-open {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    max-width: 480px;
    z-index: 150;
    box-shadow: var(--shadow-md);
  }
}
