/* ===============================
   Raycin Track Manager — Combined Layout Fix (Responsive)
   =============================== */

   .raycin-map-wrapper {
    display: flex;
    flex-direction: row;
    flex-wrap: nowrap;
    gap: 1rem;
    width: 100%;
    height: 700px;
    background: #37474f;
    color: #cfd8dc;
    padding: 1rem;
    position: relative;
    overflow: hidden;
  }
  
  /* Main map area */
  #raycin-map {
    flex: 1;
    height: 100%;
    width: 100%;
    border-radius: 10px;
    overflow: hidden;
    position: relative;
    background: #263238;
    box-shadow: 0 0 10px rgba(0,0,0,0.3);
    z-index: 1;
  }
  
  /* Sidebar / Track list */
  #raycin-tracklist {
    width: 300px;
    max-height: 700px;
    overflow-y: auto;
    background: #37474f;
    border-radius: 8px;
    padding: 1rem;
    border-right: 2px solid #4f5d64;
    z-index: 2;
    box-shadow: 0 0 8px rgba(0,0,0,0.2);
  }
  
  #raycin-tracklist h2, 
  #raycin-tracklist h4 {
    margin-top: 0;
    text-align: center;
    color: #fff;
    font-weight: 600;
    letter-spacing: 1px;
  }
  
  #raycin-tracklist label {
    color: #cfd8dc;
    font-size: 0.9rem;
    margin-bottom: 5px;
    display: block;
  }
  
  /* Track selector dropdown */
  #trackSelector {
    width: 100%;
    background: #263238;
    color: #cfd8dc;
    border: 1px solid #4f5d64;
    padding: 8px;
    border-radius: 4px;
    margin-top: 0.5rem;
    transition: all 0.2s ease;
    font-size: 0.9rem;
  }
  
  #trackSelector option {
    background: #263238;
    color: #cfd8dc;
  }
  
  #trackSelector:focus {
    outline: none;
    border-color: #80cbc4;
    box-shadow: 0 0 8px rgba(128,203,196,0.4);
  }
  
  #trackList li:hover {
    color: #80cbc4;
  }
  
  /* Track info panel */
  #trackInfo {
    color: #cfd8dc;
    font-size: 0.9rem;
    line-height: 1.5;
    margin-top: 12px;
    padding: 10px;
    background: #263238;
    border-radius: 8px;
    border: 1px solid #4f5d64;
  }
  
  #trackInfo h2,
  #trackInfo h3 {
    font-size: 1.2rem;
    text-align: center;
    color: #fff;
    margin-bottom: 10px;
  }
  
  .track-details p,
  .track-meta p {
    margin: 4px 0;
    color: #cfd8dc;
  }
  
  .track-details strong,
  .track-meta strong {
    color: #80cbc4;
  }
  
  /* Reset View button */
  #resetTrackView {
    display: block;
    width: 100%;
    background: #80cbc4;
    color: #263238;
    border: 1px solid #80cbc4;
    border-radius: 6px;
    padding: 8px 12px;
    margin-top: 1rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    cursor: pointer;
    transition: all 0.2s ease;
  }
  
  #resetTrackView:hover {
    background: #69aaf0;
    border-color: #69aaf0;
    color: #263238;
  }
  
  /* Leaflet visual layers */
  .leaflet-container {
    background: #263238 !important;
    z-index: 1;
  }
  
  .leaflet-overlay-pane img {
    opacity: 1 !important;
    display: block !important;
    visibility: visible !important;
    z-index: 5 !important;
  }
  
  .leaflet-overlay-pane path {
    filter: drop-shadow(0 0 6px rgba(128,203,196,0.7));
  }
  
  .leaflet-popup-content {
    color: #cfd8dc !important;
    background: #37474f;
    border-radius: 8px;
    padding: 10px;
  }
  
  /* Reset button cursor fix */
  .leaflet-control-custom {
    cursor: pointer;
  }
  
  /* Track filters for map view */
  .raycin-map-filters {
    margin-bottom: 15px;
    padding-bottom: 15px;
    border-bottom: 1px solid #4f5d64;
  }
  
  .raycin-map-filters h5 {
    color: #fff;
    margin-top: 0;
    margin-bottom: 10px;
    font-size: 0.9rem;
    font-weight: 600;
  }
  
  .raycin-map-filters .filter-group {
    margin-bottom: 10px;
  }
  
  .raycin-map-filters label {
    display: block;
    color: #cfd8dc;
    font-size: 0.85rem;
    margin-bottom: 5px;
  }
  
  .raycin-map-filters select,
  .raycin-map-filters input[type="number"] {
    width: 100%;
    padding: 6px;
    background: #263238;
    border: 1px solid #4f5d64;
    border-radius: 4px;
    color: #cfd8dc;
    font-size: 0.85rem;
  }
  
  .raycin-map-filters select option {
    background: #263238;
    color: #cfd8dc;
  }
  
  .raycin-map-filters select:focus,
  .raycin-map-filters input[type="number"]:focus {
    outline: none;
    border-color: #80cbc4;
    box-shadow: 0 0 6px rgba(128,203,196,0.3);
  }
  
  .raycin-map-filters .filter-actions {
    margin-top: 10px;
  }
  
  .raycin-map-filters .button {
    background: #80cbc4;
    color: #263238;
    border: 1px solid #80cbc4;
    padding: 6px 12px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.85rem;
    text-decoration: none;
    transition: all 0.2s ease;
    display: inline-block;
    margin-right: 5px;
  }
  
  .raycin-map-filters .button:hover {
    background: #69aaf0;
    border-color: #69aaf0;
  }
  
  /* ===============================
     📱 Mobile Responsiveness
     =============================== */
  @media (max-width: 900px) {
    .raycin-map-wrapper {
      flex-direction: column;
      height: auto;
      padding: 0.5rem;
    }
  
    #raycin-tracklist {
      width: 100%;
      max-height: none;
      border-right: none;
      border-bottom: 2px solid #4f5d64;
      box-shadow: none;
    }
  
    #raycin-map {
      height: 500px;
      margin-top: 0.5rem;
    }
  
    #resetTrackView {
      font-size: 0.9rem;
      padding: 6px 10px;
    }
  
    #trackInfo {
      font-size: 0.85rem;
    }
  }
  
  .track-btn {
    display: inline-block;
    background: #80cbc4;
    color: #263238;
    padding: 6px 10px;
    border-radius: 4px;
    text-decoration: none;
    font-weight: bold;
    margin-right: 6px;
    font-size: 0.85rem;
  }
  
  .track-btn:hover {
    background: #69aaf0;
    color: #263238;
  }
  
  /* 🚑 Fallback emergency map visibility fix */
  #raycin-map,
  .leaflet-container {
      min-height: 400px !important;
      height: auto !important;
      display: block !important;
      visibility: visible !important;
      opacity: 1 !important;
  }
  
  /* ===============================
     Track List Table Styles
     =============================== */
  .raycin-track-list-wrapper {
      width: 100%;
      margin: 20px 0;
  }
  
  .raycin-filters {
      background: #37474f;
      padding: 20px;
      border-radius: 8px;
      margin-bottom: 20px;
      border: 1px solid #4f5d64;
  }
  
  .raycin-filters h3 {
      color: #fff;
      margin-top: 0;
      margin-bottom: 15px;
  }
  
  .raycin-controls-row {
      display: flex;
      align-items: flex-start;
      gap: 20px;
      flex-wrap: wrap;
  }
  
  .raycin-filter-form {
      display: flex;
      flex-direction: column;
      gap: 15px;
  }
  
  .raycin-filter-row {
      display: grid;
      grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
      gap: 15px;
  }
  
  .raycin-results-wrapper .raycin-filter-form {
      width: 100%;
  }
  
  .raycin-results-wrapper .raycin-filter-row {
      display: grid;
      grid-template-columns: repeat(6, 1fr);
      gap: 15px;
      margin-bottom: 15px;
  }
  
  .raycin-results-wrapper .raycin-filter-actions {
      display: flex;
      gap: 10px;
      align-items: center;
  }
  
  @media (max-width: 1400px) {
      .raycin-results-wrapper .raycin-filter-row {
          grid-template-columns: repeat(3, 1fr);
      }
  }
  
  @media (max-width: 768px) {
      .raycin-results-wrapper .raycin-filter-row {
          grid-template-columns: 1fr;
      }
  }
  
  .raycin-filter-col {
      display: flex;
      flex-direction: column;
      min-width: 200px;
  }
  
  .raycin-filter-col label {
      color: #cfd8dc;
      margin-bottom: 5px;
      font-size: 0.9rem;
      font-weight: 500;
  }
  
