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

.profile-activity-history {
  padding: 20px;
}

.activity-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}

.activity-header .title-right {
  margin: 0;
}

.competition-performance-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.competition-performance-header .title-right {
  margin: 0;
}

.chart-controls {
  display: flex;
  gap: 12px;
  align-items: center;
}

.chart-toggle-label {
  font-size: 12px;
  font-weight: 500;
  color: #666;
  display: flex;
  align-items: center;
  gap: 4px;
  cursor: pointer;
}

.chart-toggle-label input {
  cursor: pointer;
}

.rating-stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 24px;
}

.year-selector {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px 12px;
  background: #f0f0f0;
  border-radius: 4px;
  font-size: 14px;
  cursor: pointer;
  color: #232323;
  position: relative;
  user-select: none;
}

.year-selector:focus,
.year-selector:focus-visible {
  outline: 2px solid #6936F5;
  outline-offset: 2px;
  background: #eaeaea;
}

.year-dropdown {
  position: absolute;
  top: 100%;
  right: 0;
  margin-top: 4px;
  background: #fff;
  border-radius: 4px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
  z-index: 100;
  min-width: 100px;
  max-height: 200px;
  overflow-y: auto;
}

.year-option {
  padding: 8px 12px;
  cursor: pointer;
  color: #232323;
  transition: background 0.1s;
}

.year-option:hover,
.year-option:focus,
.year-option:focus-visible {
  background: #f0f0f0;
  outline: none; /* Reset default browser outline */
}

.year-option:focus-visible {
  box-shadow: inset 0 0 0 2px #6936F5;
  background: #f7f7f7; /* Slight background change */
}

.year-option.active {
  background: #f3e5f5;
  font-weight: 600;
  color: #6936F5;
}

.year-option.active:focus-visible {
  box-shadow: inset 0 0 0 2px #6936F5;
  background: #ece0fe; /* Darker than active to show focus */
}

.activity-stats-row {
  display: flex;
  gap: 24px;
  margin-bottom: 20px;
}

.stat-item {
  display: flex;
  flex-direction: column;
}

.stat-value {
  font-size: 18px;
  font-weight: 600;
  color: #232323;
}

.stat-label {
  font-size: 12px;
  color: #707070;
}

.heatmap-container {
  position: relative;
  overflow-x: auto;
}

.heatmap-months {
  display: flex;
  height: 20px;
  font-size: 12px;
  color: #707070;
  position: relative;
  margin-bottom: 4px;
}

.month-label {
  position: absolute;
  top: 0;
}

.activity-heatmap {
  --heatmap-cell-size: 10px;
  --heatmap-cell-gap: 3px;
  display: grid;
  grid-template-rows: repeat(7, var(--heatmap-cell-size));
  grid-auto-flow: column;
  gap: var(--heatmap-cell-gap);
  height: max-content;
}

.heatmap-cell {
  width: var(--heatmap-cell-size);
  height: var(--heatmap-cell-size);
  border-radius: 2px;
  background-color: #ebedf0;
  position: relative;
}

.heatmap-tooltip {
  position: fixed;
  background: #333;
  color: #fff;
  padding: 8px 12px;
  border-radius: 4px;
  font-size: 12px;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s ease;
  z-index: 1000;
  text-align: center;
  display: none;
}

.heatmap-tooltip.visible {
  opacity: 1;
  display: block;
}

.heatmap-cell.level-1 { background-color: #9be9a8; }
.heatmap-cell.level-2 { background-color: #40c463; }
.heatmap-cell.level-3 { background-color: #30a14e; }
.heatmap-cell.level-4 { background-color: #216e39; }

.recent-activity-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 24px;
}

.profile-recent-activity .pagination-container {
  display: flex;
  justify-content: center;
  margin-top: 16px;
  gap: 5px;
}

.activity-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 24px;
  border-radius: 8px;
  background-color: #fff;
}

.activity-item.alt {
  background-color: #f9f9f9;
}

.activity-icon {
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.activity-details {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.activity-title-row {
  gap: 12px;
}

.activity-title {
  font-family: 'Inter', sans-serif;
  font-weight: 400;
  font-size: 16px;
  color: #232323;
  margin: 0;
}

.activity-time {
  font-size: 0.8em;
}

.activity-desc {
  font-family: 'Inter', sans-serif;
  font-weight: 400;
  font-size: 14px;
  color: #707070;
  margin: 0;
}

@media screen and (max-width: 900px) {
  .profile .profile-main-container {
    grid-template-columns: 1fr !important;
  }

  .profile .profile-main-container .profile-right-container .profile-right-first-two-containers {
    grid-template-columns: 1fr !important;
    gap: 20px;
  }

  .profile .profile-main-container .profile-right-container .profile-activity-history,
  .profile .profile-main-container .profile-right-container .profile-competition-rating,
  .profile .profile-main-container .profile-right-container .profile-recent-activity {
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    box-sizing: border-box !important;
    overflow-x: auto !important; /* Allow scroll for internal wide content */
  }

  .profile .profile-main-container .profile-right-container .profile-right-first-two-containers .profile-current-results {
      grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)) !important;
  }

  .profile .profile-main-container .profile-right-container .profile-right-first-two-containers .profile-current-results .results-container .result-box {
      /* Ensure problem boxes don't overflow */
      width: 100% !important;
  }
  
  /* Make heatmap scrollable */
  .heatmap-container {
      width: 100%;
      overflow-x: auto;
      padding-bottom: 10px; /* Space for scrollbar */
  }

  .profile .profile-main-container .profile-right-container .profile-activity-history .activity-stats-row {
    flex-wrap: wrap;
    gap: 16px;
  }

  .profile .profile-main-container .profile-right-container .profile-activity-history .stat-item {
    min-width: 120px;
    flex: 1; /* Allow growing */
  }

  .profile .profile-main-container .profile-right-container .profile-competition-rating .current-rating-box {
    flex-wrap: wrap;
    gap: 8px;
  }
  
  /* Force all major containers to be fluid */
  .profile .profile-main-container,
  .profile-leftbar,
  .profile-right-container,
  .profile-right-first-two-containers,
  .profile-current-results,
  .profile-activity-history,
  .profile-competition-rating,
  .profile-recent-activity,
  .results-container,
  .result-box,
  .recent-activity-list,
  .activity-item {
      width: 100% !important;
      max-width: 100% !important;
      min-width: 0 !important;
      box-sizing: border-box !important;
  }
  
  /* Reset grid columns for results to be responsive validation */
  .profile .profile-main-container .profile-right-container .profile-right-first-two-containers .profile-current-results {
      grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)) !important;
  }
}


