:root {
  /* Light theme (default) */
  --bg-color: #ffffff;
  --bg-color-rgb: 255, 255, 255;
  --text-color: #333333;
  --link-color: #888888; /* Neutral grey instead of blue/teal */
  --link-hover-color: #555555; /* Darker grey for hover */
  --border-color: #dddddd;
  --code-bg: #f5f5f5;
  --table-row-alt: #f9f9f9;
  --table-border: #e0e0e0;
}

[data-theme="dark"] {
  /* Dark theme */
  --bg-color: #1a1a1a;
  --bg-color-rgb: 26, 26, 26;
  --text-color: #e0e0e0;
  --link-color: #bbbbbb; /* Lighter grey for dark mode */
  --link-hover-color: #eeeeee; /* Even lighter grey for hover */
  --border-color: #444444;
  --code-bg: #2a2a2a;
  --table-row-alt: #252525;
  --table-border: #444444;
}

/* Base Styles */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

/* Background Canvas */
#background-canvas {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: -1;
  opacity: 0.35; /* Slightly reduced opacity for light mode */
  pointer-events: auto; /* Allow interacting with the canvas */
  will-change: transform; /* Force hardware acceleration */
  transform: translateZ(0); /* Force GPU rendering */
  backface-visibility: hidden; /* Helps with rendering on mobile devices */
}

[data-theme="dark"] #background-canvas {
  opacity: 0.6; /* Increased opacity for dark mode */
}

/* Apply a mask to fade the background in the center where content is */
body::after {
  content: "";
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: -1;
  pointer-events: none;
  /* Inverted radial gradient - transparent at edges, solid in center */
  background: radial-gradient(
    circle at center,
    var(--bg-color) 0%,
    rgba(var(--bg-color-rgb), 0.85) 40%,
    rgba(var(--bg-color-rgb), 0.5) 70%,
    rgba(var(--bg-color-rgb), 0) 100%
  );
  will-change: opacity; /* Force hardware acceleration */
  transform: translateZ(0); /* Force GPU rendering */
  backface-visibility: hidden; /* Helps with rendering */
}

html {
  scroll-behavior: smooth;
}

body {
  font-family: "Inter", -apple-system, BlinkMacSystemFont, sans-serif;
  line-height: 1.6;
  max-width: 800px;
  margin: 0 auto;
  padding: 20px;
  background-color: var(--bg-color);
  color: var(--text-color);
  transition: background-color 0.3s, color 0.3s;
}

/* Typography */
h1,
h2,
h3,
h4 {
  margin: 1.5rem 0 1rem 0;
  line-height: 1.2;
}

h1 {
  font-size: 1.8rem;
  margin-top: 0;
  font-weight: 600;
}

h2 {
  font-size: 1.4rem;
  font-weight: 500;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--border-color);
}

p,
ul,
ol,
dl {
  margin-bottom: 1rem;
  text-align: justify;
}

/* Reduced line spacing for paragraphs */
p {
  line-height: 1.4; /* Reduced from the body's 1.6 */
}

a {
  color: var(--link-color);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
  color: var(--link-hover-color);
}

/* Header */
header {
  margin-bottom: 2rem;
  position: relative;
}

.subtitle {
  font-size: 1rem;
  margin-top: 0.5rem;
}

/* Caution Box */
.caution-box {
  background-color: #ffebee;
  border: 1px solid #f44336;
  color: #c62828;
  padding: 10px 15px;
  margin: 10px 0;
  border-radius: 4px;
  font-size: 0.9rem;
  text-align: center;
  font-weight: 500;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12);
  transition: background-color 0.3s, border-color 0.3s, color 0.3s;
}

/* Dark theme version of the caution box */
[data-theme="dark"] .caution-box {
  background-color: rgba(136, 14, 10, 0.2); /* Darker, more transparent red */
  border: 1px solid #ff5252; /* Brighter red border for contrast */
  color: #ff8a80; /* Lighter red text for better readability */
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
}

.theme-toggle {
  position: absolute;
  top: 0;
  right: 0;
  display: flex;
  gap: 10px;
}

.theme-toggle button {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 1.5rem;
  color: var(--text-color);
}

/* Background toggle specific styles */
.bg-toggle-off .bg-icon {
  opacity: 0.5;
}

.bg-toggle-on .bg-icon {
  opacity: 1;
}

/* Main Content */
main {
  margin-bottom: 3rem;
}

section {
  margin-bottom: 2.5rem;
}

.actions {
  margin: 1.5rem 0;
  display: flex;
  justify-content: space-between;
  line-height: 2;
}

.actions a + a::before {
  content: "";
  margin: 0;
}