.raycin-filter-col select,
.raycin-filter-col input[type="number"],
.raycin-filter-col input[type="text"],
.raycin-filter-col input[type="date"] {
    padding: 8px;
    background: #263238;
    border: 1px solid #4f5d64;
    border-radius: 4px;
    color: #cfd8dc;
    font-size: 0.9rem;
}
  
  .raycin-filter-col select[multiple] {
      min-height: 100px;
      padding: 6px;
  }
  
  .raycin-filter-col select option {
      background: #263238;
      color: #cfd8dc;
      padding: 6px 8px;
  }
  
  .raycin-filter-col select option:checked {
      background: #80cbc4;
      color: #263238;
  }
  
.raycin-filter-col select:focus,
.raycin-filter-col input[type="number"]:focus,
.raycin-filter-col input[type="text"]:focus,
.raycin-filter-col input[type="date"]:focus {
    outline: none;
    border-color: #80cbc4;
    box-shadow: 0 0 8px rgba(128,203,196,0.4);
}
  
  .raycin-filter-col .description {
      font-size: 0.85rem;
      margin-top: 5px;
      color: #9ea8ad;
  }
  
  .raycin-filter-actions {
      display: flex;
      gap: 10px;
      align-items: flex-end;
      flex-shrink: 0;
  }
  
  .raycin-filter-actions .button {
      background: #80cbc4;
      color: #263238;
      border: 1px solid #80cbc4;
      padding: 8px 16px;
      border-radius: 4px;
      cursor: pointer;
      text-decoration: none;
      transition: all 0.2s ease;
      font-weight: 500;
      white-space: nowrap;
  }
  
  .raycin-filter-actions .button:hover {
      background: #263238;
      border-color: #263238;
  }
  
  .raycin-export-actions {
      display: flex;
      gap: 10px;
      align-items: flex-end;
      flex-shrink: 0;
  }
  
  .raycin-export-btn {
      background: #80cbc4;
      color: #263238;
      border: 1px solid #80cbc4;
      padding: 10px 20px;
      border-radius: 4px;
      text-decoration: none;
      font-weight: 500;
      transition: all 0.2s ease;
      display: inline-block;
      cursor: pointer;
      white-space: nowrap;
  }
  
  .raycin-export-btn:hover {
      background: #263238;
      border-color: #263238;
      color: #263238;
  }
  
  .raycin-export-btn:active {
      transform: translateY(1px);
  }
  
  .raycin-track-table-wrapper {
      overflow-x: auto;
      background: #37474f;
      border-radius: 8px;
      padding: 20px;
      border: 1px solid #4f5d64;
  }
  
  .raycin-track-table {
      width: 100%;
      border-collapse: collapse;
      color: #cfd8dc;
  }
  
  .raycin-track-table thead {
      background: #263238;
  }
  
  .raycin-track-table th {
      padding: 12px;
      text-align: left;
      color: #afbfbe;
      font-weight: 600;
      border-bottom: 2px solid #4f5d64;
  }
  
  .raycin-track-table th a {
      color: #afbfbe;
      text-decoration: none;
      display: flex;
      align-items: center;
      gap: 5px;
  }
  
  .raycin-track-table th a:hover {
      color: #afbfbe;
  }
  
  .raycin-track-table .sort-arrow {
      font-size: 0.8rem;
      margin-left: 5px;
      display: inline-block;
  }
  
  .raycin-track-table .sort-arrow-active {
      color: #afbfbe;
      opacity: 1;
      font-weight: bold;
  }
  
  .raycin-track-table .sort-arrow-inactive {
      color: #9ea8ad;
      opacity: 0.6;
  }
  
  .raycin-track-table tbody tr {
      border-bottom: 1px solid #4f5d64;
      transition: background 0.2s ease;
  }
  
  .raycin-track-table tbody tr:hover {
      background: rgba(128,203,196,0.1);
  }
  
  .raycin-track-table td {
      padding: 10px 12px;
      font-size: 0.9rem;
      color: #cfd8dc;
  }
  
  .raycin-track-table tbody tr:last-child {
      border-bottom: none;
  }
  
  /* Responsive table */
  @media (max-width: 768px) {
      .raycin-filter-row {
          grid-template-columns: 1fr;
      }
  
      .raycin-track-table {
          font-size: 0.85rem;
      }
  
      .raycin-track-table th,
      .raycin-track-table td {
          padding: 8px;
      }
  }
  
  /* Copy button for track list rows */
  .raycin-track-table tbody td {
      position: relative;
      cursor: pointer;
  }
  
  .raycin-track-table tbody td:hover::after {
      content: '📋';
      position: absolute;
      right: 5px;
      top: 50%;
      transform: translateY(-50%);
      font-size: 0.9rem;
      opacity: 0.7;
  }
  
  .raycin-track-table tbody td.copied::after {
      content: '✓ Copied!';
      position: absolute;
      right: 5px;
      top: 50%;
      transform: translateY(-50%);
      font-size: 0.75rem;
      opacity: 1;
      color: #80cbc4;
      background: rgba(0,0,0,0.7);
      padding: 2px 6px;
      border-radius: 3px;
      white-space: nowrap;
  }
  
  /* Checkered flag marker */
  .checkered-flag-marker {
    background: transparent !important;
    border: none !important;
    text-align: center;
  }
  
  .checkpoint-tooltip {
    background: #37474f;
    color: #cfd8dc;
    border: 1px solid #4f5d64;
    border-radius: 4px;
    padding: 4px 8px;
    font-size: 0.85rem;
  }