@media screen and (max-width: 600px) {
  .activity-item {
    align-items: flex-start;
  }

  .activity-title-row {
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
  }
}

/* ApexCharts Tooltip Override for interactivity */
.apexcharts-tooltip {
    pointer-events: auto !important;
    user-select: text !important;
    cursor: default;
}
.apexcharts-tooltip.apexcharts-theme-light {
    border: none !important; /* Let our custom border handle it */
    background: transparent !important; /* Let our custom bg handle it */
    box-shadow: none !important; /* Let our custom shadow handle it */
}

/* Keep tooltip visible for 15 seconds after mouse leave */
.apexcharts-tooltip {
    transition: opacity 0.3s ease 15s !important;
}
.apexcharts-tooltip.apexcharts-active,
.apexcharts-tooltip:hover {
    transition: opacity 0.1s ease 0s !important;
    opacity: 1 !important;
}

/* Responsive Design for Rating Stats */
@media (max-width: 600px) {
    .profile-competition-rating > div:first-child {
        flex-direction: column !important;
        align-items: flex-start !important;
        gap: 12px;
    }

    .rating-stats-grid {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 8px !important;
    }

    .rating-stats-grid .stats-card {
        padding: 10px !important;
    }

    .rating-stats-grid .stats-label {
        font-size: 10px !important;
        white-space: nowrap;
    }

    .rating-stats-grid .stats-value {
        font-size: 16px !important;
    }
    
    .chart-controls {
        flex-wrap: wrap;
        width: 100%;
        justify-content: space-between;
    }
}

/* Premium UI Upgrades */

/* Stats Cards: Elevated Look */
.rating-stats-grid .stats-card {
    background: #fff !important;
    border: 1px solid #eaeaea !important;
    padding: 12px;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    cursor: default;
}

.rating-stats-grid .stats-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    border-color: #e0e0e0 !important;
}

.rating-stats-grid .stats-label {
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 600 !important;
    font-size: 10px !important;
    color: #888 !important;
    margin-bottom: 4px;
}

.rating-stats-grid .stats-value {
    font-family: 'Inter', sans-serif;
    letter-spacing: -0.5px;
    font-size: 18px;
    font-weight: 700;
    color: #333;
}

.stats-value-positive {
    color: #28a745;
}

.stats-value-negative {
    color: #dc3545;
}

/* Controls: Segmented Button Style */
.chart-controls .range-selector {
    background: #f1f3f5 !important;
    padding: 3px !important;
    border-radius: 8px !important;
    border: 1px solid #eee;
    display: flex;
    gap: 4px;
    align-items: center;
}

.chart-controls .chart-btn {
    transition: all 0.2s ease;
    border-radius: 6px !important;
    color: #666 !important;
    padding: 4px 10px !important; /* Added base padding */
    border: none !important;      /* Added base border */
    background: transparent;      /* Added base background */
    font-size: 11px !important;   /* Added base font size */
    font-weight: 500 !important;  /* Added base font weight */
    cursor: pointer;              /* Added cursor */
}

.chart-controls .chart-btn:hover {
    color: #333 !important;
    background: rgba(255, 255, 255, 0.5) !important;
}

.chart-controls .chart-btn.active {
    background: #fff !important;
    color: #333 !important;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1) !important;
    font-weight: 600 !important;
}

/* Custom Toggle Switch */
#toggle-tiers {
    accent-color: #333;
}

/* Tier Label Styling - handles long translations */
.tier-label,
.apexcharts-yaxis-annotation-label {
    max-width: 140px !important;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
    border: 1px solid currentColor !important; /* Uses the text color (rank color) for border */
}

@media screen and (max-width: 600px) {
    .tier-label,
    .apexcharts-yaxis-annotation-label {
        max-width: 80px !important;
        font-size: 8px !important;
    }
}
