/* ========================================
   MOBILE TABLE OPTIMIZATIONS FOR RESEARCH PAGE
   Comprehensive mobile-friendly table layouts
   ======================================== */

/* ========================================
   MOBILE TABLE CONTAINER OPTIMIZATIONS
   ======================================== */

@media (max-width: 991px) {
  /* Table container adjustments */
  .table-responsive {
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    margin-bottom: 1rem;
  }
  
  /* Table base styling */
  .table {
    margin-bottom: 0;
    font-size: 0.8rem;
    border-collapse: separate;
    border-spacing: 0;
  }
  
  /* Table header optimizations */
  .table thead th {
    background-color: #f8f9fa;
    border-bottom: 2px solid #dee2e6;
    padding: 0.5rem 0.3rem;
    font-size: 0.75rem;
    font-weight: 600;
    text-align: center;
    white-space: nowrap;
    position: sticky;
    top: 0;
    z-index: 10;
  }
  
  /* Table body optimizations */
  .table tbody td {
    padding: 0.4rem 0.3rem;
    border-bottom: 1px solid #dee2e6;
    vertical-align: middle;
    font-size: 0.75rem;
  }
  
  /* Performance table specific optimizations */
  .performance-table th:nth-child(1),
  .performance-table td:nth-child(1) {
    min-width: 120px;
    max-width: 120px;
    word-wrap: break-word;
    font-weight: 600;
  }
  
  .performance-table th:nth-child(2),
  .performance-table td:nth-child(2),
  .performance-table th:nth-child(3),
  .performance-table td:nth-child(3),
  .performance-table th:nth-child(4),
  .performance-table td:nth-child(4) {
    min-width: 60px;
    max-width: 60px;
    text-align: center;
  }
  
  .performance-table th:nth-child(5),
  .performance-table td:nth-child(5),
  .performance-table th:nth-child(6),
  .performance-table td:nth-child(6) {
    min-width: 50px;
    max-width: 50px;
    text-align: center;
  }
  
  /* Risk table specific optimizations */
  .risk-table th:nth-child(1),
  .risk-table td:nth-child(1) {
    min-width: 100px;
    max-width: 100px;
    word-wrap: break-word;
    font-weight: 600;
  }
  
  .risk-table th:nth-child(2),
  .risk-table td:nth-child(2),
  .risk-table th:nth-child(3),
  .risk-table td:nth-child(3),
  .risk-table th:nth-child(4),
  .risk-table td:nth-child(4),
  .risk-table th:nth-child(5),
  .risk-table td:nth-child(5),
  .risk-table th:nth-child(6),
  .risk-table td:nth-child(6) {
    min-width: 55px;
    max-width: 55px;
    text-align: center;
  }
  
  /* Correlation table specific optimizations */
  .correlation-table th:nth-child(1),
  .correlation-table td:nth-child(1) {
    min-width: 100px;
    max-width: 100px;
    font-weight: 600;
    background-color: #f8f9fa;
  }
  
  .correlation-table th:nth-child(2),
  .correlation-table td:nth-child(2),
  .correlation-table th:nth-child(3),
  .correlation-table td:nth-child(3),
  .correlation-table th:nth-child(4),
  .correlation-table td:nth-child(4),
  .correlation-table th:nth-child(5),
  .correlation-table td:nth-child(5),
  .correlation-table th:nth-child(6),
  .correlation-table td:nth-child(6),
  .correlation-table th:nth-child(7),
  .correlation-table td:nth-child(7) {
    min-width: 50px;
    max-width: 50px;
    text-align: center;
  }
}