/* Image Lightbox Modal */
.raycin-image-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.raycin-image-modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.9);
    cursor: pointer;
}

.raycin-image-modal-content {
    position: relative;
    z-index: 10001;
    max-width: 90%;
    max-height: 90%;
    background: #263238;
    border-radius: 8px;
    padding: 20px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
}

.raycin-image-modal-close {
    position: absolute;
    top: 10px;
    right: 10px;
    background: #80cbc4;
    color: #263238;
    border: none;
    width: 35px;
    height: 35px;
    border-radius: 50%;
    font-size: 24px;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    z-index: 10002;
}

.raycin-image-modal-close:hover {
    background: #69aaf0;
    transform: scale(1.1);
}

.raycin-image-modal-img {
    max-width: 100%;
    max-height: calc(90vh - 80px);
    display: block;
    margin: 0 auto;
    border-radius: 4px;
}

.raycin-track-thumbnail {
    transition: transform 0.2s ease, opacity 0.2s ease;
}

.raycin-track-thumbnail:hover {
    transform: scale(1.1);
    opacity: 0.9;
}

/* Race Results Styles */
.raycin-results-wrapper {
    margin-bottom: 20px;
}

.raycin-results-error {
    background: #37474f;
    padding: 20px;
    border-radius: 8px;
    border: 1px solid #4f5d64;
    color: #cfd8dc;
    text-align: center;
}

.raycin-results-table-wrapper {
    overflow-x: auto;
    background: #37474f;
    border-radius: 8px;
    padding: 20px;
    border: 1px solid #4f5d64;
}