/* GAERS Research Website - Component Styles */

/* ===== CARDS ===== */
.card {
  background-color: var(--bg-white);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  padding: var(--spacing-lg);
  transition: all var(--transition-base);
  height: 100%;
  display: flex;
  flex-direction: column;
}

.card:hover {
  box-shadow: var(--shadow-lg);
  transform: translateY(-2px);
}

.card-header {
  margin-bottom: var(--spacing-md);
  padding-bottom: var(--spacing-md);
  border-bottom: 1px solid var(--border-subtle);
}

.card-title {
  font-size: 1.5rem;
  font-weight: 600;
  margin-bottom: var(--spacing-sm);
  color: var(--primary-blue);
}

.card-subtitle {
  font-size: 1rem;
  color: var(--text-secondary);
}

.card-body {
  flex: 1;
}

.card-footer {
  margin-top: var(--spacing-md);
  padding-top: var(--spacing-md);
  border-top: 1px solid var(--border-subtle);
}

.card-link {
  display: block;
  color: var(--primary-blue);
  font-weight: 500;
  text-decoration: none;
  transition: color var(--transition-fast);
}

.card-link:hover {
  color: var(--primary-dark);
}

/* Stat Cards */
.stat-card {
  text-align: center;
  background: linear-gradient(135deg, var(--primary-blue) 0%, var(--primary-dark) 100%);
  color: var(--bg-white);
  padding: var(--spacing-xl);
}

.stat-card:hover {
  transform: scale(1.02);
}

.stat-number {
  font-size: 2.5rem;
  font-weight: 700;
  margin-bottom: var(--spacing-sm);
  display: block;
}

.stat-label {
  font-size: 1rem;
  opacity: 0.9;
}

/* ===== BUTTONS ===== */
.btn {
  display: inline-block;
  padding: var(--spacing-sm) var(--spacing-lg);
  font-size: 1rem;
  font-weight: 500;
  text-align: center;
  text-decoration: none;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition-fast);
  line-height: 1.5;
}

.btn:hover {
  text-decoration: none;
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

.btn:active {
  transform: translateY(0);
}

.btn:focus {
  outline: none;
  box-shadow: 0 0 0 3px var(--focus-ring);
}

.btn:focus:not(:focus-visible) {
  box-shadow: var(--shadow-md);
}

.btn-primary {
  background-color: var(--primary-blue);
  color: var(--bg-white);
}

.btn-primary:hover {
  background-color: var(--primary-dark);
  color: var(--bg-white);
}

.btn-secondary {
  background-color: transparent;
  color: var(--text-primary);
  border: 1px solid var(--border-default);
}

.btn-secondary:hover {
  background-color: var(--bg-light);
  border-color: var(--primary-blue);
  color: var(--primary-blue);
}

.btn-success {
  background-color: var(--accent-green);
  color: var(--bg-white);
}

.btn-danger {
  background-color: var(--accent-red);
  color: var(--bg-white);
}

.btn-sm {
  padding: 0.5rem 1rem;
  font-size: 0.875rem;
}

.btn-lg {
  padding: 0.75rem 1.5rem;
  font-size: 1.125rem;
}

.btn-block {
  display: block;
  width: 100%;
}

/* ===== TABLES ===== */
.table-wrapper {
  overflow-x: auto;
  margin-bottom: var(--spacing-lg);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  -webkit-overflow-scrolling: touch;
  position: relative;
}

table {
  width: 100%;
  border-collapse: collapse;
  background-color: var(--bg-white);
}

thead {
  background-color: var(--primary-blue);
  color: var(--bg-white);
}

th {
  padding: var(--spacing-md);
  text-align: left;
  font-weight: 600;
  white-space: nowrap;
}

th.sortable {
  cursor: pointer;
  user-select: none;
  position: relative;
  padding-right: var(--spacing-xl);
}

th.sortable:hover {
  background-color: var(--primary-dark);
}

th.sortable::after {
  content: "⇅";
  position: absolute;
  right: var(--spacing-sm);
  opacity: 0.5;
}

th.sortable.asc::after {
  content: "↑";
  opacity: 1;
}

th.sortable.desc::after {
  content: "↓";
  opacity: 1;
}

td {
  padding: var(--spacing-md);
  border-bottom: 1px solid var(--border-subtle);
}

tbody tr:nth-child(even) {
  background-color: var(--bg-light);
}

tbody tr {
  transition: background-color var(--transition-fast);
}

tbody tr:hover {
  background-color: var(--primary-alpha-10);
}

.table-sm td,
.table-sm th {
  padding: var(--spacing-sm);
}

/* ===== FORMS ===== */
.form-group {
  margin-bottom: var(--spacing-lg);
}

label {
  display: block;
  margin-bottom: var(--spacing-sm);
  font-weight: 500;
  color: var(--text-primary);
}

input[type="text"],
input[type="email"],
input[type="number"],
input[type="search"],
select,
textarea {
  width: 100%;
  padding: var(--spacing-sm) var(--spacing-md);
  font-size: 1rem;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
  font-family: inherit;
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--primary-blue);
  box-shadow: 0 0 0 3px var(--focus-ring);
}

