/* LCS — user list + admin + proof (mobile-first) */

:root {
  --fb: #1877f2;
  --fb-hover: #166fe5;
  --surface: #f0f2f5;
  --card: #ffffff;
  --text: #1c1e21;
  --muted: #65676b;
  --border: #ccd0d5;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 1rem;
  background: var(--surface);
  color: var(--text);
  line-height: 1.45;
  min-height: 100dvh;
}

.app-header {
  background: var(--card);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow);
}

.header-inner {
  max-width: 920px;
  margin: 0 auto;
  padding: 12px 14px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.app-header h1 {
  margin: 0;
  font-size: clamp(1rem, 2.8vw, 1.15rem);
  font-weight: 600;
  line-height: 1.25;
}

.nav-header {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 12px;
  align-items: center;
  justify-content: flex-end;
  max-width: 100%;
}

.nav-header a {
  color: var(--fb);
  font-weight: 600;
  text-decoration: none;
  font-size: 0.9rem;
}

.nav-header a:hover {
  text-decoration: underline;
}

main {
  max-width: 520px;
  margin: 0 auto;
  padding: 16px 12px 28px;
}

main.main--wide {
  max-width: 920px;
}

.lead {
  margin: 0 0 12px;
  font-size: 0.9rem;
  color: var(--text);
}

.muted {
  color: var(--muted);
  font-size: 0.85rem;
}

.empty-msg {
  margin: 0;
  padding: 16px;
  background: var(--card);
  border-radius: var(--radius);
  border: 1px dashed var(--border);
  text-align: center;
  color: var(--muted);
}

code {
  font-size: 0.88em;
  background: #e4e6eb;
  padding: 2px 6px;
  border-radius: 4px;
}

section {
  margin-bottom: 28px;
}

h2 {
  margin: 0 0 8px;
  font-size: 1rem;
  font-weight: 600;
}

.h2-like {
  margin: 0 0 10px;
  font-size: 1rem;
  font-weight: 600;
}

p.hint {
  margin: 0 0 12px;
  font-size: 0.9rem;
  color: var(--muted);
}

label {
  display: block;
  font-size: 0.85rem;
  margin-bottom: 6px;
  color: var(--muted);
}

input[type="url"],
input[type="text"],
input[type="password"],
input[type="number"] {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 1rem;
}

input + label {
  margin-top: 14px;
}

input:focus {
  outline: 2px solid rgba(24, 119, 242, 0.35);
  outline-offset: 0;
}

.card-block {
  background: var(--card);
  padding: 18px 16px 20px;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 16px;
  border-radius: 8px;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  text-decoration: none;
  width: 100%;
}

.btn--sm {
  width: auto;
  align-self: flex-start;
  padding: 8px 14px;
  font-size: 0.875rem;
}

.btn-primary {
  background: var(--fb);
  color: #fff;
}

.btn-primary:hover {
  background: var(--fb-hover);
}

.btn-primary:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.btn-outline {
  background: var(--card);
  color: var(--text);
  border: 1px solid var(--border);
}

.btn-outline:hover {
  background: var(--surface);
}

.mt-8 {
  margin-top: 8px;
}

.mt-12 {
  margin-top: 12px;
}

.mt-24 {
  margin-top: 24px;
}

.admin-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}

.btn--toolbar {
  width: auto;
  max-width: 100%;
  min-width: 140px;
}

.admin-key-card {
  margin-bottom: 20px;
}

.posts-table .cell-num {
  text-align: right;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.posts-table thead th.cell-num {
  text-align: right;
}

.posts-table .cell-actions {
  white-space: nowrap;
  vertical-align: middle;
}

.posts-table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin: 0;
  padding: 0;
  width: 100%;
  max-width: 100%;
}

.posts-table {
  width: 100%;
  min-width: 280px;
  border-collapse: collapse;
  background: var(--card);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
}

.posts-table.admin-table {
  min-width: 640px;
}

.posts-table thead th {
  text-align: left;
  padding: 12px 14px;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  color: var(--muted);
  border-bottom: 1px solid var(--border);
  background: #fafbfc;
}