@media (max-width: 768px) {
  /* Further optimizations for smaller screens */
  .table {
    font-size: 0.7rem;
  }
  
  .table thead th {
    padding: 0.4rem 0.2rem;
    font-size: 0.7rem;
  }
  
  .table tbody td {
    padding: 0.3rem 0.2rem;
    font-size: 0.7rem;
  }
  
  /* Performance table adjustments */
  .performance-table th:nth-child(1),
  .performance-table td:nth-child(1) {
    min-width: 100px;
    max-width: 100px;
  }
  
  .performance-table th:nth-child(2),
  .performance-table td:nth-child(2),
  .performance-table th:nth-child(3),
  .performance-table td:nth-child(3),
  .performance-table th:nth-child(4),
  .performance-table td:nth-child(4) {
    min-width: 50px;
    max-width: 50px;
  }
  
  .performance-table th:nth-child(5),
  .performance-table td:nth-child(5),
  .performance-table th:nth-child(6),
  .performance-table td:nth-child(6) {
    min-width: 40px;
    max-width: 40px;
  }
  
  /* Risk table adjustments */
  .risk-table th:nth-child(1),
  .risk-table td:nth-child(1) {
    min-width: 80px;
    max-width: 80px;
  }
  
  .risk-table th:nth-child(2),
  .risk-table td:nth-child(2),
  .risk-table th:nth-child(3),
  .risk-table td:nth-child(3),
  .risk-table th:nth-child(4),
  .risk-table td:nth-child(4),
  .risk-table th:nth-child(5),
  .risk-table td:nth-child(5),
  .risk-table th:nth-child(6),
  .risk-table td:nth-child(6) {
    min-width: 45px;
    max-width: 45px;
  }
  
  /* Correlation table adjustments */
  .correlation-table th:nth-child(1),
  .correlation-table td:nth-child(1) {
    min-width: 80px;
    max-width: 80px;
  }
  
  .correlation-table th:nth-child(2),
  .correlation-table td:nth-child(2),
  .correlation-table th:nth-child(3),
  .correlation-table td:nth-child(3),
  .correlation-table th:nth-child(4),
  .correlation-table td:nth-child(4),
  .correlation-table th:nth-child(5),
  .correlation-table td:nth-child(5),
  .correlation-table th:nth-child(6),
  .correlation-table td:nth-child(6),
  .correlation-table th:nth-child(7),
  .correlation-table td:nth-child(7) {
    min-width: 40px;
    max-width: 40px;
  }
}

@media (max-width: 480px) {
  /* Mobile card layout for very small screens */
  .table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  
  .table {
    min-width: 600px; /* Force horizontal scroll on very small screens */
    font-size: 0.65rem;
  }
  
  .table thead th {
    padding: 0.3rem 0.15rem;
    font-size: 0.65rem;
  }
  
  .table tbody td {
    padding: 0.25rem 0.15rem;
    font-size: 0.65rem;
  }
  
  /* Add scroll indicator */
  .table-responsive::after {
    content: "← Swipe to see more →";
    display: block;
    text-align: center;
    font-size: 0.7rem;
    color: #6c757d;
    padding: 0.5rem;
    background-color: #f8f9fa;
    border-top: 1px solid #dee2e6;
  }
  
  /* Performance table mobile adjustments */
  .performance-table th:nth-child(1),
  .performance-table td:nth-child(1) {
    min-width: 90px;
    max-width: 90px;
  }
  
  .performance-table th:nth-child(2),
  .performance-table td:nth-child(2),
  .performance-table th:nth-child(3),
  .performance-table td:nth-child(3),
  .performance-table th:nth-child(4),
  .performance-table td:nth-child(4) {
    min-width: 45px;
    max-width: 45px;
  }
  
  .performance-table th:nth-child(5),
  .performance-table td:nth-child(5),
  .performance-table th:nth-child(6),
  .performance-table td:nth-child(6) {
    min-width: 35px;
    max-width: 35px;
  }
  
  /* Risk table mobile adjustments */
  .risk-table th:nth-child(1),
  .risk-table td:nth-child(1) {
    min-width: 70px;
    max-width: 70px;
  }
  
  .risk-table th:nth-child(2),
  .risk-table td:nth-child(2),
  .risk-table th:nth-child(3),
  .risk-table td:nth-child(3),
  .risk-table th:nth-child(4),
  .risk-table td:nth-child(4),
  .risk-table th:nth-child(5),
  .risk-table td:nth-child(5),
  .risk-table th:nth-child(6),
  .risk-table td:nth-child(6) {
    min-width: 40px;
    max-width: 40px;
  }
  
  /* Correlation table mobile adjustments */
  .correlation-table th:nth-child(1),
  .correlation-table td:nth-child(1) {
    min-width: 70px;
    max-width: 70px;
  }
  
  .correlation-table th:nth-child(2),
  .correlation-table td:nth-child(2),
  .correlation-table th:nth-child(3),
  .correlation-table td:nth-child(3),
  .correlation-table th:nth-child(4),
  .correlation-table td:nth-child(4),
  .correlation-table th:nth-child(5),
  .correlation-table td:nth-child(5),
  .correlation-table th:nth-child(6),
  .correlation-table td:nth-child(6),
  .correlation-table th:nth-child(7),
  .correlation-table td:nth-child(7) {
    min-width: 35px;
    max-width: 35px;
  }
}