input[type="checkbox"],
input[type="radio"] {
  margin-right: var(--spacing-sm);
  cursor: pointer;
}

.search-box {
  position: relative;
}

.search-box input {
  padding-left: 2.5rem;
}

.search-box::before {
  content: "🔍";
  position: absolute;
  left: var(--spacing-md);
  top: 50%;
  transform: translateY(-50%);
  font-size: 1.25rem;
}

.search-bar-container {
  display: flex;
  gap: var(--spacing-sm);
}

.search-bar-container input {
  flex: 1;
}

/* Range Sliders */
input[type="range"] {
  width: 100%;
  height: 6px;
  border-radius: 3px;
  background: var(--gray-200);
  outline: none;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--primary-blue);
  cursor: pointer;
}

input[type="range"]::-moz-range-thumb {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--primary-blue);
  cursor: pointer;
  border: none;
}

/* ===== CODE BLOCKS ===== */
.code-wrapper {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin-bottom: var(--spacing-lg);
  border-radius: var(--radius-sm);
  background-color: var(--bg-light);
}

.code-wrapper pre {
  margin: 0;
  padding: var(--spacing-md);
  white-space: pre;
  word-wrap: normal;
}

.code-wrapper code {
  background-color: transparent;
  padding: 0;
  font-size: 0.875rem;
  line-height: 1.5;
}

/* ===== BADGES ===== */
.badge {
  display: inline-block;
  padding: 0.25rem 0.5rem;
  font-size: 0.75rem;
  font-weight: 600;
  border-radius: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.badge-up {
  background-color: rgba(220, 53, 69, 0.1);
  color: var(--accent-red);
}

.badge-down {
  background-color: rgba(13, 110, 253, 0.1);
  color: var(--accent-blue);
}

.badge-sig {
  background-color: rgba(25, 135, 84, 0.1);
  color: var(--accent-green);
}

.badge-info {
  background-color: rgba(0, 102, 204, 0.1);
  color: var(--primary-blue);
}

/* ===== ALERTS ===== */
.alert {
  padding: var(--spacing-md) var(--spacing-lg);
  border-radius: var(--radius-sm);
  margin-bottom: var(--spacing-lg);
  border-left: 4px solid;
}

.alert-info {
  background-color: rgba(0, 102, 204, 0.1);
  border-color: var(--primary-blue);
  color: var(--primary-dark);
}

.alert-success {
  background-color: rgba(25, 135, 84, 0.1);
  border-color: var(--accent-green);
  color: #0f5132;
}

.alert-warning {
  background-color: rgba(255, 193, 7, 0.1);
  border-color: #ffc107;
  color: #664d03;
}

.alert-danger {
  background-color: rgba(220, 53, 69, 0.1);
  border-color: var(--accent-red);
  color: #842029;
}

/* ===== MODAL ===== */
.modal {
  display: none;
  position: fixed;
  z-index: 2000;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.5);
  animation: fadeIn var(--transition-base);
}