/* Search Bar */
.search-container {
  margin: 2rem 0 0.5rem 0;
  width: 100%;
}

.search-bar {
  display: flex;
  width: 100%;
  margin: 0 auto;
}

.search-bar input {
  flex: 1;
  padding: 10px 15px;
  border: 1px solid var(--border-color);
  border-radius: 4px 0 0 4px;
  font-size: 1rem;
  background-color: var(--bg-color);
  color: var(--text-color);
}

.search-bar button {
  flex: 0 0 auto;
  padding: 6px 10px;
  background-color: var(--code-bg);
  color: var(--text-color);
  border: 1px solid var(--border-color);
  border-radius: 0 4px 4px 0;
  margin-left: -1px;
  cursor: pointer;
  font-size: 1rem;
  text-decoration: none;
  transition: background-color 0.2s, color 0.2s;
}

.search-bar button:hover {
  background-color: var(--bg-color);
}

/* Action Buttons - New Style */
.action-buttons {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.action-button {
  flex: 1 1 auto;
  white-space: nowrap;
  text-align: center;
  padding: 6px 10px;
  border: 1px solid var(--border-color);
  background-color: var(--code-bg);
  color: var(--text-color);
  border-radius: 4px;
  cursor: pointer;
  font-size: 1rem;
  text-decoration: none;
  transition: background-color 0.2s, color 0.2s;
  min-width: 0;
}

.action-button:hover {
  background-color: var(--bg-color);
}

/* Mobile responsive adjustments for action buttons */
@media (max-width: 600px) {
  .action-buttons {
    justify-content: stretch;
    gap: 0.5rem;
  }
  
  .action-button {
    flex: 1 1 0;
    min-width: calc(50% - 0.25rem); /* Two buttons per row minimum */
    max-width: none; /* Remove max-width constraint */
  }
}

/* Members Table */
.table-container {
  position: relative;
  margin: 1rem 0;
  border: 1px solid var(--table-border);
  border-radius: 4px;
  overflow: hidden;
}

.table-wrapper {
  width: 100%;
  overflow-x: scroll;
  scroll-behavior: smooth;
}

/* Custom scrollbar styling */
.table-wrapper::-webkit-scrollbar {
  height: 8px;
}

.table-wrapper::-webkit-scrollbar-track {
  background: var(--bg-color);
}

.table-wrapper::-webkit-scrollbar-thumb {
  background: var(--border-color);
  border-radius: 4px;
}

.table-wrapper::-webkit-scrollbar-thumb:hover {
  background: var(--text-color);
}

/* Firefox scrollbar styling */
.table-wrapper {
  scrollbar-width: thin;
  scrollbar-color: var(--border-color) var(--bg-color);
}

/* Prevent column compression at all screen sizes */
#members-table {
  width: max-content;
  min-width: 100%;
}

#members-table th,
#members-table td {
  white-space: nowrap;
  min-width: fit-content;
}

/* Specific minimum widths for different columns */
#members-table th:nth-child(1),
#members-table td:nth-child(1) {
  min-width: 40px; /* Icon column */
}

#members-table th:nth-child(2),
#members-table td:nth-child(2) {
  min-width: 120px; /* Website column */
}

#members-table th:nth-child(3),
#members-table td:nth-child(3) {
  min-width: 100px; /* Name column */
}

#members-table th:nth-child(4),
#members-table td:nth-child(4) {
  min-width: 80px; /* Program column */
}

#members-table th:nth-child(5),
#members-table th:nth-child(6),
#members-table th:nth-child(7),
#members-table td:nth-child(5),
#members-table td:nth-child(6),
#members-table td:nth-child(7) {
  min-width: 30px; /* Action columns */
}

.scroll-indicator {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  font-weight: bold;
  color: var(--text-color);
  cursor: pointer;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s, visibility 0.3s;
  z-index: 10;
  user-select: none;
  pointer-events: none;
}

.scroll-indicator.left {
  left: 0;
  background: linear-gradient(
    to right,
    rgba(var(--bg-color-rgb), 0.95) 0%,
    rgba(var(--bg-color-rgb), 0.8) 70%,
    rgba(var(--bg-color-rgb), 0) 100%
  );
  border-radius: 4px 0 0 4px;
}

.scroll-indicator.right {
  right: 0;
  background: linear-gradient(
    to left,
    rgba(var(--bg-color-rgb), 0.95) 0%,
    rgba(var(--bg-color-rgb), 0.8) 70%,
    rgba(var(--bg-color-rgb), 0) 100%
  );
  border-radius: 0 4px 4px 0;
}

