/* Mobile-optimized tables for Progonki.ru
 * This file contains responsive table styles that transform
 * traditional tables into card-like layouts on small screens
 */

/* Default styling for larger screens - keep standard table layout */
@media (min-width: 768px) {
  .mobile-optimized-table {
    /* Standard table behavior for larger screens */
  }
}



/* Mobile optimization for small screens */
@media (max-width: 767.98px) {
  
  .fs-6 {
  font-size: 0.6375rem !important;
}
.custom-diagonal-showcase {
  height: 100px !important;
}

  /* Hide table headers on mobile */
  .mobile-optimized-table thead {
    display: none;
  }
  
  /* Hide specific columns on mobile */
  .mobile-hide {
    display: none !important;
  }
  
  /* Reset table layout */
  .mobile-optimized-table,
  .mobile-optimized-table tbody {
    display: block;
    width: 100%;
  }
  
  /* Make filter cards more compact on mobile */
  .filter-card .form-label {
    font-size: 0.8125rem;
    margin-bottom: 0.25rem;
  }
  
  .filter-card .form-select,
  .filter-card .form-control {
    font-size: 0.875rem;
  }
  .card-body {
        font-size: 0.795rem;
        --bs-card-spacer-y: 0.5rem;
  --bs-card-spacer-x: 0.5rem;

  }

  .container-xxl {
    padding-inline: 0.4rem;
  }
  /* Fix for mobile menu positioning - always at top of screen */
  .layout-navbar.navbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    width: 100%;
    z-index: 1030;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
  }
  
  
  /* Fix layout container to account for fixed navbar */
  .layout-container,
  .content-wrapper,
  .container-xxl {
    position: relative;
    z-index: 1;
  }
  
  /* Fix for hamburger menu button to ensure it's fully clickable */
  .navbar-toggler {
    z-index: 1031;
    position: relative;
    padding: 0.75rem;
    margin: 0;
    width: 48px;
    height: 48px;
  }
  
  /* Improve the clickable area */
  .navbar-toggler-icon {
    width: 1.5em;
    height: 1.5em;
    display: block;
    margin: 0 auto;
  }
  
  /* Clear any potential overlays */
  .layout-navbar.navbar::before,
  .layout-navbar.navbar::after {
    display: none !important;
  }
  
  /* Ensure the mobile navbar menu appears at the top and stays there */
  .navbar-collapse {
    position: fixed;
    top: 56px; /* Should match navbar height */
    right: 0;
    left: 0;
    width: 100%;
    background-color: #2b2c40;
    z-index: 1029;
    padding: 0.75rem;
    max-height: calc(100vh - 56px);
    overflow-y: auto;
    overflow-x: hidden;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.35);
    border-top: 1px solid rgba(255, 255, 255, 0.1);
  }
  
  /* Make menu items more obvious */
  .menu-link,
  .dropdown-item {
    padding: 0.75rem;
    margin-bottom: 2px;
  }
  
  /* Active menu item highlighting */
  .menu-item.active > .menu-link {
    background-color: rgba(105, 108, 255, 0.2);
    color: #fff;
  }
  
  .filter-card .form-check-label {
    font-size: 0.8125rem;
  }
  
  /* Show time differences without hover on mobile */
  @media (max-width: 767.98px) {
    .lapTimeCell {
      position: relative;
    }
    
    .lapTimeCell .time-difference {
      display: inline-block !important;
      font-size: 0.75rem;
      color: rgba(255, 255, 255, 0.65);
      margin-left: 5px;
      font-weight: normal !important;
    }
    
    /* Add parentheses to time differences */
    .lapTimeCell .time-difference::before {
      content: "(";
    }
    
    .lapTimeCell .time-difference::after {
      content: ")";
    }
    
    /* Hide the separate gap column completely since we show it inline */
    td[data-label="Отставание"] {
      display: none !important;
    }
    
    /* Improve lap time display */
    .bestLap {
      color: #ff00ff !important;
      font-weight: 500 !important;
    }
    
    /* Car name display in mobile view */
    .driver-name {
      display: block;
      font-size: 0.95rem;
      line-height: 1.2;
    }
    
    .car-model {
      display: block;
      font-size: 0.75rem;
      color: rgba(255, 255, 255, 0.75);
      line-height: 1.2;
    }
    
    /* Improve avatar display */
    .avatar img {
      width: 2.5rem;
      height: 2.5rem;
      object-fit: cover;
    }
    
    /* Improve position number display */
    .position-number {
      font-size: 0.85rem;
      color: rgba(255, 255, 255, 0.85);
      font-weight: 500;
    }
    
    /* Fixed menu during scroll - make it sticky at any scroll position */
    .navbar-toggler:focus {
      box-shadow: 0 0 0 0.1rem rgba(255, 255, 255, 0.25);
    }
  }
  
  /* Style for mobile-optimized tables */
  .mobile-optimized-table {
    border: 0;
    width: 100%;
    --bs-table-striped-bg: transparent; /* Disable striped rows */
    --bs-table-bg-type: none; /* Override bootstrap striping */
  }
  
  /* Display cards in a single column layout */
  .mobile-optimized-table tbody {
    display: block;
    width: 100%;
  }
  
  /* Style table rows as cards */
  .mobile-optimized-table tr {
    display: block;
    border-radius: 0.25rem;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
    background-color: var(--bs-table-bg);
    border: 1px solid var(--bs-border-color);
    height: 100%;
  }
  
  /* Override striped tables for mobile */
  .table-striped.mobile-optimized-table > tbody > tr:nth-of-type(odd) > * {
    background-color: transparent !important; /* Force override */
    --bs-table-accent-bg: transparent !important;
  }
  
  /* Use grid to create specific grouped rows within each card */
  /* Single-row card layout */
  .mobile-optimized-table tr {
    display: flex;
    flex-direction: row;
    flex-wrap: nowrap;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 0.75rem;
    background-color: rgba(33, 37, 45, 0.6) !important; /* Force override any striping */
    border-radius: 0.5rem;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.15);
    overflow: hidden;
    padding: 0.6rem 0.75rem;
    transition: transform 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
    min-height: 4rem;
    position: relative;
    border-left: 3px solid transparent;
  }
  
  /* Style table cells - all cells flex in a row */
  .mobile-optimized-table td {
    display: flex;
    align-items: center;
    padding: 0;
    font-size: 0.75rem;
    border: none;
    min-height: 2.5rem;
  }
  
  /* Position number in top left corner */
  .mobile-optimized-table td[data-label="Поз"] {
    position: absolute;
    top: 5px;
    left: 5px;
    font-weight: 600;
    font-size: 0.9rem;
    color: rgba(255, 255, 255, 0.7);
    margin: 0;
    padding: 0;
    z-index: 5;
  }
  
  /* Hide all data labels */
  .mobile-optimized-table td::before {
    display: none;
  }
  
  /* Add avatar image before driver name */
  .mobile-optimized-table td[data-label="Пилот"]::before {
    content: '';
    display: block;
    width: 2.5rem;
    height: 2.5rem;
    margin-right: 0.75rem;
    border-radius: 50%;
    background-color: #2a2e3a;
    background-image: url('../../assets/img/avatars/default.png');
    background-size: cover;
    background-position: center;
    border: 2px solid rgba(108, 124, 255, 0.3);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
    flex-shrink: 0;
  }
  
  /* Best lap time styling */
  .mobile-optimized-table td[data-label="Лучший круг"] {
    justify-content: flex-end;
    color: #8F93FF; /* Brighter blue for better visibility */
    font-weight: 600;
    font-size: 1.2rem;
    margin-left: auto;
    padding-right: 0.25rem;
    position: relative;
    flex-shrink: 0;
    text-shadow: 0 0 8px rgba(108, 124, 255, 0.3); /* Add subtle glow effect */
  }
  
  /* Style for gap display - show only on hover */
  .mobile-optimized-table td[data-label="Отставание"] {
    display: none;
  }
  
  /* Gap is shown in the tooltip on hover */
  .mobile-optimized-table tr:hover td[data-label="Лучший круг"]::after {
    content: attr(data-time-gap);
    display: inline-block;
    position: absolute;
    top: -20px;
    right: 0;
    background-color: rgba(20, 20, 30, 0.9);
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.9);
    font-weight: normal;
    white-space: nowrap;
    z-index: 10;
  }
  
  /* Time gap - hide it since we're showing it after the time now */
  .mobile-optimized-table td[data-label="Отставание"] {
    display: none;
  }
  
  /* Remove the hover effect that shows gap since we're showing it by default now */
  .mobile-optimized-table tr:hover td[data-label="Лучший круг"]::after {
    content: none;  /* Remove the hover-based content */
  }
  
  /* First place style - already hidden now */
  .mobile-optimized-table tr:first-child td[data-label="Отставание"] {
    display: none;
  }
  
  /* Hide date on mobile to save space */
  .mobile-optimized-table td[data-label="Дата"] {
    display: none;
  }
  
  /* Driver name */
  .mobile-optimized-table td[data-label="Пилот"] {
    justify-content: flex-start;
    font-weight: 600;
    color: #ffffff;
    flex-grow: 1;
    flex-shrink: 1;
    min-width: 0;
    z-index: 2;
    padding-left: 0;
    margin-left: 15px; /* Add space for position number */
    display: flex;
    flex-direction: row;
    align-items: center;
  }
  
  /* Create container for name and car info */
  .mobile-optimized-table td[data-label="Пилот"] a,
  .mobile-optimized-table td[data-label="Пилот"] strong,
  .mobile-optimized-table td[data-label="Пилот"] span {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    font-size: 0.95rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    min-width: 0;
  }
  
  /* Add car name after driver name */
  .mobile-optimized-table td[data-label="Пилот"] a::after,
  .mobile-optimized-table td[data-label="Пилот"] strong::after,
  .mobile-optimized-table td[data-label="Пилот"] span::after {
    content: attr(data-car);
    display: block;
    font-size: 0.75rem;
    font-weight: 400;
    color: rgba(255, 255, 255, 0.65);
    margin-top: 0.15rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
  }

  /* Enhance link colors for better contrast */
  .mobile-optimized-table td[data-label="Пилот"] a {
    color: #ffffff;
    text-decoration: none;
  }
  
  /* Hide car name column */
  .mobile-optimized-table td[data-label="Автомобиль"] {
    display: none;
  }
  
  /* Special styling for car names */
  .mobile-optimized-table td[data-label="Автомобиль"] {
    font-size: 0.75rem;
    line-height: 1.2;
  }
  
  /* Optional: hide certain less important columns on mobile */
  .mobile-optimized-table .mobile-hide {
    display: none;
  }
  
  /* Special styling for best lap */
  .mobile-optimized-table .bestLap {
    font-weight: 600; /* Slightly lighter than bold */
    color: var(--bs-primary);
  }
  
  /* Already styled position numbers above */
  
  /* Highlight for real laps */
  .mobile-optimized-table tr.bg-success-subtle td {
    background-color: rgba(var(--bs-success-rgb), 0.03); /* Even lighter background */
  }

  /* All rows have the same styling - no special highlight for first position */
  .mobile-optimized-table tr {
    position: relative; /* For absolute positioning of elements */
  }
  
  /* No special styling for first place position */
  
  /* All best laps have the same styling */
  .mobile-optimized-table td[data-label="Лучший круг"] {
    font-weight: 600;
  }
  
  /* No special styling for first place driver name or avatar */
  
  /* No special styling for first row */
  
  /* Style for time gap values */
  .mobile-optimized-table td[data-label="Отставание"] {
    color: rgba(var(--bs-body-color-rgb), 0.75);
  }
  
  /* Date is hidden on mobile */
  
  /* Make badges more compact */
  .mobile-optimized-table .badge {
    padding: 0.25rem 0.5rem;
    font-size: 0.6875rem;
  }
  
  /* Improve links in mobile tables */
  .mobile-optimized-table a {
    color: inherit;
    font-weight: inherit;
    text-decoration: none;
    display: inline-block;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  
  /* No special highlight for best lap time */
  
  /* Filter card styles for mobile */
  .filter-card {
    margin-bottom: 0.75rem;
    border-radius: 0.375rem;
  }
  
  .filter-card .card-body {
    padding: 0.625rem;
  }
  
  /* Card title styles in mobile view */
  .card-header {
    padding: 0.75rem 1rem;
  }
  
  .card-header h5 {
    font-size: 0.9375rem;
    line-height: 1.2;
    margin-bottom: 0.25rem;
  }
  
  .card-subtitle {
    font-size: 0.75rem;
    line-height: 1.2;
    margin-top: 0;
  }
  
  /* Make buttons in filter cards more compact */
  .filter-card .btn {
    padding: 0.375rem 0.75rem;
    font-size: 0.875rem;
  }
  
  /* Make all table text more compact on really small screens */
  @media (max-width: 374px) {
    .mobile-optimized-table tr {
      padding: 0.5rem 0.5rem;
      gap: 0.25rem;
      min-height: 3.75rem;
    }
    
    .mobile-optimized-table td[data-label="Пилот"]::before {
      width: 2.25rem;
      height: 2.25rem;
      margin-right: 0.5rem;
    }
    
    .mobile-optimized-table td[data-label="Поз"] {
      min-width: 1.75rem;
      width: 1.75rem;
      height: 1.75rem;
      font-size: 0.9rem;
    }
    
    .mobile-optimized-table td[data-label="Лучший круг"] {
      font-size: 1rem;
    }
    
    .mobile-optimized-table td[data-label="Пилот"] {
      font-size: 0.85rem;
    }
    
    .mobile-optimized-table td[data-label="Автомобиль"] {
      font-size: 0.7rem;
      max-width: 6rem;
    }
    
    .mobile-optimized-table td[data-label="Дата"] {
      font-size: 0.65rem;
    }
    
    /* Adjust time gap display for small screens */
    .mobile-optimized-table td[data-label="Лучший круг"]::after {
      font-size: 0.65rem;
      margin-left: 0.25rem;
    }
    
    /* No special styling for first place on small screens */
  }
  
  /* Add subtle active state effect */
  .mobile-optimized-table tr:active {
    transform: translateY(1px);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
  }
  
  /* Improve mobile pagination */
  .pagination .page-link {
    padding: 0.25rem 0.5rem;
    font-size: 0.8125rem;
  }
  
  .pagination-info {
    font-size: 0.75rem;
  }
  
  /* Display section titles in a more compact way */
  h4.py-4 {
    padding-top: 0.75rem !important;
    padding-bottom: 0.75rem !important;
    font-size: 1.125rem;
    margin-bottom: 0.5rem !important;
  }
  
  /* Style for badges in mobile view */
  .mobile-optimized-table td .badge {
    margin-left: auto;
  }
  
}