.modal.active {
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-content {
  background-color: var(--bg-white);
  border-radius: var(--radius-md);
  max-width: 800px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-xl);
  animation: slideUp var(--transition-base);
  margin: var(--spacing-lg);
}

.modal-header {
  padding: var(--spacing-lg);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-title {
  font-size: 1.5rem;
  font-weight: 600;
  margin: 0;
}

.modal-close {
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  color: var(--text-secondary);
  padding: 0;
  width: 2rem;
  height: 2rem;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
}

.modal-close:hover {
  background-color: var(--bg-light);
  color: var(--text-primary);
}

.modal-body {
  padding: var(--spacing-lg);
}

.modal-footer {
  padding: var(--spacing-lg);
  border-top: 1px solid var(--border-subtle);
  display: flex;
  gap: var(--spacing-md);
  justify-content: flex-end;
}

/* ===== PAGINATION ===== */
.pagination {
  display: flex;
  list-style: none;
  gap: var(--spacing-sm);
  justify-content: center;
  margin-top: var(--spacing-lg);
}

.pagination button {
  padding: var(--spacing-sm) var(--spacing-md);
  border: 1px solid var(--border-light);
  background-color: var(--bg-white);
  color: var(--text-primary);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-weight: 500;
  transition: all var(--transition-fast);
}

.pagination button:hover:not(:disabled) {
  border-color: var(--primary-blue);
  color: var(--primary-blue);
}

.pagination button.active {
  background-color: var(--primary-blue);
  color: var(--bg-white);
  border-color: var(--primary-blue);
}

.pagination button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* ===== LOADING SPINNER ===== */
.spinner {
  width: 40px;
  height: 40px;
  border: 4px solid var(--bg-light);
  border-top-color: var(--primary-blue);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.spinner-sm {
  width: 20px;
  height: 20px;
  border-width: 2px;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* ===== CHART CONTAINER ===== */
.chart-container {
  position: relative;
  height: 400px;
  margin-bottom: var(--spacing-lg);
}

.chart-container canvas {
  max-width: 100%;
  height: auto !important;
}

/* ===== FILTER PANEL ===== */
.filter-panel {
  background-color: var(--bg-light);
  padding: var(--spacing-lg);
  border-radius: var(--radius-md);
  margin-bottom: var(--spacing-lg);
}

.filter-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--spacing-md);
  cursor: pointer;
  user-select: none;
}

.filter-toggle {
  font-size: 1.25rem;
  transition: transform var(--transition-base);
}

.filter-panel.collapsed .filter-body {
  display: none;
}

.filter-panel.collapsed .filter-toggle {
  transform: rotate(-90deg);
}

.filter-group {
  margin-bottom: var(--spacing-md);
}

.filter-group label {
  display: flex;
  align-items: center;
  gap: var(--spacing-sm);
  font-weight: normal;
  cursor: pointer;
}

/* ===== BREADCRUMB ===== */
.breadcrumb {
  display: flex;
  list-style: none;
  gap: var(--spacing-sm);
  margin-bottom: var(--spacing-lg);
  color: var(--text-secondary);
}

.breadcrumb li::after {
  content: "/";
  margin-left: var(--spacing-sm);
}

.breadcrumb li:last-child::after {
  content: "";
}

.breadcrumb a {
  color: var(--primary-blue);
}

/* ===== ANIMATIONS ===== */
@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes slideUp {
  from {
    transform: translateY(20px);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

@keyframes slideDown {
  from {
    transform: translateY(-20px);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

/* ===== CHART CONTAINER ===== */
.chart-container {
  position: relative;
  width: 100%;
  height: 500px;
  margin-bottom: var(--spacing-lg);
}

/* ===== RESPONSIVE COMPONENTS ===== */
@media (max-width: 768px) {
  .chart-container {
    height: 400px;
  }
  .card {
    padding: var(--spacing-md);
  }

  .stat-number {
    font-size: 2rem;
  }

  .modal-content {
    margin: var(--spacing-sm);
    max-width: calc(100% - 2rem);
  }

  input[type="text"],
  input[type="email"],
  input[type="number"],
  input[type="search"],
  select,
  textarea {
    font-size: 16px;
    padding: var(--spacing-md);
  }

  .table-wrapper {
    font-size: 0.875rem;
    border-radius: var(--radius-sm);
  }

  table {
    min-width: 600px;
  }

  th,
  td {
    padding: var(--spacing-sm);
    font-size: 0.875rem;
  }

  th {
    white-space: nowrap;
  }
}

@media (max-width: 576px) {
  .chart-container {
    height: 300px;
  }

  .stat-number {
    font-size: 1.5rem;
  }
}

@media (max-width: 400px) {
  .chart-container {
    height: 250px;
  }

  .search-bar-container {
    flex-direction: column;
  }

  .search-bar-container button {
    width: 100%;
  }
}

/* ===== LOUPE BROWSER COMPONENTS ===== */
/* Loupe Browser Download Cards */
.loupe-download-card {
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.loupe-download-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 12px 24px rgba(0, 102, 204, 0.15);
}

/* Mobile Responsiveness for Loupe Cards */
@media (max-width: 768px) {
  .loupe-download-card .grid {
    grid-template-columns: 1fr;
  }

  .loupe-download-card .btn {
    width: 100%;
    margin-bottom: 0.5rem;
  }
}

/* File Size Badges */
.file-size-badge {
  display: inline-block;
  background: #6c757d;
  color: white;
  padding: 0.25rem 0.75rem;
  border-radius: 12px;
  font-size: 0.875rem;
  font-weight: 500;
}

/* Download Button Animation */
.download-btn {
  position: relative;
}

.download-btn:hover {
  animation: pulse 1s ease infinite;
}

@keyframes pulse {
  0%, 100% {
    transform: translateY(-1px);
  }
  50% {
    transform: translateY(-3px);
  }
}

/* ===== PUBLICATIONS DATABASE COMPONENTS ===== */

/* Publication Table Cells */
.pub-title {
  max-width: 400px;
  line-height: 1.4;
}

.pub-title strong {
  color: var(--text-primary);
  font-weight: 600;
}

.pub-takeaway {
  display: block;
  margin-top: 0.5rem;
  color: var(--text-secondary);
  font-style: italic;
  font-size: 0.9rem;
  line-height: 1.3;
}

.pub-authors {
  max-width: 200px;
  font-size: 0.9rem;
}

/* Quartile Badges */
.badge-quartile-q1 {
  background-color: #198754 !important; /* Green for Q1 */
  color: white !important;
}

.badge-quartile-q2 {
  background-color: #0066cc !important; /* Blue for Q2 */
  color: white !important;
}

.badge-quartile-q3 {
  background-color: #ffc107 !important; /* Yellow for Q3 */
  color: #212529 !important;
}

.badge-quartile-q4 {
  background-color: #6c757d !important; /* Gray for Q4 */
  color: white !important;
}

.badge-quartile-na {
  background-color: var(--gray-200) !important; /* Light gray for N/A */
  color: #6c757d !important;
}

/* Modal */
.modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 9999;
  background: rgba(0, 0, 0, 0.7);
  justify-content: center;
  align-items: center;
  padding: 1rem;
}

.modal.active {
  display: flex !important;
}

.modal-backdrop {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
}

.modal-dialog {
  position: relative;
  width: 100%;
  max-width: 800px;
  max-height: 90vh;
  z-index: 10000;
}

.modal-content {
  background: var(--bg-white);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-xl);
  max-height: 90vh;
  overflow-y: auto;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: 1.5rem;
  border-bottom: 1px solid var(--bg-light);
  position: sticky;
  top: 0;
  background: var(--bg-white);
  z-index: 10;
}

.modal-title {
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0;
  padding-right: 2rem;
  line-height: 1.3;
}

.modal-close {
  background: none;
  border: none;
  font-size: 2rem;
  line-height: 1;
  cursor: pointer;
  color: var(--text-secondary);
  padding: 0;
  width: 2rem;
  height: 2rem;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: all 0.2s;
}

.modal-close:hover {
  background: var(--bg-light);
  color: var(--text-primary);
}

.modal-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  padding: 1rem 1.5rem;
  background: var(--bg-light);
  border-bottom: 1px solid #dee2e6;
  font-size: 0.9rem;
}

.modal-meta span {
  color: var(--text-secondary);
}

.modal-meta strong {
  color: var(--text-primary);
  font-weight: 600;
}

.modal-section {
  padding: 1.5rem;
}

.modal-section h3 {
  font-size: 1.2rem;
  font-weight: 600;
  color: var(--primary-blue);
  margin-bottom: 1rem;
}

.modal-takeaway {
  background: var(--primary-alpha-10);
  border-left: 4px solid var(--primary-blue);
  padding: 1rem;
  border-radius: 4px;
  font-style: italic;
  line-height: 1.6;
  color: var(--text-primary);
}

.modal-abstract {
  line-height: 1.7;
  color: var(--text-primary);
  text-align: justify;
}

.modal-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.modal-links .btn {
  flex: 0 1 auto;
}

/* Filter Section */
.filter-section {
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--bg-light);
  transition: all 0.3s ease;
}

.filter-section.hidden {
  display: none;
}

/* Export Controls */
.export-controls {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
}

/* Search Bar */
.search-bar {
  display: flex;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.search-bar .form-input {
  flex: 1;
}

/* Form Groups */
.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.form-group label {
  font-weight: 500;
  color: var(--text-primary);
  font-size: 0.9rem;
}

/* Responsive Design for Publications */
@media (max-width: 768px) {
  /* Mobile card layout for publications table */
  #publicationsTable thead {
    display: none;
  }

  #publicationsTable tbody tr {
    display: block;
    margin-bottom: 1.5rem;
    border: 1px solid var(--bg-light);
    border-radius: var(--radius-sm);
    background: var(--bg-white);
    box-shadow: var(--shadow-sm);
  }

  #publicationsTable tbody td {
    display: block;
    text-align: left !important;
    padding: 0.75rem 1rem !important;
    border: none;
    border-bottom: 1px solid var(--bg-light);
  }

  #publicationsTable tbody td:last-child {
    border-bottom: none;
  }

  #publicationsTable tbody td::before {
    content: attr(data-label);
    font-weight: 600;
    color: var(--primary-blue);
    display: block;
    margin-bottom: 0.25rem;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
  }

  .pub-title {
    max-width: 100%;
  }

  .pub-authors {
    max-width: 100%;
  }

  /* Modal adjustments for mobile */
  .modal-dialog {
    max-width: 100%;
    margin: 0;
  }

  .modal-content {
    border-radius: 0;
    max-height: 100vh;
  }

  .modal-header {
    padding: 1rem;
  }

  .modal-title {
    font-size: 1.2rem;
  }

  .modal-meta {
    flex-direction: column;
    gap: 0.5rem;
  }

  .modal-section {
    padding: 1rem;
  }

  .modal-links {
    flex-direction: column;
  }

  .modal-links .btn {
    width: 100%;
  }

  /* Search and filter controls */
  .search-bar {
    flex-direction: column;
  }

  .search-bar .btn {
    width: 100%;
  }

  .export-controls {
    flex-direction: column;
  }

  .export-controls .btn {
    width: 100%;
  }

  .card-header {
    flex-direction: column;
    align-items: flex-start !important;
    gap: 0.75rem;
  }

  .card-header .btn {
    width: 100%;
  }
}
