/**
 * Common component styles for legacy content pages
 * Includes dark mode support for tables, info boxes, and other shared elements
 */

/* ========================================
   LOGIC ENGINE COMPONENTS
   ======================================== */

/* Wide container for logic engine */
body.logic-engine {
  background: #f9fafb;
  padding: 0;
}

.logic-engine-container {
  max-width: 960px;
  margin: 0 auto;
  padding: 0 1rem 3rem;
}

/* Dark header with icon */
.logic-engine-header {
  background: #2d3748;
  color: white;
  padding: 1.5rem 0 2rem;
  margin-bottom: 2rem;
  box-shadow: 0 4px 6px rgb(0, 0, 0, 0.1);
}

.logic-engine-header .container-inner {
  max-width: 960px;
  margin: 0 auto;
  padding: 0 1rem;
}

.logic-engine-header .breadcrumbs {
  font-size: 0.875rem;
  margin-bottom: 0.5rem;
  color: #d1d5db;
}

.logic-engine-header .breadcrumbs a {
  color: #d1d5db;
  text-decoration: none;
}

.logic-engine-header .breadcrumbs a:hover {
  color: white;
}

.logic-engine-header .breadcrumbs .separator {
  margin: 0 0.5rem;
}

.logic-engine-header .breadcrumbs .current {
  color: white;
}