.posts-table tbody td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
  font-size: 0.9rem;
}

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

.posts-table tbody tr:hover {
  background: #f7f8fa;
}

.table-link {
  color: var(--fb);
  font-weight: 600;
  text-decoration: none;
  word-break: break-word;
}

.table-link:hover {
  text-decoration: underline;
}

.table-link--url {
  font-weight: 500;
  color: var(--text);
  word-break: break-word;
  overflow-wrap: anywhere;
}

.pill {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 600;
  line-height: 1.2;
}

.pill--complete {
  background: #e7f3e8;
  color: #1e4620;
}

.pill--incomplete {
  background: #eef0f2;
  color: #65676b;
}

@media (max-width: 639px) {
  body {
    font-size: 0.875rem;
  }

  .app-header h1 {
    font-size: 0.95rem;
  }

  .nav-header a {
    font-size: 0.8rem;
  }

  .nav-header .muted {
    font-size: 0.78rem;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  main {
    padding: 12px 10px 24px;
  }

  main.main--wide {
    padding-left: 10px;
    padding-right: 10px;
  }

  .lead {
    font-size: 0.82rem;
  }

  .admin-toolbar {
    gap: 8px;
    margin-bottom: 12px;
  }

  .admin-toolbar .btn--toolbar {
    width: 100%;
    min-width: 0;
  }

  /* Desktop: admin needs horizontal scroll. Mobile: card rows — walang min-width. */
  .posts-table.admin-table {
    min-width: 0;
    width: 100%;
  }

  .posts-table thead {
    display: none;
  }

  .posts-table tbody tr {
    display: block;
    margin-bottom: 10px;
    border: 1px solid var(--border);
    border-radius: 10px;
    overflow: hidden;
    background: var(--card);
    box-shadow: var(--shadow);
  }

  .posts-table tbody tr:last-child {
    margin-bottom: 0;
  }

  .posts-table tbody td {
    display: grid;
    grid-template-columns: minmax(4.5rem, 26%) 1fr;
    column-gap: 8px;
    align-items: start;
    padding: 7px 10px;
    border-bottom: 1px solid var(--border);
    font-size: 0.8rem;
    line-height: 1.35;
  }

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

  .posts-table tbody td::before {
    content: attr(data-label);
    font-weight: 600;
    font-size: 0.62rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: var(--muted);
    line-height: 1.3;
    padding-top: 1px;
    word-break: break-word;
  }

  .posts-table tbody td > * {
    min-width: 0;
  }

  .posts-table .cell-num {
    text-align: right;
    font-variant-numeric: tabular-nums;
  }

  .posts-table .cell-num::before {
    text-align: left;
  }

  .posts-table .table-link,
  .posts-table .table-link--url {
    font-size: 0.78rem;
    font-weight: 600;
  }

  .posts-table .pill {
    font-size: 0.68rem;
    padding: 3px 8px;
  }

  .posts-table .cell-actions .btn {
    width: 100%;
  }

  .card-block {
    padding: 14px 12px 16px;
  }

  .proof-panel {
    padding: 12px;
  }

  .proof-placeholder {
    font-size: 0.8rem;
    padding: 12px;
  }

  .h2-like {
    font-size: 0.9rem;
  }

  p.hint {
    font-size: 0.78rem;
  }

  .proof-box {
    max-height: min(44vw, 200px);
  }

  .modal__title {
    font-size: 0.95rem;
  }

  .modal__body {
    padding: 12px;
  }

  label {
    font-size: 0.78rem;
  }

  input[type="url"],
  input[type="text"],
  input[type="password"],
  input[type="number"] {
    padding: 8px 10px;
    font-size: 16px; /* iwas zoom sa iOS */
  }

  .btn {
    font-size: 0.85rem;
    padding: 9px 14px;
  }
}

.proof-duo {
  display: grid;
  grid-template-columns: 1fr;
  gap: 24px;
}

@media (min-width: 640px) {
  .proof-duo {
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    align-items: start;
  }
}

.proof-panel {
  margin: 0;
  background: var(--card);
  padding: 16px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}

.proof-box {
  aspect-ratio: 16 / 10;
  background: #e4e6eb;
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  position: relative;
  max-height: min(56vw, 320px);
}

.proof-box.has-image {
  border-style: solid;
  padding: 0;
}

.proof-preview {
  display: none;
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #0a0a0a;
}

.proof-box.has-image .proof-preview {
  display: block;
}

.proof-placeholder {
  text-align: center;
  padding: 16px;
  color: var(--muted);
  font-size: 0.9rem;
}

.btn-clear {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: none;
  background: rgba(255, 255, 255, 0.9);
  cursor: pointer;
  font-size: 1.2rem;
  line-height: 1;
  box-shadow: var(--shadow);
}

.btn-clear:hover {
  background: #fff;
}

.file-hidden {
  position: absolute;
  width: 0;
  height: 0;
  opacity: 0;
  pointer-events: none;
}

.status {
  margin-top: 12px;
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 0.9rem;
  display: none;
}

.status.show {
  display: block;
}

.status.ok {
  background: #e7f3e8;
  color: #1e4620;
}

.status.err {
  background: #fde8e8;
  color: #8a1f1f;
}

footer.note {
  font-size: 0.8rem;
  color: var(--muted);
  margin-top: 8px;
}

.admin-list-mount {
  margin-top: 12px;
}

.admin-posts {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.admin-posts__item {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 14px 16px;
  background: var(--card);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}

@media (min-width: 560px) {
  .admin-posts__item {
    flex-direction: row;
    align-items: flex-start;
    justify-content: space-between;
  }
}

.admin-posts__body {
  flex: 1;
  min-width: 0;
}

.admin-posts__url {
  margin-top: 6px;
  word-break: break-all;
  font-size: 0.9rem;
}

.admin-posts__url a {
  color: var(--fb);
}

.admin-posts__id {
  margin-top: 8px;
  font-size: 0.8rem;
}

/* Modal — Add Post (blocks parent interaction) */
body.modal-open {
  overflow: hidden;
}

.modal[hidden] {
  display: none !important;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
}

.modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  cursor: pointer;
}

.modal__dialog {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: min(100% - 32px, 480px);
  max-height: min(92dvh, 720px);
  overflow-y: auto;
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.22);
  border: 1px solid var(--border);
  -webkit-overflow-scrolling: touch;
}

