/* Shared CSS Variables and Common Styles */
:root {
  --accent: #136f8f;
  --muted: #6b7280;
  --card: #ffffff;
  --bg: #f6f9fb;
  --max-width: 1000px;
  --parameter-map-size: 256px;
}

/* Typography */
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

/* Common page layout for subpages */
body.subpage {
  padding: 2rem;
  max-width: 1200px;
  margin: 0 auto;
}

body.subpage h1 {
  margin-bottom: 1rem;
  color: #333;
}

/* Common Components */
.back-link {
  display: inline-block;
  margin-bottom: 1rem;
  color: var(--accent);
  text-decoration: none;
  font-weight: bold;
}

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

/* Card Title Styling (from index page) */
.card-title {
  margin: 0;
  font-size: 1.1rem;
  color: var(--accent);
  font-weight: bold;
}

/* Tab Navigation with Card Title Styling */
.tab-nav button {
  color: var(--accent);
  font-weight: bold;
  font-size: 1.1rem;
}

/* Info Box Styling */
.info-box {
  background: #e7f3ff;
  border-left: 4px solid var(--accent);
  padding: 1rem;
  margin: 1rem 0 2rem 0;
}

.info-box a {
  color: var(--accent);
}

/* Tab Navigation */
.tab-container {
  margin: 2rem 0;
}

.tab-nav {
  display: flex;
  border-bottom: 2px solid #dee2e6;
  margin: 0;
  padding: 0;
  list-style: none;
}

.tab-nav li {
  margin: 0;
}

.tab-nav button {
  background: none;
  border: none;
  padding: 1rem 2rem;
  cursor: pointer;
  border-bottom: 3px solid transparent;
  transition: all 0.2s ease;
  white-space: nowrap;
  /* Card title styling inherited from shared.css */
}

.tab-nav button:hover {
  background: #f8f9fa;
}

.tab-nav button.active {
  border-bottom-color: var(--accent);
  background: #fff;
}

/* Tab Content */
.tab-content {
  display: none;
  padding: 2rem 0;
  animation: fadeIn 0.3s ease-in;
}

.tab-content.active {
  display: block;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Tab Cards */
.tab-card {
  background: #f8f9fa;
  border: 1px solid #dee2e6;
  border-radius: 8px;
  padding: 2rem;
}

.tab-description {
  margin: 1rem 0 2rem 0;
  line-height: 1.6;
  color: #555;
}

/* Responsive Tab Navigation */
@media (max-width: 768px) {
  .tab-nav {
    flex-direction: column;
  }
  .tab-nav button {
    text-align: left;
    border-bottom: none;
    border-left: 3px solid transparent;
  }
  .tab-nav button.active {
    border-left-color: var(--accent);
    border-bottom-color: transparent;
  }
}

/* =============================================================================
   Generic Zoom/Pan Container Styles
   ============================================================================= */

/* Base zoom container - apply to any element that should support zoom/pan */
.zoom-enabled-container {
  position: relative;
  overflow: hidden;
  cursor: crosshair;
  background: #000;
  border: 1px solid #ddd;
  border-radius: 6px;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

/* Image inside a zoom container - positioned for transform */
.zoom-enabled-image {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(1);
  transform-origin: center center;
  user-select: none;
  pointer-events: none;
  border: none;
  box-shadow: none;
}

/* Parameter map image rendering - use nearest-neighbor for crisp pixels */
.zoom-enabled-image,
.grid-image img,
.image-container img,
.comparison-base img,
.comparison-overlay img,
.toggle-container img {
  image-rendering: pixelated;
  image-rendering: -moz-crisp-edges;
  image-rendering: crisp-edges;
}

/* =============================================================================
   Common Grid and Container Styles
   ============================================================================= */

/* Comparison grid layout - used by compare_methods and view_invivo */
.comparison-grid {
  display: grid;
  grid-template-columns: auto 1fr 1fr 1fr;
  gap: 1rem;
  margin-top: 2rem;
  align-items: start;
}

/* Column headers */
.column-header {
  text-align: center;
  margin-bottom: 0.5rem;
}

.image-title {
  margin: 0.5rem 0;
  font-weight: bold;
  color: #555;
}

/* Row headers */
.row-header {
  font-weight: bold;
  color: var(--accent);
  padding: 0.5rem;
  text-align: right;
  white-space: nowrap;
  align-self: center;
}

/* Image cells */
.grid-image {
  text-align: center;
}

.grid-image img {
  width: 100%;
  max-width: var(--parameter-map-size);
  height: auto;
}

/* Zoom/pan container for grids */
.zoom-container {
  position: relative;
  width: var(--parameter-map-size);
  height: var(--parameter-map-size);
  margin: 0 auto;
  border: 1px solid #ddd;
  border-radius: 6px;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
  overflow: hidden;
  cursor: crosshair;
  background: #000;
}

.zoom-image {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(1);
  transform-origin: center center;
  user-select: none;
  pointer-events: none;
  width: 100%;
  height: 100%;
  object-fit: contain;
  border: none;
  box-shadow: none;
}

/* Text column using details-container styling */
.grid-details {
  background: #d1d5db;
  border-radius: 8px;
  padding: 1rem;
  line-height: 1.6;
  color: #555;
  font-size: 0.9em;
}

/* Empty cell for top-left corner */
.empty-cell {
  grid-column: 1;
  grid-row: 1;
}

/* Zoom/Pan Instructions */
.zoom-instructions {
  margin-top: 2rem;
  padding: 1rem;
  background: #f8f9fa;
  border: 1px solid #dee2e6;
  border-radius: 6px;
  font-size: 0.9em;
  color: #495057;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 1.5rem;
}

.zoom-instructions .control-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* Responsive grid styles */
@media (max-width: 768px) {
  .comparison-grid {
    grid-template-columns: 1fr;
    gap: 1.5rem;
  }
  
  .column-header,
  .row-header {
    text-align: left;
  }
  
  .empty-cell {
    display: none;
  }
}