.logic-engine-header h1 {
  font-size: 1.875rem;
  font-weight: bold;
  margin: 0;
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.logic-engine-header h1 svg {
  width: 2rem;
  height: 2rem;
  flex-shrink: 0;
}

.logic-engine-header p {
  color: #d1d5db;
  margin-top: 0.5rem;
}

/* Card sections */
.logic-card {
  background: white;
  border-radius: 0.5rem;
  box-shadow: 0 1px 3px rgb(0, 0, 0, 0.1);
  padding: 1.5rem;
  margin-bottom: 1.5rem;
}

.logic-card h2 {
  font-size: 1.25rem;
  font-weight: bold;
  margin: 0 0 1rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.logic-card h2 svg {
  width: 1.5rem;
  height: 1.5rem;
}

.logic-card h3 {
  font-size: 1.125rem;
  font-weight: 600;
  margin: 0 0 0.75rem;
  color: #374151;
}

.logic-card p {
  color: #4b5563;
  font-size: 0.875rem;
  margin-bottom: 1rem;
}

/* Input field */
.logic-input {
  flex: 1;
  padding: 0.5rem 1rem;
  border: 1px solid #d1d5db;
  border-radius: 0.25rem;
  font-family: monospace;
  font-size: 0.875rem;
}

.logic-input:focus {
  outline: none;
  box-shadow: 0 0 0 2px #3b82f6;
  border-color: #3b82f6;
}

.logic-input:disabled {
  background: #f3f4f6;
  cursor: not-allowed;
}

/* Buttons */
.btn-primary {
  padding: 0.5rem 1.5rem;
  background: #2563eb;
  color: white;
  border: none;
  border-radius: 0.25rem;
  font-weight: 500;
  cursor: pointer;
  transition: background-color 0.2s;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}

.btn-primary:hover:not(:disabled) {
  background: #1d4ed8;
}

.btn-primary:focus {
  outline: 2px solid #3b82f6;
  outline-offset: 2px;
}

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

.btn-secondary {
  padding: 0.5rem 1.5rem;
  background: #16a34a;
  color: white;
  border: none;
  border-radius: 0.25rem;
  font-weight: 500;
  cursor: pointer;
  transition: background-color 0.2s;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}

.btn-secondary:hover:not(:disabled) {
  background: #15803d;
}

.btn-secondary:focus {
  outline: 2px solid #16a34a;
  outline-offset: 2px;
}

.btn-secondary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-tertiary {
  padding: 0.5rem 1.5rem;
  background: #e5e7eb;
  color: #374151;
  border: none;
  border-radius: 0.25rem;
  font-weight: 500;
  cursor: pointer;
  transition: background-color 0.2s;
}

.btn-tertiary:hover:not(:disabled) {
  background: #d1d5db;
}

.btn-tertiary:focus {
  outline: 2px solid #6b7280;
  outline-offset: 2px;
}

.btn-tertiary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-icon {
  width: 1.25rem;
  height: 1.25rem;
  flex-shrink: 0;
}

/* Button group */
.button-group {
  display: flex;
  gap: 0.75rem;
  margin-top: 1rem;
  margin-bottom: 1rem;
}

/* Details/Summary for operators */
.operator-details {
  font-size: 0.875rem;
  color: #4b5563;
  margin-bottom: 1rem;
}

.operator-details summary {
  cursor: pointer;
  font-weight: 500;
}

.operator-details summary:hover {
  color: #1f2937;
}

.operator-details ul {
  margin-top: 0.5rem;
  margin-left: 1.5rem;
  list-style: none;
  padding: 0;
}

.operator-details li {
  margin: 0.25rem 0;
}

.operator-details code {
  background: #f3f4f6;
  padding: 0.125rem 0.25rem;
  border-radius: 0.25rem;
  font-family: monospace;
}

/* Example buttons */
.example-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.example-btn {
  padding: 0.375rem 0.75rem;
  font-size: 0.875rem;
  background: #f3f4f6;
  color: #374151;
  border: none;
  border-radius: 0.25rem;
  cursor: pointer;
  transition: background-color 0.2s;
}

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

.example-btn:focus {
  outline: 2px solid #6b7280;
  outline-offset: 2px;
}

/* Proof steps */
.steps-container {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.proof-step {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 0.75rem;
  border-radius: 0.25rem;
  border: 1px solid;
}

.proof-step.premise {
  background: #eff6ff;
  border-color: #bfdbfe;
}

.proof-step.derived {
  background: #f0fdf4;
  border-color: #bbf7d0;
}

.step-badge {
  flex-shrink: 0;
  width: 2rem;
  height: 2rem;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  font-family: monospace;
  font-size: 0.875rem;
  font-weight: bold;
}

.step-badge.premise {
  background: #dbeafe;
  color: #1d4ed8;
}

.step-badge.derived {
  background: #dcfce7;
  color: #15803d;
}

.step-content {
  flex: 1;
  min-width: 0;
}

.step-expression {
  font-family: monospace;
  font-size: 1rem;
  margin-bottom: 0.25rem;
}

.step-justification {
  font-size: 0.75rem;
}

.step-justification.premise {
  color: #2563eb;
  font-weight: 500;
}

.step-justification.derived {
  color: #16a34a;
}

.step-justification .rule-name {
  font-weight: 500;
}

.step-justification .step-refs {
  color: #6b7280;
}

/* Empty state */
.empty-state {
  text-align: center;
  padding: 3rem 0;
  color: #6b7280;
}

.empty-state svg {
  margin: 0 auto 1rem;
  width: 4rem;
  height: 4rem;
  color: #d1d5db;
}

.empty-state p:first-of-type {
  font-size: 1.125rem;
  font-weight: 500;
  color: #6b7280;
}

.empty-state p:last-of-type {
  font-size: 0.875rem;
  margin-top: 0.25rem;
}

/* Status messages */
.status-message {
  padding: 1rem;
  border-radius: 0.25rem;
  border: 1px solid;
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  margin-bottom: 1.5rem;
}

.status-message svg {
  width: 1.25rem;
  height: 1.25rem;
  flex-shrink: 0;
  margin-top: 0.125rem;
}

.status-message .message-text {
  font-size: 0.875rem;
  flex: 1;
}

.status-message.error {
  background: #fef2f2;
  border-color: #fecaca;
}

.status-message.error svg {
  color: #ef4444;
}

.status-message.error .message-text {
  color: #991b1b;
}

.status-message.success {
  background: #f0fdf4;
  border-color: #bbf7d0;
}

.status-message.success svg {
  color: #22c55e;
}

.status-message.success .message-text {
  color: #14532d;
}

/* Info box */
.info-card {
  margin-top: 2rem;
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  border-radius: 0.5rem;
  padding: 1.5rem;
}

.info-card h3 {
  font-weight: bold;
  font-size: 1.125rem;
  margin: 0 0 0.75rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.info-card h3 svg {
  width: 1.25rem;
  height: 1.25rem;
}

.info-card .info-content {
  font-size: 0.875rem;
  color: #374151;
}

.info-card .info-content p {
  margin-bottom: 0.5rem;
  color: #374151;
}

.info-card .info-content ul {
  list-style: disc;
  list-style-position: inside;
  margin-left: 1rem;
}

.info-card .info-content li {
  margin: 0.25rem 0;
}

/* Spinner animation */
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.animate-spin {
  animation: spin 1s linear infinite;
}

/* Flex utilities for logic engine */
.flex-row {
  display: flex;
  gap: 0.75rem;
}

.flex-1 {
  flex: 1;
}

/* ========================================
   ORIGINAL COMPONENTS
   ======================================== */

/* Data Tables */
.data-table,
.syllabary-table,
.truth-table table {
  border-collapse: collapse;
  width: 100%;
  background: white;
  font-size: 1.1rem;
  box-shadow: 0 2px 8px rgb(0, 0, 0, 0.1);
  border-radius: 8px;
  overflow: hidden;
}

.data-table th,
.syllabary-table th,
.truth-table th {
  background: #007bff;
  color: white;
  padding: 0.75rem;
  text-align: center;
  font-weight: 600;
  border: 1px solid #0056b3;
}

.data-table td,
.syllabary-table td,
.truth-table td {
  padding: 0.5rem;
  text-align: center;
  border: 1px solid #dee2e6;
  vertical-align: middle;
}

.data-table tr:nth-child(even),
.syllabary-table tr:nth-child(even),
.truth-table tr:nth-child(even) {
  background: #f8f9fa;
}

.data-table tr:hover,
.syllabary-table tr:hover,
.truth-table tr:hover {
  background: #e9ecef;
}

/* Special table header styling */
.syllabary-table th {
  position: sticky;
  top: 0;
  z-index: 10;
}

.syllabary-table th:first-child {
  background: #495057;
  font-weight: 700;
  min-width: 3rem;
}

/* Table containers */
.table-container,
.syllabary-container,
.truth-table {
  overflow-x: auto;
  margin: 2rem 0;
  border-radius: 8px;
}

/* Info Boxes and Legends */
.legend,
.data-files,
.operators,
.info-box {
  background: #f8f9fa;
  padding: 1rem;
  border-radius: 4px;
  border: 1px solid #e9ecef;
  margin: 1rem 0;
}

.legend h3,
.data-files h3,
.info-box h3 {
  margin-top: 0;
  color: #495057;
}

.data-files {
  background: #e7f3ff;
  border-left: 4px solid #007bff;
}

.data-files h3 {
  color: #0056b3;
}

/* Operator/Example Lists */
.operator-list,
.example-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.operator-item,
.example-item {
  font-family: monospace;
  background: white;
  padding: 0.5rem 1rem;
  border-radius: 4px;
  border: 1px solid #dee2e6;
  font-weight: 600;
}

/* Frequency/Category Indicators */
.frequent {
  color: #000;
  font-weight: 600;
}

.infrequent {
  color: #6c757d;
  font-weight: 400;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin: 0.5rem 0;
}

.legend-color {
  width: 1rem;
  height: 1rem;
  border-radius: 2px;
}

.frequent-color {
  background: #000;
}

.infrequent-color {
  background: #6c757d;
}

/* Interactive Elements */
.syllabary-table span {
  cursor: pointer;
  transition: background-color 0.2s;
  border-radius: 3px;
  padding: 0.25rem;
  display: inline-block;
}

.syllabary-table span:hover {
  background: #007bff !important;
  color: white !important;
}

/* Dark Mode Support */
@media (prefers-color-scheme: dark) {
  /* Logic Engine Dark Mode */
  body.logic-engine {
    background: #1a202c;
  }

  .logic-card {
    background: #2d3748;
    border: 1px solid #4a5568;
  }

  .logic-card h2 {
    color: #e2e8f0;
  }

  .logic-card h3 {
    color: #cbd5e0;
  }

  .logic-card p {
    color: #a0aec0;
  }

  .logic-input {
    background: #1a202c;
    border-color: #4a5568;
    color: #e2e8f0;
  }

  .logic-input:focus {
    border-color: #63b3ed;
    box-shadow: 0 0 0 2px #63b3ed;
  }

  .logic-input:disabled {
    background: #2d3748;
  }

  .operator-details {
    color: #a0aec0;
  }

  .operator-details summary:hover {
    color: #cbd5e0;
  }

  .operator-details code {
    background: #1a202c;
    color: #e2e8f0;
  }

  .example-btn {
    background: #1a202c;
    color: #cbd5e0;
    border: 1px solid #4a5568;
  }

  .example-btn:hover {
    background: #4a5568;
  }

  /* Proof steps - ensure text is visible */
  .proof-step.premise {
    background: #1e3a5f;
    border-color: #2c5aa0;
  }

  .proof-step.derived {
    background: #1e4d2b;
    border-color: #15803d;
  }

  .step-badge.premise {
    background: #2c5aa0;
    color: #bfdbfe;
  }

  .step-badge.derived {
    background: #15803d;
    color: #bbf7d0;
  }

  .step-expression {
    color: #e2e8f0;
  }

  .step-justification.premise {
    color: #90cdf4;
  }

  .step-justification.derived {
    color: #86efac;
  }

  .step-justification .step-refs {
    color: #a0aec0;
  }

  .empty-state {
    color: #a0aec0;
  }

  .empty-state svg {
    color: #4a5568;
  }

  .empty-state p:first-of-type {
    color: #a0aec0;
  }

  .status-message.error {
    background: #742a2a;
    border-color: #9b2c2c;
  }

  .status-message.error svg {
    color: #fc8181;
  }

  .status-message.error .message-text {
    color: #feb2b2;
  }

  .status-message.success {
    background: #1e4d2b;
    border-color: #15803d;
  }

  .status-message.success svg {
    color: #86efac;
  }

  .status-message.success .message-text {
    color: #bbf7d0;
  }

  .info-card {
    background: #1e3a5f;
    border-color: #2c5aa0;
  }

  .info-card h3 {
    color: #e2e8f0;
  }

  .info-card .info-content,
  .info-card .info-content p {
    color: #cbd5e0;
  }

  /* Tables */
  .data-table,
  .syllabary-table,
  .truth-table table {
    background: #2d3748;
    border-color: #4a5568;
  }

  .data-table th,
  .syllabary-table th,
  .truth-table th {
    background: #63b3ed;
    color: #1a202c;
    border-color: #4299e1;
  }

  .syllabary-table th:first-child {
    background: #4a5568;
    color: #e2e8f0;
  }

  .data-table td,
  .syllabary-table td,
  .truth-table td {
    border-color: #4a5568;
    color: #e2e8f0;
  }

  .data-table tr:nth-child(even),
  .syllabary-table tr:nth-child(even),
  .truth-table tr:nth-child(even) {
    background: #1a202c;
  }

  .data-table tr:hover,
  .syllabary-table tr:hover,
  .truth-table tr:hover {
    background: #4a5568;
  }

  /* Info Boxes */
  .legend,
  .operators,
  .info-box {
    background: #1a202c;
    border-color: #4a5568;
  }

  .legend h3,
  .data-files h3,
  .info-box h3 {
    color: #e2e8f0;
  }

  .data-files {
    background: #1e3a5f;
    border-color: #63b3ed;
  }

  .data-files h3 {
    color: #90cdf4;
  }

  /* Lists */
  .operator-item,
  .example-item {
    background: #2d3748;
    border-color: #4a5568;
    color: #e2e8f0;
  }

  /* Frequency indicators */
  .frequent {
    color: #e2e8f0;
  }

  .infrequent {
    color: #a0aec0;
  }

  .frequent-color {
    background: #e2e8f0;
  }

  .infrequent-color {
    background: #a0aec0;
  }

  /* Interactive */
  .syllabary-table span:hover {
    background: #63b3ed !important;
    color: #1a202c !important;
  }
}