.modal__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: var(--card);
  z-index: 1;
}

.modal__title {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 600;
}

.modal__close {
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  border: none;
  background: transparent;
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
  color: var(--muted);
  border-radius: 8px;
}

.modal__close:hover {
  background: var(--surface);
  color: var(--text);
}

.modal__body {
  padding: 16px;
}

.modal__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 8px;
  justify-content: flex-end;
}

.modal__actions .btn {
  width: auto;
  min-width: 120px;
}

/* Admin — row select + context menu */
.posts-table.admin-table tbody tr.is-selected {
  background: #e8f0fe;
  outline: 2px solid var(--fb);
  outline-offset: -2px;
}

.context-menu {
  position: fixed;
  z-index: 1100;
  min-width: 220px;
  padding: 6px 0;
  margin: 0;
  list-style: none;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.18);
}

.context-menu[hidden] {
  display: none !important;
}

.context-menu__item {
  display: block;
  width: 100%;
  padding: 10px 14px;
  border: none;
  background: transparent;
  font: inherit;
  font-size: 0.9rem;
  text-align: left;
  cursor: pointer;
  color: var(--text);
}

.context-menu__item:hover,
.context-menu__item:focus {
  background: #f0f2f5;
  outline: none;
}

.context-menu__item--danger {
  color: #c62828;
}

.context-menu__item--danger:hover,
.context-menu__item--danger:focus {
  background: #ffebee;
}

.engagement-table-wrap {
  overflow-x: auto;
  margin-top: 12px;
}

table.engagement-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

table.engagement-table th,
table.engagement-table td {
  padding: 8px 10px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

table.engagement-table th {
  color: var(--muted);
  font-weight: 600;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

table.engagement-table .cell-check {
  text-align: center;
  width: 72px;
}
