/* Beacon ARC Data Viewer */

/* ─── Reset & Base ─── */
*, *::before, *::after { box-sizing: border-box; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', sans-serif;
  background: #f1f5f9;
  color: #1e293b;
  font-size: 14px;
  line-height: 1.5;
}

/* ─── Layout ─── */
.app-container {
  max-width: 1440px;
  margin: 0 auto;
  padding: 1rem 1.5rem;
}

/* ─── Header ─── */
.header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.25rem;
}

.header h1 {
  margin: 0;
  font-size: 1.3rem;
  font-weight: 700;
  color: #0f172a;
  letter-spacing: -0.01em;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 0.85rem;
  color: #64748b;
}

#session-timer {
  font-variant-numeric: tabular-nums;
  background: #e2e8f0;
  padding: 0.15rem 0.5rem;
  border-radius: 4px;
  font-size: 0.8rem;
  font-weight: 500;
  color: #475569;
}

#btn-help {
  all: unset;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 1px solid #cbd5e1;
  background: white;
  color: #64748b;
  font-size: 0.8rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s;
  font-family: inherit;
}

#btn-help:hover {
  background: #f1f5f9;
  border-color: #94a3b8;
  color: #1e293b;
}

#btn-extend {
  all: unset;
  display: inline-flex;
  align-items: center;
  padding: 0.15rem 0.5rem;
  font-size: 0.75rem;
  font-weight: 500;
  color: #2563eb;
  cursor: pointer;
  border-radius: 4px;
  transition: all 0.15s;
  font-family: inherit;
}

#btn-extend:hover {
  background: #eff6ff;
}

/* ─── Tabs ─── */
.tab-bar {
  display: flex;
  gap: 0;
  border-bottom: 2px solid #e2e8f0;
  margin-bottom: 1rem;
}

.tab-bar button {
  all: unset;
  cursor: pointer;
  padding: 0.5rem 1rem;
  font-size: 0.9rem;
  color: #64748b;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: color 0.15s, border-color 0.15s;
}

.tab-bar button:hover { color: #1e293b; }

.tab-bar button.active {
  color: #2563eb;
  border-bottom-color: #2563eb;
  font-weight: 600;
}

/* ─── Toolbar ─── */
.toolbar {
  display: flex;
  gap: 0.6rem;
  align-items: center;
  margin-bottom: 0.75rem;
  flex-wrap: wrap;
}

#search-box {
  width: 200px;
  padding: 0.4rem 0.6rem;
  font-size: 0.85rem;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  outline: none;
  background: white;
  color: #1e293b;
  font-family: inherit;
}

#search-box:focus {
  border-color: #2563eb;
  box-shadow: 0 0 0 2px rgba(37,99,235,0.12);
}

.toolbar select {
  padding: 0.4rem 0.5rem;
  font-size: 0.85rem;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  background: white;
  outline: none;
  color: #1e293b;
  font-family: inherit;
}

.toolbar select:focus {
  border-color: #2563eb;
  box-shadow: 0 0 0 2px rgba(37,99,235,0.12);
}

.toolbar .spacer { flex: 1; }

/* Toolbar buttons */
.toolbar button {
  all: unset;
  display: inline-flex;
  align-items: center;
  padding: 0.4rem 0.75rem;
  font-size: 0.85rem;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  background: white;
  color: #374151;
  cursor: pointer;
  transition: all 0.15s;
  font-family: inherit;
  white-space: nowrap;
}

.toolbar button:hover:not(:disabled) {
  background: #f1f5f9;
  border-color: #94a3b8;
}

.toolbar button:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

/* ─── Archived toggle ─── */
#archived-toggle {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.85rem;
  color: #475569;
  cursor: pointer;
  user-select: none;
}

#archived-toggle input[type="checkbox"] {
  width: 2rem;
  height: 1.1rem;
  appearance: none;
  -webkit-appearance: none;
  background: #cbd5e1;
  border-radius: 0.55rem;
  position: relative;
  cursor: pointer;
  transition: background 0.2s;
  flex-shrink: 0;
}

#archived-toggle input[type="checkbox"]::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 0.7rem;
  height: 0.7rem;
  background: white;
  border-radius: 50%;
  transition: transform 0.2s;
}

#archived-toggle input[type="checkbox"]:checked { background: #2563eb; }
#archived-toggle input[type="checkbox"]:checked::after { transform: translateX(0.9rem); }

/* ─── Table container ─── */
#table-container {
  min-height: 300px;
  background: white;
  border-radius: 8px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
  overflow: hidden;
}

/* ─── Tabulator overrides ─── */
.tabulator {
  font-size: 0.85rem;
  border: none;
  background: transparent;
}

/* Header */
.tabulator .tabulator-header {
  background: #f8fafc;
  border-bottom: 2px solid #e2e8f0;
}

.tabulator .tabulator-header .tabulator-col {
  background: transparent;
  border-right: 1px solid #e2e8f0;
}

.tabulator .tabulator-header .tabulator-col .tabulator-col-content {
  padding: 0.6rem 0.75rem;
}

