/* ==========================================================================
   Base
   ========================================================================== */

/* Fallback for Tailwind's hidden class if CDN is delayed or unavailable. */
.hidden {
  display: none !important;
}

body {
  background: #f3f4f6;
  color: #111827;
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  line-height: 1.45;
}

/* ==========================================================================
   Components
   ========================================================================== */

.panel {
  background: #ffffff;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.03);
  transition: box-shadow 0.15s ease, border-color 0.15s ease;
}

.panel-header {
  background: #f3f4f6;
  border-bottom: 1px solid #d1d5db;
}

.table {
  width: 100%;
  border-collapse: collapse;
}

.table th {
  background: #f3f4f6;
  color: #374151;
  font-weight: 600;
  text-align: left;
}

.table th,
.table td {
  padding: 12px 14px;
  border-bottom: 1px solid #e5e7eb;
  vertical-align: top;
  line-height: 1.4;
}

.table tr[data-clickable="true"] {
  cursor: pointer;
}

.table tr[data-clickable="true"]:hover {
  background: #f9fafb;
}

.sort-indicator {
  margin-left: 6px;
  font-size: 11px;
  color: #6b7280;
}

.btn {
  background: #e5e7eb;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  padding: 8px 12px;
  font-size: 13px;
  font-weight: 500;
  color: #111827;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
}

.btn:hover {
  background: #e2e8f0;
}

.btn:active {
  transform: translateY(1px);
}

.btn-primary {
  background: #111827;
  border-color: #111827;
  color: #ffffff;
}

.btn-primary:hover {
  background: #1f2937;
  border-color: #1f2937;
}

.btn-danger {
  background: #ffffff;
  border-color: #fca5a5;
  color: #b91c1c;
}

.btn-danger:hover {
  background: #fef2f2;
  border-color: #ef4444;
}

.link {
  color: #111827;
  text-decoration: underline;
  text-underline-offset: 2px;
  text-decoration-thickness: 1px;
}

.tag {
  display: inline-block;
  padding: 2px 6px;
  border-radius: 999px;
  border: 1px solid #d1d5db;
  font-size: 11px;
  color: #374151;
  background: #f9fafb;
}

.stat-card {
  border: 1px solid #d1d5db;
  border-radius: 8px;
  background: #ffffff;
}

/* ==========================================================================
   Layout And Overflow
   ========================================================================== */

/* Keep dense admin tables usable on narrow screens. */
#programs-list,
#sessions-list,
#users-list,
#diagnostics-list,
#page-feedback .panel,
#user-detail-sessions-table {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

#programs-list .table {
  min-width: 900px;
}

#sessions-list .table {
  min-width: 1200px;
}

#users-list .table {
  min-width: 1400px;
}

#diagnostics-list .table {
  min-width: 900px;
}

#page-feedback .table {
  min-width: 1000px;
}

#user-detail-sessions-table {
  min-width: 700px;
}

#top-nav-links {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
}

#top-nav-links .nav-link {
  flex: 0 0 auto;
  transition: background 0.15s ease, color 0.15s ease;
}

#top-nav-links .nav-link.active {
  background: #111827;
  color: #ffffff;
}

/* Improve keyboard navigation clarity across controls. */
.btn:focus-visible,
.link:focus-visible,
.nav-link:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 2px solid #1f2937;
  outline-offset: 2px;
}

.btn:disabled,
button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.table thead th {
  position: sticky;
  top: 0;
  z-index: 1;
}

.table tbody tr:nth-child(even) {
  background: #fcfcfd;
}

.page-header {
  margin-bottom: 1.25rem;
}

.page-header h2 {
  letter-spacing: -0.01em;
}

@keyframes skeleton-shimmer {
  0% { background-position: -400px 0; }
  100% { background-position: 400px 0; }
}

.skeleton {
  border-radius: 6px;
  background: linear-gradient(90deg, #f3f4f6 25%, #e5e7eb 37%, #f3f4f6 63%);
  background-size: 800px 100%;
  animation: skeleton-shimmer 1.2s infinite linear;
}

.skeleton-line {
  height: 12px;
  width: 100%;
}

/* ==========================================================================
   Responsive
   ========================================================================== */

@media (max-width: 768px) {
  .table th,
  .table td {
    padding: 10px 12px;
  }

  .panel {
    border-radius: 10px;
  }

  #main-content main {
    padding: 1rem;
  }

  #main-content h2 {
    font-size: 1.5rem;
    line-height: 1.9rem;
  }
}

/* ==========================================================================
   Diff View
   ========================================================================== */

.diff-line {
  position: relative;
}

.diff-line.diff-added:hover,
.diff-line.diff-removed:hover {
  filter: brightness(0.95);
}

/* Blame tooltip on hover */
.diff-line[title]:hover::after {
  content: attr(title);
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  background: #1f2937;
  color: #f9fafb;
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 10px;
  font-family: system-ui, -apple-system, sans-serif;
  white-space: nowrap;
  z-index: 10;
  pointer-events: none;
}

.btn-secondary {
  background: #f3f4f6;
  border: 1px solid #d1d5db;
  border-radius: 4px;
  font-size: 12px;
  color: #374151;
}

.btn-secondary:hover {
  background: #e5e7eb;
}

/* History item selection states */
.history-item {
  transition: all 0.15s ease;
}