/* ========================================
   MOBILE TABLE ALTERNATIVE LAYOUTS
   ======================================== */

@media (max-width: 360px) {
  /* Ultra-small screen: Stack table data as cards */
  .table-responsive {
    overflow: visible;
  }
  
  .table {
    display: none; /* Hide table on ultra-small screens */
  }
  
  /* Show mobile card layout instead */
  .mobile-table-cards {
    display: block;
  }
  
  .mobile-table-cards .table-card {
    background: white;
    border: 1px solid #dee2e6;
    border-radius: 8px;
    margin-bottom: 1rem;
    padding: 1rem;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
  }
  
  .mobile-table-cards .table-card .card-header {
    font-weight: 600;
    font-size: 0.9rem;
    margin-bottom: 0.5rem;
    color: #2c2c2c;
    border-bottom: 1px solid #dee2e6;
    padding-bottom: 0.5rem;
  }
  
  .mobile-table-cards .table-card .card-data {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem;
    font-size: 0.8rem;
  }
  
  .mobile-table-cards .table-card .data-item {
    display: flex;
    justify-content: space-between;
    padding: 0.25rem 0;
  }
  
  .mobile-table-cards .table-card .data-label {
    font-weight: 500;
    color: #6c757d;
  }
  
  .mobile-table-cards .table-card .data-value {
    font-weight: 600;
    text-align: right;
  }
}

/* ========================================
   TABLE LEGEND MOBILE OPTIMIZATIONS
   ======================================== */

@media (max-width: 991px) {
  .legend-container {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.5rem;
    margin-bottom: 1rem;
    padding: 0.75rem;
    background-color: #f8f9fa;
    border-radius: 6px;
  }
  
  .legend-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.75rem;
    margin-bottom: 0.25rem;
  }
  
  .legend-color {
    min-width: 20px;
    height: 16px;
    border-radius: 3px;
    display: inline-block;
  }
}

@media (max-width: 768px) {
  .legend-container {
    padding: 0.5rem;
  }
  
  .legend-item {
    font-size: 0.7rem;
  }
  
  .legend-color {
    min-width: 18px;
    height: 14px;
  }
}

@media (max-width: 480px) {
  .legend-container {
    padding: 0.4rem;
  }
  
  .legend-item {
    font-size: 0.65rem;
  }
  
  .legend-color {
    min-width: 16px;
    height: 12px;
  }
}

/* ========================================
   TABLE DESCRIPTION MOBILE OPTIMIZATIONS
   ======================================== */

@media (max-width: 991px) {
  .table-description {
    font-size: 0.85rem;
    line-height: 1.4;
    margin-bottom: 1rem;
  }
  
  .table-note {
    font-size: 0.75rem;
    line-height: 1.3;
  }
}

@media (max-width: 768px) {
  .table-description {
    font-size: 0.8rem;
  }
  
  .table-note {
    font-size: 0.7rem;
  }
}

@media (max-width: 480px) {
  .table-description {
    font-size: 0.75rem;
  }
  
  .table-note {
    font-size: 0.65rem;
  }
}
