/* === CSS Reset and Base Styles === */
* {
  box-sizing: border-box;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background-color: #f8f9fa;
  color: #212529;
  margin: 0;
  padding: 2rem;
  line-height: 1.6;
}

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0;
}

/* === Typography === */
h1,
h2,
h3,
h4,
h5,
h6 {
  color: #343a40;
  margin-top: 0;
  margin-bottom: 1rem;
  font-weight: 600;
  line-height: 1.2;
}

.page-title {
  font-size: 2.5rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.page-subtitle {
  font-size: 1.125rem;
  color: #6c757d;
  margin-bottom: 2rem;
}

.page-icon {
  font-size: 2rem;
}

/* === Links === */
a {
  color: #007bff;
  text-decoration: none;
  transition: color 0.2s ease;
}

a:hover {
  color: #0056b3;
  text-decoration: underline;
}

/* === Breadcrumb Navigation === */
.breadcrumb-nav {
  margin-bottom: 2rem;
}

.breadcrumb-list {
  display: flex;
  align-items: center;
  list-style: none;
  padding: 0;
  margin: 0;
  background-color: #e9ecef;
  border-radius: 6px;
  padding: 0.75rem 1rem;
  font-size: 0.9rem;
}

.breadcrumb-item {
  display: flex;
  align-items: center;
}

.breadcrumb-link {
  color: #007bff;
  text-decoration: none;
  padding: 0.25rem 0.5rem;
  border-radius: 4px;
  transition: background-color 0.2s ease;
}

.breadcrumb-link:hover {
  background-color: #dee2e6;
  text-decoration: none;
}

.breadcrumb-current {
  color: #495057;
  font-weight: 500;
  padding: 0.25rem 0.5rem;
}

.breadcrumb-separator {
  margin: 0 0.5rem;
  color: #6c757d;
  font-weight: 300;
}

/* === Page Header === */
.page-header {
  margin-bottom: 2rem;
  text-align: center;
}

.table-header {
  margin-bottom: 2rem;
}

.table-title-section {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 1rem;
}

.table-title {
  font-size: 2rem;
  margin: 0;
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.table-badge {
  font-size: 0.75rem;
  font-weight: 500;
  color: #6c757d;
  background-color: #e9ecef;
  padding: 0.25rem 0.5rem;
  border-radius: 4px;
}

.table-actions {
  display: flex;
  gap: 1rem;
  align-items: center;
}

/* === Cards === */
.content-card {
  background-color: #ffffff;
  border-radius: 8px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
  margin-bottom: 1.5rem;
  overflow: hidden;
}

.card-header {
  padding: 1.5rem 1.5rem 0;
  border-bottom: 1px solid #e9ecef;
  margin-bottom: 1.5rem;
}

.card-title {
  font-size: 1.25rem;
  margin: 0;
  padding-bottom: 1rem;
}

.card-content {
  padding: 1.5rem;
}

/* === Dashboard Layout === */
.dashboard-container {
  display: grid;
  grid-template-columns: 1fr 2fr;
  gap: 2rem;
  margin-top: 2rem;
}

.dashboard-column {
  min-width: 0; /* Prevents grid overflow */
}

.section-header {
  font-size: 1.5rem;
  font-weight: 600;
  margin: 0 0 1.5rem 0;
  color: #343a40;
}

/* === Table List (Dashboard) === */
.table-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.table-list li {
  margin-bottom: 0.5rem;
}

.table-link {
  display: flex;
  align-items: center;
  padding: 1rem;
  text-decoration: none;
  color: #212529;
  font-family: "SF Mono", Monaco, "Cascadia Code", "Roboto Mono", Consolas, "Courier New", monospace;
  font-size: 0.95rem;
  font-weight: 500;
  border-radius: 6px;
  transition: all 0.2s ease;
  border: 1px solid transparent;
}

.table-link:hover {
  background-color: #f8f9fa;
  color: #0056b3;
  text-decoration: none;
  border-color: #dee2e6;
}

.list-icon {
  margin-right: 0.75rem;
  color: #007bff;
  font-size: 1.1rem;
}

.table-name {
  flex: 1;
}

.link-arrow {
  color: #6c757d;
  transition: transform 0.2s ease;
}

.table-link:hover .link-arrow {
  transform: translateX(2px);
}

/* === Chart Grid === */
.chart-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 1.5rem;
}

.chart-display-card {
  background-color: #f8f9fa;
  border: 1px solid #dee2e6;
  border-radius: 8px;
  overflow: hidden;
  transition: all 0.2s ease;
  display: flex;
  flex-direction: column;
  min-height: 400px;
  min-height: 200px;
}

.chart-card:hover {
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  transform: translateY(-2px);
  border-color: #007bff;
}

.chart-link {
  display: flex;
  flex-direction: column;
  height: 100%;
  padding: 1.5rem;
  text-decoration: none;
  color: inherit;
}

.chart-link:hover {
  text-decoration: none;
  color: inherit;
}

.chart-header {
  flex: 1;
}

.chart-title {
  font-size: 1.25rem;
  font-weight: 600;
  margin: 0 0 0.75rem 0;
  color: #343a40;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.chart-description {
  font-size: 0.9rem;
  color: #6c757d;
  margin: 0;
  line-height: 1.5;
}

.chart-footer {
  margin-top: 1.5rem;
  text-align: right;
}

.view-link {
  font-weight: 600;
  color: #007bff;
  font-size: 0.9rem;
}

.chart-card--special {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  border: none;
}

.chart-card--special .chart-title,
.chart-card--special .chart-description,
.chart-card--special .view-link {
  color: white;
}

.chart-icon {
  font-size: 1.1rem;
}

/* === Forms === */
.form-group {
  margin-bottom: 1.5rem;
}

.form-label {
  display: block;
  font-size: 0.9rem;
  font-weight: 500;
  color: #495057;
  margin-bottom: 0.5rem;
}

.required {
  color: #dc3545;
  margin-left: 0.25rem;
}

.form-input,
.form-textarea,
.form-select {
  display: block;
  width: 100%;
  padding: 0.75rem;
  font-size: 1rem;
  line-height: 1.5;
  color: #495057;
  background-color: #fff;
  border: 1px solid #ced4da;
  border-radius: 6px;
  transition: border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
}

.form-input:focus,
.form-textarea:focus,
.form-select:focus {
  border-color: #80bdff;
  outline: 0;
  box-shadow: 0 0 0 0.2rem rgba(0, 123, 255, 0.25);
}

.form-select--small {
  padding: 0.5rem;
  font-size: 0.9rem;
}

.form-hint {
  font-size: 0.8rem;
  color: #6c757d;
  margin-left: 0.25rem;
}

.form-help {
  font-size: 0.85rem;
  color: #6c757d;
  margin-top: 0.5rem;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
  margin-bottom: 1.5rem;
}

.form-group--full {
  grid-column: 1 / -1;
}

.form-actions {
  display: flex;
  gap: 1rem;
  align-items: center;
  margin-top: 2rem;
}

/* === Buttons === */
.btn {
  display: inline-flex;
  align-items: center;
  padding: 0.75rem 1.5rem;
  font-size: 0.9rem;
  font-weight: 500;
  line-height: 1;
  text-align: center;
  text-decoration: none;
  border: 1px solid transparent;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s ease;
  gap: 0.5rem;
}

.btn-primary {
  color: #fff;
  background-color: #007bff;
  border-color: #007bff;
}

.btn-primary:hover {
  color: #fff;
  background-color: #0056b3;
  border-color: #0056b3;
  text-decoration: none;
}

.btn-secondary {
  color: #495057;
  background-color: #e9ecef;
  border-color: #e9ecef;
}

.btn-secondary:hover {
  color: #495057;
  background-color: #dae0e5;
  border-color: #d3d9df;
  text-decoration: none;
}

.btn-large {
  padding: 1rem 2rem;
  font-size: 1rem;
}

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

/* === Tables === */
.table-container {
  overflow-x: auto;
  background: white;
  border-radius: 8px;
  margin: 1rem 0;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.data-table th,
.data-table td {
  padding: 0.75rem;
  text-align: left;
  border-bottom: 1px solid #dee2e6;
  white-space: nowrap;
}

.data-table thead th {
  background-color: #f8f9fa;
  font-weight: 600;
  position: sticky;
  top: 0;
  z-index: 10;
}

.data-table tbody tr:hover {
  background-color: #f8f9fa;
}

.sort-link {
  color: #495057;
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.sort-link:hover {
  color: #007bff;
  text-decoration: none;
}

.sort-indicator {
  font-size: 0.8rem;
  color: #007bff;
}

.filter-row th {
  padding: 0.5rem 0.75rem;
  background-color: #fff;
}

.filter-input {
  width: 100%;
  padding: 0.5rem;
  border: 1px solid #ced4da;
  border-radius: 4px;
  font-size: 0.85rem;
}

.filter-input:focus {
  border-color: #007bff;
  box-shadow: 0 0 0 2px rgba(0, 123, 255, 0.25);
  outline: none;
}

.record-link {
  color: #007bff;
  font-weight: 500;
}

.record-link:hover {
  color: #0056b3;
  text-decoration: underline;
}

.empty-state {
  text-align: center;
  padding: 3rem 1rem;
  color: #6c757d;
}

.empty-message {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
}

.empty-icon {
  font-size: 3rem;
  opacity: 0.5;
}

/* === Table Meta Info === */
.table-meta {
  margin-bottom: 1.5rem;
}

.pagination-info {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem;
  background-color: #f8f9fa;
  border-radius: 6px;
  border: 1px solid #dee2e6;
  margin-bottom: 1rem;
}

.page-info {
  font-weight: 500;
  color: #495057;
}

.page-details {
  color: #6c757d;
  font-weight: normal;
}

.page-size-selector {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* === Filter Controls === */
.filter-controls {
  display: flex;
  gap: 1rem;
  align-items: center;
  margin-bottom: 1.5rem;
  padding: 1rem;
  background-color: #f8f9fa;
  border-radius: 6px;
  border: 1px solid #dee2e6;
}

/* === Pagination === */
.pagination-nav {
  margin: 2rem 0;
  display: flex;
  justify-content: center;
}

.pagination-controls {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.pagination-pages {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  margin: 0 1rem;
}

.pagination-btn {
  padding: 0.5rem 0.75rem;
  text-decoration: none;
  border: 1px solid #dee2e6;
  border-radius: 4px;
  color: #007bff;
  background-color: white;
  transition: all 0.2s ease;
  min-width: 40px;
  text-align: center;
  display: inline-block;
  font-size: 0.9rem;
}

.pagination-btn:hover:not(.disabled):not(.current) {
  background-color: #e9ecef;
  border-color: #adb5bd;
  text-decoration: none;
}

.pagination-btn.current {
  background-color: #007bff;
  color: white;
  border-color: #007bff;
  font-weight: 600;
}

.pagination-btn.disabled {
  color: #6c757d;
  background-color: #e9ecef;
  border-color: #dee2e6;
  cursor: not-allowed;
}

.pagination-ellipsis {
  padding: 0.5rem 0.25rem;
  color: #6c757d;
}

/* === Record Detail Layout === */
.record-detail-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 2fr); /* Allow columns to shrink */
  gap: 2rem;
}

.record-main,
.record-related {
  min-width: 0; /* Allow grid items to shrink */
}

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

.record-table th,
.record-table td {
  padding: 0.75rem;
  border-bottom: 1px solid #dee2e6;
  text-align: left;
}

.record-field {
  font-weight: 600;
  color: #495057;
  width: 30%;
  background-color: #f8f9fa;
}

.record-value {
  font-family: "SF Mono", Monaco, "Cascadia Code", "Roboto Mono", Consolas, "Courier New", monospace;
  font-size: 0.9rem;
}

.null-value {
  color: #6c757d;
  font-style: italic;
}

.related-data-container {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.related-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
}

.related-title {
  font-size: 1.1rem;
  margin: 0;
}

.related-count {
  font-size: 0.85rem;
  color: #6c757d;
  background-color: #e9ecef;
  padding: 0.25rem 0.5rem;
  border-radius: 4px;
}

.related-table-container {
  overflow-x: auto;
}

.scrollable-table-wrapper {
  max-height: 300px; /* Adjust as needed */
  overflow-y: auto;
  overflow-x: auto;
  border: 1px solid #e9ecef; /* Optional: Add a border to make the scrollable area clear */
  border-radius: 6px; /* Optional: Match card border-radius */
}

.related-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

.related-table th,
.related-table td {
  padding: 0.5rem;
  border-bottom: 1px solid #dee2e6;
  white-space: nowrap;
}

.related-table th {
  background-color: #f8f9fa;
  font-weight: 600;
}

/* === Chart Styles === */
.chart-section {
  margin-bottom: 2rem;
}

.chart-placeholder {
  width: 100%;
  height: 400px;
  border: 2px dashed #dee2e6;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: #f8f9fa;
}

.error-state {
  text-align: center;
  padding: 2rem;
  color: #dc3545;
}

.error-icon {
  font-size: 2rem;
  margin-bottom: 1rem;
}

/* === Utility Classes === */
.hidden {
  display: none !important;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* === Responsive Design === */
@media (max-width: 1024px) {
  .dashboard-container {
    grid-template-columns: 1fr;
  }

  .record-detail-layout {
    grid-template-columns: 1fr;
  }

  .form-row {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 768px) {
  body {
    padding: 1rem;
  }

  .page-title {
    font-size: 2rem;
  }

  .table-title-section {
    flex-direction: column;
    align-items: flex-start;
  }

  .pagination-info {
    flex-direction: column;
    gap: 1rem;
    align-items: flex-start;
  }

  .pagination-controls {
    flex-wrap: wrap;
    justify-content: center;
  }

  .pagination-pages {
    margin: 0;
  }

  .filter-controls {
    flex-direction: column;
    align-items: flex-start;
  }

  .chart-grid {
    grid-template-columns: 1fr;
  }

  .breadcrumb-list {
    flex-wrap: wrap;
  }
}

@media (max-width: 480px) {
  .table-container {
    font-size: 0.8rem;
  }

  .data-table th,
  .data-table td {
    padding: 0.5rem 0.25rem;
  }
}