.scroll-indicator.visible {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

.scroll-indicator:hover {
  color: var(--link-hover-color);
}

.scroll-indicator:hover.left {
  background: linear-gradient(
    to right,
    rgba(var(--bg-color-rgb), 1) 0%,
    rgba(var(--bg-color-rgb), 0.9) 70%,
    rgba(var(--bg-color-rgb), 0) 100%
  );
}

.scroll-indicator:hover.right {
  background: linear-gradient(
    to left,
    rgba(var(--bg-color-rgb), 1) 0%,
    rgba(var(--bg-color-rgb), 0.9) 70%,
    rgba(var(--bg-color-rgb), 0) 100%
  );
}

table {
  width: 100%;
  border-collapse: collapse;
  margin: 0;
  font-size: 0.9rem;
  border: none;
}

th,
td {
  padding: 0.25rem 0.5rem; /* Reduced vertical padding while keeping horizontal padding */
  text-align: left;
  border-bottom: 1px solid var(--table-border);
}

th {
  font-weight: 500;
}

tr:nth-child(even) {
  background-color: var(--table-row-alt);
}

#member-count {
  font-weight: 500;
}

/* Code Blocks */
pre {
  background-color: var(--code-bg);
  padding: 1rem;
  border-radius: 8px;
  overflow-x: auto;
  margin: 1rem 0;
}

code {
  font-family: "Fira Mono", monospace;
  font-size: 0.85rem;
}

/* Lists */
ol,
ul {
  padding-left: 1.5rem;
}

li {
  margin-bottom: 0.5rem;
}

/* Definition Lists */
dl {
  margin: 1rem 0;
}

dt {
  font-weight: 500;
  margin-top: 0.5rem;
}

dd {
  margin-left: 1.5rem;
}

/* Footer */
footer {
  padding-top: 1rem;
  margin-top: 2rem;
  border-top: 1px solid var(--border-color);
  font-size: 0.9rem;
  text-align: center;
}

/* Widget Example */
.widget-example {
  margin: 2rem 0;
  display: flex;
  justify-content: center;
}

.widget-container {
  display: flex;
  align-items: center;
  gap: 15px;
  background-color: var(--code-bg);
  padding: 15px 25px;
  border-radius: 8px;
  border: 1px solid var(--border-color);
}

.widget-container a {
  color: var(--text-color);
  text-decoration: none;
  font-size: 1.5rem;
}

.widget-icon {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.widget-icon img {
  width: 100%;
  height: 100%;
}

/* Responsive Adjustments */
@media (max-width: 600px) {
  body {
    padding: 15px;
  }

  /* Table wrapper ensures proper scrolling */
  .table-wrapper {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch; /* Smooth scrolling on iOS */
  }
  
  /* Slightly more horizontal padding for mobile */
  #members-table th,
  #members-table td {
    padding: 0.25rem 0.75rem;
  }
}

/* Pagination */
.pagination {
  display: flex;
  justify-content: center;
  margin: 0;
  gap: 0;
  border-top: 1px solid var(--table-border);
  background-color: var(--bg-color);
  padding: 0;
  position: relative;
  z-index: 5;
}

.pagination button {
  padding: 6px 10px;
  border: 1px solid var(--border-color);
  background-color: var(--code-bg);
  color: var(--text-color);
  cursor: pointer;
  font-size: 1rem;
  border-radius: 0;
  margin-left: -1px;
  transition: background-color 0.2s, color 0.2s;
  text-decoration: none;
}

.pagination button:first-child {
  border-radius: 4px 0 0 4px;
  margin-left: 0;
}

.pagination button:last-child {
  border-radius: 0 4px 4px 0;
}

.pagination button.active {
  background-color: var(--bg-color);
  color: var(--text-color);
  border-color: var(--border-color);
  font-weight: normal;
}

.pagination button:hover:not(.active):not(:disabled) {
  background-color: var(--bg-color);
}

.pagination button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  background-color: var(--code-bg);
}

/* Member Badge */
.member-badge {
  max-width: 88px;
  max-height: 31px;
  width: auto;
  height: auto;
  border-radius: 0;
  display: block;
  margin: 0 auto;
  object-fit: contain;
  background-color: transparent;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

/* Remove hover effect on badges */
.member-badge:hover {
  transform: none;
}

/* Badge Row (for button.html) */
.badge-row {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 0;
  margin: 1.5rem 0;
  flex-wrap: wrap;
}

@media (max-width: 600px) {
  .badge-row {
    gap: 8px;
    margin: 1rem 0;
    justify-content: center;
  }
  .badge-row img {
    margin-bottom: 6px;
  }
}

/* Email Example (for button.html) */
.email-example {
  background: var(--code-bg);
  padding: 1em;
  border-radius: 6px;
  font-family: monospace;
  margin-top: 1em;
}