.tabulator .tabulator-header .tabulator-col .tabulator-col-title {
  font-weight: 600;
  color: #475569;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/* Rows */
.tabulator .tabulator-tableholder .tabulator-table .tabulator-row {
  border-bottom: 1px solid #f1f5f9;
}

.tabulator .tabulator-row .tabulator-cell {
  padding: 0.5rem 0.75rem;
  border-right: none;
}

.tabulator .tabulator-row:hover {
  background: #f8fafc;
}

.tabulator .tabulator-row.tabulator-selected {
  background: #eff6ff;
}

.tabulator .tabulator-row.tabulator-selected:hover {
  background: #dbeafe;
}

/* ─── Pagination (the big fix) ─── */
.tabulator .tabulator-footer {
  background: #f8fafc;
  border-top: 1px solid #e2e8f0;
  padding: 0.5rem 0.75rem;
}

.tabulator .tabulator-footer .tabulator-footer-contents {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.tabulator .tabulator-footer .tabulator-paginator {
  display: flex;
  align-items: center;
  gap: 3px;
  flex-wrap: wrap;
}

.tabulator .tabulator-footer .tabulator-paginator label {
  font-size: 0.8rem;
  color: #64748b;
  margin: 0 0.3rem 0 0.5rem;
}

.tabulator .tabulator-footer .tabulator-page {
  all: unset;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 30px;
  height: 30px;
  padding: 0 0.35rem;
  font-size: 0.8rem;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  background: white;
  color: #374151;
  cursor: pointer;
  transition: all 0.12s;
  text-align: center;
  font-family: inherit;
}

.tabulator .tabulator-footer .tabulator-page:hover:not(:disabled):not(.active) {
  background: #e2e8f0;
  border-color: #94a3b8;
  color: #1e293b;
}

.tabulator .tabulator-footer .tabulator-page.active {
  background: #2563eb;
  color: white;
  border-color: #2563eb;
  font-weight: 600;
}

.tabulator .tabulator-footer .tabulator-page:disabled {
  opacity: 0.3;
  cursor: default;
}

.tabulator .tabulator-footer .tabulator-page-size {
  all: unset;
  display: inline-block;
  padding: 0.25rem 0.4rem;
  font-size: 0.8rem;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  background: white;
  cursor: pointer;
  font-family: inherit;
  color: #374151;
}

.tabulator .tabulator-footer .tabulator-page-counter {
  font-size: 0.8rem;
  color: #64748b;
}

/* ─── Checkboxes in table ─── */
.tabulator .tabulator-cell input[type="checkbox"],
.tabulator .tabulator-header input[type="checkbox"] {
  margin: 0;
  width: 1rem;
  height: 1rem;
  accent-color: #2563eb;
  cursor: pointer;
}

/* Prevent checkbox column from truncating */
.tabulator .tabulator-row .tabulator-cell:first-child,
.tabulator .tabulator-header .tabulator-col:first-child .tabulator-col-content {
  overflow: visible;
  text-overflow: clip;
}

/* ─── Status badges ─── */
.status-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 0.75rem;
  font-weight: 500;
  line-height: 1.5;
  white-space: nowrap;
}

.status-active   { background: #dcfce7; color: #166534; }
.status-waiting  { background: #fef3c7; color: #92400e; }
.status-blocked  { background: #fee2e2; color: #991b1b; }
.status-someday  { background: #f1f5f9; color: #475569; }
.status-done     { background: #dbeafe; color: #1e40af; }
.status-todo     { background: #fef3c7; color: #92400e; }
.status-filed    { background: #dcfce7; color: #166534; }
.status-needs_review { background: #fef3c7; color: #92400e; }
.status-fixed    { background: #dbeafe; color: #1e40af; }
.status-updated  { background: #dbeafe; color: #1e40af; }
.status-error    { background: #fee2e2; color: #991b1b; }
.status-archived { background: #fef3c7; color: #92400e; }

/* ─── Tags ─── */
.cell-tags span {
  display: inline-block;
  background: #eff6ff;
  color: #2563eb;
  padding: 1px 8px;
  border-radius: 10px;
  margin: 1px 2px;
  font-size: 0.75rem;
  font-weight: 500;
}

/* ─── Truncated text ─── */
.cell-truncate {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ─── Action column (no truncation) ─── */
.tabulator .tabulator-row .tabulator-cell.cell-action {
  overflow: visible;
  text-overflow: clip;
}

/* ─── Inline edit button (in row) ─── */
.row-edit-btn {
  all: unset;
  display: inline-flex;
  align-items: center;
  padding: 0.15rem 0.5rem;
  font-size: 0.78rem;
  color: #2563eb;
  cursor: pointer;
  border-radius: 4px;
  transition: background 0.1s;
  font-family: inherit;
}

.row-edit-btn:hover {
  background: #eff6ff;
}

/* ─── Modal ─── */
dialog {
  border: none;
  border-radius: 12px;
  padding: 0;
  max-width: 560px;
  width: 90vw;
  box-shadow: 0 20px 60px rgba(0,0,0,0.15), 0 4px 16px rgba(0,0,0,0.08);
}

dialog::backdrop {
  background: rgba(15,23,42,0.4);
  backdrop-filter: blur(2px);
}

dialog article {
  padding: 1.5rem;
}

dialog header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.25rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid #e2e8f0;
}

dialog header h3 {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 600;
  color: #0f172a;
}

#modal-close {
  all: unset;
  cursor: pointer;
  font-size: 1.3rem;
  color: #94a3b8;
  padding: 0.25rem;
  border-radius: 4px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
}

#modal-close:hover {
  color: #475569;
  background: #f1f5f9;
}

/* Form fields */
.form-field {
  margin-bottom: 1rem;
}

.form-field label {
  display: block;
  font-size: 0.78rem;
  font-weight: 600;
  color: #475569;
  margin-bottom: 0.35rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.form-field input[type="text"],
.form-field input[type="date"],
.form-field textarea,
.form-field select {
  width: 100%;
  padding: 0.5rem 0.6rem;
  font-size: 0.9rem;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  background: white;
  outline: none;
  font-family: inherit;
  color: #1e293b;
}

.form-field input[type="text"]:focus,
.form-field input[type="date"]:focus,
.form-field textarea:focus,
.form-field select:focus {
  border-color: #2563eb;
  box-shadow: 0 0 0 2px rgba(37,99,235,0.12);
}

.form-field textarea {
  min-height: 80px;
  resize: vertical;
}

.form-field small {
  display: block;
  font-size: 0.75rem;
  color: #94a3b8;
  margin-top: 0.2rem;
}

/* Switch in modal */
.form-field input[type="checkbox"] {
  width: 2.2rem;
  height: 1.2rem;
  appearance: none;
  -webkit-appearance: none;
  background: #cbd5e1;
  border-radius: 0.6rem;
  position: relative;
  cursor: pointer;
  transition: background 0.2s;
  vertical-align: middle;
}

.form-field input[type="checkbox"]::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 0.85rem;
  height: 0.85rem;
  background: white;
  border-radius: 50%;
  transition: transform 0.2s;
  box-shadow: 0 1px 2px rgba(0,0,0,0.1);
}

.form-field input[type="checkbox"]:checked { background: #2563eb; }
.form-field input[type="checkbox"]:checked::after { transform: translateX(1rem); }

/* Modal footer buttons */
dialog footer {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  margin-top: 1.25rem;
  padding-top: 0.75rem;
  border-top: 1px solid #e2e8f0;
}

#modal-cancel, #modal-save {
  all: unset;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.45rem 1.1rem;
  font-size: 0.9rem;
  font-weight: 500;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s;
  font-family: inherit;
}

#modal-cancel {
  background: #f1f5f9;
  color: #475569;
  border: 1px solid #e2e8f0;
}

#modal-cancel:hover { background: #e2e8f0; }

#modal-save {
  background: #2563eb;
  color: white;
}

#modal-save:hover { background: #1d4ed8; }

/* ─── Expired / Loading ─── */
.expired-container {
  text-align: center;
  padding: 6rem 1rem;
}

.expired-container h2 {
  margin: 0 0 0.5rem;
  font-size: 1.5rem;
  color: #0f172a;
}

.expired-container p {
  color: #64748b;
  font-size: 1rem;
}

.expired-container strong {
  color: #1e293b;
}

/* Loading spinner */
[aria-busy="true"]::before {
  content: '';
  display: inline-block;
  width: 1rem;
  height: 1rem;
  border: 2px solid #e2e8f0;
  border-top-color: #2563eb;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  margin-right: 0.5rem;
  vertical-align: middle;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ─── Help modal ─── */
#help-modal {
  max-width: 640px;
}

.help-article {
  padding: 1.5rem;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
}

.help-content {
  overflow-y: auto;
  padding-right: 0.5rem;
}

.help-content h4 {
  margin: 1.25rem 0 0.4rem;
  font-size: 0.9rem;
  font-weight: 600;
  color: #0f172a;
}

.help-content h4:first-child {
  margin-top: 0;
}

.help-content p {
  margin: 0 0 0.6rem;
  font-size: 0.85rem;
  color: #475569;
  line-height: 1.6;
}

.help-content strong {
  color: #1e293b;
  font-weight: 600;
}

.help-content em {
  color: #64748b;
  font-style: normal;
  background: #f1f5f9;
  padding: 0.1rem 0.3rem;
  border-radius: 3px;
  font-size: 0.82rem;
}

#help-dismiss {
  all: unset;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.45rem 1.5rem;
  font-size: 0.9rem;
  font-weight: 500;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s;
  font-family: inherit;
  background: #2563eb;
  color: white;
}

#help-dismiss:hover { background: #1d4ed8; }

/* ─── Responsive ─── */
@media (max-width: 768px) {
  .app-container { padding: 0.5rem; }
  .toolbar { flex-direction: column; align-items: stretch; }
  #search-box { width: 100%; }
}
