.user-stats-container {
  max-width: 1800px;
  margin: 0 auto;
  padding: 0.5rem;
  height: calc(100dvh - 6.25rem);
  overflow-y: auto;
}

.header-section {
  background: var(--card-background);
  border-radius: 12px;
  padding: 1rem;
  backdrop-filter: blur(10px);
  border: 1px solid var(--p-content-border-color);
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
  margin-bottom: 2rem;
  transition: all 0.3s ease;

  &:hover {
    border-color: rgba(255, 255, 255, 0.2);
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.15);
  }

  .header-content {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 2rem;
    position: relative;
  }

  .greeting {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    position: absolute;
    left: 50%;
    transform: translateX(-50%);

    i {
      font-size: 1.5rem;
      color: var(--primary-color);
    }

    h2 {
      color: var(--text-color, #ffffff);
      font-size: 1.5rem;
      font-weight: 600;
      margin: 0;
      white-space: nowrap;
    }
  }

  .config-toggle-btn {
    margin-left: auto;
  }
}

.config-header {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 1rem;
}

.config-toggle-btn {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 1.25rem;
  background: var(--card-background);
  border: 1px solid var(--p-content-border-color);
  border-radius: 8px;
  color: var(--text-color);
  cursor: pointer;
  transition: all 0.3s ease;
  font-size: 0.9rem;
  white-space: nowrap;

  &:hover {
    background: var(--p-primary-color);
    color: white;
    border-color: var(--p-primary-color);
  }

  i {
    font-size: 1rem;
  }
}

// Dialog styles
::ng-deep .config-dialog {
  .p-dialog-header {
    border-bottom: 1px solid var(--p-content-border-color);
  }

  .p-dialog-content {
    background: var(--card-background);
    padding: 1.5rem;
  }

  .p-dialog-footer {
    border-top: 1px solid var(--p-content-border-color);
    padding: 1rem 1.5rem;
    display: flex;
    gap: 0.75rem;
    justify-content: flex-end;

    .reset-btn {
      margin-right: auto;
    }

    .hide-all-btn,
    .show-all-btn {
      display: flex;
      align-items: center;
      gap: 0.5rem;
    }
  }
}

.config-dialog-content {
  .config-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
  }

  .config-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.5rem 1.25rem;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--p-content-border-color);
    border-radius: 8px;
    cursor: move;
    transition: all 0.2s ease;

    &:hover {
      background: rgba(255, 255, 255, 0.05);
      border-color: var(--p-primary-color);
    }

    .drag-handle {
      cursor: grab;
      color: var(--text-color-secondary);
      display: flex;
      align-items: center;

      &:active {
        cursor: grabbing;
      }
    }

    .chart-title {
      flex: 1;
      color: var(--text-color);
      font-size: 0.95rem;
    }

    .visibility-toggle {
      padding: 0.5rem;
      background: transparent;
      border: 1px solid var(--p-content-border-color);
      border-radius: 6px;
      color: var(--p-primary-color);
      cursor: pointer;
      transition: all 0.2s ease;

      &:hover {
        background: var(--p-primary-color);
        color: white;
        border-color: var(--p-primary-color);
      }

      &.disabled {
        color: var(--text-color-secondary);
        opacity: 0.5;

        &:hover {
          background: transparent;
          color: var(--text-color-secondary);
          border-color: var(--p-content-border-color);
        }
      }
    }
  }
}

.charts-container {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: 1.5rem;
  overflow: visible;
}

.chart-card {
  background: var(--card-background);
  border-radius: 12px;
  padding: 1.5rem;
  backdrop-filter: blur(10px);
  border: 1px solid var(--p-content-border-color);
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
  transition: all 0.3s ease;
  position: relative;
  overflow: visible;

  &:hover {
    border-color: rgba(255, 255, 255, 0.2);
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.15);

    .chart-drag-handle {
      opacity: 1;
    }
  }

  .chart-drag-handle {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    padding: 0.5rem;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 6px;
    cursor: grab;
    opacity: 0;
    transition: opacity 0.2s ease;
    z-index: 10;
    color: var(--text-color);

    &:active {
      cursor: grabbing;
    }

    &:hover {
      background: rgba(0, 0, 0, 0.5);
    }
  }

  &.chart-small-square {
    grid-column: span 3;
  }

  &.chart-small {
    grid-column: span 4;
  }

  &.chart-medium {
    grid-column: span 6;
  }

  &.chart-large {
    grid-column: span 8;
  }

  &.chart-wide {
    grid-column: span 9;
  }

  &.chart-full {
    grid-column: span 12;
  }
}

.cdk-drag-preview {
  opacity: 0.8;
  box-shadow: 0 8px 16px rgba(0, 0, 0, 0.3);
}

.cdk-drag-placeholder {
  opacity: 0.3;
  border: 2px dashed var(--p-primary-color);
}

.cdk-drag-animating {
  transition: transform 250ms cubic-bezier(0, 0, 0.2, 1);
}

@media (max-width: 1440px) {
  .charts-container {
    grid-template-columns: repeat(12, 1fr);
  }

  .chart-card {
    &.chart-small-square {
      grid-column: span 4;
    }

    &.chart-small {
      grid-column: span 4;
    }

    &.chart-medium {
      grid-column: span 6;
    }

    &.chart-large {
      grid-column: span 8;
    }

    &.chart-wide {
      grid-column: span 12;
    }

    &.chart-full {
      grid-column: span 12;
    }
  }
}

@media (max-width: 1024px) {
  .charts-container {
    grid-template-columns: repeat(6, 1fr);
  }

  .chart-card {
    &.chart-small-square,
    &.chart-small {
      grid-column: span 3;
    }

    &.chart-medium {
      grid-column: span 3;
    }

    &.chart-large,
    &.chart-wide,
    &.chart-full {
      grid-column: span 6;
    }
  }
}

@media (max-width: 768px) {
  .user-stats-container {
    padding: 1rem;
  }

  .config-toggle-btn {
    span {
      display: none;
    }
  }

  ::ng-deep .config-dialog {
    .p-dialog-content {
      padding: 1rem;
    }

    .p_dialog_footer {
      flex-direction: column;
      gap: 0.5rem;

      .reset-btn {
        margin-right: 0;
        width: 100%;
      }

      button {
        width: 100%;
      }
    }
  }

  .config-panel {
    padding: 1rem;

    .config-panel-header {
      flex-direction: column;
      align-items: flex-start;
      gap: 1rem;

      .reset-btn {
        width: 100%;
        justify-content: center;
      }
    }
  }

  .header-section {
    padding: 1rem;

    .header-content {
      flex-direction: column;
      gap: 1rem;
      position: static;
    }

    .greeting {
      position: static;
      transform: none;

      i {
        font-size: 1.25rem;
      }

      h2 {
        font-size: 1.25rem;
        white-space: normal;
      }
    }
  }

  .config-toggle-btn {
    width: 100%;
    justify-content: center;
    margin-left: 0;

    span {
      display: inline;
    }
  }

  .charts-container {
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
  }

  .chart-card {
    padding: 1rem;

    .chart-drag-handle {
      opacity: 1;
    }

    &.chart-small-square,
    &.chart-small {
      grid-column: span 1;
    }

    &.chart-medium {
      grid-column: span 1;
    }

    &.chart-large,
    &.chart-wide,
    &.chart-full {
      grid-column: span 2;
    }
  }
}

@media (max-width: 480px) {
  .user-stats-container {
    padding: 0.75rem;
  }

  .config-toggle-btn {
    padding: 0.5rem 0.75rem;
  }

  ::ng-deep .config-dialog {
    .p-dialog-content {
      padding: 0.75rem;
    }
  }

  .config-panel {
    padding: 0.75rem;
  }

  .header-section {
    padding: 0.75rem;

    .greeting {
      gap: 0.5rem;

      i {
        font-size: 1rem;
      }

      h2 {
        font-size: 1rem;
        white-space: normal;
      }
    }
  }

  .charts-container {
    grid-template-columns: 1fr;
    gap: 0.75rem;
  }

  .chart-card {
    padding: 0.75rem;

    &.chart-small-square,
    &.chart-small,
    &.chart-medium,
    &.chart-large,
    &.chart-wide,
    &.chart-full {
      grid-column: span 1;
    }
  }
}
